From d67e5189802e89e74217244b36cc7263883d5dba Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Fri, 8 Dec 2017 16:46:09 -0500 Subject: Move ImGui support code to ImGuiLayer Viewer still has plenty of code that uses ImGui to create application specific UI, but the structural code that forwards input to ImGui, and converts per-frame ImGui rendering data to Skia draw commands is now in a single component that can be reused in any sk_app-based application. Bug: skia: Change-Id: Ic14ece659d4af8ee13b69c638bdaf7df6c24f5c0 Reviewed-on: https://skia-review.googlesource.com/82627 Commit-Queue: Brian Osman Reviewed-by: Jim Van Verth --- tools/sk_app/Window.cpp | 3 +++ tools/sk_app/Window.h | 3 +++ 2 files changed, 6 insertions(+) (limited to 'tools/sk_app') diff --git a/tools/sk_app/Window.cpp b/tools/sk_app/Window.cpp index 436b6b9aa9..6713c4c2c9 100644 --- a/tools/sk_app/Window.cpp +++ b/tools/sk_app/Window.cpp @@ -87,6 +87,9 @@ void Window::onPaint() { // draw into the canvas of this surface SkCanvas* canvas = backbuffer->getCanvas(); + for (int i = 0; i < fLayers.count(); ++i) { + fLayers[i]->onPrePaint(); + } for (int i = 0; i < fLayers.count(); ++i) { fLayers[i]->onPaint(canvas); } diff --git a/tools/sk_app/Window.h b/tools/sk_app/Window.h index 77478b598e..b541e241a2 100644 --- a/tools/sk_app/Window.h +++ b/tools/sk_app/Window.h @@ -136,16 +136,19 @@ public: // return value of 'true' means 'I have handled this event' virtual void onBackendCreated() {} + virtual void onAttach(Window* window) {} virtual bool onChar(SkUnichar c, uint32_t modifiers) { return false; } virtual bool onKey(Key key, InputState state, uint32_t modifiers) { return false; } virtual bool onMouse(int x, int y, InputState state, uint32_t modifiers) { return false; } virtual bool onMouseWheel(float delta, uint32_t modifiers) { return false; } virtual bool onTouch(intptr_t owner, InputState state, float x, float y) { return false; } virtual void onUIStateChanged(const SkString& stateName, const SkString& stateValue) {} + virtual void onPrePaint() {} virtual void onPaint(SkCanvas*) {} }; void pushLayer(Layer* layer) { + layer->onAttach(this); fLayers.push(layer); } -- cgit v1.2.3