Chromium Code Reviews| Index: experimental/SkiaExamples/SkExample.h |
| diff --git a/experimental/SkiaExamples/BaseExample.h b/experimental/SkiaExamples/SkExample.h |
| similarity index 45% |
| rename from experimental/SkiaExamples/BaseExample.h |
| rename to experimental/SkiaExamples/SkExample.h |
| index b9cc25930117d58c1619e2aee4994ffb8864d7b4..3e1ee7290f10ae93e34ae2f337ede5b126895a33 100644 |
| --- a/experimental/SkiaExamples/BaseExample.h |
| +++ b/experimental/SkiaExamples/SkExample.h |
| @@ -7,8 +7,8 @@ |
| * |
| */ |
| -#ifndef BaseExample_DEFINED |
| -#define BaseExample_DEFINED |
| +#ifndef SkExample_DEFINED |
| +#define SkExample_DEFINED |
| #include "SkWindow.h" |
| @@ -17,13 +17,44 @@ struct GrGLInterface; |
| class GrRenderTarget; |
| class SkCanvas; |
| -class BaseExample : public SkOSWindow { |
| +class HelloSkia; |
|
caryclark
2013/07/08 12:42:35
remove this if it isn't required for this header
|
| + |
| +class SkExample : public SkOSWindow { |
| public: |
| + /** |
| + * Member function that creates the SkExample. By default it will create a sample |
| + * defined in SkExample.cpp |
| + * The user of this framework can register a new (and only one) example by running: |
| + * |
| + * SkExample::SetExample<DerivedClass> reg("My derived class"); |
| + * |
| + * ... where DerivedClass is a child of SkExample and 'reg' can be any name. |
| + * |
| + */ |
| + static SkOSWindow* (*create_user_example) (void* hwnd, int argc, char** argv); |
|
caryclark
2013/07/08 12:42:35
use gCreateUserExample to hint to reader that this
|
| + |
| + template<typename T> |
| + class SetExample { |
| + public: |
|
caryclark
2013/07/08 12:42:35
unindent
|
| + static SkOSWindow* create(void* hwnd, int argc, char** argv) { |
| + return new T(hwnd, argc, argv); |
| + } |
|
caryclark
2013/07/08 12:42:35
add a blank line here
|
| + SetExample(const char* name) { |
| + if (SkExample::userExampleExists) { |
| + SkDebugf("Rejecting the following Skia Example: %s\n", name); |
| + return; |
| + } |
| + SkDebugf("Using skia example: %s\n", name); |
| + SkExample::create_user_example = &create; |
| + SkExample::userExampleExists = true; |
| + } |
| + }; |
| + |
| enum DeviceType { |
| kRaster_DeviceType, |
| kGPU_DeviceType, |
| }; |
| - BaseExample(void* hWnd, int argc, char** argv); |
| + SkExample(void* hWnd, int argc, char** argv); |
| // Changes the device type of the object. |
| bool setupBackend(DeviceType type); |
| @@ -44,6 +75,8 @@ protected: |
| SkCanvas* createCanvas() SK_OVERRIDE; |
| private: |
| + static bool userExampleExists; |
|
caryclark
2013/07/08 12:42:35
use 'gUserExampleExists' to hint to reader that th
|
| + |
| void setupRenderTarget(); |
| DeviceType fType; |
| @@ -52,6 +85,9 @@ private: |
| GrRenderTarget* fRenderTarget; |
| AttachmentInfo fAttachmentInfo; |
| const GrGLInterface* fInterface; |
| + |
| typedef SkOSWindow INHERITED; |
| }; |
| + |
| #endif |
| + |