diff options
author | 2017-07-13 15:07:54 -0400 | |
---|---|---|
committer | 2017-07-13 21:29:33 +0000 | |
commit | b76a72a659f53b8bf449c5ca2685045d08a21e43 (patch) | |
tree | cc2e1b3c997817f514438e79c248d3b890e65ef7 /tools/gpu/GrContextFactory.cpp | |
parent | ee3e0bacc8bedd1e3ebfb52fbc8b1cc3ccdad358 (diff) |
Add support for creating a GrContext backed by Metal.
Also adds the support code to allow our TestContext to create a Metal
backend.
Bug: skia:
Change-Id: Ia850687019d79b897bb16e2c151f4f8526721ad9
Reviewed-on: https://skia-review.googlesource.com/22644
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tools/gpu/GrContextFactory.cpp')
-rw-r--r-- | tools/gpu/GrContextFactory.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp index d614b0643e..0686b79902 100644 --- a/tools/gpu/GrContextFactory.cpp +++ b/tools/gpu/GrContextFactory.cpp @@ -20,6 +20,9 @@ #ifdef SK_VULKAN #include "vk/VkTestContext.h" #endif +#ifdef SK_METAL +#include "mtl/MtlTestContext.h" +#endif #include "gl/null/NullGLTestContext.h" #include "gl/GrGLGpu.h" #include "mock/MockTestContext.h" @@ -221,6 +224,16 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv break; } #endif +#ifdef SK_METAL + case kMetal_GrBackend: { + SkASSERT(!masterContext); + testCtx.reset(CreatePlatformMtlTestContext(nullptr)); + if (!testCtx) { + return ContextInfo(); + } + break; + } +#endif case kMock_GrBackend: { TestContext* sharedContext = masterContext ? masterContext->fTestContext : nullptr; SkASSERT(kMock_ContextType == type); @@ -252,7 +265,10 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv if (ContextOverrides::kAvoidStencilBuffers & overrides) { grOptions.fAvoidStencilBuffers = true; } - sk_sp<GrContext> grCtx(GrContext::Create(backend, backendContext, grOptions)); + sk_sp<GrContext> grCtx = testCtx->makeGrContext(grOptions); + if (!grCtx.get() && kMetal_GrBackend != backend) { + grCtx.reset(GrContext::Create(backend, backendContext, grOptions)); + } if (!grCtx.get()) { return ContextInfo(); } |