xref: /aosp_15_r20/external/skia/src/gpu/graphite/vk/VulkanYcbcrConversion.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2023 Google Inc.
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 skgpu_graphite_VulkanYcbcrConversion_DEFINED
9 #define skgpu_graphite_VulkanYcbcrConversion_DEFINED
10 
11 #include "src/gpu/graphite/Resource.h"
12 
13 #include "include/private/gpu/vk/SkiaVulkan.h"
14 #include "src/core/SkChecksum.h"
15 
16 #include <cinttypes>
17 
18 namespace skgpu {
19 struct VulkanYcbcrConversionInfo;
20 }
21 
22 namespace skgpu::graphite {
23 
24 class VulkanSharedContext;
25 
26 class VulkanYcbcrConversion : public Resource {
27 public:
28     static sk_sp<VulkanYcbcrConversion> Make(const VulkanSharedContext*,
29                                              const VulkanYcbcrConversionInfo&);
30 
31     static sk_sp<VulkanYcbcrConversion> Make(const VulkanSharedContext*,
32                                              uint32_t nonFormatInfo,
33                                              uint64_t format);
34 
35     static GraphiteResourceKey MakeYcbcrConversionKey(const VulkanSharedContext*,
36                                                       const VulkanYcbcrConversionInfo&);
37 
38     // Return a fully-formed GraphiteResourceKey that represents a YCbCr conversion by extracting
39     // relevant information from a SamplerDesc.
40     static GraphiteResourceKey GetKeyFromSamplerDesc(const SamplerDesc& samplerDesc);
41 
ycbcrConversion()42     VkSamplerYcbcrConversion ycbcrConversion() const { return fYcbcrConversion; }
43 
getResourceType()44     const char* getResourceType() const override { return "Vulkan YCbCr Conversion"; }
45 
46 private:
47     VulkanYcbcrConversion(const VulkanSharedContext*, VkSamplerYcbcrConversion);
48 
49     void freeGpuData() override;
50 
51     VkSamplerYcbcrConversion fYcbcrConversion;
52 };
53 } // namespace skgpu::graphite
54 
55 #endif // skgpu_graphite_VulkanYcbcrConversion_DEFINED
56 
57