@shopify/react-native-skia 0.1.129 → 0.1.130

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +1 -0
  2. package/cpp/api/JsiSkRuntimeEffect.h +7 -9
  3. package/cpp/api/JsiSkVertices.h +0 -2
  4. package/cpp/rnskia/values/RNSkValue.h +1 -1
  5. package/cpp/skia/include/codec/SkCodec.h +7 -1
  6. package/cpp/skia/include/core/SkAlphaType.h +45 -0
  7. package/cpp/skia/include/core/SkBitmap.h +4 -2
  8. package/cpp/skia/include/core/SkCanvas.h +31 -20
  9. package/cpp/skia/include/core/SkColor.h +1 -1
  10. package/cpp/skia/include/core/SkColorFilter.h +1 -0
  11. package/cpp/skia/include/core/SkColorType.h +66 -0
  12. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +1 -1
  13. package/cpp/skia/include/core/SkDrawable.h +7 -0
  14. package/cpp/skia/include/core/SkEncodedImageFormat.h +1 -0
  15. package/cpp/skia/include/core/SkFont.h +4 -3
  16. package/cpp/skia/include/core/SkFontArguments.h +33 -1
  17. package/cpp/skia/include/core/SkGraphics.h +13 -0
  18. package/cpp/skia/include/core/SkImage.h +67 -22
  19. package/cpp/skia/include/core/SkImageEncoder.h +0 -3
  20. package/cpp/skia/include/core/SkImageGenerator.h +4 -3
  21. package/cpp/skia/include/core/SkImageInfo.h +35 -142
  22. package/cpp/skia/include/core/SkMesh.h +303 -0
  23. package/cpp/skia/include/core/SkMilestone.h +1 -1
  24. package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +30 -0
  25. package/cpp/skia/include/core/SkPaint.h +4 -19
  26. package/cpp/skia/include/core/SkPath.h +20 -33
  27. package/cpp/skia/include/core/SkPathBuilder.h +1 -6
  28. package/cpp/skia/include/core/SkPixelRef.h +1 -1
  29. package/cpp/skia/include/core/SkPixmap.h +3 -2
  30. package/cpp/skia/include/core/SkRSXform.h +1 -1
  31. package/cpp/skia/include/core/SkSamplingOptions.h +16 -5
  32. package/cpp/skia/include/core/SkSpan.h +5 -5
  33. package/cpp/skia/include/core/SkString.h +5 -8
  34. package/cpp/skia/include/core/SkSurface.h +21 -0
  35. package/cpp/skia/include/core/SkTypeface.h +20 -4
  36. package/cpp/skia/include/core/SkTypes.h +9 -5
  37. package/cpp/skia/include/effects/SkGradientShader.h +9 -18
  38. package/cpp/skia/include/effects/SkRuntimeEffect.h +16 -12
  39. package/cpp/skia/include/gpu/GpuTypes.h +32 -0
  40. package/cpp/skia/include/gpu/GrBackendSemaphore.h +1 -1
  41. package/cpp/skia/include/gpu/GrBackendSurface.h +6 -5
  42. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +1 -1
  43. package/cpp/skia/include/gpu/GrContextOptions.h +11 -20
  44. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +7 -0
  45. package/cpp/skia/include/gpu/GrDirectContext.h +16 -11
  46. package/cpp/skia/include/gpu/GrDriverBugWorkaroundsAutogen.h +0 -2
  47. package/cpp/skia/include/gpu/GrRecordingContext.h +14 -7
  48. package/cpp/skia/include/gpu/GrSurfaceInfo.h +6 -6
  49. package/cpp/skia/include/gpu/dawn/GrDawnTypes.h +1 -1
  50. package/cpp/skia/include/gpu/gl/GrGLFunctions.h +3 -1
  51. package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -2
  52. package/cpp/skia/include/gpu/graphite/BackendTexture.h +64 -0
  53. package/cpp/skia/include/gpu/graphite/Context.h +124 -0
  54. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +71 -0
  55. package/cpp/skia/include/gpu/graphite/Recorder.h +104 -0
  56. package/cpp/skia/include/gpu/graphite/Recording.h +39 -0
  57. package/cpp/skia/include/gpu/graphite/SkStuff.h +47 -0
  58. package/cpp/skia/include/gpu/graphite/TextureInfo.h +91 -0
  59. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +24 -0
  60. package/cpp/skia/include/gpu/graphite/mtl/MtlTypes.h +68 -0
  61. package/cpp/skia/include/gpu/mock/GrMockTypes.h +1 -2
  62. package/cpp/skia/include/ports/SkCFObject.h +0 -4
  63. package/cpp/skia/include/ports/SkTypeface_win.h +2 -2
  64. package/cpp/skia/include/private/{GrSingleOwner.h → SingleOwner.h} +17 -10
  65. package/cpp/skia/include/private/SkChecksum.h +11 -0
  66. package/cpp/skia/include/private/SkEncodedInfo.h +22 -5
  67. package/cpp/skia/include/private/SkFloatingPoint.h +0 -53
  68. package/cpp/skia/include/private/SkImageInfoPriv.h +8 -2
  69. package/cpp/skia/include/private/SkMacros.h +13 -18
  70. package/cpp/skia/include/private/SkMutex.h +8 -0
  71. package/cpp/skia/include/private/SkPathRef.h +2 -16
  72. package/cpp/skia/include/private/SkSLDefines.h +9 -1
  73. package/cpp/skia/include/private/SkSLIRNode.h +6 -5
  74. package/cpp/skia/include/private/SkSLLayout.h +11 -10
  75. package/cpp/skia/include/private/SkSLModifiers.h +4 -3
  76. package/cpp/skia/include/private/SkSLProgramElement.h +2 -2
  77. package/cpp/skia/include/private/SkSLProgramKind.h +8 -5
  78. package/cpp/skia/include/private/SkSLStatement.h +2 -3
  79. package/cpp/skia/include/private/SkSLString.h +17 -56
  80. package/cpp/skia/include/private/SkSLSymbol.h +4 -4
  81. package/cpp/skia/include/private/SkShadowFlags.h +3 -1
  82. package/cpp/skia/include/private/SkStringView.h +47 -0
  83. package/cpp/skia/include/private/SkTArray.h +4 -3
  84. package/cpp/skia/include/private/SkTHash.h +66 -24
  85. package/cpp/skia/include/private/SkTLogic.h +2 -32
  86. package/cpp/skia/include/private/SkTemplates.h +2 -2
  87. package/cpp/skia/include/private/SkThreadAnnotations.h +4 -4
  88. package/cpp/skia/include/private/SkVx.h +28 -28
  89. package/cpp/skia/include/private/chromium/GrSlug.h +40 -3
  90. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +12 -6
  91. package/cpp/skia/include/private/{GrContext_Base.h → gpu/ganesh/GrContext_Base.h} +7 -0
  92. package/cpp/skia/include/private/{GrD3DTypesMinimal.h → gpu/ganesh/GrD3DTypesMinimal.h} +0 -0
  93. package/cpp/skia/include/private/{GrDawnTypesPriv.h → gpu/ganesh/GrDawnTypesPriv.h} +0 -0
  94. package/cpp/skia/include/private/{GrGLTypesPriv.h → gpu/ganesh/GrGLTypesPriv.h} +1 -0
  95. package/cpp/skia/include/private/{GrImageContext.h → gpu/ganesh/GrImageContext.h} +4 -4
  96. package/cpp/skia/include/private/{GrMockTypesPriv.h → gpu/ganesh/GrMockTypesPriv.h} +0 -0
  97. package/cpp/skia/include/private/{GrMtlTypesPriv.h → gpu/ganesh/GrMtlTypesPriv.h} +0 -0
  98. package/cpp/skia/include/private/{GrTypesPriv.h → gpu/ganesh/GrTypesPriv.h} +25 -367
  99. package/cpp/skia/include/private/{GrVkTypesPriv.h → gpu/ganesh/GrVkTypesPriv.h} +0 -0
  100. package/cpp/skia/include/private/gpu/graphite/MtlTypesPriv.h +74 -0
  101. package/cpp/skia/include/sksl/DSL.h +4 -0
  102. package/cpp/skia/include/sksl/DSLBlock.h +8 -3
  103. package/cpp/skia/include/sksl/DSLCase.h +6 -6
  104. package/cpp/skia/include/sksl/DSLCore.h +89 -78
  105. package/cpp/skia/include/sksl/DSLExpression.h +78 -45
  106. package/cpp/skia/include/sksl/DSLFunction.h +23 -18
  107. package/cpp/skia/include/sksl/DSLLayout.h +14 -16
  108. package/cpp/skia/include/sksl/DSLModifiers.h +7 -5
  109. package/cpp/skia/include/sksl/DSLRuntimeEffects.h +1 -1
  110. package/cpp/skia/include/sksl/DSLStatement.h +16 -10
  111. package/cpp/skia/include/sksl/DSLSymbols.h +7 -7
  112. package/cpp/skia/include/sksl/DSLType.h +27 -23
  113. package/cpp/skia/include/sksl/DSLVar.h +72 -61
  114. package/cpp/skia/include/sksl/SkSLErrorReporter.h +12 -49
  115. package/cpp/skia/include/sksl/SkSLOperator.h +151 -0
  116. package/cpp/skia/include/sksl/SkSLPosition.h +102 -0
  117. package/cpp/skia/include/svg/SkSVGCanvas.h +5 -1
  118. package/cpp/skia/include/utils/SkAnimCodecPlayer.h +7 -0
  119. package/cpp/skia/include/utils/SkCamera.h +2 -0
  120. package/cpp/skia/include/utils/SkCanvasStateUtils.h +4 -1
  121. package/cpp/skia/include/utils/SkCustomTypeface.h +6 -4
  122. package/cpp/skia/include/utils/SkNWayCanvas.h +34 -0
  123. package/cpp/skia/include/utils/SkNullCanvas.h +5 -1
  124. package/cpp/skia/include/utils/SkOrderedFontMgr.h +12 -0
  125. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +30 -1
  126. package/cpp/skia/include/utils/SkParse.h +2 -0
  127. package/cpp/skia/include/utils/SkShadowUtils.h +3 -2
  128. package/cpp/skia/include/utils/SkTextUtils.h +8 -4
  129. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +27 -1
  130. package/cpp/skia/modules/svg/include/SkSVGDOM.h +4 -0
  131. package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +32 -0
  132. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
  133. package/cpp/skia/modules/svg/include/SkSVGSVG.h +2 -0
  134. package/cpp/skia/modules/svg/include/SkSVGTypes.h +48 -9
  135. package/ios/RNSkia-iOS/PlatformContext.h +1 -1
  136. package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +1 -0
  137. package/ios/RNSkia-iOS/SkiaDrawView.mm +1 -1
  138. package/lib/commonjs/renderer/components/shaders/Shader.js +1 -2
  139. package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
  140. package/lib/module/renderer/components/shaders/Shader.js +1 -2
  141. package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
  142. package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +0 -1
  143. package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +2 -4
  144. package/libs/android/arm64-v8a/libskia.a +0 -0
  145. package/libs/android/arm64-v8a/libsvg.a +0 -0
  146. package/libs/android/armeabi-v7a/libskia.a +0 -0
  147. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  148. package/libs/android/x86/libskia.a +0 -0
  149. package/libs/android/x86/libsvg.a +0 -0
  150. package/libs/android/x86_64/libskia.a +0 -0
  151. package/libs/android/x86_64/libsvg.a +0 -0
  152. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  153. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  154. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  155. package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
  156. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  157. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  158. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  159. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  160. package/package.json +2 -2
  161. package/src/renderer/components/shaders/Shader.tsx +1 -3
  162. package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -8
  163. package/cpp/skia/include/core/SkCustomMesh.h +0 -202
  164. package/cpp/skia/include/core/SkStringView.h +0 -185
  165. package/cpp/skia/include/private/SkPaintParamsKey.h +0 -110
  166. package/cpp/skia/include/private/SkShaderCodeDictionary.h +0 -63
  167. package/cpp/skia/include/private/SkTOptional.h +0 -362
@@ -1,185 +0,0 @@
1
- /*
2
- * Copyright 2021 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 SkStringView_DEFINED
9
- #define SkStringView_DEFINED
10
-
11
- #include <algorithm>
12
- #include <cstring>
13
- #include <string>
14
-
15
- namespace skstd {
16
-
17
- class string_view {
18
- public:
19
- using value_type = char;
20
- using traits_type = std::char_traits<value_type>;
21
- using const_pointer = const value_type*;
22
- using const_reference = const value_type&;
23
- using iterator = const_pointer;
24
- using const_iterator = iterator;
25
- using size_type = size_t;
26
- static constexpr size_type npos = size_type(-1);
27
-
28
- constexpr string_view()
29
- : fData(nullptr)
30
- , fLength(0) {}
31
-
32
- constexpr string_view(const string_view&) = default;
33
-
34
- constexpr string_view(const_pointer data, size_type length)
35
- : fData(data)
36
- , fLength(length) {}
37
-
38
- string_view(const_pointer data)
39
- : string_view(data, strlen(data)) {}
40
-
41
- string_view(const std::string& str)
42
- : string_view(str.data(), str.length()) {}
43
-
44
- constexpr string_view& operator=(const string_view&) = default;
45
-
46
- constexpr iterator begin() const {
47
- return fData;
48
- }
49
-
50
- constexpr iterator end() const {
51
- return fData + fLength;
52
- }
53
-
54
- constexpr const_reference operator[](size_type idx) const {
55
- return fData[idx];
56
- }
57
-
58
- constexpr const_reference front() const {
59
- return fData[0];
60
- }
61
-
62
- constexpr const_reference back() const {
63
- return fData[fLength - 1];
64
- }
65
-
66
- constexpr const_pointer data() const {
67
- return fData;
68
- }
69
-
70
- constexpr size_type size() const {
71
- return fLength;
72
- }
73
-
74
- constexpr size_type length() const {
75
- return fLength;
76
- }
77
-
78
- constexpr bool empty() const {
79
- return fLength == 0;
80
- }
81
-
82
- constexpr bool starts_with(string_view s) const {
83
- if (s.length() > fLength) {
84
- return false;
85
- }
86
- return s.length() == 0 || !memcmp(fData, s.fData, s.length());
87
- }
88
-
89
- constexpr bool starts_with(value_type c) const {
90
- return !this->empty() && this->front() == c;
91
- }
92
-
93
- constexpr bool ends_with(string_view s) const {
94
- if (s.length() > fLength) {
95
- return false;
96
- }
97
- return s.length() == 0 || !memcmp(this->end() - s.length(), s.fData, s.length());
98
- }
99
-
100
- constexpr bool ends_with(value_type c) const {
101
- return !this->empty() && this->back() == c;
102
- }
103
-
104
- size_type find(string_view needle, size_type pos = 0) const {
105
- if (needle.length() == 0) {
106
- return 0;
107
- }
108
- if (this->length() < needle.length()) {
109
- return npos;
110
- }
111
- const char* match = nullptr;
112
- const char* start = this->data() + pos;
113
- const char* end = start + this->length() - needle.length() + 1;
114
- while ((match = (const char*)(memchr(start, needle[0], (size_t)(end - start))))) {
115
- if (!memcmp(match, needle.data(), needle.length())) {
116
- return (size_type)(match - this->data());
117
- } else {
118
- start = match + 1;
119
- }
120
- }
121
- return npos;
122
- }
123
-
124
- bool contains(string_view needle) const {
125
- return this->find(needle) != npos;
126
- }
127
-
128
- constexpr string_view substr(size_type pos = 0, size_type count = npos) const {
129
- if (pos > fLength) {
130
- return {};
131
- }
132
- return string_view{fData + pos, std::min(count, fLength - pos)};
133
- }
134
-
135
- constexpr void swap(string_view& other) {
136
- const_pointer tempData = fData;
137
- fData = other.fData;
138
- other.fData = tempData;
139
-
140
- size_type tempLength = fLength;
141
- fLength = other.fLength;
142
- other.fLength = tempLength;
143
- }
144
-
145
- constexpr void remove_prefix(size_type n) {
146
- fData += n;
147
- fLength -= n;
148
- }
149
-
150
- constexpr void remove_suffix(size_type n) {
151
- fLength -= n;
152
- }
153
-
154
- private:
155
- const_pointer fData;
156
- size_type fLength;
157
- };
158
-
159
- bool operator==(string_view left, string_view right);
160
-
161
- bool operator!=(string_view left, string_view right);
162
-
163
- bool operator<(string_view left, string_view right);
164
-
165
- bool operator<=(string_view left, string_view right);
166
-
167
- bool operator>(string_view left, string_view right);
168
-
169
- bool operator>=(string_view left, string_view right);
170
-
171
- } // namespace skstd
172
-
173
- namespace std {
174
- template<> struct hash<skstd::string_view> {
175
- size_t operator()(const skstd::string_view& s) const {
176
- size_t result = 0;
177
- for (auto iter = s.begin(); iter != s.end(); ++iter) {
178
- result = result * 101 + (size_t) *iter;
179
- }
180
- return result;
181
- }
182
- };
183
- } // namespace std
184
-
185
- #endif
@@ -1,110 +0,0 @@
1
- /*
2
- * Copyright 2022 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 SkPaintParamsKey_DEFINED
9
- #define SkPaintParamsKey_DEFINED
10
-
11
- #include <array>
12
- #include <limits>
13
- #include "include/core/SkTypes.h"
14
-
15
- enum class SkBackend : uint8_t {
16
- kGanesh,
17
- kGraphite,
18
- kSkVM
19
- };
20
-
21
- // TODO: this needs to be expanded into a more flexible dictionary (esp. for user-supplied SkSL)
22
- // TODO: should this enum actually be in ShaderCodeDictionary.h?
23
- enum class CodeSnippetID : uint8_t {
24
- // TODO: It seems like this requires some refinement. Fundamentally this doesn't seem like a
25
- // draw that originated from a PaintParams.
26
- kDepthStencilOnlyDraw,
27
-
28
- // SkShader code snippets
29
- kSolidColorShader,
30
- kLinearGradientShader,
31
- kRadialGradientShader,
32
- kSweepGradientShader,
33
- kConicalGradientShader,
34
-
35
- // BlendMode code snippets
36
- kSimpleBlendMode,
37
-
38
- kLast = kSimpleBlendMode
39
- };
40
- static constexpr int kCodeSnippetIDCount = static_cast<int>(CodeSnippetID::kLast) + 1;
41
-
42
- // This class is a compact representation of the shader needed to implement a given
43
- // PaintParams. Its structure is a series of blocks where each block has a
44
- // header that consists of 2-bytes - a 1-byte code-snippet ID and a 1-byte number-of-bytes-in-the-
45
- // block field. The rest of the data in the block is dependent on the individual code snippet.
46
- class SkPaintParamsKey {
47
- public:
48
- static const int kBlockHeaderSizeInBytes = 2;
49
- static const int kBlockSizeOffsetInBytes = 1; // offset to the block size w/in the header
50
-
51
- // Block headers have the following structure:
52
- // 1st byte: codeSnippetID
53
- // 2nd byte: total blockSize in bytes
54
- // Returns the header's offset in the key - to be passed back into endBlock
55
- int beginBlock(CodeSnippetID codeSnippetID) {
56
- SkASSERT(fNumBytes < kMaxKeySize);
57
-
58
- this->addByte((uint8_t) codeSnippetID);
59
- this->addByte(0); // this needs to be patched up with a call to endBlock
60
- return fNumBytes - kBlockHeaderSizeInBytes;
61
- }
62
-
63
- // Update the size byte of a block header
64
- void endBlock(int headerOffset, CodeSnippetID codeSnippetID) {
65
- SkASSERT(fData[headerOffset] == (uint32_t) codeSnippetID);
66
- int blockSize = fNumBytes - headerOffset;
67
- SkASSERT(blockSize <= kMaxBlockSize);
68
- fData[headerOffset+1] = blockSize;
69
- }
70
-
71
- std::pair<CodeSnippetID, uint8_t> readCodeSnippetID(int headerOffset) const {
72
- SkASSERT(headerOffset < kMaxKeySize - kBlockHeaderSizeInBytes);
73
-
74
- CodeSnippetID id = static_cast<CodeSnippetID>(fData[headerOffset]);
75
- uint8_t blockSize = fData[headerOffset+1];
76
- SkASSERT(headerOffset + blockSize <= this->sizeInBytes());
77
-
78
- return { id, blockSize };
79
- }
80
-
81
- void addByte(uint8_t byte) {
82
- SkASSERT(fNumBytes < kMaxKeySize);
83
-
84
- fData[fNumBytes++] = byte;
85
- }
86
-
87
- #ifdef SK_DEBUG
88
- static int DumpBlock(const SkPaintParamsKey&, int headerOffset);
89
- void dump() const;
90
- #endif
91
-
92
- uint8_t byte(int offset) const { SkASSERT(offset < fNumBytes); return fData[offset]; }
93
- const void* data() const { return fData.data(); }
94
- int sizeInBytes() const { return fNumBytes; }
95
-
96
- bool operator==(const SkPaintParamsKey& that) const;
97
- bool operator!=(const SkPaintParamsKey& that) const { return !(*this == that); }
98
-
99
- private:
100
- // TODO: need to make it so the key can can dynamically grow
101
- static const int kMaxKeySize = 32;
102
- static const int kMaxBlockSize = std::numeric_limits<uint8_t>::max();
103
-
104
- // TODO: It is probably overkill but we could encode the SkBackend in the first byte of
105
- // the key.
106
- int fNumBytes = 0;
107
- std::array<uint8_t, kMaxKeySize> fData;
108
- };
109
-
110
- #endif // SkPaintParamsKey_DEFINED
@@ -1,63 +0,0 @@
1
- /*
2
- * Copyright 2022 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 SkShaderCodeDictionary_DEFINED
9
- #define SkShaderCodeDictionary_DEFINED
10
-
11
- #include <unordered_map>
12
- #include "include/private/SkPaintParamsKey.h"
13
- #include "include/private/SkSpinlock.h"
14
- #include "include/private/SkUniquePaintParamsID.h"
15
- #include "src/core/SkArenaAlloc.h"
16
-
17
- class SkShaderCodeDictionary {
18
- public:
19
- SkShaderCodeDictionary();
20
-
21
- struct Entry {
22
- public:
23
- SkUniquePaintParamsID uniqueID() const {
24
- SkASSERT(fUniqueID.isValid());
25
- return fUniqueID;
26
- }
27
- const SkPaintParamsKey& paintParamsKey() const { return fPaintParamsKey; }
28
-
29
- private:
30
- friend class SkShaderCodeDictionary;
31
-
32
- Entry(const SkPaintParamsKey& paintParamsKey) : fPaintParamsKey(paintParamsKey) {}
33
-
34
- void setUniqueID(uint32_t newID) {
35
- SkASSERT(!fUniqueID.isValid());
36
- fUniqueID = SkUniquePaintParamsID(newID);
37
- }
38
-
39
- SkUniquePaintParamsID fUniqueID; // fixed-size (uint32_t) unique ID assigned to a key
40
- SkPaintParamsKey fPaintParamsKey; // variable-length paint key descriptor
41
- };
42
-
43
- const Entry* findOrCreate(const SkPaintParamsKey&) SK_EXCLUDES(fSpinLock);
44
-
45
- const Entry* lookup(SkUniquePaintParamsID) const SK_EXCLUDES(fSpinLock);
46
-
47
- private:
48
- Entry* makeEntry(const SkPaintParamsKey&);
49
-
50
- struct Hash {
51
- size_t operator()(const SkPaintParamsKey&) const;
52
- };
53
-
54
- // TODO: can we do something better given this should have write-seldom/read-often behavior?
55
- mutable SkSpinlock fSpinLock;
56
-
57
- std::unordered_map<SkPaintParamsKey, Entry*, Hash> fHash SK_GUARDED_BY(fSpinLock);
58
- std::vector<Entry*> fEntryVector SK_GUARDED_BY(fSpinLock);
59
-
60
- SkArenaAlloc fArena{256};
61
- };
62
-
63
- #endif // SkShaderCodeDictionary_DEFINED