aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkImage_Gpu.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-04-04 15:54:55 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-04 20:34:28 +0000
commitc5509955b98daa0643da7fcd7ad356a9aa5a42da (patch)
treeb8f9628b518b8efb5c4de5fd566ca4cc10be7b07 /src/image/SkImage_Gpu.cpp
parent1fda0247a77e5c7af57163750a3f7a04fddffdd5 (diff)
Add GrBackendTexture accessor to SkImage (take 2)
This makes accessing the GPU resource behind an SkImage a lot more typesafe. Additionally, the GrBackendObject is being deprecated so this is the path forward. I split the controversial stuff off into https://skia-review.googlesource.com/c/skia/+/118575 (Add SkImage::setLayout call). Change-Id: I297e72770e8fb360fac7c7cd74f050ae759ae133 Reviewed-on: https://skia-review.googlesource.com/118571 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/image/SkImage_Gpu.cpp')
-rw-r--r--src/image/SkImage_Gpu.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 3c05f1d219..0dd7e95843 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -198,6 +198,28 @@ GrBackendObject SkImage_Gpu::onGetTextureHandle(bool flushPendingGrContextIO,
return 0;
}
+GrBackendTexture SkImage_Gpu::onGetBackendTexture(bool flushPendingGrContextIO,
+ GrSurfaceOrigin* origin) const {
+ SkASSERT(fProxy);
+
+ if (!fProxy->instantiate(fContext->contextPriv().resourceProvider())) {
+ return GrBackendTexture(); // invalid
+ }
+
+ GrTexture* texture = fProxy->priv().peekTexture();
+
+ if (texture) {
+ if (flushPendingGrContextIO) {
+ fContext->contextPriv().prepareSurfaceForExternalIO(fProxy.get());
+ }
+ if (origin) {
+ *origin = fProxy->origin();
+ }
+ return texture->getBackendTexture();
+ }
+ return GrBackendTexture(); // invalid
+}
+
GrTexture* SkImage_Gpu::onGetTexture() const {
GrTextureProxy* proxy = this->peekProxy();
if (!proxy) {