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 <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2017-01-31 18:24:12 -05:00 committed by Skia Commit-Bot
parent 6520a69e64
commit 77b3f32936
3 changed files with 28 additions and 0 deletions

View File

@ -256,6 +256,10 @@ public:
sk_sp<GrTexture> tex(sk_ref_sp(GrRefCachedBitmapTexture(
context, fBitmap, GrSamplerParams::ClampNoFilter(), nullptr)));
sk_sp<GrSurfaceProxy> sProxy = GrSurfaceProxy::MakeWrapped(std::move(tex));
if (!sProxy) {
return nullptr;
}
return sk_ref_sp(sProxy->asTextureProxy());
}

View File

@ -591,6 +591,9 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeWrappedRenderTargetContext(
ASSERT_SINGLE_OWNER_PRIV
sk_sp<GrSurfaceProxy> 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<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurface
ASSERT_SINGLE_OWNER_PRIV
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface)));
if (!proxy) {
return nullptr;
}
return this->makeWrappedSurfaceContext(std::move(proxy), nullptr);
}
@ -624,6 +630,9 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrSurfac
sk_sp<GrSurfaceProxy> 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<GrSurfaceContext> GrContextPriv::makeBackendSurfaceContext(const GrBackend
}
sk_sp<GrSurfaceProxy> 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<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContex
}
sk_sp<GrSurfaceProxy> 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<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetC
}
sk_sp<GrSurfaceProxy> 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<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRend
}
sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface)));
if (!proxy) {
return nullptr;
}
return this->drawingManager()->makeRenderTargetContext(std::move(proxy),
std::move(colorSpace),

View File

@ -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);