diff options
author | Robert Phillips <robertphillips@google.com> | 2017-01-31 11:31:39 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-31 17:22:38 +0000 |
commit | 6de99041f13e87ed440f7db13a07693c6c4c461a (patch) | |
tree | 560cfdcc0efb88cd82f04b2c9b0219f2f3d07c71 /tests | |
parent | 6d3b7aaf79b2cbacdf00bafc15ded2dfd2fa000a (diff) |
Reduce use of SkImage_Base::peekTexture
Change-Id: I079093c9706df4911d47fba04b786e59240e8cb4
Reviewed-on: https://skia-review.googlesource.com/7792
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/SpecialImageTest.cpp | 12 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 22 |
2 files changed, 19 insertions, 15 deletions
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp index 33f394811a..551efff6c5 100644 --- a/tests/SpecialImageTest.cpp +++ b/tests/SpecialImageTest.cpp @@ -51,7 +51,7 @@ static SkBitmap create_bm() { // Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels & draw) static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* reporter, - GrContext* context, bool peekTextureSucceeds, + GrContext* context, bool isGPUBacked, int offset, int size) { const SkIRect subset = img->subset(); REPORTER_ASSERT(reporter, offset == subset.left()); @@ -61,7 +61,7 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep //-------------- // Test that peekTexture reports the correct backing type - REPORTER_ASSERT(reporter, peekTextureSucceeds == img->isTextureBacked()); + REPORTER_ASSERT(reporter, isGPUBacked == img->isTextureBacked()); #if SK_SUPPORT_GPU //-------------- @@ -118,9 +118,9 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep REPORTER_ASSERT(reporter, tightImg->width() == subset.width()); REPORTER_ASSERT(reporter, tightImg->height() == subset.height()); - REPORTER_ASSERT(reporter, peekTextureSucceeds == !!tightImg->getTexture()); + REPORTER_ASSERT(reporter, isGPUBacked == !!tightImg->isTextureBacked()); SkPixmap tmpPixmap; - REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightImg->peekPixels(&tmpPixmap)); + REPORTER_ASSERT(reporter, isGPUBacked != !!tightImg->peekPixels(&tmpPixmap)); } { SkImageFilter::OutputProperties outProps(img->getColorSpace()); @@ -128,10 +128,10 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep REPORTER_ASSERT(reporter, tightSurf->width() == subset.width()); REPORTER_ASSERT(reporter, tightSurf->height() == subset.height()); - REPORTER_ASSERT(reporter, peekTextureSucceeds == + REPORTER_ASSERT(reporter, isGPUBacked == !!tightSurf->getTextureHandle(SkSurface::kDiscardWrite_BackendHandleAccess)); SkPixmap tmpPixmap; - REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightSurf->peekPixels(&tmpPixmap)); + REPORTER_ASSERT(reporter, isGPUBacked != !!tightSurf->peekPixels(&tmpPixmap)); } } diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 29aee9ccf9..2097ab3fa6 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -415,20 +415,22 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCRBug263329_Gpu, reporter, ctxInfo) { DEF_TEST(SurfaceGetTexture, reporter) { auto surface(create_surface()); sk_sp<SkImage> image(surface->makeImageSnapshot()); - REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == nullptr); + REPORTER_ASSERT(reporter, !as_IB(image)->isTextureBacked()); surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); - REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == nullptr); + REPORTER_ASSERT(reporter, !as_IB(image)->isTextureBacked()); } #if SK_SUPPORT_GPU DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, ctxInfo) { for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) { auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr)); sk_sp<SkImage> image(surface->makeImageSnapshot()); - GrTexture* texture = as_IB(image)->peekTexture(); - REPORTER_ASSERT(reporter, texture); - REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle()); + + REPORTER_ASSERT(reporter, as_IB(image)->isTextureBacked()); + GrBackendObject textureHandle = image->getTextureHandle(false); + REPORTER_ASSERT(reporter, 0 != textureHandle); surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); - REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == texture); + REPORTER_ASSERT(reporter, as_IB(image)->isTextureBacked()); + REPORTER_ASSERT(reporter, textureHandle == image->getTextureHandle(false)); } } #endif @@ -441,8 +443,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, ctxInfo) { static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) { SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get(); - return gsurf->getDevice()->accessRenderTargetContext() - ->accessRenderTarget()->resourcePriv().isBudgeted(); + + GrRenderTargetProxy* proxy = gsurf->getDevice()->accessRenderTargetContext() + ->asRenderTargetProxy(); + return proxy->isBudgeted(); } static SkBudgeted is_budgeted(SkImage* image) { @@ -676,7 +680,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) { [] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot()); SkImage_Gpu* gpuImage = (SkImage_Gpu *) as_IB(i); - sk_sp<GrSurfaceProxy> proxy = gpuImage->refProxy(); + sk_sp<GrTextureProxy> proxy = gpuImage->asTextureProxyRef(); GrContext* context = gpuImage->context(); return context->contextPriv().makeWrappedSurfaceContext(std::move(proxy), gpuImage->refColorSpace()); |