Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: tools/PictureRenderer.h

Issue 1338003002: skia: Add ANGLE with GL backend to nanobench/DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: consistent naming Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/SkpSkGrTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/PictureRenderer.h
diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h
index e935f401700abd590c2f92bb10c12772e1c9f1df..f28eae1f6ac69b5255e35474873449d2c6f80d39 100644
--- a/tools/PictureRenderer.h
+++ b/tools/PictureRenderer.h
@@ -44,6 +44,7 @@ public:
enum SkDeviceTypes {
#if SK_ANGLE
kAngle_DeviceType,
+ kAngle_GL_DeviceType,
bsalomon 2015/09/11 18:54:47 The PictureRenderer stuff isn't really used anymor
#endif
#if SK_COMMAND_BUFFER
kCommandBuffer_DeviceType,
@@ -177,44 +178,20 @@ public:
bool setDeviceType(SkDeviceTypes deviceType) {
#endif
fDeviceType = deviceType;
+ if (deviceType == kBitmap_DeviceType) {
+ return true;
+ }
+
#if SK_SUPPORT_GPU
// In case this function is called more than once
SkSafeUnref(fGrContext);
fGrContext = nullptr;
// Set to Native so it will have an initial value.
- GrContextFactory::GLContextType glContextType = GrContextFactory::kNative_GLContextType;
-#endif
- switch(deviceType) {
- case kBitmap_DeviceType:
- return true;
-#if SK_SUPPORT_GPU
- case kGPU_DeviceType:
- // Already set to GrContextFactory::kNative_GLContextType, above.
- break;
- case kNVPR_DeviceType:
- glContextType = GrContextFactory::kNVPR_GLContextType;
- break;
-#if SK_ANGLE
- case kAngle_DeviceType:
- glContextType = GrContextFactory::kANGLE_GLContextType;
- break;
-#endif
-#if SK_COMMAND_BUFFER
- case kCommandBuffer_DeviceType:
- glContextType = GrContextFactory::kCommandBuffer_GLContextType;
- break;
-#endif
-#if SK_MESA
- case kMesa_DeviceType:
- glContextType = GrContextFactory::kMESA_GLContextType;
- break;
-#endif
-#endif
- default:
- // Invalid device type.
- return false;
+ GrContextFactory::GLContextType glContextType = getGPUContextType(fDeviceType);
+ if (GrContextFactory::kNull_GLContextType == glContextType) {
+ return false;
}
-#if SK_SUPPORT_GPU
+
fGrContext = fGrContextFactory.get(glContextType, gpuAPI);
if (nullptr == fGrContext) {
return false;
@@ -223,6 +200,7 @@ public:
return true;
}
#endif
+ return false;
}
#if SK_SUPPORT_GPU
@@ -295,6 +273,9 @@ public:
case kAngle_DeviceType:
config.append("_angle");
break;
+ case kAngle_GL_DeviceType:
+ config.append("_angle-gl");
+ break;
#endif
#if SK_COMMAND_BUFFER
case kCommandBuffer_DeviceType:
@@ -349,6 +330,9 @@ public:
case kAngle_DeviceType:
result["config"] = "angle";
break;
+ case kAngle_GL_DeviceType:
+ result["config"] = "angle-gl";
+ break;
#endif
#if SK_COMMAND_BUFFER
case kCommandBuffer_DeviceType:
@@ -376,6 +360,7 @@ public:
// fall through
#if SK_ANGLE
case kAngle_DeviceType:
+ case kAngle_GL_DeviceType:
// fall through
#endif
#if SK_COMMAND_BUFFER
@@ -392,32 +377,9 @@ public:
}
SkGLContext* getGLContext() {
- GrContextFactory::GLContextType glContextType
- = GrContextFactory::kNull_GLContextType;
- switch(fDeviceType) {
- case kGPU_DeviceType:
- glContextType = GrContextFactory::kNative_GLContextType;
- break;
- case kNVPR_DeviceType:
- glContextType = GrContextFactory::kNVPR_GLContextType;
- break;
-#if SK_ANGLE
- case kAngle_DeviceType:
- glContextType = GrContextFactory::kANGLE_GLContextType;
- break;
-#endif
-#if SK_COMMAND_BUFFER
- case kCommandBuffer_DeviceType:
- glContextType = GrContextFactory::kCommandBuffer_GLContextType;
- break;
-#endif
-#if SK_MESA
- case kMesa_DeviceType:
- glContextType = GrContextFactory::kMESA_GLContextType;
- break;
-#endif
- default:
- return nullptr;
+ GrContextFactory::GLContextType glContextType = getGPUContextType(fDeviceType);
+ if (GrContextFactory::kNull_GLContextType == glContextType) {
+ return nullptr;
}
return fGrContextFactory.getGLContext(glContextType);
}
@@ -512,6 +474,43 @@ protected:
*/
static void CopyString(SkString* dest, const SkString* src);
+#if SK_SUPPORT_GPU
+ /**
+ * Get the context type for a given device type. Returns kNull_GLContextType for non gpu
+ * device types.
+ */
+ GrContextFactory::GLContextType getGPUContextType(SkDeviceTypes deviceType) const {
+ GrContextFactory::GLContextType glContextType = GrContextFactory::kNull_GLContextType;
+ switch(deviceType) {
+ case kGPU_DeviceType:
+ glContextType = GrContextFactory::kNative_GLContextType;
+ break;
+ case kNVPR_DeviceType:
+ glContextType = GrContextFactory::kNVPR_GLContextType;
+ break;
+#if SK_ANGLE
+ case kAngle_DeviceType:
+ glContextType = GrContextFactory::kANGLE_GLContextType;
+ break;
+ case kAngle_GL_DeviceType:
+ glContextType = GrContextFactory::kANGLE_GL_GLContextType;
+ break;
+#endif // SK_ANGLE
+#if SK_COMMAND_BUFFER
+ case kCommandBuffer_DeviceType:
+ glContextType = GrContextFactory::kCommandBuffer_GLContextType;
+ break;
+#endif // SK_COMMAND_BUFFER
+#if SK_MESA
+ case kMesa_DeviceType:
+ glContextType = GrContextFactory::kMESA_GLContextType;
+ break;
+#endif // SK_MESA
+ }
+ return glContextType;
+ }
+#endif // SK_SUPPORT_GPU
+
private:
SkISize fViewport;
SkScalar fScaleFactor;
« no previous file with comments | « tests/SkpSkGrTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698