OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 #include "SampleApp.h" | 8 #include "SampleApp.h" |
9 | 9 |
10 #include "OverView.h" | 10 #include "OverView.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 169 } |
170 | 170 |
171 virtual ~DefaultDeviceManager() { | 171 virtual ~DefaultDeviceManager() { |
172 #if SK_SUPPORT_GPU | 172 #if SK_SUPPORT_GPU |
173 SkSafeUnref(fCurContext); | 173 SkSafeUnref(fCurContext); |
174 SkSafeUnref(fCurIntf); | 174 SkSafeUnref(fCurIntf); |
175 SkSafeUnref(fCurRenderTarget); | 175 SkSafeUnref(fCurRenderTarget); |
176 #endif | 176 #endif |
177 } | 177 } |
178 | 178 |
179 virtual void setUpBackend(SampleWindow* win, int msaaSampleCount) { | 179 void setUpBackend(SampleWindow* win, int msaaSampleCount) override { |
180 SkASSERT(kNone_BackEndType == fBackend); | 180 SkASSERT(kNone_BackEndType == fBackend); |
181 | 181 |
182 fBackend = kNone_BackEndType; | 182 fBackend = kNone_BackEndType; |
183 | 183 |
184 #if SK_SUPPORT_GPU | 184 #if SK_SUPPORT_GPU |
185 switch (win->getDeviceType()) { | 185 switch (win->getDeviceType()) { |
186 case kRaster_DeviceType: // fallthrough | 186 case kRaster_DeviceType: // fallthrough |
187 case kPicture_DeviceType: // fallthrough | 187 case kPicture_DeviceType: // fallthrough |
188 case kDeferred_DeviceType: // fallthrough | 188 case kDeferred_DeviceType: // fallthrough |
189 case kGPU_DeviceType: | 189 case kGPU_DeviceType: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 fCurIntf = NULL; | 243 fCurIntf = NULL; |
244 SkDebugf("Failed to setup 3D"); | 244 SkDebugf("Failed to setup 3D"); |
245 | 245 |
246 win->detach(); | 246 win->detach(); |
247 } | 247 } |
248 #endif // SK_SUPPORT_GPU | 248 #endif // SK_SUPPORT_GPU |
249 // call windowSizeChanged to create the render target | 249 // call windowSizeChanged to create the render target |
250 this->windowSizeChanged(win); | 250 this->windowSizeChanged(win); |
251 } | 251 } |
252 | 252 |
253 virtual void tearDownBackend(SampleWindow *win) { | 253 void tearDownBackend(SampleWindow *win) override { |
254 #if SK_SUPPORT_GPU | 254 #if SK_SUPPORT_GPU |
255 if (fCurContext) { | 255 if (fCurContext) { |
256 // in case we have outstanding refs to this guy (lua?) | 256 // in case we have outstanding refs to this guy (lua?) |
257 fCurContext->abandonContext(); | 257 fCurContext->abandonContext(); |
258 fCurContext->unref(); | 258 fCurContext->unref(); |
259 fCurContext = NULL; | 259 fCurContext = NULL; |
260 } | 260 } |
261 | 261 |
262 SkSafeUnref(fCurIntf); | 262 SkSafeUnref(fCurIntf); |
263 fCurIntf = NULL; | 263 fCurIntf = NULL; |
264 | 264 |
265 SkSafeUnref(fCurRenderTarget); | 265 SkSafeUnref(fCurRenderTarget); |
266 fCurRenderTarget = NULL; | 266 fCurRenderTarget = NULL; |
267 #endif | 267 #endif |
268 win->detach(); | 268 win->detach(); |
269 fBackend = kNone_BackEndType; | 269 fBackend = kNone_BackEndType; |
270 } | 270 } |
271 | 271 |
272 virtual SkSurface* createSurface(SampleWindow::DeviceType dType, | 272 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win)
override { |
273 SampleWindow* win) override { | |
274 #if SK_SUPPORT_GPU | 273 #if SK_SUPPORT_GPU |
275 if (IsGpuDeviceType(dType) && fCurContext) { | 274 if (IsGpuDeviceType(dType) && fCurContext) { |
276 SkSurfaceProps props(win->getSurfaceProps()); | 275 SkSurfaceProps props(win->getSurfaceProps()); |
277 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); | 276 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); |
278 } | 277 } |
279 #endif | 278 #endif |
280 return NULL; | 279 return NULL; |
281 } | 280 } |
282 | 281 |
283 virtual void publishCanvas(SampleWindow::DeviceType dType, | 282 void publishCanvas(SampleWindow::DeviceType dType, |
284 SkCanvas* canvas, | 283 SkCanvas* canvas, SampleWindow* win) override { |
285 SampleWindow* win) { | |
286 #if SK_SUPPORT_GPU | 284 #if SK_SUPPORT_GPU |
287 if (fCurContext) { | 285 if (fCurContext) { |
288 // in case we have queued drawing calls | 286 // in case we have queued drawing calls |
289 fCurContext->flush(); | 287 fCurContext->flush(); |
290 | 288 |
291 if (!IsGpuDeviceType(dType)) { | 289 if (!IsGpuDeviceType(dType)) { |
292 // need to send the raster bits to the (gpu) window | 290 // need to send the raster bits to the (gpu) window |
293 const SkBitmap& bm = win->getBitmap(); | 291 const SkBitmap& bm = win->getBitmap(); |
294 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(), | 292 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(), |
295 SkImageInfo2GrPixelConfig(bm.colorT
ype(), | 293 SkImageInfo2GrPixelConfig(bm.colorT
ype(), |
296 bm.alphaT
ype(), | 294 bm.alphaT
ype(), |
297 bm.profil
eType()), | 295 bm.profil
eType()), |
298 bm.getPixels(), | 296 bm.getPixels(), |
299 bm.rowBytes(), | 297 bm.rowBytes(), |
300 GrContext::kFlushWrites_PixelOp); | 298 GrContext::kFlushWrites_PixelOp); |
301 } | 299 } |
302 } | 300 } |
303 #endif | 301 #endif |
304 | 302 |
305 win->present(); | 303 win->present(); |
306 } | 304 } |
307 | 305 |
308 virtual void windowSizeChanged(SampleWindow* win) { | 306 void windowSizeChanged(SampleWindow* win) override { |
309 #if SK_SUPPORT_GPU | 307 #if SK_SUPPORT_GPU |
310 if (fCurContext) { | 308 if (fCurContext) { |
311 AttachmentInfo attachmentInfo; | 309 AttachmentInfo attachmentInfo; |
312 win->attach(fBackend, fMSAASampleCount, &attachmentInfo); | 310 win->attach(fBackend, fMSAASampleCount, &attachmentInfo); |
313 SkSafeUnref(fCurRenderTarget); | 311 SkSafeUnref(fCurRenderTarget); |
314 fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurC
ontext); | 312 fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurC
ontext); |
315 } | 313 } |
316 #endif | 314 #endif |
317 } | 315 } |
318 | 316 |
319 virtual GrContext* getGrContext() { | 317 GrContext* getGrContext() override { |
320 #if SK_SUPPORT_GPU | 318 #if SK_SUPPORT_GPU |
321 return fCurContext; | 319 return fCurContext; |
322 #else | 320 #else |
323 return NULL; | 321 return NULL; |
324 #endif | 322 #endif |
325 } | 323 } |
326 | 324 |
327 GrRenderTarget* getGrRenderTarget() override { | 325 GrRenderTarget* getGrRenderTarget() override { |
328 #if SK_SUPPORT_GPU | 326 #if SK_SUPPORT_GPU |
329 return fCurRenderTarget; | 327 return fCurRenderTarget; |
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2303 setenv("ANDROID_ROOT", "/android/device/data", 0); |
2306 #endif | 2304 #endif |
2307 SkGraphics::Init(); | 2305 SkGraphics::Init(); |
2308 SkEvent::Init(); | 2306 SkEvent::Init(); |
2309 } | 2307 } |
2310 | 2308 |
2311 void application_term() { | 2309 void application_term() { |
2312 SkEvent::Term(); | 2310 SkEvent::Term(); |
2313 SkGraphics::Term(); | 2311 SkGraphics::Term(); |
2314 } | 2312 } |
OLD | NEW |