diff options
author | Greg Daniel <egdaniel@google.com> | 2018-03-09 12:05:04 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-09 18:02:00 +0000 |
commit | a8d9211bc3f34fcb3cf331d8fd76e4ea5803fe20 (patch) | |
tree | 5e13626cb2fc91f839ecf624953921ee7bf31b1b /tools/gpu | |
parent | 33cb22cb2b60255a2755cc88072490fe8d05b0b9 (diff) |
Add promise images for deferred instantiation of wrapped gpu textures
This will allow a client to make an SkImage that "wraps" a gpu texture,
however the client does need to supply the actual gpu texture at Image
creation time. Instead it is retrieve at flush time via a callback.
Bug: skia:
Change-Id: I6267a55ab7102101a7bd80a6f547b6a870d2df08
Reviewed-on: https://skia-review.googlesource.com/109021
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Diffstat (limited to 'tools/gpu')
-rw-r--r-- | tools/gpu/GrTest.cpp | 24 | ||||
-rw-r--r-- | tools/gpu/GrTest.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp index 2160c7f47e..ae86aaed82 100644 --- a/tools/gpu/GrTest.cpp +++ b/tools/gpu/GrTest.cpp @@ -78,6 +78,30 @@ GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height, } } +GrBackendFormat CreateBackendFormatFromTexture(const GrBackendTexture& tex) { + switch (tex.backend()) { +#ifdef SK_VULKAN + case kVulkan_GrBackend: { + const GrVkImageInfo* vkInfo = tex.getVkImageInfo(); + SkASSERT(vkInfo); + return GrBackendFormat::MakeVk(vkInfo->fFormat); + } +#endif + case kOpenGL_GrBackend: { + const GrGLTextureInfo* glInfo = tex.getGLTextureInfo(); + SkASSERT(glInfo); + return GrBackendFormat::MakeGL(glInfo->fFormat, glInfo->fTarget); + } + case kMock_GrBackend: { + const GrMockTextureInfo* mockInfo = tex.getMockTextureInfo(); + SkASSERT(mockInfo); + return GrBackendFormat::MakeMock(mockInfo->fConfig); + } + default: + return GrBackendFormat(); + } +} + } // namespace GrTest bool GrSurfaceProxy::isWrapped_ForTesting() const { diff --git a/tools/gpu/GrTest.h b/tools/gpu/GrTest.h index 6666ab1a20..76e5e93e03 100644 --- a/tools/gpu/GrTest.h +++ b/tools/gpu/GrTest.h @@ -22,6 +22,8 @@ namespace GrTest { // TODO: remove this. It is only used in the SurfaceSemaphores Test. GrBackendTexture CreateBackendTexture(GrBackend, int width, int height, GrPixelConfig, GrMipMapped, GrBackendObject); + + GrBackendFormat CreateBackendFormatFromTexture(const GrBackendTexture& tex); }; #endif |