aboutsummaryrefslogtreecommitdiffhomepage
path: root/example/HelloWorld.h
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2015-02-02 12:55:14 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-02 12:55:14 -0800
commit52edc4d05380c88de5b334479ad8e537ef2b4925 (patch)
tree0c143dcdf9bc714458d80754a314756aeaba3b36 /example/HelloWorld.h
parent76113a9b7716748c70ea0ecf7aacbabe4cce5009 (diff)
move HelloWorld to be a peer of SampleApp
This is working towards making a simple example part of the buildbot compile step and removing SkExamples from the experimental directory. This works on Mac, Windows, and Linux but isn't complete for Android, ChromeOS and iOS. Review URL: https://codereview.chromium.org/886413004
Diffstat (limited to 'example/HelloWorld.h')
-rw-r--r--example/HelloWorld.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/example/HelloWorld.h b/example/HelloWorld.h
new file mode 100644
index 0000000000..e5cde271bf
--- /dev/null
+++ b/example/HelloWorld.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2015 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"
+
+class GrContext;
+struct GrGLInterface;
+class GrRenderTarget;
+class SkCanvas;
+
+class HelloWorldWindow : public SkOSWindow {
+public:
+ enum DeviceType {
+ kRaster_DeviceType,
+ kGPU_DeviceType,
+ };
+ HelloWorldWindow(void* hwnd);
+ virtual ~HelloWorldWindow() SK_OVERRIDE;
+
+ // Changes the device type of the object.
+ bool setUpBackend();
+
+ DeviceType getDeviceType() const { return fType; }
+
+protected:
+ SkSurface* createSurface() SK_OVERRIDE {
+ if (kGPU_DeviceType == fType) {
+ SkSurfaceProps props(INHERITED::getSurfaceProps());
+ return SkSurface::NewRenderTargetDirect(fRenderTarget, &props);
+ }
+ static const SkImageInfo info = SkImageInfo::MakeN32Premul(
+ SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->height()));
+ return fSurface = SkSurface::NewRaster(info);
+ }
+
+ void draw(SkCanvas* canvas) SK_OVERRIDE;
+ void drawContents(SkCanvas* canvas);
+
+ void onSizeChange() SK_OVERRIDE;
+
+private:
+ bool findNextMatch(); // Set example to the first one that matches FLAGS_match.
+ void setTitle();
+ void setUpRenderTarget();
+ bool onHandleChar(SkUnichar unichar) SK_OVERRIDE;
+ void tearDownBackend();
+
+ // draw contents
+ SkScalar fRotationAngle;
+
+ // support framework
+ DeviceType fType;
+ SkSurface* fSurface;
+ GrContext* fContext;
+ GrRenderTarget* fRenderTarget;
+ AttachmentInfo fAttachmentInfo;
+ const GrGLInterface* fInterface;
+
+ typedef SkOSWindow INHERITED;
+};
+
+#endif