diff options
author | 2018-01-23 16:38:14 -0500 | |
---|---|---|
committer | 2018-01-24 15:12:30 +0000 | |
commit | f2336e4500769bc0ff6a208289d757581b0ea91a (patch) | |
tree | 097f306d11e48aea68f6e2df26f0e3d3ef031c1c /src/image/SkImage_Gpu.cpp | |
parent | 4e69f14814d14fd44aa93404656280b388419265 (diff) |
Add lazy proxy's for wrapping backend textures
Bug: skia:
Change-Id: I3bb557cefc35312adc9515b5683d2ed747bb4eb3
Reviewed-on: https://skia-review.googlesource.com/96862
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/image/SkImage_Gpu.cpp')
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index fe4c2b95cf..c00c50d000 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -156,6 +156,22 @@ GrBackendObject SkImage_Gpu::onGetTextureHandle(bool flushPendingGrContextIO, GrSurfaceOrigin* origin) const { SkASSERT(fProxy); + if (!fContext->contextPriv().resourceProvider() && !fProxy->priv().isInstantiated()) { + // This image was created with a DDL context and cannot be instantiated. Thus we return 0 + // here which is considered invalid for all backends. + return 0; + } + + if (GrSurfaceProxy::LazyState::kNot != fProxy->lazyInstantiationState()) { + SkASSERT(fContext->contextPriv().resourceProvider()); + fProxy->priv().doLazyInstantiation(fContext->contextPriv().resourceProvider()); + if (!fProxy->priv().isInstantiated()) { + // We failed to instantiate the lazy proxy. Thus we return 0 here which is considered + // invalid for all backends. + return 0; + } + } + if (!fProxy->instantiate(fContext->contextPriv().resourceProvider())) { return 0; } @@ -335,6 +351,10 @@ sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx, sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx, const GrBackendTexture& tex, GrSurfaceOrigin origin, SkAlphaType at, sk_sp<SkColorSpace> cs) { + if (!ctx->contextPriv().resourceProvider()) { + // We have a DDL context and we don't support adopted textures for them. + return nullptr; + } return new_wrapped_texture_common(ctx, tex, origin, at, std::move(cs), kAdopt_GrWrapOwnership, nullptr, nullptr); } |