diff options
author | kkinnunen <kkinnunen@nvidia.com> | 2015-12-01 04:35:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-01 04:35:26 -0800 |
commit | 1530283c483cb88aa725bce50a6d193dd00ee570 (patch) | |
tree | c34d73ac28d83690a4cbf1196854176677e07366 /tests/ResourceCacheTest.cpp | |
parent | 362c900625dc2ece854678455776b711c1e44c04 (diff) |
Generate list of GPU contexts outside tests
Use DEF_GPUTEST_FOR_*_CONTEXT macros to obtain the
test GPU context.
Makes changing the context -related classes easier,
since not all tests need to be changed.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1448873002
Diffstat (limited to 'tests/ResourceCacheTest.cpp')
-rw-r--r-- | tests/ResourceCacheTest.cpp | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index 08d3678073..ee8d7c7eea 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -30,7 +30,17 @@ static const int gWidth = 640; static const int gHeight = 480; //////////////////////////////////////////////////////////////////////////////// -static void test_cache(skiatest::Reporter* reporter, GrContext* context, SkCanvas* canvas) { +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheCache, reporter, context) { + GrSurfaceDesc desc; + desc.fConfig = kSkia8888_GrPixelConfig; + desc.fFlags = kRenderTarget_GrSurfaceFlag; + desc.fWidth = gWidth; + desc.fHeight = gHeight; + SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight); + SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, + SkSurface::kNo_Budgeted, info)); + SkCanvas* canvas = surface->getCanvas(); + const SkIRect size = SkIRect::MakeWH(gWidth, gHeight); SkBitmap src; @@ -70,7 +80,7 @@ static void test_cache(skiatest::Reporter* reporter, GrContext* context, SkCanva context->setResourceCacheLimits(oldMaxNum, oldMaxBytes); } -static void test_stencil_buffers(skiatest::Reporter* reporter, GrContext* context) { +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, context) { GrSurfaceDesc smallDesc; smallDesc.fFlags = kRenderTarget_GrSurfaceFlag; smallDesc.fConfig = kSkia8888_GrPixelConfig; @@ -176,7 +186,7 @@ static void test_stencil_buffers(skiatest::Reporter* reporter, GrContext* contex } } -static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* context) { +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, context) { const GrGpu* gpu = context->getGpu(); // this test is only valid for GL if (!gpu || !gpu->glContextForTesting()) { @@ -1284,30 +1294,7 @@ static void test_abandoned(skiatest::Reporter* reporter) { resource->resourcePriv().removeUniqueKey(); } -//////////////////////////////////////////////////////////////////////////////// -DEF_GPUTEST(ResourceCache, reporter, factory) { - for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { - GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type); - if (!GrContextFactory::IsRenderingGLContext(glType)) { - continue; - } - GrContext* context = factory->get(glType); - if (nullptr == context) { - continue; - } - GrSurfaceDesc desc; - desc.fConfig = kSkia8888_GrPixelConfig; - desc.fFlags = kRenderTarget_GrSurfaceFlag; - desc.fWidth = gWidth; - desc.fHeight = gHeight; - SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight); - SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, - SkSurface::kNo_Budgeted, info)); - test_cache(reporter, context, surface->getCanvas()); - test_stencil_buffers(reporter, context); - test_wrapped_resources(reporter, context); - } - +DEF_GPUTEST(ResourceCacheMisc, reporter, factory) { // The below tests create their own mock contexts. test_no_key(reporter); test_budgeting(reporter); |