diff options
Diffstat (limited to 'tools/gpu/GrContextFactory.cpp')
-rw-r--r-- | tools/gpu/GrContextFactory.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp index 5b5f31415d..2407da930a 100644 --- a/tools/gpu/GrContextFactory.cpp +++ b/tools/gpu/GrContextFactory.cpp @@ -31,6 +31,8 @@ GrContextFactory::GrContextFactory() { } GrContextFactory::GrContextFactory(const GrContextOptions& opts) : fGlobalOptions(opts) { + // In this factory, instanced rendering is specified with kUseInstanced_ContextOptions. + SkASSERT(!fGlobalOptions.fEnableInstancedRendering); } GrContextFactory::~GrContextFactory() { @@ -150,8 +152,9 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op } testCtx.reset(glCtx); glInterface.reset(SkRef(glCtx->gl())); - // Block NVPR from non-NVPR types. - if (!(kEnableNVPR_ContextOptions & options)) { + // Block NVPR from non-NVPR types. We don't block NVPR from contexts that will use + // instanced rendering because that would prevent us from testing mixed samples. + if (!((kEnableNVPR_ContextOptions | kUseInstanced_ContextOptions) & options)) { glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface.get())); if (!glInterface) { return ContextInfo(); @@ -188,7 +191,11 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op } testCtx->makeCurrent(); SkASSERT(testCtx && testCtx->backend() == backend); - grCtx.reset(GrContext::Create(backend, backendContext, fGlobalOptions)); + GrContextOptions grOptions = fGlobalOptions; + if (kUseInstanced_ContextOptions & options) { + grOptions.fEnableInstancedRendering = true; + } + grCtx.reset(GrContext::Create(backend, backendContext, grOptions)); if (!grCtx.get()) { return ContextInfo(); } @@ -197,6 +204,11 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op return ContextInfo(); } } + if (kUseInstanced_ContextOptions & options) { + if (GrCaps::InstancedSupport::kNone == grCtx->caps()->instancedSupport()) { + return ContextInfo(); + } + } if (kRequireSRGBSupport_ContextOptions & options) { if (!grCtx->caps()->srgbSupport()) { return ContextInfo(); |