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>
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 29aee9c..2097ab3 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -415,20 +415,22 @@
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 @@
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 @@
[] (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());