aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/GrBackendSurface.h46
-rw-r--r--include/gpu/vk/GrVkTypes.h16
2 files changed, 52 insertions, 10 deletions
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index f0d716cad0..f0bbab5689 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -14,6 +14,9 @@
#ifdef SK_VULKAN
#include "vk/GrVkTypes.h"
+#include "../private/GrVkTypesPriv.h"
+
+class GrVkImageLayout;
#endif
#if !SK_SUPPORT_GPU
@@ -136,24 +139,33 @@ public:
GrMipMapped,
const GrMockTextureInfo& mockInfo);
+ GrBackendTexture(const GrBackendTexture& that);
+
+ ~GrBackendTexture();
+
+ GrBackendTexture& operator=(const GrBackendTexture& that);
+
int width() const { return fWidth; }
int height() const { return fHeight; }
bool hasMipMaps() const { return GrMipMapped::kYes == fMipMapped; }
GrBackend backend() const {return fBackend; }
- // If the backend API is GL, this returns a pointer to the GrGLTextureInfo struct. Otherwise
- // it returns nullptr.
- const GrGLTextureInfo* getGLTextureInfo() const;
+ // If the backend API is GL, copies a snapshot of the GrGLTextureInfo struct into the passed in
+ // pointer and returns true. Otherwise returns false if the backend API is not GL.
+ bool getGLTextureInfo(GrGLTextureInfo*) const;
#ifdef SK_VULKAN
- // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise
- // it returns nullptr.
- const GrVkImageInfo* getVkImageInfo() const;
+ // If the backend API is Vulkan, copies a snapshot of the GrGLImageInfo struct into the passed
+ // in pointer and returns true. This snapshot will set the fImageLayout to the current layout
+ // state. Otherwise returns false if the backend API is not Vulkan.
+ bool getVkImageInfo(GrVkImageInfo*) const;
+
+ void setVkImageLayout(VkImageLayout);
#endif
- // If the backend API is Mock, this returns a pointer to the GrMockTextureInfo struct. Otherwise
- // it returns nullptr.
- const GrMockTextureInfo* getMockTextureInfo() const;
+ // If the backend API is Mock, copies a snapshot of the GrMockTextureInfo struct into the passed
+ // in pointer and returns true. Otherwise returns false if the backend API is not Mock.
+ bool getMockTextureInfo(GrMockTextureInfo*) const;
// Returns true if the backend texture has been initialized.
bool isValid() const { return fIsValid; }
@@ -182,6 +194,20 @@ private:
GrPixelConfig config() const { return fConfig; }
+#ifdef SK_VULKAN
+ // Requires friending of GrVkGpu (done above already)
+ sk_sp<GrVkImageLayout> getGrVkImageLayout() const;
+
+ friend class GrVkTexture;
+ GrBackendTexture(int width,
+ int height,
+ const GrVkImageInfo& vkInfo,
+ sk_sp<GrVkImageLayout> layout);
+#endif
+
+ // Free and release and resources being held by the GrBackendTexture.
+ void cleanup();
+
bool fIsValid;
int fWidth; //<! width in pixels
int fHeight; //<! height in pixels
@@ -192,7 +218,7 @@ private:
union {
GrGLTextureInfo fGLInfo;
#ifdef SK_VULKAN
- GrVkImageInfo fVkInfo;
+ GrVkBackendSurfaceInfo fVkInfo;
#endif
GrMockTextureInfo fMockInfo;
};
diff --git a/include/gpu/vk/GrVkTypes.h b/include/gpu/vk/GrVkTypes.h
index bfc3d5ac3e..e57845ec5d 100644
--- a/include/gpu/vk/GrVkTypes.h
+++ b/include/gpu/vk/GrVkTypes.h
@@ -75,6 +75,22 @@ struct GrVkImageInfo {
VkFormat fFormat;
uint32_t fLevelCount;
+ GrVkImageInfo()
+ : fImage(VK_NULL_HANDLE)
+ , fAlloc()
+ , fImageTiling(VK_IMAGE_TILING_OPTIMAL)
+ , fImageLayout(VK_IMAGE_LAYOUT_UNDEFINED)
+ , fFormat(VK_FORMAT_UNDEFINED)
+ , fLevelCount(0) {}
+
+ GrVkImageInfo(const GrVkImageInfo& info, VkImageLayout layout)
+ : fImage(info.fImage)
+ , fAlloc(info.fAlloc)
+ , fImageTiling(info.fImageTiling)
+ , fImageLayout(layout)
+ , fFormat(info.fFormat)
+ , fLevelCount(info.fLevelCount) {}
+
// This gives a way for a client to update the layout of the Image if they change the layout
// while we're still holding onto the wrapped texture. They will first need to get a handle
// to our internal GrVkImageInfo by calling getTextureHandle on a GrVkTexture.