aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dm/DM.cpp53
-rwxr-xr-xsrc/gpu/GrContextFactory.cpp19
-rwxr-xr-xtests/GLInterfaceValidationTest.cpp39
-rw-r--r--tests/GrContextFactoryTest.cpp31
4 files changed, 63 insertions, 79 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 7497161369..c28f688697 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -597,32 +597,43 @@ static bool gpu_supported() {
return false;
#endif
}
-
+static Sink* create_gpu_sink(const char* tag, GrContextFactory::GLContextType contextType, int samples, bool diText, bool threaded) {
+#if SK_SUPPORT_GPU
+ GrContextFactory testFactory;
+ const GrGLStandard api = get_gpu_api();
+ if (testFactory.get(contextType, api)) {
+ return new GPUSink(contextType, api, samples, diText, threaded);
+ }
+ SkDebugf("WARNING: can not create GPU context for config '%s'. GM tests will be skipped.\n", tag);
+#endif
+ return nullptr;
+}
static Sink* create_sink(const char* tag) {
-#define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS__); }
+#define GPU_SINK(t, ...) if (0 == strcmp(t, tag)) { return create_gpu_sink(tag, __VA_ARGS__); }
if (gpu_supported()) {
typedef GrContextFactory Gr;
- const GrGLStandard api = get_gpu_api();
- SINK("gpunull", GPUSink, Gr::kNull_GLContextType, api, 0, false, FLAGS_gpu_threading);
- SINK("gpudebug", GPUSink, Gr::kDebug_GLContextType, api, 0, false, FLAGS_gpu_threading);
- SINK("gpu", GPUSink, Gr::kNative_GLContextType, api, 0, false, FLAGS_gpu_threading);
- SINK("gpudft", GPUSink, Gr::kNative_GLContextType, api, 0, true, FLAGS_gpu_threading);
- SINK("msaa4", GPUSink, Gr::kNative_GLContextType, api, 4, false, FLAGS_gpu_threading);
- SINK("msaa16", GPUSink, Gr::kNative_GLContextType, api, 16, false, FLAGS_gpu_threading);
- SINK("nvprmsaa4", GPUSink, Gr::kNVPR_GLContextType, api, 4, true, FLAGS_gpu_threading);
- SINK("nvprmsaa16", GPUSink, Gr::kNVPR_GLContextType, api, 16, true, FLAGS_gpu_threading);
- #if SK_ANGLE
- SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0, false, FLAGS_gpu_threading);
- SINK("angle-gl", GPUSink, Gr::kANGLE_GL_GLContextType, api, 0, false, FLAGS_gpu_threading);
- #endif
- #if SK_COMMAND_BUFFER
- SINK("commandbuffer", GPUSink, Gr::kCommandBuffer_GLContextType, api, 0, false, FLAGS_gpu_threading);
- #endif
- #if SK_MESA
- SINK("mesa", GPUSink, Gr::kMESA_GLContextType, api, 0, false, FLAGS_gpu_threading);
- #endif
+ GPU_SINK("gpunull", Gr::kNull_GLContextType, 0, false, FLAGS_gpu_threading);
+ GPU_SINK("gpudebug", Gr::kDebug_GLContextType, 0, false, FLAGS_gpu_threading);
+ GPU_SINK("gpu", Gr::kNative_GLContextType, 0, false, FLAGS_gpu_threading);
+ GPU_SINK("gpudft", Gr::kNative_GLContextType, 0, true, FLAGS_gpu_threading);
+ GPU_SINK("msaa4", Gr::kNative_GLContextType, 4, false, FLAGS_gpu_threading);
+ GPU_SINK("msaa16", Gr::kNative_GLContextType, 16, false, FLAGS_gpu_threading);
+ GPU_SINK("nvprmsaa4", Gr::kNVPR_GLContextType, 4, true, FLAGS_gpu_threading);
+ GPU_SINK("nvprmsaa16", Gr::kNVPR_GLContextType, 16, true, FLAGS_gpu_threading);
+#if SK_ANGLE
+ GPU_SINK("angle", Gr::kANGLE_GLContextType, 0, false, FLAGS_gpu_threading);
+ GPU_SINK("angle-gl", Gr::kANGLE_GL_GLContextType, 0, false, FLAGS_gpu_threading);
+#endif
+#if SK_COMMAND_BUFFER
+ GPU_SINK("commandbuffer", Gr::kCommandBuffer_GLContextType, 0, false, FLAGS_gpu_threading);
+#endif
+#if SK_MESA
+ GPU_SINK("mesa", Gr::kMESA_GLContextType, 0, false, FLAGS_gpu_threading);
+#endif
}
+#undef GPU_SINK
+#define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS__); }
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
SINK("hwui", HWUISink);
#endif
diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp
index 424b3fda3a..097b99b0b7 100755
--- a/src/gpu/GrContextFactory.cpp
+++ b/src/gpu/GrContextFactory.cpp
@@ -80,10 +80,6 @@ GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType ty
if (!glInterface) {
return nullptr;
}
- } else {
- if (!glInterface->hasExtension("GL_NV_path_rendering")) {
- return nullptr;
- }
}
glCtx->makeCurrent();
@@ -96,22 +92,9 @@ GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType ty
if (!grCtx.get()) {
return nullptr;
}
- // Warn if path rendering support is not available for the NVPR type.
if (kNVPR_GLContextType == type) {
if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) {
- GrGpu* gpu = grCtx->getGpu();
- const GrGLContext* ctx = gpu->glContextForTesting();
- if (ctx) {
- const GrGLubyte* verUByte;
- GR_GL_CALL_RET(ctx->interface(), verUByte, GetString(GR_GL_VERSION));
- const char* ver = reinterpret_cast<const char*>(verUByte);
- SkDebugf("\nWARNING: nvprmsaa config requested, but driver path rendering "
- "support not available. Maybe update the driver? Your driver version "
- "string: \"%s\"\n", ver);
- } else {
- SkDebugf("\nWARNING: nvprmsaa config requested, but driver path rendering "
- "support not available.\n");
- }
+ return nullptr;
}
}
diff --git a/tests/GLInterfaceValidationTest.cpp b/tests/GLInterfaceValidationTest.cpp
deleted file mode 100755
index 5736e2d2d6..0000000000
--- a/tests/GLInterfaceValidationTest.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "Test.h"
-
-// This is a GPU-backend specific test
-#if SK_SUPPORT_GPU
-
-#include "GrContextFactory.h"
-
-DEF_GPUTEST(GLInterfaceValidation, reporter, factory) {
- for (int i = 0; i <= GrContextFactory::kLastGLContextType; ++i) {
- GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType)i;
- // this forces the factory to make the context if it hasn't yet
- GrContextFactory::ContextInfo* contextInfo = factory->getContextInfo(glCtxType);
- SkGLContext* glCtx = contextInfo ? contextInfo->fGLContext : nullptr;
-
- // We're supposed to fail the NVPR context type when we the native context that does not
- // support the NVPR extension.
- if (GrContextFactory::kNVPR_GLContextType == glCtxType &&
- factory->getContextInfo(GrContextFactory::kNative_GLContextType) &&
- !factory->getContextInfo(GrContextFactory::kNative_GLContextType)->fGLContext->gl()->hasExtension("GL_NV_path_rendering")) {
- REPORTER_ASSERT(reporter, nullptr == glCtx);
- continue;
- }
-
- REPORTER_ASSERT(reporter, glCtx);
- if (glCtx) {
- const GrGLInterface* interface = glCtx->gl();
- REPORTER_ASSERT(reporter, interface->validate());
- }
- }
-}
-
-#endif
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 79209c719f..176391ef8d 100644
--- a/tests/GrContextFactoryTest.cpp
+++ b/tests/GrContextFactoryTest.cpp
@@ -10,8 +10,37 @@
#if SK_SUPPORT_GPU
#include "GrContextFactory.h"
+#include "GrCaps.h"
#include "Test.h"
-// TODO: test GrContextFactory.
+DEF_GPUTEST(GrContextFactory_NVPRContextTypeHasPathRenderingSupport, reporter, /*factory*/) {
+ // Test that if NVPR is requested, the context always has path rendering
+ // or the context creation fails.
+ GrContextFactory testFactory;
+ GrContext* context = testFactory.get(GrContextFactory::kNVPR_GLContextType);
+ if (context) {
+ REPORTER_ASSERT(
+ reporter,
+ context->caps()->shaderCaps()->pathRenderingSupport());
+ }
+}
+
+DEF_GPUTEST(GrContextFactory_NoPathRenderingUnlessNVPRRequested, reporter, /*factory*/) {
+ // Test that if NVPR is not requested, the context never has path rendering support.
+
+ GrContextFactory testFactory;
+ for (int i = 0; i <= GrContextFactory::kLastGLContextType; ++i) {
+ GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType)i;
+ if (glCtxType == GrContextFactory::kNVPR_GLContextType) {
+ continue;
+ }
+ GrContext* context = testFactory.get(glCtxType);
+ if (context) {
+ REPORTER_ASSERT(
+ reporter,
+ !context->caps()->shaderCaps()->pathRenderingSupport());
+ }
+ }
+}
#endif