diff options
author | 2016-07-21 07:17:54 -0700 | |
---|---|---|
committer | 2016-07-21 07:17:54 -0700 | |
commit | 1f3923e4e5bf9afb9e52a15ced30e3854af73f7b (patch) | |
tree | b3d9484a73598754f40e74b67971f49e32b44a23 /tests/SurfaceTest.cpp | |
parent | afbf71dd924c7bb46ccdac49e7408b4b088563ff (diff) |
Deprecate SkDevice::accessBitmap method
Relies on https://codereview.chromium.org/2162423003/ (Add SK_SUPPORT_LEGACY_ACCESSBITMAP Skia guard) landing in Chromium first.
Calved off: https://codereview.chromium.org/2163323002/ (Add desired width & height to drawContext (as opposed to using the width & height of the RT))
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2168483003
Review-Url: https://codereview.chromium.org/2168483003
Diffstat (limited to 'tests/SurfaceTest.cpp')
-rw-r--r-- | tests/SurfaceTest.cpp | 63 |
1 files changed, 1 insertions, 62 deletions
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 3996ab7429..16db3e3c4e 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -128,38 +128,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCanvasPeek_Gpu, reporter, ctxInfo) { } #endif -// For compatibility with clients that still call accessBitmap(), we need to ensure that we bump -// the bitmap's genID when we draw to it, else they won't know it has new values. When they are -// exclusively using surface/image, and we can hide accessBitmap from device, we can remove this -// test. -void test_access_pixels(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface) { - SkCanvas* canvas = surface->getCanvas(); - canvas->clear(0); - - SkBaseDevice* device = canvas->getDevice_just_for_deprecated_compatibility_testing(); - SkBitmap bm = device->accessBitmap(false); - uint32_t genID0 = bm.getGenerationID(); - // Now we draw something, which needs to "dirty" the genID (sorta like copy-on-write) - canvas->drawColor(SK_ColorBLUE); - // Now check that we get a different genID - uint32_t genID1 = bm.getGenerationID(); - REPORTER_ASSERT(reporter, genID0 != genID1); -} -DEF_TEST(SurfaceAccessPixels, reporter) { - for (auto& surface_func : { &create_surface, &create_direct_surface }) { - auto surface(surface_func(kPremul_SkAlphaType, nullptr)); - test_access_pixels(reporter, surface); - } -} -#if SK_SUPPORT_GPU -DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceAccessPixels_Gpu, reporter, ctxInfo) { - for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) { - auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr)); - test_access_pixels(reporter, surface); - } -} -#endif - static void test_snapshot_alphatype(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface, bool expectOpaque) { REPORTER_ASSERT(reporter, surface); @@ -380,36 +348,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) { #endif #if SK_SUPPORT_GPU -// May we (soon) eliminate the need to keep testing this, by hiding the bloody device! -static uint32_t get_legacy_gen_id(SkSurface* surface) { - SkBaseDevice* device = - surface->getCanvas()->getDevice_just_for_deprecated_compatibility_testing(); - return device->accessBitmap(false).getGenerationID(); -} -/* - * Test legacy behavor of bumping the surface's device's bitmap's genID when we access its - * texture handle for writing. - * - * Note: this needs to be tested separately from checking makeImageSnapshot, as calling that - * can also incidentally bump the genID (when a new backing surface is created). - */ -static void test_backend_handle_gen_id( - skiatest::Reporter* reporter, SkSurface* surface, - GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) { - const uint32_t gen0 = get_legacy_gen_id(surface); - func(surface, SkSurface::kFlushRead_BackendHandleAccess); - const uint32_t gen1 = get_legacy_gen_id(surface); - REPORTER_ASSERT(reporter, gen0 == gen1); - func(surface, SkSurface::kFlushWrite_BackendHandleAccess); - const uint32_t gen2 = get_legacy_gen_id(surface); - REPORTER_ASSERT(reporter, gen0 != gen2); - - func(surface, SkSurface::kDiscardWrite_BackendHandleAccess); - const uint32_t gen3 = get_legacy_gen_id(surface); - REPORTER_ASSERT(reporter, gen0 != gen3); - REPORTER_ASSERT(reporter, gen2 != gen3); -} static void test_backend_handle_unique_id( skiatest::Reporter* reporter, SkSurface* surface, GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) { @@ -436,7 +375,7 @@ static void test_backend_handle_unique_id( // No CPU test. DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessIDs_Gpu, reporter, ctxInfo) { for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) { - for (auto& test_func : { &test_backend_handle_unique_id, &test_backend_handle_gen_id }) { + for (auto& test_func : { &test_backend_handle_unique_id }) { for (auto& handle_access_func : { &get_surface_backend_texture_handle, &get_surface_backend_render_target_handle}) { auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr)); |