diff options
author | Brian Osman <brianosman@google.com> | 2017-02-28 10:02:49 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-28 20:59:57 +0000 |
commit | 2c2bc11aea4dfcd7ee2f5859838a2aa0a56939e0 (patch) | |
tree | 733d0feaee5fa7695cb1b33a5d9ab5d8a1b2a39e /include/gpu/gl | |
parent | 585dba831c83447861c1977c2e4896d65d449858 (diff) |
Add GrExternalTextureData and SkCrossContextImageData
GrExternalTextureData is an API for exporting the backend-specific
information about a texture in a type-safe way, and without pointing
into the GrTexture. The new detachBackendTexture API lets us release
ownership of a texture to the client.
SkCrossContextImageData is the public API that lets clients upload
textures on one thread/GrContext, then safely transfer ownership to
another thread and GrContext for rendering.
Only GL is implemented/supported right now. Vulkan support requires
that we add thread-safe memory pools, or otherwise transfer the
actual memory block containing the texture to the new context.
Re-land of https://skia-review.googlesource.com/c/8529/
BUG=skia:
Change-Id: I48ebd57d1ea0cfd3a1db10c475f2903afb821966
Reviewed-on: https://skia-review.googlesource.com/8960
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'include/gpu/gl')
-rw-r--r-- | include/gpu/gl/GrGLTypes.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/gpu/gl/GrGLTypes.h b/include/gpu/gl/GrGLTypes.h index 5b9e31de1a..d03363c75e 100644 --- a/include/gpu/gl/GrGLTypes.h +++ b/include/gpu/gl/GrGLTypes.h @@ -9,6 +9,7 @@ #ifndef GrGLTypes_DEFINED #define GrGLTypes_DEFINED +#include "GrExternalTextureData.h" #include "GrGLConfig.h" /** @@ -112,6 +113,23 @@ struct GrGLTextureInfo { GrGLuint fID; }; +class GrGLExternalTextureData : public GrExternalTextureData { +public: + GrGLExternalTextureData(const GrGLTextureInfo& info, GrFence fence) + : INHERITED(fence) + , fInfo(info) {} + GrBackend getBackend() const override { return kOpenGL_GrBackend; } + +protected: + GrBackendObject getBackendObject() const override { + return reinterpret_cast<GrBackendObject>(&fInfo); + } + + GrGLTextureInfo fInfo; + + typedef GrExternalTextureData INHERITED; +}; + GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLTextureInfo*)); #endif |