OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Skia | 2 * Copyright 2011 Skia |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SampleApp_DEFINED | 8 #ifndef SampleApp_DEFINED |
9 #define SampleApp_DEFINED | 9 #define SampleApp_DEFINED |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 class DeviceManager : public SkRefCnt { | 67 class DeviceManager : public SkRefCnt { |
68 public: | 68 public: |
69 | 69 |
70 | 70 |
71 virtual void setUpBackend(SampleWindow* win, int msaaSampleCount, bool d
eepColor) = 0; | 71 virtual void setUpBackend(SampleWindow* win, int msaaSampleCount, bool d
eepColor) = 0; |
72 | 72 |
73 virtual void tearDownBackend(SampleWindow* win) = 0; | 73 virtual void tearDownBackend(SampleWindow* win) = 0; |
74 | 74 |
75 // called before drawing. should install correct device | 75 // called before drawing. should install correct device |
76 // type on the canvas. Will skip drawing if returns false. | 76 // type on the canvas. Will skip drawing if returns false. |
77 virtual SkSurface* createSurface(DeviceType dType, SampleWindow* win) =
0; | 77 virtual sk_sp<SkSurface> makeSurface(DeviceType dType, SampleWindow* win
) = 0; |
78 | 78 |
79 // called after drawing, should get the results onto the | 79 // called after drawing, should get the results onto the |
80 // screen. | 80 // screen. |
81 virtual void publishCanvas(DeviceType dType, | 81 virtual void publishCanvas(DeviceType dType, |
82 SkCanvas* canvas, | 82 SkCanvas* canvas, |
83 SampleWindow* win) = 0; | 83 SampleWindow* win) = 0; |
84 | 84 |
85 // called when window changes size, guaranteed to be called | 85 // called when window changes size, guaranteed to be called |
86 // at least once before first draw (after init) | 86 // at least once before first draw (after init) |
87 virtual void windowSizeChanged(SampleWindow* win) = 0; | 87 virtual void windowSizeChanged(SampleWindow* win) = 0; |
88 | 88 |
89 // return the GrContext backing gpu devices (nullptr if not built with G
PU support) | 89 // return the GrContext backing gpu devices (nullptr if not built with G
PU support) |
90 virtual GrContext* getGrContext() = 0; | 90 virtual GrContext* getGrContext() = 0; |
91 | 91 |
92 // return the GrRenderTarget backing gpu devices (nullptr if not built w
ith GPU support) | 92 // return the GrRenderTarget backing gpu devices (nullptr if not built w
ith GPU support) |
93 virtual GrRenderTarget* getGrRenderTarget() = 0; | 93 virtual int numColorSamples() const = 0; |
94 | 94 |
95 // return the color depth of the output device | 95 // return the color depth of the output device |
96 virtual int getColorBits() = 0; | 96 virtual int getColorBits() = 0; |
97 | 97 |
98 private: | 98 private: |
99 typedef SkRefCnt INHERITED; | 99 typedef SkRefCnt INHERITED; |
100 }; | 100 }; |
101 | 101 |
102 SampleWindow(void* hwnd, int argc, char** argv, DeviceManager*); | 102 SampleWindow(void* hwnd, int argc, char** argv, DeviceManager*); |
103 virtual ~SampleWindow(); | 103 virtual ~SampleWindow(); |
104 | 104 |
105 SkSurface* createSurface() override { | 105 sk_sp<SkSurface> makeSurface() override { |
106 SkSurface* surface = nullptr; | 106 sk_sp<SkSurface> surface; |
107 if (fDevManager) { | 107 if (fDevManager) { |
108 surface = fDevManager->createSurface(fDeviceType, this); | 108 surface = fDevManager->makeSurface(fDeviceType, this); |
109 } | 109 } |
110 if (nullptr == surface) { | 110 if (!surface) { |
111 surface = this->INHERITED::createSurface(); | 111 surface = this->INHERITED::makeSurface(); |
112 } | 112 } |
113 return surface; | 113 return surface; |
114 } | 114 } |
115 | 115 |
116 void draw(SkCanvas*) override; | 116 void draw(SkCanvas*) override; |
117 | 117 |
118 void setDeviceType(DeviceType type); | 118 void setDeviceType(DeviceType type); |
119 void setDeviceColorType(SkColorType, sk_sp<SkColorSpace>); | 119 void setDeviceColorType(SkColorType, sk_sp<SkColorSpace>); |
120 void toggleRendering(); | 120 void toggleRendering(); |
121 void toggleSlideshow(); | 121 void toggleSlideshow(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 void postAnimatingEvent(); | 233 void postAnimatingEvent(); |
234 int findByTitle(const char*); | 234 int findByTitle(const char*); |
235 void listTitles(); | 235 void listTitles(); |
236 SkSize tileSize() const; | 236 SkSize tileSize() const; |
237 bool sendAnimatePulse(); | 237 bool sendAnimatePulse(); |
238 | 238 |
239 typedef SkOSWindow INHERITED; | 239 typedef SkOSWindow INHERITED; |
240 }; | 240 }; |
241 | 241 |
242 #endif | 242 #endif |
OLD | NEW |