Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
GrVkSamplerYcbcrConversion Class Reference

#include <GrVkSamplerYcbcrConversion.h>

Inheritance diagram for GrVkSamplerYcbcrConversion:
GrVkManagedResource GrManagedResource SkNoncopyable

Classes

struct  Key
 

Public Member Functions

VkSamplerYcbcrConversion ycbcrConversion () const
 
- Public Member Functions inherited from GrVkManagedResource
 GrVkManagedResource (const GrVkGpu *gpu)
 
- Public Member Functions inherited from GrManagedResource
 GrManagedResource ()
 
virtual ~GrManagedResource ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static GrVkSamplerYcbcrConversionCreate (GrVkGpu *gpu, const skgpu::VulkanYcbcrConversionInfo &)
 
static SK_END_REQUIRE_DENSE Key GenerateKey (const skgpu::VulkanYcbcrConversionInfo &ycbcrInfo)
 
static const KeyGetKey (const GrVkSamplerYcbcrConversion &ycbcrConversion)
 
static uint32_t Hash (const Key &key)
 

Additional Inherited Members

- Protected Attributes inherited from GrVkManagedResource
const GrVkGpufGpu
 

Detailed Description

Definition at line 20 of file GrVkSamplerYcbcrConversion.h.

Member Function Documentation

◆ Create()

GrVkSamplerYcbcrConversion * GrVkSamplerYcbcrConversion::Create ( GrVkGpu gpu,
const skgpu::VulkanYcbcrConversionInfo info 
)
static

Definition at line 14 of file GrVkSamplerYcbcrConversion.cpp.

15 {
16 if (!gpu->vkCaps().supportsYcbcrConversion()) {
17 return nullptr;
18 }
19
22
23#ifdef SK_BUILD_FOR_ANDROID
24 VkExternalFormatANDROID externalFormat;
25 if (info.fExternalFormat) {
26 // Format must not be specified for external images.
29 externalFormat.pNext = nullptr;
30 externalFormat.externalFormat = info.fExternalFormat;
31 SkASSERT(ycbcrCreateInfo.pNext == nullptr);
32 ycbcrCreateInfo.pNext = &externalFormat;
33 }
34#else
35 // External images are supported only on Android.
36 SkASSERT(!info.fExternalFormat);
37#endif
38
39 if (!info.fExternalFormat) {
41 }
42
43 VkSamplerYcbcrConversion conversion;
45 GR_VK_CALL_RESULT(gpu, result, CreateSamplerYcbcrConversion(gpu->device(), &ycbcrCreateInfo,
46 nullptr, &conversion));
47 if (result != VK_SUCCESS) {
48 return nullptr;
49 }
50
51 return new GrVkSamplerYcbcrConversion(gpu, conversion, GenerateKey(info));
52}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition: GrVkUtil.h:35
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool supportsYcbcrConversion() const
Definition: GrVkCaps.h:153
const GrVkCaps & vkCaps() const
Definition: GrVkGpu.h:61
VkDevice device() const
Definition: GrVkGpu.h:71
static SK_END_REQUIRE_DENSE Key GenerateKey(const skgpu::VulkanYcbcrConversionInfo &ycbcrInfo)
GAsyncResult * result
void SetupSamplerYcbcrConversionInfo(VkSamplerYcbcrConversionCreateInfo *outInfo, const VulkanYcbcrConversionInfo &conversionInfo)
VkStructureType sType
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
@ VK_FORMAT_UNDEFINED
Definition: vulkan_core.h:1459
@ VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID
Definition: vulkan_core.h:647

◆ GenerateKey()

GrVkSamplerYcbcrConversion::Key GrVkSamplerYcbcrConversion::GenerateKey ( const skgpu::VulkanYcbcrConversionInfo ycbcrInfo)
static

Definition at line 60 of file GrVkSamplerYcbcrConversion.cpp.

61 {
62 SkASSERT(static_cast<int>(ycbcrInfo.fYcbcrModel <= 7));
63 static const int kRangeShift = 3;
64 SkASSERT(static_cast<int>(ycbcrInfo.fYcbcrRange) <= 1);
65 static const int kXChromaOffsetShift = kRangeShift + 1;
66 SkASSERT(static_cast<int>(ycbcrInfo.fXChromaOffset) <= 1);
67 static const int kYChromaOffsetShift = kXChromaOffsetShift + 1;
68 SkASSERT(static_cast<int>(ycbcrInfo.fXChromaOffset) <= 1);
69 static const int kChromaFilterShift = kYChromaOffsetShift + 1;
70 SkASSERT(static_cast<int>(ycbcrInfo.fChromaFilter) <= 1);
71 static const int kReconShift = kChromaFilterShift + 1;
72 SkASSERT(static_cast<int>(ycbcrInfo.fForceExplicitReconstruction) <= 1);
73 static const int kCompRShift = kReconShift + 1;
74 static const int kCompGShift = kCompRShift + 3;
75 static const int kCompBShift = kCompGShift + 3;
76 static const int kCompAShift = kCompBShift + 3;
77 SkASSERT(static_cast<int>(ycbcrInfo.fComponents.r <= 6) &&
78 static_cast<int>(ycbcrInfo.fComponents.g <= 6) &&
79 static_cast<int>(ycbcrInfo.fComponents.b <= 6) &&
80 static_cast<int>(ycbcrInfo.fComponents.a <= 6));
81 static_assert(kCompAShift <= 17);
82
83 uint32_t ycbcrKey = static_cast<uint32_t>(ycbcrInfo.fYcbcrModel);
84 ycbcrKey |= (static_cast<uint32_t>(ycbcrInfo.fYcbcrRange) << kRangeShift);
85 ycbcrKey |= (static_cast<uint32_t>(ycbcrInfo.fXChromaOffset) << kXChromaOffsetShift);
86 ycbcrKey |= (static_cast<uint32_t>(ycbcrInfo.fYChromaOffset) << kYChromaOffsetShift);
87 ycbcrKey |= (static_cast<uint32_t>(ycbcrInfo.fChromaFilter) << kChromaFilterShift);
88 ycbcrKey |= (static_cast<uint32_t>(ycbcrInfo.fForceExplicitReconstruction) << kReconShift);
89 ycbcrKey |= (static_cast<uint32_t>(ycbcrInfo.fComponents.r) << kCompRShift);
90 ycbcrKey |= (static_cast<uint32_t>(ycbcrInfo.fComponents.g) << kCompGShift);
91 ycbcrKey |= (static_cast<uint32_t>(ycbcrInfo.fComponents.b) << kCompBShift);
92 ycbcrKey |= (static_cast<uint32_t>(ycbcrInfo.fComponents.a) << kCompAShift);
93
94 return Key{ycbcrInfo.fFormat, ycbcrInfo.fExternalFormat, ycbcrKey};
95}
VkComponentSwizzle r
Definition: vulkan_core.h:3460
VkComponentSwizzle a
Definition: vulkan_core.h:3463
VkComponentSwizzle g
Definition: vulkan_core.h:3461
VkComponentSwizzle b
Definition: vulkan_core.h:3462
VkSamplerYcbcrRange fYcbcrRange
Definition: VulkanTypes.h:104
VkSamplerYcbcrModelConversion fYcbcrModel
Definition: VulkanTypes.h:103
VkComponentMapping fComponents
Definition: VulkanTypes.h:115

◆ GetKey()

static const Key & GrVkSamplerYcbcrConversion::GetKey ( const GrVkSamplerYcbcrConversion ycbcrConversion)
inlinestatic

Definition at line 51 of file GrVkSamplerYcbcrConversion.h.

51 {
52 return ycbcrConversion.fKey;
53 }
VkSamplerYcbcrConversion ycbcrConversion() const

◆ Hash()

static uint32_t GrVkSamplerYcbcrConversion::Hash ( const Key key)
inlinestatic

Definition at line 54 of file GrVkSamplerYcbcrConversion.h.

54 {
55 return SkChecksum::Hash32(&key, sizeof(Key));
56 }
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
Definition: SkChecksum.cpp:113

◆ ycbcrConversion()

VkSamplerYcbcrConversion GrVkSamplerYcbcrConversion::ycbcrConversion ( ) const
inline

Definition at line 25 of file GrVkSamplerYcbcrConversion.h.

25{ return fYcbcrConversion; }

The documentation for this class was generated from the following files: