aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GrContextFactoryTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-11-15 15:48:03 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-15 22:03:07 +0000
commitdcfca431e3c350e17eedb3402cc63577cea8d4ea (patch)
treeb65ff91284663aef37e7603bbdba1fda51eb0c89 /tests/GrContextFactoryTest.cpp
parent20800c8b1bb7181fc7d3c6af756dc4440094ac90 (diff)
Use GrContextFactories that produce a single GrContext in unit tests.
This is to alleviate problems due to the command buffer getting bent out of shape when the current OpenGL context is switched out from under it (because we ran a test with a native GL context). This, however is not a full solution. More changes will be required to ensure that after running each command buffer or native test we bind the null context. This does allow us to take a step in that direction without breaking anything too badly. Moreover, there is no real benefit to reusing a GrContextFactory. Modifies DEF_GPUTEST to take GrContextOptions rather than a factory to use. Tests were already using their own factories anyway. In tests that use GrContextFactory the factory instance is moved to the inner loop. Modifies gpucts and skia_test to not use persistent GrContextFactories. Change-Id: Ie7a36793545c775f2f30653ead6fec93a3d22717 Reviewed-on: https://skia-review.googlesource.com/71861 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/GrContextFactoryTest.cpp')
-rw-r--r--tests/GrContextFactoryTest.cpp43
1 files changed, 21 insertions, 22 deletions
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 1514d67717..29f68366c3 100644
--- a/tests/GrContextFactoryTest.cpp
+++ b/tests/GrContextFactoryTest.cpp
@@ -17,12 +17,12 @@
using namespace sk_gpu_test;
-DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter, /*factory*/) {
+DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter, options) {
// Test that if NVPR is requested, the context always has path rendering
// or the context creation fails.
- GrContextFactory testFactory;
- // Test that if NVPR is possible, caps are in sync.
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
+ // Test that if NVPR is possible, caps are in sync.
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
GrContext* context = testFactory.get(ctxType,
GrContextFactory::ContextOverrides::kRequireNVPRSupport);
@@ -35,11 +35,11 @@ DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter,
}
}
-DEF_GPUTEST(GrContextFactory_NoPathRenderingIfNVPRDisabled, reporter, /*factory*/) {
+DEF_GPUTEST(GrContextFactory_NoPathRenderingIfNVPRDisabled, reporter, options) {
// Test that if NVPR is explicitly disabled, the context has no path rendering support.
- GrContextFactory testFactory;
for (int i = 0; i <= GrContextFactory::kLastContextType; ++i) {
+ GrContextFactory testFactory(options);
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType)i;
GrContext* context =
testFactory.get(ctxType, GrContextFactory::ContextOverrides::kDisableNVPR);
@@ -51,13 +51,13 @@ DEF_GPUTEST(GrContextFactory_NoPathRenderingIfNVPRDisabled, reporter, /*factory*
}
}
-DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, /*factory*/) {
+DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, options) {
// Test that if sRGB support is requested, the context always has that capability
// or the context creation fails. Also test that if the creation fails, a context
// created without that flag would not have had sRGB support.
- GrContextFactory testFactory;
- // Test that if sRGB is requested, caps are in sync.
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
+ // Test that if sRGB is requested, caps are in sync.
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
GrContext* context =
testFactory.get(ctxType, GrContextFactory::ContextOverrides::kRequireSRGBSupport);
@@ -73,9 +73,9 @@ DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, /*factory*/) {
}
}
-DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) {
- GrContextFactory testFactory;
+DEF_GPUTEST(GrContextFactory_abandon, reporter, options) {
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType) i;
ContextInfo info1 = testFactory.getContextInfo(ctxType);
if (!info1.grContext()) {
@@ -98,10 +98,9 @@ DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) {
}
}
-DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, /*factory*/) {
- GrContextFactory testFactory;
-
+DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, options) {
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
ContextInfo info1 = testFactory.getContextInfo(ctxType);
if (!info1.grContext()) {
@@ -141,17 +140,17 @@ DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, /*factory*/) {
}
}
-DEF_GPUTEST(GrContextFactory_executorAndTaskGroup, reporter, /*factory*/) {
- // Verify that contexts have a task group iff we supply an executor with context options
- GrContextOptions contextOptions;
- contextOptions.fExecutor = nullptr;
- GrContextFactory serialFactory(contextOptions);
+DEF_GPUTEST(GrContextFactory_executorAndTaskGroup, reporter, options) {
+ for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ // Verify that contexts have a task group iff we supply an executor with context options
+ GrContextOptions contextOptions = options;
+ contextOptions.fExecutor = nullptr;
+ GrContextFactory serialFactory(contextOptions);
- std::unique_ptr<SkExecutor> threadPool = SkExecutor::MakeFIFOThreadPool(1);
- contextOptions.fExecutor = threadPool.get();
- GrContextFactory threadedFactory(contextOptions);
+ std::unique_ptr<SkExecutor> threadPool = SkExecutor::MakeFIFOThreadPool(1);
+ contextOptions.fExecutor = threadPool.get();
+ GrContextFactory threadedFactory(contextOptions);
- for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
ContextInfo serialInfo = serialFactory.getContextInfo(ctxType);
if (GrContext* serialContext = serialInfo.grContext()) {