diff options
author | Robert Phillips <robertphillips@google.com> | 2017-06-23 14:09:30 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-26 15:29:18 +0000 |
commit | 8744405448b9402e1368aebd321c4f555543301a (patch) | |
tree | b5df1fbe70897eca74072f9c5b9920977c817d36 | |
parent | 6945c946ea800b7bff31920914a990c88a706718 (diff) |
Remove SkImage_Base::peekTexture call
Change-Id: Ie5b6bec8df083e0a128aa234d80f5a214cd98f0d
Reviewed-on: https://skia-review.googlesource.com/20741
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r-- | src/image/SkImage_Base.h | 3 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 4 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.h | 9 | ||||
-rw-r--r-- | tests/GrTextureMipMapInvalidationTest.cpp | 4 | ||||
-rw-r--r-- | tests/ImageTest.cpp | 17 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 12 |
6 files changed, 22 insertions, 27 deletions
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 9604dc6b31..650041870c 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -44,8 +44,7 @@ public: virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint) const = 0; - // MDB TODO: this entry point needs to go away - virtual GrTexture* peekTexture() const { return nullptr; } + virtual GrContext* context() const { return nullptr; } #if SK_SUPPORT_GPU virtual GrTextureProxy* peekProxy() const { return nullptr; } virtual sk_sp<GrTextureProxy> asTextureProxyRef() const { return nullptr; } diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 41990e842b..4e8b28bc74 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -454,8 +454,8 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext* context, SkColorSpace* dstCo if (!context) { return nullptr; } - if (GrTexture* peek = as_IB(this)->peekTexture()) { - return peek->getContext() == context ? sk_ref_sp(const_cast<SkImage*>(this)) : nullptr; + if (GrContext* incumbent = as_IB(this)->context()) { + return incumbent == context ? sk_ref_sp(const_cast<SkImage*>(this)) : nullptr; } if (this->isLazyGenerated()) { diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h index 32a6647a73..9c3517bac5 100644 --- a/src/image/SkImage_Gpu.h +++ b/src/image/SkImage_Gpu.h @@ -33,16 +33,10 @@ public: bool getROPixels(SkBitmap*, SkColorSpace* dstColorSpace, CachingHint) const override; sk_sp<SkImage> onMakeSubset(const SkIRect&) const override; + GrContext* context() const override { return fContext; } GrTextureProxy* peekProxy() const override { return fProxy.get(); } - GrTexture* peekTexture() const override { - if (!fProxy->instantiate(fContext->resourceProvider())) { - return nullptr; - } - - return fProxy->priv().peekTexture(); - } sk_sp<GrTextureProxy> asTextureProxyRef() const override { return fProxy; } @@ -61,7 +55,6 @@ public: bool onReadPixels(const SkImageInfo&, void* dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint) const override; - GrContext* context() { return fContext; } sk_sp<SkColorSpace> refColorSpace() { return fColorSpace; } sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>, SkColorType, diff --git a/tests/GrTextureMipMapInvalidationTest.cpp b/tests/GrTextureMipMapInvalidationTest.cpp index e7573dc010..c9c4d7ef8a 100644 --- a/tests/GrTextureMipMapInvalidationTest.cpp +++ b/tests/GrTextureMipMapInvalidationTest.cpp @@ -20,11 +20,11 @@ // Tests that MIP maps are created and invalidated as expected when drawing to and from GrTextures. DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrTextureMipMapInvalidationTest, reporter, ctxInfo) { auto isMipped = [] (SkSurface* surf) { - return as_IB(surf->makeImageSnapshot())->peekTexture()->texturePriv().hasMipMaps(); + return surf->makeImageSnapshot()->getTexture()->texturePriv().hasMipMaps(); }; auto mipsAreDirty = [] (SkSurface* surf) { - return as_IB(surf->makeImageSnapshot())->peekTexture()->texturePriv().mipMapsAreDirty(); + return surf->makeImageSnapshot()->getTexture()->texturePriv().mipMapsAreDirty(); }; GrContext* context = ctxInfo.grContext(); diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 13a8a131d9..511b6f24b6 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -483,23 +483,26 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextIn ERRORF(reporter, "Error creating image."); continue; } - GrTexture* origTexture = as_IB(image)->peekTexture(); sk_sp<SkImage> texImage(image->makeTextureImage(context, dstColorSpace.get())); if (!texImage) { + GrContext* imageContext = as_IB(image)->context(); + // We expect to fail if image comes from a different GrContext. - if (!origTexture || origTexture->getContext() == context) { + if (!image->isTextureBacked() || imageContext == context) { ERRORF(reporter, "makeTextureImage failed."); } continue; } - GrTexture* copyTexture = as_IB(texImage)->peekTexture(); - if (!copyTexture) { + if (!texImage->isTextureBacked()) { ERRORF(reporter, "makeTextureImage returned non-texture image."); continue; } - if (origTexture) { - if (origTexture != copyTexture) { + if (image->isTextureBacked()) { + GrSurfaceProxy* origProxy = as_IB(image)->peekProxy(); + GrSurfaceProxy* copyProxy = as_IB(texImage)->peekProxy(); + + if (origProxy->underlyingUniqueID() != copyProxy->underlyingUniqueID()) { ERRORF(reporter, "makeTextureImage made unnecessary texture copy."); } } @@ -546,7 +549,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_drawAbandonedGpuImage, reporter, c auto image = create_gpu_image(context); auto info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info)); - as_IB(image)->peekTexture()->abandon(); + image->getTexture()->abandon(); surface->getCanvas()->drawImage(image, 0, 0); } diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 1dd68ffb38..dc051a54b6 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -397,13 +397,13 @@ static void test_crbug263329(skiatest::Reporter* reporter, // be recycling a texture that is held by an existing image. canvas2->clear(5); sk_sp<SkImage> image4(surface2->makeImageSnapshot()); - REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image3)->peekTexture()); + REPORTER_ASSERT(reporter, as_IB(image4)->getTexture() != as_IB(image3)->getTexture()); // The following assertion checks crbug.com/263329 - REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image2)->peekTexture()); - REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image1)->peekTexture()); - REPORTER_ASSERT(reporter, as_IB(image3)->peekTexture() != as_IB(image2)->peekTexture()); - REPORTER_ASSERT(reporter, as_IB(image3)->peekTexture() != as_IB(image1)->peekTexture()); - REPORTER_ASSERT(reporter, as_IB(image2)->peekTexture() != as_IB(image1)->peekTexture()); + REPORTER_ASSERT(reporter, as_IB(image4)->getTexture() != as_IB(image2)->getTexture()); + REPORTER_ASSERT(reporter, as_IB(image4)->getTexture() != as_IB(image1)->getTexture()); + REPORTER_ASSERT(reporter, as_IB(image3)->getTexture() != as_IB(image2)->getTexture()); + REPORTER_ASSERT(reporter, as_IB(image3)->getTexture() != as_IB(image1)->getTexture()); + REPORTER_ASSERT(reporter, as_IB(image2)->getTexture() != as_IB(image1)->getTexture()); } DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCRBug263329_Gpu, reporter, ctxInfo) { for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) { |