Flutter Engine
The Flutter Engine
GrVkSamplerYcbcrConversion.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 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 GrVkSamplerYcbcrConverison_DEFINED
9#define GrVkSamplerYcbcrConverison_DEFINED
10
12
14#include "src/core/SkChecksum.h"
15
16#include <cinttypes>
17
18class GrVkGpu;
19
21public:
24
25 VkSamplerYcbcrConversion ycbcrConversion() const { return fYcbcrConversion; }
26
28 struct Key {
29 Key() = default;
30 Key(VkFormat vkFormat, uint64_t externalFormat, uint32_t conversionKey) {
31 fVkFormat = vkFormat;
32 fExternalFormat = externalFormat;
33 fConversionKey = conversionKey;
34 }
35
37 uint32_t fConversionKey = 0;
38 uint64_t fExternalFormat = 0;
39
40 bool operator==(const Key& that) const {
41 return this->fVkFormat == that.fVkFormat &&
42 this->fExternalFormat == that.fExternalFormat &&
43 this->fConversionKey == that.fConversionKey;
44 }
45 };
47
48 // Helpers for hashing GrVkSamplerYcbcrConversion
49 static Key GenerateKey(const skgpu::VulkanYcbcrConversionInfo& ycbcrInfo);
50
52 return ycbcrConversion.fKey;
53 }
54 static uint32_t Hash(const Key& key) {
55 return SkChecksum::Hash32(&key, sizeof(Key));
56 }
57
58#ifdef SK_TRACE_MANAGED_RESOURCES
59 void dumpInfo() const override {
60 SkDebugf("GrVkSamplerYcbcrConversion: %" PRIdPTR " (%d refs)\n", (intptr_t)fYcbcrConversion,
61 this->getRefCnt());
62 }
63#endif
64
65private:
66 GrVkSamplerYcbcrConversion(const GrVkGpu* gpu, VkSamplerYcbcrConversion ycbcrConversion,
67 Key key)
68 : INHERITED(gpu)
69 , fYcbcrConversion(ycbcrConversion)
70 , fKey(key) {}
71
72 void freeGPUData() const override;
73
74 VkSamplerYcbcrConversion fYcbcrConversion;
75 Key fKey;
76
77 using INHERITED = GrVkManagedResource;
78};
79
80#endif
81
TArray< uint32_t > Key
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define SK_BEGIN_REQUIRE_DENSE
Definition: SkMacros.h:37
#define SK_END_REQUIRE_DENSE
Definition: SkMacros.h:38
GrVkManagedResource(const GrVkGpu *gpu)
static GrVkSamplerYcbcrConversion * Create(GrVkGpu *gpu, const skgpu::VulkanYcbcrConversionInfo &)
static const Key & GetKey(const GrVkSamplerYcbcrConversion &ycbcrConversion)
VkSamplerYcbcrConversion ycbcrConversion() const
static uint32_t Hash(const Key &key)
static SK_END_REQUIRE_DENSE Key GenerateKey(const skgpu::VulkanYcbcrConversionInfo &ycbcrInfo)
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
Definition: SkChecksum.cpp:113
Key(VkFormat vkFormat, uint64_t externalFormat, uint32_t conversionKey)
bool operator==(const Key &that) const
VkFormat
Definition: vulkan_core.h:1458
@ VK_FORMAT_UNDEFINED
Definition: vulkan_core.h:1459