aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrBackendSurface.h
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-02-13 17:03:00 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-14 12:42:18 +0000
commitfc711a2b0143aa4f559ef041068af1c04d7dab85 (patch)
tree3cd87b121b87566b9837112badccd5aa958f75f5 /include/gpu/GrBackendSurface.h
parent6ce969472e2ede1e3d6549579c095a12c2d576ca (diff)
Add SkCharacterization creation helper to GrContextThreadSafeProxy (take 2)
TBR=bsalomon@google.com Change-Id: Id96d4fdbb6889065f10a4a7e0c22a03ad9aa5fef Reviewed-on: https://skia-review.googlesource.com/107000 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include/gpu/GrBackendSurface.h')
-rw-r--r--include/gpu/GrBackendSurface.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index ffe422d0a7..c8072c9bfb 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -16,6 +16,69 @@
#include "vk/GrVkTypes.h"
#endif
+class SK_API GrBackendFormat {
+public:
+ // Creates an invalid backend format.
+ GrBackendFormat() : fValid(false) {}
+
+ static GrBackendFormat MakeGL(GrGLenum format, GrGLenum target) {
+ return GrBackendFormat(format, target);
+ }
+
+#ifdef SK_VULKAN
+ static GrBackendFormat MakeVK(VkFormat format) {
+ return GrBackendFormat(format);
+ }
+#endif
+
+ static GrBackendFormat MakeMock(GrPixelConfig config) {
+ return GrBackendFormat(config);
+ }
+
+ GrBackend backend() const {return fBackend; }
+
+ // If the backend API is GL, these return a pointer to the format and target. Otherwise
+ // it returns nullptr.
+ const GrGLenum* getGLFormat() const;
+ const GrGLenum* getGLTarget() const;
+
+#ifdef SK_VULKAN
+ // If the backend API is Vulkan, this returns a pointer to a VkFormat. Otherwise
+ // it returns nullptr
+ const VkFormat* getVkFormat() const;
+#endif
+
+ // If the backend API is Mock, this returns a pointer to a GrPixelConfig. Otherwise
+ // it returns nullptr.
+ const GrPixelConfig* getMockFormat() const;
+
+ // Returns true if the backend format has been initialized.
+ bool isValid() const { return fValid; }
+
+private:
+ GrBackendFormat(GrGLenum format, GrGLenum target);
+
+#ifdef SK_VULKAN
+ GrBackendFormat(const VkFormat vkFormat);
+#endif
+
+ GrBackendFormat(const GrPixelConfig config);
+
+ GrBackend fBackend;
+ bool fValid;
+
+ union {
+ struct {
+ GrGLenum fTarget; // GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL or GL_TEXTURE_RECTANGLE
+ GrGLenum fFormat; // the sized, internal format of the GL resource
+ } fGL;
+#ifdef SK_VULKAN
+ VkFormat fVkFormat;
+#endif
+ GrPixelConfig fMockFormat;
+ };
+};
+
class SK_API GrBackendTexture {
public:
// Creates an invalid backend texture.