Give ImGui the correct DeltaTime

Fixes key repeat rate when vsync is disabled

Bug: skia:
Change-Id: I315932d0e0bcfd491a3c81deba56b137db1c3a0f
Reviewed-on: https://skia-review.googlesource.com/c/190304
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Brian Osman 2019-02-07 14:10:44 -05:00 committed by Skia Commit-Bot
parent 1be431f60f
commit 5b9126bc19

View File

@ -11,6 +11,7 @@
#include "SkImage.h"
#include "SkPixmap.h"
#include "SkSwizzle.h"
#include "SkTime.h"
#include "SkVertices.h"
#include "imgui.h"
@ -95,7 +96,12 @@ void ImGuiLayer::skiaWidget(const ImVec2& size, SkiaWidgetFunc func) {
void ImGuiLayer::onPrePaint() {
// Update ImGui input
ImGuiIO& io = ImGui::GetIO();
io.DeltaTime = 1.0f / 60.0f;
static double previousTime = 0.0;
double currentTime = SkTime::GetSecs();
io.DeltaTime = static_cast<float>(currentTime - previousTime);
previousTime = currentTime;
io.DisplaySize.x = static_cast<float>(fWindow->width());
io.DisplaySize.y = static_cast<float>(fWindow->height());