aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkImage_Gpu.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-04-11 10:41:20 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-12 14:35:10 +0000
commita6aef2a975aec22a03c8f32605dd03aa0b943a27 (patch)
tree34cbdc2b39697de337617a9b768a74965b7439eb /src/image/SkImage_Gpu.cpp
parenta5914286edef94636252f5fd50ba94f1805c616c (diff)
Allow SkImage_Gpu to fail some requests in DDL mode
In particular, anything that forces an instantiation is forbidden. Change-Id: I3cf83a6fdedb03105dda7d928b9c0f73315199cc Reviewed-on: https://skia-review.googlesource.com/120421 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/image/SkImage_Gpu.cpp')
-rw-r--r--src/image/SkImage_Gpu.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index be570c3097..0538172b90 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -74,6 +74,11 @@ SkColorType SkImage_Gpu::onColorType() const {
}
bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkColorSpace*, CachingHint chint) const {
+ if (!fContext->contextPriv().resourceProvider()) {
+ // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
+ return false;
+ }
+
// The SkColorSpace parameter "dstColorSpace" is really just a hint about how/where the bitmap
// will be used. The client doesn't expect that we convert to that color space, it's intended
// for codec-backed images, to drive our decoding heuristic. In theory we *could* read directly
@@ -202,6 +207,11 @@ GrBackendTexture SkImage_Gpu::onGetBackendTexture(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.
+ return GrBackendTexture();
+ }
+
if (!fProxy->instantiate(fContext->contextPriv().resourceProvider())) {
return GrBackendTexture(); // invalid
}
@@ -226,6 +236,11 @@ GrTexture* SkImage_Gpu::onGetTexture() const {
return nullptr;
}
+ if (!fContext->contextPriv().resourceProvider() && !fProxy->priv().isInstantiated()) {
+ // This image was created with a DDL context and cannot be instantiated.
+ return nullptr;
+ }
+
if (!proxy->instantiate(fContext->contextPriv().resourceProvider())) {
return nullptr;
}
@@ -235,6 +250,11 @@ GrTexture* SkImage_Gpu::onGetTexture() const {
bool SkImage_Gpu::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
int srcX, int srcY, CachingHint) const {
+ if (!fContext->contextPriv().resourceProvider()) {
+ // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
+ return false;
+ }
+
if (!SkImageInfoValidConversion(dstInfo, this->onImageInfo())) {
return false;
}