aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-04-05 12:59:06 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-05 12:59:06 -0700
commitf2f1c17e331fe1e0ce695969970ecebc81e12ceb (patch)
treee4dc53ee03e1803307a43917fb440d19cfe3f6f1 /dm
parent4319593988db5796023d9f5f34a8ed285c2097dd (diff)
One signature for creating unit tests that run on premade GrContexts
Diffstat (limited to 'dm')
-rw-r--r--dm/DM.cpp48
1 files changed, 9 insertions, 39 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 00cb279e81..4a81cee9e1 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -72,6 +72,7 @@ DEFINE_bool(simpleCodec, false, "Only decode images to native scale");
using namespace DM;
using sk_gpu_test::GrContextFactory;
using sk_gpu_test::GLTestContext;
+using sk_gpu_test::ContextInfo;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -1415,28 +1416,8 @@ int dm_main() {
// TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards.
// Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0.
namespace skiatest {
-namespace {
-typedef void(*TestWithGrContext)(skiatest::Reporter*, GrContext*);
-typedef void(*TestWithGrContextAndGLContext)(skiatest::Reporter*, GrContext*, GLTestContext*);
-#if SK_SUPPORT_GPU
-template<typename T>
-void call_test(T test, skiatest::Reporter* reporter, const GrContextFactory::ContextInfo& context);
-template<>
-void call_test(TestWithGrContext test, skiatest::Reporter* reporter,
- const GrContextFactory::ContextInfo& context) {
- test(reporter, context.fGrContext);
-}
-template<>
-void call_test(TestWithGrContextAndGLContext test, skiatest::Reporter* reporter,
- const GrContextFactory::ContextInfo& context) {
- test(reporter, context.fGrContext, context.fGLContext);
-}
-#endif
-} // namespace
-
-template<typename T>
-void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* reporter,
- GrContextFactory* factory) {
+void RunWithGPUTestContexts(GrContextTestFn* test, GPUTestContexts testContexts,
+ Reporter* reporter, GrContextFactory* factory) {
#if SK_SUPPORT_GPU
// Iterate over context types, except use "native" instead of explicitly trying OpenGL and
// OpenGL ES. Do not use GLES on desktop, since tests do not account for not fixing
@@ -1476,29 +1457,18 @@ void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo
if ((testContexts & contextSelector) == 0) {
continue;
}
- GrContextFactory::ContextInfo context = factory->getContextInfo(contextType);
- if (context.fGrContext) {
- call_test(test, reporter, context);
+ ContextInfo ctxInfo = factory->getContextInfo(contextType);
+ if (ctxInfo.fGrContext) {
+ (*test)(reporter, ctxInfo);
}
- context = factory->getContextInfo(contextType,
+ ctxInfo = factory->getContextInfo(contextType,
GrContextFactory::kEnableNVPR_ContextOptions);
- if (context.fGrContext) {
- call_test(test, reporter, context);
+ if (ctxInfo.fGrContext) {
+ (*test)(reporter, ctxInfo);
}
}
#endif
}
-
-template
-void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test,
- GPUTestContexts testContexts,
- Reporter* reporter,
- GrContextFactory* factory);
-template
-void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndGLContext test,
- GPUTestContexts testContexts,
- Reporter* reporter,
- GrContextFactory* factory);
} // namespace skiatest
#if !defined(SK_BUILD_FOR_IOS)