diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-08 19:38:21 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-02-08 19:38:21 +0000 |
commit | 0556ea0ede7066b9b3ed9f03f5a6eb72cd718897 (patch) | |
tree | 8afc8bdd79e7fda177938ad1084b02813371a670 /tools/PictureRenderer.cpp | |
parent | 6184c978b827c7350f085d0ba65cf03cd04eb85b (diff) |
Add support for using ANGLE in bench_pictures.
BUG=https://code.google.com/p/skia/issues/detail?id=1012
Other cleanups:
Remove setDeviceType from PictureBenchmark, since it is unnecessary.
Dereference PictureRenderer::fGrContext when done with it.
Make PictureRenderer::fGrContext and PictureRenderer::fGrContextFactory private, since they are not used by subclasses.
Review URL: https://codereview.appspot.com/7314063
git-svn-id: http://skia.googlecode.com/svn/trunk@7677 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/PictureRenderer.cpp')
-rw-r--r-- | tools/PictureRenderer.cpp | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index e2dd5f82c1..16768c79e2 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -107,13 +107,38 @@ SkCanvas* PictureRenderer::setupCanvas(int width, int height) { } break; #if SK_SUPPORT_GPU +#if SK_ANGLE + case kAngle_DeviceType: + // fall through +#endif case kGPU_DeviceType: { - SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, - (fGrContext, SkBitmap::kARGB_8888_Config, - width, height))); + SkAutoTUnref<GrRenderTarget> rt; + bool grSuccess = false; + if (fGrContext) { + // create a render target to back the device + GrTextureDesc desc; + desc.fConfig = kSkia8888_GrPixelConfig; + desc.fFlags = kRenderTarget_GrTextureFlagBit; + desc.fWidth = width; + desc.fHeight = height; + desc.fSampleCnt = 0; + GrTexture* tex = fGrContext->createUncachedTexture(desc, NULL, 0); + if (tex) { + rt.reset(tex->asRenderTarget()); + rt.get()->ref(); + tex->unref(); + grSuccess = NULL != rt.get(); + } + } + if (!grSuccess) { + SkASSERT(0); + return NULL; + } + + SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (fGrContext, rt))); canvas = SkNEW_ARGS(SkCanvas, (device.get())); + break; } - break; #endif default: SkASSERT(0); @@ -175,19 +200,15 @@ void PictureRenderer::buildBBoxHierarchy() { void PictureRenderer::resetState(bool callFinish) { #if SK_SUPPORT_GPU - if (this->isUsingGpuDevice()) { - SkGLContext* glContext = fGrContextFactory.getGLContext( - GrContextFactory::kNative_GLContextType); - - SkASSERT(glContext != NULL); - if (NULL == glContext) { - return; - } + SkGLContext* glContext = this->getGLContext(); + if (NULL == glContext) { + SkASSERT(kBitmap_DeviceType == fDeviceType); + return; + } - fGrContext->flush(); - if (callFinish) { - SK_GL(*glContext, Finish()); - } + fGrContext->flush(); + if (callFinish) { + SK_GL(*glContext, Finish()); } #endif } |