aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/image')
-rw-r--r--src/image/SkImage.cpp11
-rw-r--r--src/image/SkImage_Base.h6
-rw-r--r--src/image/SkImage_Gpu.cpp40
-rw-r--r--src/image/SkImage_Gpu.h4
-rw-r--r--src/image/SkSurface.cpp10
-rw-r--r--src/image/SkSurface_Base.h10
-rw-r--r--src/image/SkSurface_Gpu.cpp23
-rw-r--r--src/image/SkSurface_Gpu.h5
8 files changed, 109 insertions, 0 deletions
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 72285bd698..3be804fca8 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -163,6 +163,13 @@ GrTexture* SkImage::getTexture() const {
bool SkImage::isTextureBacked() const { return SkToBool(as_IB(this)->peekProxy()); }
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+GrBackendObject SkImage::getTextureHandle(bool flushPendingGrContextIO,
+ GrSurfaceOrigin* origin) const {
+ return as_IB(this)->onGetTextureHandle(flushPendingGrContextIO, origin);
+}
+#endif
+
GrBackendTexture SkImage::getBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const {
return as_IB(this)->onGetBackendTexture(flushPendingGrContextIO, origin);
@@ -181,6 +188,10 @@ GrTexture* SkImage::getTexture() const { return nullptr; }
bool SkImage::isTextureBacked() const { return false; }
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+GrBackendObject SkImage::getTextureHandle(bool, GrSurfaceOrigin*) const { return 0; }
+#endif
+
GrBackendTexture SkImage::getBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const {
return GrBackendTexture(); // invalid
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 9cf70fb1d3..c74a7b97e0 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -55,6 +55,12 @@ public:
virtual sk_sp<GrTextureProxy> refPinnedTextureProxy(uint32_t* uniqueID) const {
return nullptr;
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+ virtual GrBackendObject onGetTextureHandle(bool flushPendingGrContextIO,
+ GrSurfaceOrigin* origin) const {
+ return 0;
+ }
+#endif
virtual GrTexture* onGetTexture() const { return nullptr; }
#endif
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 08c9010228..17a0a25f5a 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -162,6 +162,46 @@ static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes)
}
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+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;
+ }
+
+ GrTexture* texture = fProxy->priv().peekTexture();
+
+ if (texture) {
+ if (flushPendingGrContextIO) {
+ fContext->contextPriv().prepareSurfaceForExternalIO(fProxy.get());
+ }
+ if (origin) {
+ *origin = fProxy->origin();
+ }
+ return texture->getTextureHandle();
+ }
+ return 0;
+}
+#endif
+
GrBackendTexture SkImage_Gpu::onGetBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const {
SkASSERT(fProxy);
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index cb9a7c7a9f..1425c875ce 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -50,6 +50,10 @@ public:
return fProxy;
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+ GrBackendObject onGetTextureHandle(bool flushPendingGrContextIO,
+ GrSurfaceOrigin* origin) const override;
+#endif
GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const override;
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index 1a3eb4312e..73f3175ab9 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -218,6 +218,16 @@ void SkSurface::writePixels(const SkBitmap& src, int x, int y) {
}
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+GrBackendObject SkSurface::getTextureHandle(BackendHandleAccess access) {
+ return asSB(this)->onGetTextureHandle(access);
+}
+
+bool SkSurface::getRenderTargetHandle(GrBackendObject* obj, BackendHandleAccess access) {
+ return asSB(this)->onGetRenderTargetHandle(obj, access);
+}
+#endif
+
GrBackendTexture SkSurface::getBackendTexture(BackendHandleAccess access) {
return asSB(this)->onGetBackendTexture(access);
}
diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h
index 67d330f9bb..90bcdff1dd 100644
--- a/src/image/SkSurface_Base.h
+++ b/src/image/SkSurface_Base.h
@@ -19,6 +19,16 @@ public:
SkSurface_Base(const SkImageInfo&, const SkSurfaceProps*);
virtual ~SkSurface_Base();
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+ virtual GrBackendObject onGetTextureHandle(BackendHandleAccess) {
+ return 0;
+ }
+
+ virtual bool onGetRenderTargetHandle(GrBackendObject*, BackendHandleAccess) {
+ return false;
+ }
+#endif
+
virtual GrBackendTexture onGetBackendTexture(BackendHandleAccess);
virtual GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess);
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index d86b316ef6..c81fc28417 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -52,6 +52,29 @@ static GrRenderTarget* prepare_rt_for_external_access(SkSurface_Gpu* surface,
return rtc->accessRenderTarget();
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+GrBackendObject SkSurface_Gpu::onGetTextureHandle(BackendHandleAccess access) {
+ GrRenderTarget* rt = prepare_rt_for_external_access(this, access);
+ if (!rt) {
+ return 0;
+ }
+ GrTexture* texture = rt->asTexture();
+ if (texture) {
+ return texture->getTextureHandle();
+ }
+ return 0;
+}
+
+bool SkSurface_Gpu::onGetRenderTargetHandle(GrBackendObject* obj, BackendHandleAccess access) {
+ GrRenderTarget* rt = prepare_rt_for_external_access(this, access);
+ if (!rt) {
+ return false;
+ }
+ *obj = rt->getRenderTargetHandle();
+ return true;
+}
+#endif
+
GrBackendTexture SkSurface_Gpu::onGetBackendTexture(BackendHandleAccess access) {
GrRenderTarget* rt = prepare_rt_for_external_access(this, access);
if (!rt) {
diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h
index 97fe5e5d5a..fc014c2cd2 100644
--- a/src/image/SkSurface_Gpu.h
+++ b/src/image/SkSurface_Gpu.h
@@ -23,6 +23,11 @@ public:
// This is an internal-only factory
static sk_sp<SkSurface> MakeWrappedRenderTarget(GrContext*, sk_sp<GrRenderTargetContext>);
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+ GrBackendObject onGetTextureHandle(BackendHandleAccess) override;
+ bool onGetRenderTargetHandle(GrBackendObject*, BackendHandleAccess) override;
+#endif
+
GrBackendTexture onGetBackendTexture(BackendHandleAccess) override;
GrBackendRenderTarget onGetBackendRenderTarget(BackendHandleAccess) override;