aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/sk_app
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-12-08 16:46:09 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-11 17:37:58 +0000
commitd67e5189802e89e74217244b36cc7263883d5dba (patch)
tree89870d274c56c96dda04329f73538011c762a3d6 /tools/sk_app
parent2326177e3499d96e1e5df68504cc98764d80209a (diff)
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 <brianosman@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'tools/sk_app')
-rw-r--r--tools/sk_app/Window.cpp3
-rw-r--r--tools/sk_app/Window.h3
2 files changed, 6 insertions, 0 deletions
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
@@ -88,6 +88,9 @@ void Window::onPaint() {
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);
}