aboutsummaryrefslogtreecommitdiffhomepage
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/HelloWorld.cpp19
-rw-r--r--example/HelloWorld.h9
2 files changed, 6 insertions, 22 deletions
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index fba7f7e5a0..5954e71532 100644
--- a/example/HelloWorld.cpp
+++ b/example/HelloWorld.cpp
@@ -18,21 +18,6 @@ Application* Application::Create(int argc, char** argv, void* platformData) {
return new HelloWorld(argc, argv, platformData);
}
-static void on_backend_created_func(void* userData) {
- HelloWorld* hw = reinterpret_cast<HelloWorld*>(userData);
- return hw->onBackendCreated();
-}
-
-static void on_paint_handler(SkCanvas* canvas, void* userData) {
- HelloWorld* hw = reinterpret_cast<HelloWorld*>(userData);
- return hw->onPaint(canvas);
-}
-
-static bool on_char_handler(SkUnichar c, uint32_t modifiers, void* userData) {
- HelloWorld* hw = reinterpret_cast<HelloWorld*>(userData);
- return hw->onChar(c, modifiers);
-}
-
HelloWorld::HelloWorld(int argc, char** argv, void* platformData)
: fBackendType(Window::kNativeGL_BackendType)
, fRotationAngle(0) {
@@ -42,9 +27,7 @@ HelloWorld::HelloWorld(int argc, char** argv, void* platformData)
fWindow->setRequestedDisplayParams(DisplayParams());
// register callbacks
- fWindow->registerBackendCreatedFunc(on_backend_created_func, this);
- fWindow->registerPaintFunc(on_paint_handler, this);
- fWindow->registerCharFunc(on_char_handler, this);
+ fWindow->pushLayer(this);
fWindow->attach(fBackendType);
}
diff --git a/example/HelloWorld.h b/example/HelloWorld.h
index 44f1321d6b..28715fe89b 100644
--- a/example/HelloWorld.h
+++ b/example/HelloWorld.h
@@ -13,15 +13,16 @@
class SkCanvas;
-class HelloWorld : public sk_app::Application {
+class HelloWorld : public sk_app::Application, sk_app::Window::Layer {
public:
HelloWorld(int argc, char** argv, void* platformData);
~HelloWorld() override;
- void onBackendCreated();
- void onPaint(SkCanvas* canvas);
void onIdle() override;
- bool onChar(SkUnichar c, uint32_t modifiers);
+
+ void onBackendCreated() override;
+ void onPaint(SkCanvas* canvas) override;
+ bool onChar(SkUnichar c, uint32_t modifiers) override;
private:
void updateTitle();