Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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:
23
24 VkSamplerYcbcrConversion ycbcrConversion() const { return fYcbcrConversion; }
25
27 struct Key {
28 Key() = default;
29 Key(VkFormat vkFormat, uint64_t externalFormat, uint32_t conversionKey) {
30 fVkFormat = vkFormat;
31 fExternalFormat = externalFormat;
32 fConversionKey = conversionKey;
33 }
34
36 uint32_t fConversionKey = 0;
37 uint64_t fExternalFormat = 0;
38
39 bool operator==(const Key& that) const {
40 return this->fVkFormat == that.fVkFormat &&
41 this->fExternalFormat == that.fExternalFormat &&
42 this->fConversionKey == that.fConversionKey;
43 }
44 };
46
47 // Helpers for hashing GrVkSamplerYcbcrConversion
48 static Key GenerateKey(const GrVkYcbcrConversionInfo& ycbcrInfo);
49
51 return ycbcrConversion.fKey;
52 }
53 static uint32_t Hash(const Key& key) {
54 return SkChecksum::Hash32(&key, sizeof(Key));
55 }
56
57#ifdef SK_TRACE_MANAGED_RESOURCES
58 void dumpInfo() const override {
59 SkDebugf("GrVkSamplerYcbcrConversion: %" PRIdPTR " (%d refs)\n", (intptr_t)fYcbcrConversion,
60 this->getRefCnt());
61 }
62#endif
63
64private:
65 GrVkSamplerYcbcrConversion(const GrVkGpu* gpu, VkSamplerYcbcrConversion ycbcrConversion,
66 Key key)
67 : INHERITED(gpu)
68 , fYcbcrConversion(ycbcrConversion)
69 , fKey(key) {}
70
71 void freeGPUData() const override;
72
73 VkSamplerYcbcrConversion fYcbcrConversion;
74 Key fKey;
75
76 using INHERITED = GrVkManagedResource;
77};
78
79#endif
80
static sk_sp< Effect > Create()
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
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 GrVkYcbcrConversionInfo &ycbcrInfo)
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
Key(VkFormat vkFormat, uint64_t externalFormat, uint32_t conversionKey)
VkFormat
@ VK_FORMAT_UNDEFINED