1 /* 2 * Copyright 2023 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrVkBackendSurface_DEFINED 9 #define GrVkBackendSurface_DEFINED 10 11 #include "include/gpu/vk/GrVkTypes.h" 12 #include "include/private/base/SkAPI.h" 13 14 #include <string_view> 15 16 class GrBackendFormat; 17 class GrBackendTexture; 18 class GrBackendRenderTarget; 19 20 21 namespace GrBackendFormats { 22 23 SK_API GrBackendFormat MakeVk(VkFormat format, bool willUseDRMFormatModifiers = false); 24 SK_API GrBackendFormat MakeVk(const GrVkYcbcrConversionInfo& ycbcrInfo, 25 bool willUseDRMFormatModifiers = false); 26 27 SK_API bool AsVkFormat(const GrBackendFormat&, VkFormat*); 28 SK_API const GrVkYcbcrConversionInfo* GetVkYcbcrConversionInfo(const GrBackendFormat&); 29 30 } // namespace GrBackendFormats 31 32 33 namespace GrBackendTextures { 34 35 SK_API GrBackendTexture MakeVk(int width, 36 int height, 37 const GrVkImageInfo&, 38 std::string_view label = {}); 39 40 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed 41 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout 42 // state. Otherwise returns false if the backend API is not Vulkan. 43 SK_API bool GetVkImageInfo(const GrBackendTexture&, GrVkImageInfo*); 44 45 // Anytime the client changes the VkImageLayout of the VkImage captured by this 46 // GrBackendTexture, they must call this function to notify Skia of the changed layout. 47 SK_API void SetVkImageLayout(GrBackendTexture*, VkImageLayout); 48 49 } // namespace GrBackendTextures 50 51 52 namespace GrBackendRenderTargets { 53 54 SK_API GrBackendRenderTarget MakeVk(int width, int height, const GrVkImageInfo&); 55 56 // If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed 57 // in pointer and returns true. This snapshot will set the fImageLayout to the current layout 58 // state. Otherwise returns false if the backend API is not Vulkan. 59 SK_API bool GetVkImageInfo(const GrBackendRenderTarget&, GrVkImageInfo*); 60 61 // Anytime the client changes the VkImageLayout of the VkImage captured by this 62 // GrBackendRenderTarget, they must call this function to notify Skia of the changed layout. 63 SK_API void SetVkImageLayout(GrBackendRenderTarget*, VkImageLayout); 64 65 } // namespace GrBackendRenderTargets 66 67 #endif 68