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(); | |
bsalomon
2015/01/30 19:19:12
~SkExampleWindow() SK_OVERRIDE?
caryclark
2015/01/30 19:55:28
Done.
| |
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 static void release_storage(void* pixels, void* context) { | |
bsalomon
2015/01/30 19:19:12
ReleaseStorage?
caryclark
2015/01/30 19:55:28
The whole function is unused so I deleted it.
| |
57 SkASSERT(pixels == context); | |
58 sk_free(pixels); | |
59 } | |
60 | |
61 SkSurface* createSurface() SK_OVERRIDE { | |
62 if (kGPU_DeviceType == fType) { | |
63 SkSurfaceProps props(INHERITED::getSurfaceProps()); | |
64 return SkSurface::NewRenderTargetDirect(fRenderTarget, &props); | |
65 } | |
66 static const SkImageInfo info = SkImageInfo::MakeN32Premul( | |
67 SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->heig ht())); | |
68 return fSurface = SkSurface::NewRaster(info); | |
69 } | |
70 | |
55 void draw(SkCanvas* canvas) SK_OVERRIDE; | 71 void draw(SkCanvas* canvas) SK_OVERRIDE; |
56 | 72 |
57 void onSizeChange() SK_OVERRIDE; | 73 void onSizeChange() SK_OVERRIDE; |
58 | 74 |
59 #ifdef SK_BUILD_FOR_WIN | |
60 void onHandleInval(const SkIRect&) SK_OVERRIDE; | |
61 #endif | |
62 | |
63 SkCanvas* createCanvas() SK_OVERRIDE; | |
64 | |
65 private: | 75 private: |
66 bool findNextMatch(); // Set example to the first one that matches FLAGS_ma tch. | 76 bool findNextMatch(); // Set example to the first one that matches FLAGS_ma tch. |
67 void setupRenderTarget(); | 77 void setTitle(); |
78 void setUpRenderTarget(); | |
68 bool onHandleChar(SkUnichar unichar) SK_OVERRIDE; | 79 bool onHandleChar(SkUnichar unichar) SK_OVERRIDE; |
80 void tearDownBackend(); | |
69 | 81 |
70 DeviceType fType; | 82 DeviceType fType; |
71 | 83 SkSurface* fSurface; |
72 SkExample* fCurrExample; | 84 SkExample* fCurrExample; |
73 const SkExample::Registry* fRegistry; | 85 const SkExample::Registry* fRegistry; |
74 GrContext* fContext; | 86 GrContext* fContext; |
75 GrRenderTarget* fRenderTarget; | 87 GrRenderTarget* fRenderTarget; |
76 AttachmentInfo fAttachmentInfo; | 88 AttachmentInfo fAttachmentInfo; |
77 const GrGLInterface* fInterface; | 89 const GrGLInterface* fInterface; |
78 | 90 |
79 typedef SkOSWindow INHERITED; | 91 typedef SkOSWindow INHERITED; |
80 }; | 92 }; |
81 | 93 |
82 #endif | 94 #endif |
OLD | NEW |