OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 * | 7 * |
8 */ | 8 */ |
9 | 9 |
10 #ifndef BaseExample_DEFINED | 10 #ifndef SkExample_DEFINED |
11 #define BaseExample_DEFINED | 11 #define SkExample_DEFINED |
12 | 12 |
13 #include "SkWindow.h" | 13 #include "SkWindow.h" |
| 14 #include "SkTRegistry.h" |
14 | 15 |
15 class GrContext; | 16 class GrContext; |
16 struct GrGLInterface; | 17 struct GrGLInterface; |
17 class GrRenderTarget; | 18 class GrRenderTarget; |
18 class SkCanvas; | 19 class SkCanvas; |
| 20 class SkExampleWindow; |
19 | 21 |
20 class BaseExample : public SkOSWindow { | 22 class SkExample : public SkNoncopyable { |
| 23 public: |
| 24 SkExample(SkExampleWindow* window) : fWindow(window) {} |
| 25 |
| 26 // Your class should override this method to do its thing. |
| 27 virtual void draw(SkCanvas* canvas) = 0; |
| 28 |
| 29 SkString getName() { return fName; }; |
| 30 // Use this public registry to tell the world about your sample. |
| 31 typedef SkTRegistry<SkExample*, SkExampleWindow*> Registry; |
| 32 |
| 33 protected: |
| 34 SkExampleWindow* fWindow; |
| 35 SkString fName; |
| 36 }; |
| 37 |
| 38 class SkExampleWindow : public SkOSWindow { |
21 public: | 39 public: |
22 enum DeviceType { | 40 enum DeviceType { |
23 kRaster_DeviceType, | 41 kRaster_DeviceType, |
24 kGPU_DeviceType, | 42 kGPU_DeviceType, |
25 }; | 43 }; |
26 BaseExample(void* hWnd, int argc, char** argv); | 44 SkExampleWindow(void* hwnd); |
27 | 45 |
28 // Changes the device type of the object. | 46 // Changes the device type of the object. |
29 bool setupBackend(DeviceType type); | 47 bool setupBackend(DeviceType type); |
30 void tearDownBackend(); | 48 void tearDownBackend(); |
31 | 49 |
32 DeviceType getDeviceType() const { return fType; } | 50 DeviceType getDeviceType() const { return fType; } |
33 | 51 |
34 protected: | 52 protected: |
35 // Your class should override this method to do its thing. | |
36 virtual void draw(SkCanvas* canvas) SK_OVERRIDE; | 53 virtual void draw(SkCanvas* canvas) SK_OVERRIDE; |
37 | 54 |
38 virtual void onSizeChange() SK_OVERRIDE; | 55 virtual void onSizeChange() SK_OVERRIDE; |
39 | 56 |
40 #ifdef SK_BUILD_FOR_WIN | 57 #ifdef SK_BUILD_FOR_WIN |
41 virtual void onHandleInval(const SkIRect&) SK_OVERRIDE; | 58 virtual void onHandleInval(const SkIRect&) SK_OVERRIDE; |
42 #endif | 59 #endif |
43 | 60 |
44 SkCanvas* createCanvas() SK_OVERRIDE; | 61 SkCanvas* createCanvas() SK_OVERRIDE; |
45 | 62 |
46 private: | 63 private: |
| 64 bool findNextMatch(); // Set example to the first one that matches FLAGS_ma
tch. |
47 void setupRenderTarget(); | 65 void setupRenderTarget(); |
| 66 bool onHandleChar(SkUnichar unichar) SK_OVERRIDE; |
48 | 67 |
49 DeviceType fType; | 68 DeviceType fType; |
50 | 69 |
| 70 SkExample* fCurrExample; |
| 71 const SkExample::Registry* fRegistry; |
| 72 SkTDArray<const char*> fMatchStrs; |
51 GrContext* fContext; | 73 GrContext* fContext; |
52 GrRenderTarget* fRenderTarget; | 74 GrRenderTarget* fRenderTarget; |
53 AttachmentInfo fAttachmentInfo; | 75 AttachmentInfo fAttachmentInfo; |
54 const GrGLInterface* fInterface; | 76 const GrGLInterface* fInterface; |
| 77 |
55 typedef SkOSWindow INHERITED; | 78 typedef SkOSWindow INHERITED; |
56 }; | 79 }; |
| 80 |
57 #endif | 81 #endif |
| 82 |
OLD | NEW |