diff options
author | bsalomon <bsalomon@google.com> | 2016-04-05 12:59:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-05 12:59:06 -0700 |
commit | f2f1c17e331fe1e0ce695969970ecebc81e12ceb (patch) | |
tree | e4dc53ee03e1803307a43917fb440d19cfe3f6f1 /dm | |
parent | 4319593988db5796023d9f5f34a8ed285c2097dd (diff) |
One signature for creating unit tests that run on premade GrContexts
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1860593002
Review URL: https://codereview.chromium.org/1860593002
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DM.cpp | 48 |
1 files changed, 9 insertions, 39 deletions
@@ -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) |