aboutsummaryrefslogtreecommitdiffhomepage
path: root/example/HelloWorld.h
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-11-21 13:18:02 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-21 18:37:19 +0000
commiteff04b5ec287e0fee0d44207c10d2d11f7eade8a (patch)
treeea2cf00ea329c81611536aaa9a9f1eca47c67e9a /example/HelloWorld.h
parent2aa09dbe8aced37aa6bb285e62df45deb0e81650 (diff)
Remove SampleApp and convert HelloWorld to sk_app
There is still a large amount of views code that could be trimmed down, but which is used to implement samples (in viewer). Seemed simpler to remove some of this code in pieces. Bug: skia: Change-Id: Ia3415060d03c8de604a154e3dc38379b754daab6 Reviewed-on: https://skia-review.googlesource.com/72801 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'example/HelloWorld.h')
-rw-r--r--example/HelloWorld.h74
1 files changed, 18 insertions, 56 deletions
diff --git a/example/HelloWorld.h b/example/HelloWorld.h
index 05d9b81e82..44f1321d6b 100644
--- a/example/HelloWorld.h
+++ b/example/HelloWorld.h
@@ -1,73 +1,35 @@
/*
- * Copyright 2015 Google Inc.
- *
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- */
+* Copyright 2017 Google Inc.
+*
+* Use of this source code is governed by a BSD-style license that can be
+* found in the LICENSE file.
+*/
#ifndef HelloWorld_DEFINED
#define HelloWorld_DEFINED
-#include "SkSurface.h"
-#include "SkWindow.h"
+#include "sk_app/Application.h"
+#include "sk_app/Window.h"
-class GrContext;
-struct GrGLInterface;
-class GrRenderTarget;
class SkCanvas;
-class HelloWorldWindow : public SkOSWindow {
+class HelloWorld : public sk_app::Application {
public:
- enum DeviceType {
- kRaster_DeviceType,
- kGPU_DeviceType,
- };
- HelloWorldWindow(void* hwnd);
- virtual ~HelloWorldWindow() override;
+ HelloWorld(int argc, char** argv, void* platformData);
+ ~HelloWorld() override;
- // Changes the device type of the object.
- bool setUpBackend();
-
- DeviceType getDeviceType() const { return fType; }
-
-protected:
- sk_sp<SkSurface> makeSurface() override {
- SkSurfaceProps props(INHERITED::getSurfaceProps());
- if (kGPU_DeviceType == fType) {
- return fGpuSurface;
- }
- const SkImageInfo info = SkImageInfo::MakeN32Premul(SkScalarRoundToInt(this->width()),
- SkScalarRoundToInt(this->height()));
- fRasterSurface = SkSurface::MakeRaster(info, &props);
- return fRasterSurface;
- }
-
- void draw(SkCanvas* canvas) override;
- void drawContents(SkCanvas* canvas);
-
- void onSizeChange() override;
+ void onBackendCreated();
+ void onPaint(SkCanvas* canvas);
+ void onIdle() override;
+ bool onChar(SkUnichar c, uint32_t modifiers);
private:
- bool findNextMatch(); // Set example to the first one that matches FLAGS_match.
- void setTitle();
- void setUpGpuBackedSurface();
- bool onHandleChar(SkUnichar unichar) override;
- void tearDownBackend();
+ void updateTitle();
- // draw contents
- SkScalar fRotationAngle;
-
- // support framework
- DeviceType fType;
- sk_sp<SkSurface> fRasterSurface;
- sk_sp<GrContext> fContext;
- sk_sp<SkSurface> fGpuSurface;
- AttachmentInfo fAttachmentInfo;
- sk_sp<const GrGLInterface> fInterface;
+ sk_app::Window* fWindow;
+ sk_app::Window::BackendType fBackendType;
- typedef SkOSWindow INHERITED;
+ SkScalar fRotationAngle;
};
#endif