aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gpu/GrContextFactory.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-02-24 14:51:44 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-27 02:29:24 +0000
commit9eac2ea77340d13bac58c7171e2e3971028ef8f8 (patch)
treeaaa5e140959c52429d23f73a315cbc6bbfef0614 /tools/gpu/GrContextFactory.cpp
parenta07741a75aa694c0e7c00c2301c9de2daf9b5f9e (diff)
Fixes to shared context test API
Fixes a bug in Windows shared context creation, and makes the API less fiddly. BUG=skia: Change-Id: Ia32b2e3b4816e0b8d7e9be92c22a182ca1393177 Reviewed-on: https://skia-review.googlesource.com/8965 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools/gpu/GrContextFactory.cpp')
-rw-r--r--tools/gpu/GrContextFactory.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp
index 637c569f89..0c6c87ad6f 100644
--- a/tools/gpu/GrContextFactory.cpp
+++ b/tools/gpu/GrContextFactory.cpp
@@ -103,8 +103,8 @@ const GrContextFactory::ContextType GrContextFactory::kNativeGL_ContextType =
GrContextFactory::kGLES_ContextType;
#endif
-ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOverrides overrides,
- GrContext* shareContext, uint32_t shareIndex) {
+ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOverrides overrides,
+ GrContext* shareContext, uint32_t shareIndex) {
// (shareIndex != 0) -> (shareContext != nullptr)
SkASSERT((shareIndex == 0) || (shareContext != nullptr));
@@ -129,10 +129,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOverrides
break;
}
}
-
- if (!masterContext || masterContext->fType != type) {
- return ContextInfo();
- }
+ SkASSERT(masterContext && masterContext->fType == type);
}
std::unique_ptr<TestContext> testCtx;
@@ -273,4 +270,20 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOverrides
return ContextInfo(context.fBackend, context.fTestContext, context.fGrContext);
}
+ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOverrides overrides) {
+ return this->getContextInfoInternal(type, overrides, nullptr, 0);
+}
+
+ContextInfo GrContextFactory::getSharedContextInfo(GrContext* shareContext, uint32_t shareIndex) {
+ SkASSERT(shareContext);
+ for (int i = 0; i < fContexts.count(); ++i) {
+ if (!fContexts[i].fAbandoned && fContexts[i].fGrContext == shareContext) {
+ return this->getContextInfoInternal(fContexts[i].fType, fContexts[i].fOverrides,
+ shareContext, shareIndex);
+ }
+ }
+
+ return ContextInfo();
+}
+
} // namespace sk_gpu_test