From 77b3f32936dd069fa6a27f870b3b30035733d940 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 31 Jan 2017 18:24:12 -0500 Subject: [PATCH] Broaden checking of GrSurfaceProxy::MakeDeferred's return value We now expect MakeDeferred to baulk if the ultimate texture/rendertarget will not be instantiable. Added checks for MakeWrapped too since, technically, it too can baulk. BUG=676753 Change-Id: I3e052ebf98303fc46124272082c10f303d89da27 Reviewed-on: https://skia-review.googlesource.com/7830 Reviewed-by: Brian Salomon Commit-Queue: Robert Phillips --- src/core/SkSpecialImage.cpp | 4 ++++ src/gpu/GrContext.cpp | 21 +++++++++++++++++++++ src/gpu/text/GrAtlasGlyphCache.cpp | 3 +++ 3 files changed, 28 insertions(+) diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index 1d1a557..0ec5459 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -256,6 +256,10 @@ public: sk_sp tex(sk_ref_sp(GrRefCachedBitmapTexture( context, fBitmap, GrSamplerParams::ClampNoFilter(), nullptr))); sk_sp sProxy = GrSurfaceProxy::MakeWrapped(std::move(tex)); + if (!sProxy) { + return nullptr; + } + return sk_ref_sp(sProxy->asTextureProxy()); } diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index aeab9d1..b5586b4 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -591,6 +591,9 @@ sk_sp GrContextPriv::makeWrappedRenderTargetContext( ASSERT_SINGLE_OWNER_PRIV sk_sp proxy(GrSurfaceProxy::MakeWrapped(std::move(rt))); + if (!proxy) { + return nullptr; + } return this->drawingManager()->makeRenderTargetContext(std::move(proxy), std::move(colorSpace), @@ -614,6 +617,9 @@ sk_sp GrContextPriv::makeWrappedSurfaceContext(sk_sp proxy(GrSurfaceProxy::MakeWrapped(std::move(surface))); + if (!proxy) { + return nullptr; + } return this->makeWrappedSurfaceContext(std::move(proxy), nullptr); } @@ -624,6 +630,9 @@ sk_sp GrContextPriv::makeDeferredSurfaceContext(const GrSurfac sk_sp proxy = GrSurfaceProxy::MakeDeferred(*fContext->caps(), dstDesc, fit, isDstBudgeted); + if (!proxy) { + return nullptr; + } return this->makeWrappedSurfaceContext(std::move(proxy), nullptr); } @@ -639,6 +648,9 @@ sk_sp GrContextPriv::makeBackendSurfaceContext(const GrBackend } sk_sp proxy(GrSurfaceProxy::MakeWrapped(std::move(surface))); + if (!proxy) { + return nullptr; + } return this->makeWrappedSurfaceContext(std::move(proxy), std::move(colorSpace)); } @@ -657,6 +669,9 @@ sk_sp GrContextPriv::makeBackendTextureRenderTargetContex } sk_sp proxy(GrSurfaceProxy::MakeWrapped(std::move(surface))); + if (!proxy) { + return nullptr; + } return this->drawingManager()->makeRenderTargetContext(std::move(proxy), std::move(colorSpace), props); @@ -674,6 +689,9 @@ sk_sp GrContextPriv::makeBackendRenderTargetRenderTargetC } sk_sp proxy(GrSurfaceProxy::MakeWrapped(std::move(rt))); + if (!proxy) { + return nullptr; + } return this->drawingManager()->makeRenderTargetContext(std::move(proxy), std::move(colorSpace), @@ -693,6 +711,9 @@ sk_sp GrContextPriv::makeBackendTextureAsRenderTargetRend } sk_sp proxy(GrSurfaceProxy::MakeWrapped(std::move(surface))); + if (!proxy) { + return nullptr; + } return this->drawingManager()->makeRenderTargetContext(std::move(proxy), std::move(colorSpace), diff --git a/src/gpu/text/GrAtlasGlyphCache.cpp b/src/gpu/text/GrAtlasGlyphCache.cpp index 58e78c1..95cadd8 100644 --- a/src/gpu/text/GrAtlasGlyphCache.cpp +++ b/src/gpu/text/GrAtlasGlyphCache.cpp @@ -119,6 +119,9 @@ void GrAtlasGlyphCache::HandleEviction(GrDrawOpAtlas::AtlasID id, void* ptr) { * @param filename Full path to desired file */ static bool save_pixels(GrContext* context, GrSurfaceProxy* sProxy, const char* filename) { + if (!sProxy) { + return false; + } SkImageInfo ii = SkImageInfo::Make(sProxy->width(), sProxy->height(), kRGBA_8888_SkColorType, kPremul_SkAlphaType); -- 2.7.4