diff options
author | Robert Phillips <robertphillips@google.com> | 2018-04-05 09:30:38 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-05 14:21:07 +0000 |
commit | 8caf85f9f40f6bad38bf66bd02b87dcebe139a5c (patch) | |
tree | 46a2b1414601ca99f6c60bd3442e8075bc27173f /include | |
parent | 91749c82523c8b0b3f2b6f800d85893ca5386fbd (diff) |
Add GrBackendTexture/RenderTarget accessors to SkSurface
Change-Id: I63477fd4b8d48dc50af72736f0f8df566cd96d4a
Reviewed-on: https://skia-review.googlesource.com/85220
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Cary Clark <caryclark@skia.org>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkSurface.h | 30 | ||||
-rw-r--r-- | include/gpu/GrBackendSurface.h | 24 | ||||
-rw-r--r-- | include/gpu/gl/GrGLTypes.h | 4 |
3 files changed, 58 insertions, 0 deletions
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h index 55a34fc9fc..1950d36fea 100644 --- a/include/core/SkSurface.h +++ b/include/core/SkSurface.h @@ -20,6 +20,7 @@ class SkPaint; class SkSurfaceCharacterization; class GrBackendRenderTarget; class GrBackendSemaphore; +class GrBackendTexture; class GrContext; class GrRenderTarget; @@ -458,6 +459,35 @@ public: bool getRenderTargetHandle(GrBackendObject* backendObject, BackendHandleAccess backendHandleAccess); +#if GR_TEST_UTILS + /** Retrieves the backend texture. If Surface has no backend texture, an invalid + object is returned. Call GrBackendTexture::isValid to determine if the result + is valid. + + The returned GrBackendTexture should be discarded if the Surface is drawn to or deleted. + + @param backendHandleAccess one of: kFlushRead_BackendHandleAccess, + kFlushWrite_BackendHandleAccess, + kDiscardWrite_BackendHandleAccess + @return GPU texture reference; invalid on failure + */ + GrBackendTexture getBackendTexture(BackendHandleAccess backendHandleAccess); + + /** Retrieves the backend render target. If Surface has no backend render target, an invalid + object is returned. Call GrBackendRenderTarget::isValid to determine if the result + is valid. + + The returned GrBackendRenderTarget should be discarded if the Surface is drawn to + or deleted. + + @param backendHandleAccess one of: kFlushRead_BackendHandleAccess, + kFlushWrite_BackendHandleAccess, + kDiscardWrite_BackendHandleAccess + @return GPU render target reference; invalid on failure + */ + GrBackendRenderTarget getBackendRenderTarget(BackendHandleAccess backendHandleAccess); +#endif + /** Returns SkCanvas that draws into SkSurface. Subsequent calls return the same SkCanvas. SkCanvas returned is managed and owned by SkSurface, and is deleted when SkSurface is deleted. diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h index 106edb751e..8d7886ee14 100644 --- a/include/gpu/GrBackendSurface.h +++ b/include/gpu/GrBackendSurface.h @@ -16,6 +16,24 @@ #include "vk/GrVkTypes.h" #endif +#if !SK_SUPPORT_GPU + +// SkSurface and SkImage rely on a minimal version of these always being available +class SK_API GrBackendTexture { +public: + GrBackendTexture() {} + + bool isValid() const { return false; } +}; + +class SK_API GrBackendRenderTarget { +public: + GrBackendRenderTarget() {} + + bool isValid() const { return false; } +}; +#else + class SK_API GrBackendFormat { public: // Creates an invalid backend format. @@ -239,7 +257,11 @@ public: // Returns true if the backend texture has been initialized. bool isValid() const { return fConfig != kUnknown_GrPixelConfig; } + +#if GR_TEST_UTILS GrPixelConfig testingOnly_getPixelConfig() const; + static bool TestingOnly_Equals(const GrBackendRenderTarget&, const GrBackendRenderTarget&); +#endif private: // Friending for access to the GrPixelConfig @@ -272,3 +294,5 @@ private: #endif +#endif + diff --git a/include/gpu/gl/GrGLTypes.h b/include/gpu/gl/GrGLTypes.h index c152e42d32..442b14dfd2 100644 --- a/include/gpu/gl/GrGLTypes.h +++ b/include/gpu/gl/GrGLTypes.h @@ -124,6 +124,10 @@ GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLTextureInfo*)); struct GrGLFramebufferInfo { GrGLuint fFBOID; GrGLenum fFormat = 0; + + bool operator==(const GrGLFramebufferInfo& that) const { + return fFBOID == that.fFBOID && fFormat == that.fFormat; + } }; GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLFramebufferInfo*)); |