aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gn/flutter_defines.gni1
-rw-r--r--include/core/SkImage.h2
-rw-r--r--include/core/SkSurface.h2
-rw-r--r--include/gpu/GrRenderTarget.h2
-rw-r--r--include/gpu/GrTexture.h2
-rw-r--r--include/gpu/GrTypes.h3
-rw-r--r--include/gpu/gl/GrGLTypes.h5
-rw-r--r--include/gpu/vk/GrVkTypes.h2
-rw-r--r--public.bzl2
-rw-r--r--src/gpu/gl/GrGLRenderTarget.h2
-rw-r--r--src/gpu/gl/GrGLTexture.cpp2
-rw-r--r--src/gpu/gl/GrGLTexture.h2
-rw-r--r--src/gpu/mock/GrMockTexture.h6
-rw-r--r--src/gpu/mtl/GrMtlRenderTarget.h2
-rw-r--r--src/gpu/mtl/GrMtlRenderTarget.mm2
-rw-r--r--src/gpu/mtl/GrMtlTexture.h2
-rw-r--r--src/gpu/mtl/GrMtlTexture.mm2
-rw-r--r--src/gpu/vk/GrVkRenderTarget.cpp2
-rw-r--r--src/gpu/vk/GrVkRenderTarget.h3
-rw-r--r--src/gpu/vk/GrVkTexture.cpp2
-rw-r--r--src/gpu/vk/GrVkTexture.h2
-rw-r--r--src/image/SkImage.cpp4
-rw-r--r--src/image/SkImage_Base.h2
-rw-r--r--src/image/SkImage_Gpu.cpp2
-rw-r--r--src/image/SkImage_Gpu.h3
-rw-r--r--src/image/SkSurface.cpp2
-rw-r--r--src/image/SkSurface_Base.h2
-rw-r--r--src/image/SkSurface_Gpu.cpp2
-rw-r--r--src/image/SkSurface_Gpu.h2
-rw-r--r--tests/ImageTest.cpp47
-rw-r--r--tests/SurfaceSemaphoreTest.cpp18
-rw-r--r--tests/VkBackendSurfaceTest.cpp2
-rw-r--r--tools/gpu/GrTest.cpp25
-rw-r--r--tools/gpu/GrTest.h4
-rw-r--r--tools/sk_app/VulkanWindowContext.cpp20
35 files changed, 99 insertions, 86 deletions
diff --git a/gn/flutter_defines.gni b/gn/flutter_defines.gni
index d817f3c510..36fc74d62b 100644
--- a/gn/flutter_defines.gni
+++ b/gn/flutter_defines.gni
@@ -5,4 +5,5 @@
flutter_defines = [
"SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION",
"SK_DISABLE_RENDER_TARGET_SORTING",
+ "SK_SUPPORT_LEGACY_BACKEND_OBJECTS",
]
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 32869b7a5d..c4b5efb1e7 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -530,6 +530,7 @@ public:
*/
bool isValid(GrContext* context) const;
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
/** Retrieves the back-end API handle of texture. If flushPendingGrContextIO is true,
complete deferred I/O operations.
@@ -542,6 +543,7 @@ public:
*/
GrBackendObject getTextureHandle(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin = nullptr) const;
+#endif
/** Retrieves the backend texture. If SkImage has no backend texture, an invalid
object is returned. Call GrBackendTexture::isValid to determine if the result
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 482fdcab85..fb0a3685d7 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -428,6 +428,7 @@ public:
static const BackendHandleAccess kDiscardWrite_TextureHandleAccess =
kDiscardWrite_BackendHandleAccess;
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
/** Returns the GPU back-end reference of the texture used by SkSurface, or zero
if SkSurface is not backed by a GPU texture.
@@ -458,6 +459,7 @@ public:
*/
bool getRenderTargetHandle(GrBackendObject* backendObject,
BackendHandleAccess backendHandleAccess);
+#endif
/** Retrieves the backend texture. If Surface has no backend texture, an invalid
object is returned. Call GrBackendTexture::isValid to determine if the result
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index ebfa4fd77f..1c86eaa374 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -99,11 +99,13 @@ public:
};
virtual ResolveType getResolveType() const = 0;
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
/**
* Return the native ID or handle to the rendertarget, depending on the
* platform. e.g. on OpenGL, return the FBO ID.
*/
virtual GrBackendObject getRenderTargetHandle() const = 0;
+#endif
virtual GrBackendRenderTarget getBackendRenderTarget() const = 0;
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 59cf76f032..f7fdb77207 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -25,11 +25,13 @@ public:
GrTexture* asTexture() override { return this; }
const GrTexture* asTexture() const override { return this; }
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
/**
* Return the native ID or handle to the texture, depending on the
* platform. e.g. on OpenGL, return the texture ID.
*/
virtual GrBackendObject getTextureHandle() const = 0;
+#endif
virtual GrBackendTexture getBackendTexture() const = 0;
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 7eb5848558..d0e977ebc1 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -207,12 +207,13 @@ enum class GrMipMapped : bool {
///////////////////////////////////////////////////////////////////////////////
-
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
/**
* Opaque type for 3D API object handles. We are moving away from this type and towards type-safe
* GrBackend* classes (e.g. GrBackendTexture). However, not all replacement APIs are in place yet.
*/
typedef intptr_t GrBackendObject;
+#endif
/**
* GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to
diff --git a/include/gpu/gl/GrGLTypes.h b/include/gpu/gl/GrGLTypes.h
index 442b14dfd2..75aa87d971 100644
--- a/include/gpu/gl/GrGLTypes.h
+++ b/include/gpu/gl/GrGLTypes.h
@@ -119,8 +119,6 @@ struct GrGLTextureInfo {
}
};
-GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLTextureInfo*));
-
struct GrGLFramebufferInfo {
GrGLuint fFBOID;
GrGLenum fFormat = 0;
@@ -130,6 +128,9 @@ struct GrGLFramebufferInfo {
}
};
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
+GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLTextureInfo*));
GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLFramebufferInfo*));
+#endif
#endif
diff --git a/include/gpu/vk/GrVkTypes.h b/include/gpu/vk/GrVkTypes.h
index 6c6ebc7737..68b7f63064 100644
--- a/include/gpu/vk/GrVkTypes.h
+++ b/include/gpu/vk/GrVkTypes.h
@@ -112,6 +112,8 @@ struct GrVkImageInfo {
}
};
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrVkImageInfo*));
+#endif
#endif
diff --git a/public.bzl b/public.bzl
index ecae59d394..294c01db1b 100644
--- a/public.bzl
+++ b/public.bzl
@@ -597,6 +597,8 @@ def base_defines(os_conditions):
"SK_JUMPER_DISABLE_8BIT",
# JPEG is in codec_limited
"SK_HAS_JPEG_LIBRARY",
+ # Legacy back-end gpu object access
+ "SK_SUPPORT_LEGACY_BACKEND_OBJECTS",
] + skia_select(
os_conditions,
[
diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h
index 3da4812dff..4412dcf425 100644
--- a/src/gpu/gl/GrGLRenderTarget.h
+++ b/src/gpu/gl/GrGLRenderTarget.h
@@ -61,7 +61,9 @@ public:
}
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject getRenderTargetHandle() const override { return fRTFBOID; }
+#endif
GrBackendRenderTarget getBackendRenderTarget() const override;
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index 69b214de27..9a8dbd8f4b 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -98,9 +98,11 @@ void GrGLTexture::onAbandon() {
INHERITED::onAbandon();
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject GrGLTexture::getTextureHandle() const {
return reinterpret_cast<GrBackendObject>(&fInfo);
}
+#endif
GrBackendTexture GrGLTexture::getBackendTexture() const {
return GrBackendTexture(this->width(), this->height(), this->texturePriv().mipMapped(), fInfo);
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 7da2bb4428..fcc85bc700 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -39,7 +39,9 @@ public:
SkASSERT(!fReleaseHelper);
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject getTextureHandle() const override;
+#endif
GrBackendTexture getBackendTexture() const override;
void textureParamsModified() override { fTexParams.invalidate(); }
diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h
index 55dc6f3946..071b4f4615 100644
--- a/src/gpu/mock/GrMockTexture.h
+++ b/src/gpu/mock/GrMockTexture.h
@@ -31,9 +31,11 @@ public:
~GrMockTexture() override {}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject getTextureHandle() const override {
return reinterpret_cast<GrBackendObject>(&fInfo);
}
+#endif
GrBackendTexture getBackendTexture() const override {
return GrBackendTexture(this->width(), this->height(), this->texturePriv().mipMapped(),
fInfo);
@@ -118,9 +120,11 @@ public:
return {this->width(), this->height(), this->numColorSamples(), numStencilBits, fInfo};
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject getRenderTargetHandle() const override {
return reinterpret_cast<GrBackendObject>(&fInfo);
}
+#endif
protected:
// constructor for subclasses
@@ -156,7 +160,9 @@ public:
this->registerWithCacheWrapped();
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject getRenderTargetHandle() const override { return 0; }
+#endif
GrTexture* asTexture() override { return this; }
GrRenderTarget* asRenderTarget() override { return this; }
diff --git a/src/gpu/mtl/GrMtlRenderTarget.h b/src/gpu/mtl/GrMtlRenderTarget.h
index 83e7d3c240..c653952482 100644
--- a/src/gpu/mtl/GrMtlRenderTarget.h
+++ b/src/gpu/mtl/GrMtlRenderTarget.h
@@ -40,7 +40,9 @@ public:
return true;
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject getRenderTargetHandle() const override;
+#endif
GrBackendRenderTarget getBackendRenderTarget() const override {
return GrBackendRenderTarget(); // invalid
diff --git a/src/gpu/mtl/GrMtlRenderTarget.mm b/src/gpu/mtl/GrMtlRenderTarget.mm
index 12b507b801..c8060cf88c 100644
--- a/src/gpu/mtl/GrMtlRenderTarget.mm
+++ b/src/gpu/mtl/GrMtlRenderTarget.mm
@@ -63,10 +63,12 @@ GrMtlGpu* GrMtlRenderTarget::getMtlGpu() const {
return static_cast<GrMtlGpu*>(this->getGpu());
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject GrMtlRenderTarget::getRenderTargetHandle() const {
void* voidRT = (__bridge_retained void*)fRenderTexture;
return (GrBackendObject)voidRT;
}
+#endif
void GrMtlRenderTarget::onAbandon() {
fRenderTexture = nil;
diff --git a/src/gpu/mtl/GrMtlTexture.h b/src/gpu/mtl/GrMtlTexture.h
index 3433f38db0..21f5e13b19 100644
--- a/src/gpu/mtl/GrMtlTexture.h
+++ b/src/gpu/mtl/GrMtlTexture.h
@@ -26,7 +26,9 @@ public:
id<MTLTexture> mtlTexture() const { return fTexture; }
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject getTextureHandle() const override;
+#endif
GrBackendTexture getBackendTexture() const override;
void textureParamsModified() override {}
diff --git a/src/gpu/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm
index 92afe31a9a..534eb6baf7 100644
--- a/src/gpu/mtl/GrMtlTexture.mm
+++ b/src/gpu/mtl/GrMtlTexture.mm
@@ -71,10 +71,12 @@ GrMtlGpu* GrMtlTexture::getMtlGpu() const {
return static_cast<GrMtlGpu*>(this->getGpu());
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject GrMtlTexture::getTextureHandle() const {
void* voidTex = (__bridge_retained void*)fTexture;
return (GrBackendObject)voidTex;
}
+#endif
GrBackendTexture GrMtlTexture::getBackendTexture() const {
return GrBackendTexture(); // invalid
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp
index 83c3b97776..3cab94d7dc 100644
--- a/src/gpu/vk/GrVkRenderTarget.cpp
+++ b/src/gpu/vk/GrVkRenderTarget.cpp
@@ -352,12 +352,14 @@ void GrVkRenderTarget::onAbandon() {
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject GrVkRenderTarget::getRenderTargetHandle() const {
// If the render target is multisampled, we currently return the ImageInfo for the resolved
// image. If we only wrap the msaa target (currently not implemented) we should return a handle
// to that instead.
return (GrBackendObject)&fInfo;
}
+#endif
GrBackendRenderTarget GrVkRenderTarget::getBackendRenderTarget() const {
return GrBackendRenderTarget(this->width(), this->height(), this->numColorSamples(),
diff --git a/src/gpu/vk/GrVkRenderTarget.h b/src/gpu/vk/GrVkRenderTarget.h
index 64be0b78e4..ed840fc226 100644
--- a/src/gpu/vk/GrVkRenderTarget.h
+++ b/src/gpu/vk/GrVkRenderTarget.h
@@ -70,7 +70,10 @@ public:
return true;
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject getRenderTargetHandle() const override;
+#endif
+
GrBackendRenderTarget getBackendRenderTarget() const override;
void getAttachmentsDescriptor(GrVkRenderPass::AttachmentsDescriptor* desc,
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 0b9862443c..c4393fdd36 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -161,9 +161,11 @@ void GrVkTexture::onAbandon() {
INHERITED::onAbandon();
}
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject GrVkTexture::getTextureHandle() const {
return (GrBackendObject)&fInfo;
}
+#endif
GrBackendTexture GrVkTexture::getBackendTexture() const {
return GrBackendTexture(this->width(), this->height(), fInfo, this->grVkImageLayout());
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index e37b53ebbf..79506eff9e 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -29,7 +29,9 @@ public:
~GrVkTexture() override;
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
GrBackendObject getTextureHandle() const override;
+#endif
GrBackendTexture getBackendTexture() const override;
void textureParamsModified() override {}
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index bbbbceeed8..3be804fca8 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -163,10 +163,12 @@ 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 {
@@ -186,7 +188,9 @@ 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 {
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 191cf0354e..c74a7b97e0 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -55,10 +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 0538172b90..05259f6a3c 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -165,6 +165,7 @@ 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);
@@ -202,6 +203,7 @@ GrBackendObject SkImage_Gpu::onGetTextureHandle(bool flushPendingGrContextIO,
}
return 0;
}
+#endif
GrBackendTexture SkImage_Gpu::onGetBackendTexture(bool flushPendingGrContextIO,
GrSurfaceOrigin* origin) const {
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index af7c1fac6a..1425c875ce 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -49,8 +49,11 @@ public:
*uniqueID = this->uniqueID();
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 b1c434d37b..73f3175ab9 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -218,6 +218,7 @@ 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);
}
@@ -225,6 +226,7 @@ GrBackendObject SkSurface::getTextureHandle(BackendHandleAccess 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 2771d5ff16..90bcdff1dd 100644
--- a/src/image/SkSurface_Base.h
+++ b/src/image/SkSurface_Base.h
@@ -19,6 +19,7 @@ public:
SkSurface_Base(const SkImageInfo&, const SkSurfaceProps*);
virtual ~SkSurface_Base();
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
virtual GrBackendObject onGetTextureHandle(BackendHandleAccess) {
return 0;
}
@@ -26,6 +27,7 @@ public:
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 9d1a2f61f6..e9ae9104e2 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -51,6 +51,7 @@ 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) {
@@ -71,6 +72,7 @@ bool SkSurface_Gpu::onGetRenderTargetHandle(GrBackendObject* obj, BackendHandleA
*obj = rt->getRenderTargetHandle();
return true;
}
+#endif
GrBackendTexture SkSurface_Gpu::onGetBackendTexture(BackendHandleAccess access) {
GrRenderTarget* rt = prepare_rt_for_external_access(this, access);
diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h
index ecb84a8c00..fc014c2cd2 100644
--- a/src/image/SkSurface_Gpu.h
+++ b/src/image/SkSurface_Gpu.h
@@ -23,8 +23,10 @@ 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;
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 55730816bb..9940574eee 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -1044,35 +1044,6 @@ DEF_GPUTEST(SkImage_CrossContextGrayAlphaConfigs, reporter, options) {
}
}
-static uint32_t GetIdForBackendObject(GrContext* ctx, GrBackendObject object) {
- if (!object) {
- return 0;
- }
-
- if (ctx->contextPriv().getBackend() != kOpenGL_GrBackend) {
- return 0;
- }
-
- return reinterpret_cast<const GrGLTextureInfo*>(object)->fID;
-}
-
-static uint32_t GetIdForBackendTexture(GrBackendTexture texture) {
- if (!texture.isValid()) {
- return 0;
- }
-
- if (texture.backend() != kOpenGL_GrBackend) {
- return 0;
- }
-
- GrGLTextureInfo info;
- if (!texture.getGLTextureInfo(&info)) {
- return 0;
- }
-
- return info.fID;
-}
-
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
sk_gpu_test::TestContext* testContext = ctxInfo.testContext();
@@ -1114,18 +1085,26 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) {
continue;
}
- uint32_t originalID = GetIdForBackendObject(context, image->getTextureHandle(true, nullptr));
- GrBackendTexture texture;
+ GrBackendTexture origBackend = image->getBackendTexture(true);
+ if (testCase.fCanTakeDirectly) {
+ SkASSERT(origBackend.isValid());
+ }
+
+ GrBackendTexture newBackend;
SkImage::BackendTextureReleaseProc proc;
- bool result =
- SkImage::MakeBackendTextureFromSkImage(context, std::move(image), &texture, &proc);
+ bool result = SkImage::MakeBackendTextureFromSkImage(context, std::move(image),
+ &newBackend, &proc);
if (result != testCase.fExpectation) {
static const char *const kFS[] = { "fail", "succeed" };
ERRORF(reporter, "This image was expected to %s but did not.",
kFS[testCase.fExpectation]);
}
- bool tookDirectly = result && originalID == GetIdForBackendTexture(texture);
+ if (result) {
+ SkASSERT(newBackend.isValid());
+ }
+
+ bool tookDirectly = result && GrBackendTexture::TestingOnly_Equals(origBackend, newBackend);
if (testCase.fCanTakeDirectly != tookDirectly) {
static const char *const kExpectedState[] = { "not expected", "expected" };
ERRORF(reporter, "This backend texture was %s to be taken directly.",
diff --git a/tests/SurfaceSemaphoreTest.cpp b/tests/SurfaceSemaphoreTest.cpp
index eea6e37670..980478bcef 100644
--- a/tests/SurfaceSemaphoreTest.cpp
+++ b/tests/SurfaceSemaphoreTest.cpp
@@ -63,13 +63,8 @@ void check_pixels(skiatest::Reporter* reporter, const SkBitmap& bitmap) {
void draw_child(skiatest::Reporter* reporter,
const sk_gpu_test::ContextInfo& childInfo,
- const GrBackendObject& backendImage,
+ const GrBackendTexture& backendTexture,
const GrBackendSemaphore& semaphore) {
- GrBackendTexture backendTexture = GrTest::CreateBackendTexture(childInfo.backend(),
- MAIN_W, MAIN_H,
- kRGBA_8888_GrPixelConfig,
- GrMipMapped::kNo,
- backendImage);
childInfo.testContext()->makeCurrent();
@@ -156,21 +151,22 @@ void surface_semaphore_test(skiatest::Reporter* reporter,
}
sk_sp<SkImage> mainImage = mainSurface->makeImageSnapshot();
- GrBackendObject backendImage = mainImage->getTextureHandle(false);
+ GrBackendTexture backendTexture = mainImage->getBackendTexture(false);
- draw_child(reporter, childInfo1, backendImage, semaphores[0]);
+ draw_child(reporter, childInfo1, backendTexture, semaphores[0]);
#ifdef SK_VULKAN
if (kVulkan_GrBackend == mainInfo.backend()) {
// In Vulkan we need to make sure we are sending the correct VkImageLayout in with the
// backendImage. After the first child draw the layout gets changed to SHADER_READ, so
// we just manually set that here.
- GrVkImageInfo* vkInfo = (GrVkImageInfo*)backendImage;
- vkInfo->updateImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+ GrVkImageInfo vkInfo;
+ SkAssertResult(backendTexture.getVkImageInfo(&vkInfo));
+ vkInfo.updateImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
}
#endif
- draw_child(reporter, childInfo2, backendImage, semaphores[1]);
+ draw_child(reporter, childInfo2, backendTexture, semaphores[1]);
}
DEF_GPUTEST(SurfaceSemaphores, reporter, options) {
diff --git a/tests/VkBackendSurfaceTest.cpp b/tests/VkBackendSurfaceTest.cpp
index 298dc38b4e..fc0464d981 100644
--- a/tests/VkBackendSurfaceTest.cpp
+++ b/tests/VkBackendSurfaceTest.cpp
@@ -84,6 +84,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
backendTexImage.setVkImageLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
REPORTER_ASSERT(reporter, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL == vkTexture->currentLayout());
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
// Verify that modifying the layout via the old textureHandle sitll works in is reflected in the
// GrVkTexture and GrBackendTexture.
GrVkImageInfo* backendInfo = (GrVkImageInfo*)wrappedImage->getTextureHandle(false);
@@ -94,6 +95,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == vkTexture->currentLayout());
REPORTER_ASSERT(reporter, backendTexImage.getVkImageInfo(&info));
REPORTER_ASSERT(reporter, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == info.fImageLayout);
+#endif
vkTexture->updateImageLayout(initLayout);
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index cff99a11e2..3c6046712d 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -53,31 +53,6 @@ void SetupAlwaysEvictAtlas(GrContext* context, int dim) {
context->contextPriv().setTextContextAtlasSizes_ForTesting(configs);
}
-GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
- GrPixelConfig config, GrMipMapped mipMapped,
- GrBackendObject handle) {
- switch (backend) {
-#ifdef SK_VULKAN
- case kVulkan_GrBackend: {
- GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
- SkASSERT((GrMipMapped::kYes == mipMapped) == (vkInfo->fLevelCount > 1));
- return GrBackendTexture(width, height, *vkInfo);
- }
-#endif
- case kOpenGL_GrBackend: {
- GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
- SkASSERT(glInfo->fFormat);
- return GrBackendTexture(width, height, mipMapped, *glInfo);
- }
- case kMock_GrBackend: {
- GrMockTextureInfo* mockInfo = (GrMockTextureInfo*)(handle);
- return GrBackendTexture(width, height, mipMapped, *mockInfo);
- }
- default:
- return GrBackendTexture();
- }
-}
-
} // namespace GrTest
bool GrSurfaceProxy::isWrapped_ForTesting() const {
diff --git a/tools/gpu/GrTest.h b/tools/gpu/GrTest.h
index 6666ab1a20..9bf4344e6d 100644
--- a/tools/gpu/GrTest.h
+++ b/tools/gpu/GrTest.h
@@ -18,10 +18,6 @@ namespace GrTest {
* constantly be evicting entries
*/
void SetupAlwaysEvictAtlas(GrContext*, int dim = GrDrawOpAtlas::kGlyphMaxDim);
-
- // TODO: remove this. It is only used in the SurfaceSemaphores Test.
- GrBackendTexture CreateBackendTexture(GrBackend, int width, int height,
- GrPixelConfig, GrMipMapped, GrBackendObject);
};
#endif
diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp
index b39c564eca..ecf6d80b2c 100644
--- a/tools/sk_app/VulkanWindowContext.cpp
+++ b/tools/sk_app/VulkanWindowContext.cpp
@@ -543,11 +543,11 @@ sk_sp<SkSurface> VulkanWindowContext::getBackbufferSurface() {
QueueSubmit(fBackendContext->fQueue, 1, &submitInfo,
backbuffer->fUsageFences[0]));
- GrVkImageInfo* imageInfo;
SkSurface* surface = fSurfaces[backbuffer->fImageIndex].get();
- surface->getRenderTargetHandle((GrBackendObject*)&imageInfo,
- SkSurface::kFlushRead_BackendHandleAccess);
- imageInfo->updateImageLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
+ GrBackendRenderTarget backendRT = surface->getBackendRenderTarget(
+ SkSurface::kFlushRead_BackendHandleAccess);
+ backendRT.setVkImageLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
+
return sk_ref_sp(surface);
}
@@ -555,14 +555,16 @@ sk_sp<SkSurface> VulkanWindowContext::getBackbufferSurface() {
void VulkanWindowContext::swapBuffers() {
BackbufferInfo* backbuffer = fBackbuffers + fCurrentBackbufferIndex;
- GrVkImageInfo* imageInfo;
SkSurface* surface = fSurfaces[backbuffer->fImageIndex].get();
- surface->getRenderTargetHandle((GrBackendObject*)&imageInfo,
- SkSurface::kFlushRead_BackendHandleAccess);
+
+ GrBackendRenderTarget backendRT = surface->getBackendRenderTarget(
+ SkSurface::kFlushRead_BackendHandleAccess);
+ GrVkImageInfo imageInfo;
+ SkAssertResult(backendRT.getVkImageInfo(&imageInfo));
// Check to make sure we never change the actually wrapped image
- SkASSERT(imageInfo->fImage == fImages[backbuffer->fImageIndex]);
+ SkASSERT(imageInfo.fImage == fImages[backbuffer->fImageIndex]);
- VkImageLayout layout = imageInfo->fImageLayout;
+ VkImageLayout layout = imageInfo.fImageLayout;
VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(layout);
VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(layout);