Make NVPR a GL context option instead of a GL context
Make NVPR a GL context option instead of a GL context.
This may enable NVPR to be run with command buffer
interface.
No functionality change in DM or nanobench. NVPR can
only be run with normal GL APIs.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1448883002
diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp
index 424b3fd..19382ee 100755
--- a/src/gpu/GrContextFactory.cpp
+++ b/src/gpu/GrContextFactory.cpp
@@ -24,21 +24,21 @@
#include "GrCaps.h"
GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType type,
- GrGLStandard forcedGpuAPI) {
+ GrGLStandard forcedGpuAPI,
+ GLContextOptions options) {
for (int i = 0; i < fContexts.count(); ++i) {
- if (forcedGpuAPI != kNone_GrGLStandard &&
- forcedGpuAPI != fContexts[i]->fGLContext->gl()->fStandard)
- continue;
-
- if (fContexts[i]->fType == type) {
+ if (fContexts[i]->fType == type &&
+ fContexts[i]->fOptions == options &&
+ (forcedGpuAPI == kNone_GrGLStandard ||
+ forcedGpuAPI == fContexts[i]->fGLContext->gl()->fStandard)) {
fContexts[i]->fGLContext->makeCurrent();
return fContexts[i];
}
}
+
SkAutoTUnref<SkGLContext> glCtx;
SkAutoTUnref<GrContext> grCtx;
switch (type) {
- case kNVPR_GLContextType: // fallthru
case kNative_GLContextType:
glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI));
break;
@@ -75,7 +75,7 @@
// Block NVPR from non-NVPR types.
SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl()));
- if (kNVPR_GLContextType != type) {
+ if (!(kEnableNVPR_GLContextOptions & options)) {
glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface));
if (!glInterface) {
return nullptr;
@@ -97,7 +97,7 @@
return nullptr;
}
// Warn if path rendering support is not available for the NVPR type.
- if (kNVPR_GLContextType == type) {
+ if (kEnableNVPR_GLContextOptions & options) {
if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) {
GrGpu* gpu = grCtx->getGpu();
const GrGLContext* ctx = gpu->glContextForTesting();
@@ -119,5 +119,6 @@
ctx->fGLContext = SkRef(glCtx.get());
ctx->fGrContext = SkRef(grCtx.get());
ctx->fType = type;
+ ctx->fOptions = options;
return ctx;
}