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
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index e2dd5f8..16768c7 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -107,13 +107,38 @@
         }
         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::resetState(bool callFinish) {
 #if SK_SUPPORT_GPU
-    if (this->isUsingGpuDevice()) {
-        SkGLContext* glContext = fGrContextFactory.getGLContext(
-            GrContextFactory::kNative_GLContextType);
+    SkGLContext* glContext = this->getGLContext();
+    if (NULL == glContext) {
+        SkASSERT(kBitmap_DeviceType == fDeviceType);
+        return;
+    }
 
-        SkASSERT(glContext != NULL);
-        if (NULL == glContext) {
-            return;
-        }
-
-        fGrContext->flush();
-        if (callFinish) {
-            SK_GL(*glContext, Finish());
-        }
+    fGrContext->flush();
+    if (callFinish) {
+        SK_GL(*glContext, Finish());
     }
 #endif
 }