OLD | NEW |
1 #import "SkSampleUIView.h" | 1 #import "SkSampleUIView.h" |
2 | 2 |
3 #define SKGL_CONFIG kEAGLColorFormatRGB565 | 3 #define SKGL_CONFIG kEAGLColorFormatRGB565 |
4 //#define SKGL_CONFIG kEAGLColorFormatRGBA8 | 4 //#define SKGL_CONFIG kEAGLColorFormatRGBA8 |
5 | 5 |
6 #define FORCE_REDRAW | 6 #define FORCE_REDRAW |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCGUtils.h" | 9 #include "SkCGUtils.h" |
10 #include "SkSurface.h" | 10 #include "SkSurface.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 virtual ~SkiOSDeviceManager() { | 35 virtual ~SkiOSDeviceManager() { |
36 #if SK_SUPPORT_GPU | 36 #if SK_SUPPORT_GPU |
37 SkSafeUnref(fCurContext); | 37 SkSafeUnref(fCurContext); |
38 SkSafeUnref(fCurIntf); | 38 SkSafeUnref(fCurIntf); |
39 SkSafeUnref(fCurRenderTarget); | 39 SkSafeUnref(fCurRenderTarget); |
40 #endif | 40 #endif |
41 } | 41 } |
42 | 42 |
43 void setUpBackend(SampleWindow* win, int msaaSampleCount) SK_OVERRIDE { | 43 void setUpBackend(SampleWindow* win, int msaaSampleCount) override { |
44 SkASSERT(SkOSWindow::kNone_BackEndType == fBackend); | 44 SkASSERT(SkOSWindow::kNone_BackEndType == fBackend); |
45 | 45 |
46 fBackend = SkOSWindow::kNone_BackEndType; | 46 fBackend = SkOSWindow::kNone_BackEndType; |
47 | 47 |
48 #if SK_SUPPORT_GPU | 48 #if SK_SUPPORT_GPU |
49 switch (win->getDeviceType()) { | 49 switch (win->getDeviceType()) { |
50 // these two don't use GL | 50 // these two don't use GL |
51 case SampleWindow::kRaster_DeviceType: | 51 case SampleWindow::kRaster_DeviceType: |
52 case SampleWindow::kPicture_DeviceType: | 52 case SampleWindow::kPicture_DeviceType: |
53 break; | 53 break; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 SkSafeUnref(fCurContext); | 94 SkSafeUnref(fCurContext); |
95 SkSafeUnref(fCurIntf); | 95 SkSafeUnref(fCurIntf); |
96 SkDebugf("Failed to setup 3D"); | 96 SkDebugf("Failed to setup 3D"); |
97 win->detach(); | 97 win->detach(); |
98 } | 98 } |
99 #endif // SK_SUPPORT_GPU | 99 #endif // SK_SUPPORT_GPU |
100 // call windowSizeChanged to create the render target | 100 // call windowSizeChanged to create the render target |
101 this->windowSizeChanged(win); | 101 this->windowSizeChanged(win); |
102 } | 102 } |
103 | 103 |
104 void tearDownBackend(SampleWindow *win) SK_OVERRIDE { | 104 void tearDownBackend(SampleWindow *win) override { |
105 #if SK_SUPPORT_GPU | 105 #if SK_SUPPORT_GPU |
106 SkSafeUnref(fCurContext); | 106 SkSafeUnref(fCurContext); |
107 fCurContext = NULL; | 107 fCurContext = NULL; |
108 | 108 |
109 SkSafeUnref(fCurIntf); | 109 SkSafeUnref(fCurIntf); |
110 fCurIntf = NULL; | 110 fCurIntf = NULL; |
111 | 111 |
112 SkSafeUnref(fCurRenderTarget); | 112 SkSafeUnref(fCurRenderTarget); |
113 fCurRenderTarget = NULL; | 113 fCurRenderTarget = NULL; |
114 #endif | 114 #endif |
115 win->detach(); | 115 win->detach(); |
116 fBackend = SampleWindow::kNone_BackEndType; | 116 fBackend = SampleWindow::kNone_BackEndType; |
117 } | 117 } |
118 | 118 |
119 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win)
SK_OVERRIDE{ | 119 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win)
override{ |
120 #if SK_SUPPORT_GPU | 120 #if SK_SUPPORT_GPU |
121 if (SampleWindow::IsGpuDeviceType(dType) && fCurContext) { | 121 if (SampleWindow::IsGpuDeviceType(dType) && fCurContext) { |
122 SkSurfaceProps props(win->getSurfaceProps()); | 122 SkSurfaceProps props(win->getSurfaceProps()); |
123 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); | 123 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); |
124 } | 124 } |
125 #endif | 125 #endif |
126 return NULL; | 126 return NULL; |
127 } | 127 } |
128 | 128 |
129 virtual void publishCanvas(SampleWindow::DeviceType dType, | 129 virtual void publishCanvas(SampleWindow::DeviceType dType, |
130 SkCanvas* canvas, | 130 SkCanvas* canvas, |
131 SampleWindow* win) SK_OVERRIDE { | 131 SampleWindow* win) override { |
132 #if SK_SUPPORT_GPU | 132 #if SK_SUPPORT_GPU |
133 if (NULL != fCurContext) { | 133 if (NULL != fCurContext) { |
134 fCurContext->flush(); | 134 fCurContext->flush(); |
135 } | 135 } |
136 #endif | 136 #endif |
137 win->present(); | 137 win->present(); |
138 } | 138 } |
139 | 139 |
140 void windowSizeChanged(SampleWindow* win) SK_OVERRIDE { | 140 void windowSizeChanged(SampleWindow* win) override { |
141 #if SK_SUPPORT_GPU | 141 #if SK_SUPPORT_GPU |
142 if (NULL != fCurContext) { | 142 if (NULL != fCurContext) { |
143 SkOSWindow::AttachmentInfo info; | 143 SkOSWindow::AttachmentInfo info; |
144 | 144 |
145 win->attach(fBackend, fMSAASampleCount, &info); | 145 win->attach(fBackend, fMSAASampleCount, &info); |
146 | 146 |
147 glBindFramebuffer(GL_FRAMEBUFFER, fLayerFBO); | 147 glBindFramebuffer(GL_FRAMEBUFFER, fLayerFBO); |
148 GrBackendRenderTargetDesc desc; | 148 GrBackendRenderTargetDesc desc; |
149 desc.fWidth = SkScalarRoundToInt(win->width()); | 149 desc.fWidth = SkScalarRoundToInt(win->width()); |
150 desc.fHeight = SkScalarRoundToInt(win->height()); | 150 desc.fHeight = SkScalarRoundToInt(win->height()); |
151 desc.fConfig = kSkia8888_GrPixelConfig; | 151 desc.fConfig = kSkia8888_GrPixelConfig; |
152 desc.fRenderTargetHandle = fLayerFBO; | 152 desc.fRenderTargetHandle = fLayerFBO; |
153 desc.fSampleCnt = info.fSampleCount; | 153 desc.fSampleCnt = info.fSampleCount; |
154 desc.fStencilBits = info.fStencilBits; | 154 desc.fStencilBits = info.fStencilBits; |
155 | 155 |
156 SkSafeUnref(fCurRenderTarget); | 156 SkSafeUnref(fCurRenderTarget); |
157 fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); | 157 fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); |
158 } | 158 } |
159 #endif | 159 #endif |
160 } | 160 } |
161 | 161 |
162 GrContext* getGrContext() SK_OVERRIDE { | 162 GrContext* getGrContext() override { |
163 #if SK_SUPPORT_GPU | 163 #if SK_SUPPORT_GPU |
164 return fCurContext; | 164 return fCurContext; |
165 #else | 165 #else |
166 return NULL; | 166 return NULL; |
167 #endif | 167 #endif |
168 } | 168 } |
169 | 169 |
170 GrRenderTarget* getGrRenderTarget() SK_OVERRIDE { | 170 GrRenderTarget* getGrRenderTarget() override { |
171 #if SK_SUPPORT_GPU | 171 #if SK_SUPPORT_GPU |
172 return fCurRenderTarget; | 172 return fCurRenderTarget; |
173 #else | 173 #else |
174 return NULL; | 174 return NULL; |
175 #endif | 175 #endif |
176 } | 176 } |
177 | 177 |
178 bool isUsingGL() const { return SkOSWindow::kNone_BackEndType != fBackend; } | 178 bool isUsingGL() const { return SkOSWindow::kNone_BackEndType != fBackend; } |
179 | 179 |
180 private: | 180 private: |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 glBindRenderbuffer(GL_RENDERBUFFER, fGL.fRenderbuffer); | 464 glBindRenderbuffer(GL_RENDERBUFFER, fGL.fRenderbuffer); |
465 glGetRenderbufferParameteriv(GL_RENDERBUFFER, | 465 glGetRenderbufferParameteriv(GL_RENDERBUFFER, |
466 GL_RENDERBUFFER_STENCIL_SIZE, | 466 GL_RENDERBUFFER_STENCIL_SIZE, |
467 &info->fStencilBits); | 467 &info->fStencilBits); |
468 glGetRenderbufferParameteriv(GL_RENDERBUFFER, | 468 glGetRenderbufferParameteriv(GL_RENDERBUFFER, |
469 GL_RENDERBUFFER_SAMPLES_APPLE, | 469 GL_RENDERBUFFER_SAMPLES_APPLE, |
470 &info->fSampleCount); | 470 &info->fSampleCount); |
471 } | 471 } |
472 | 472 |
473 @end | 473 @end |
OLD | NEW |