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 SkExample_DEFINED | 10 #ifndef SkExample_DEFINED |
11 #define SkExample_DEFINED | 11 #define SkExample_DEFINED |
12 | 12 |
| 13 #include "SkSurface.h" |
13 #include "SkWindow.h" | 14 #include "SkWindow.h" |
14 #include "SkTRegistry.h" | 15 #include "SkTRegistry.h" |
15 | 16 |
16 class GrContext; | 17 class GrContext; |
17 struct GrGLInterface; | 18 struct GrGLInterface; |
18 class GrRenderTarget; | 19 class GrRenderTarget; |
19 class SkCanvas; | 20 class SkCanvas; |
20 class SkExampleWindow; | 21 class SkExampleWindow; |
21 | 22 |
22 class SkExample : SkNoncopyable { | 23 class SkExample : SkNoncopyable { |
(...skipping 14 matching lines...) Expand all Loading... |
37 SkString fName; | 38 SkString fName; |
38 }; | 39 }; |
39 | 40 |
40 class SkExampleWindow : public SkOSWindow { | 41 class SkExampleWindow : public SkOSWindow { |
41 public: | 42 public: |
42 enum DeviceType { | 43 enum DeviceType { |
43 kRaster_DeviceType, | 44 kRaster_DeviceType, |
44 kGPU_DeviceType, | 45 kGPU_DeviceType, |
45 }; | 46 }; |
46 SkExampleWindow(void* hwnd); | 47 SkExampleWindow(void* hwnd); |
| 48 virtual ~SkExampleWindow() SK_OVERRIDE; |
47 | 49 |
48 // Changes the device type of the object. | 50 // Changes the device type of the object. |
49 bool setupBackend(DeviceType type); | 51 bool setUpBackend(); |
50 void tearDownBackend(); | |
51 | 52 |
52 DeviceType getDeviceType() const { return fType; } | 53 DeviceType getDeviceType() const { return fType; } |
53 | 54 |
54 protected: | 55 protected: |
| 56 SkSurface* createSurface() SK_OVERRIDE { |
| 57 if (kGPU_DeviceType == fType) { |
| 58 SkSurfaceProps props(INHERITED::getSurfaceProps()); |
| 59 return SkSurface::NewRenderTargetDirect(fRenderTarget, &props); |
| 60 } |
| 61 static const SkImageInfo info = SkImageInfo::MakeN32Premul( |
| 62 SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->heig
ht())); |
| 63 return fSurface = SkSurface::NewRaster(info); |
| 64 } |
| 65 |
55 void draw(SkCanvas* canvas) SK_OVERRIDE; | 66 void draw(SkCanvas* canvas) SK_OVERRIDE; |
| 67 void drawContents(SkCanvas* canvas); |
56 | 68 |
57 void onSizeChange() SK_OVERRIDE; | 69 void onSizeChange() SK_OVERRIDE; |
58 | 70 |
59 #ifdef SK_BUILD_FOR_WIN | |
60 void onHandleInval(const SkIRect&) SK_OVERRIDE; | |
61 #endif | |
62 | |
63 SkCanvas* createCanvas() SK_OVERRIDE; | |
64 | |
65 private: | 71 private: |
66 bool findNextMatch(); // Set example to the first one that matches FLAGS_ma
tch. | 72 bool findNextMatch(); // Set example to the first one that matches FLAGS_ma
tch. |
67 void setupRenderTarget(); | 73 void setTitle(); |
| 74 void setUpRenderTarget(); |
68 bool onHandleChar(SkUnichar unichar) SK_OVERRIDE; | 75 bool onHandleChar(SkUnichar unichar) SK_OVERRIDE; |
| 76 void tearDownBackend(); |
69 | 77 |
| 78 // draw contents |
| 79 SkScalar fRotationAngle; |
| 80 |
| 81 // support framework |
70 DeviceType fType; | 82 DeviceType fType; |
71 | 83 SkSurface* fSurface; |
72 SkExample* fCurrExample; | |
73 const SkExample::Registry* fRegistry; | |
74 GrContext* fContext; | 84 GrContext* fContext; |
75 GrRenderTarget* fRenderTarget; | 85 GrRenderTarget* fRenderTarget; |
76 AttachmentInfo fAttachmentInfo; | 86 AttachmentInfo fAttachmentInfo; |
77 const GrGLInterface* fInterface; | 87 const GrGLInterface* fInterface; |
78 | 88 |
79 typedef SkOSWindow INHERITED; | 89 typedef SkOSWindow INHERITED; |
80 }; | 90 }; |
81 | 91 |
82 #endif | 92 #endif |
OLD | NEW |