@shopify/react-native-skia 0.1.129 → 0.1.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,303 @@
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 SkMesh_DEFINED
9
+ #define SkMesh_DEFINED
10
+
11
+ #include "include/core/SkTypes.h"
12
+
13
+ #ifdef SK_ENABLE_SKSL
14
+ #include "include/core/SkAlphaType.h"
15
+ #include "include/core/SkRect.h"
16
+ #include "include/core/SkRefCnt.h"
17
+ #include "include/core/SkSpan.h"
18
+ #include "include/core/SkString.h"
19
+
20
+ #include <memory>
21
+ #include <vector>
22
+
23
+ class GrDirectContext;
24
+ class SkColorSpace;
25
+ class SkData;
26
+
27
+ namespace SkSL { struct Program; }
28
+
29
+ /**
30
+ * A specification for custom meshes. Specifies the vertex buffer attributes and stride, the
31
+ * vertex program that produces a user-defined set of varyings, a fragment program that ingests
32
+ * the interpolated varyings and produces local coordinates and optionally a color.
33
+ *
34
+ * The signature of the vertex program must be:
35
+ * float2 main(Attributes, out Varyings)
36
+ * where the return value is a local position that will be transformed by SkCanvas's matrix.
37
+ *
38
+ * The signature of the fragment program must be either:
39
+ * (float2|void) main(Varyings)
40
+ * or
41
+ * (float2|void) main(Varyings, out (half4|float4) color)
42
+ *
43
+ * where the return value is the local coordinates that will be used to access SkShader. If the
44
+ * return type is void then the interpolated position from vertex shader return is used as the local
45
+ * coordinate. If the color variant is used it will be blended with SkShader (or SkPaint color in
46
+ * absence of a shader) using the SkBlender provided to the SkCanvas draw call.
47
+ */
48
+ class SkMeshSpecification : public SkNVRefCnt<SkMeshSpecification> {
49
+ public:
50
+ /** These values are enforced when creating a specification. */
51
+ static constexpr size_t kMaxStride = 1024;
52
+ static constexpr size_t kMaxAttributes = 8;
53
+ static constexpr size_t kStrideAlignment = 4;
54
+ static constexpr size_t kOffsetAlignment = 4;
55
+ static constexpr size_t kMaxVaryings = 6;
56
+
57
+ struct Attribute {
58
+ enum class Type : uint32_t { // CPU representation Shader Type
59
+ kFloat, // float float
60
+ kFloat2, // two floats float2
61
+ kFloat3, // three floats float3
62
+ kFloat4, // four floats float4
63
+ kUByte4_unorm, // four bytes half4
64
+
65
+ kLast = kUByte4_unorm
66
+ };
67
+ Type type;
68
+ size_t offset;
69
+ SkString name;
70
+ };
71
+
72
+ struct Varying {
73
+ enum class Type : uint32_t {
74
+ kFloat, // "float"
75
+ kFloat2, // "float2"
76
+ kFloat3, // "float3"
77
+ kFloat4, // "float4"
78
+ kHalf, // "half"
79
+ kHalf2, // "half2"
80
+ kHalf3, // "half3"
81
+ kHalf4, // "half4"
82
+
83
+ kLast = kHalf4
84
+ };
85
+ Type type;
86
+ SkString name;
87
+ };
88
+
89
+ ~SkMeshSpecification();
90
+
91
+ struct Result {
92
+ sk_sp<SkMeshSpecification> specification;
93
+ SkString error;
94
+ };
95
+
96
+ /**
97
+ * If successful the return is a specification and an empty error string. Otherwise, it is a
98
+ * null specification a non-empty error string.
99
+ *
100
+ * @param attributes The vertex attributes that will be consumed by 'vs'. Attributes need
101
+ * not be tightly packed but attribute offsets must be aligned to
102
+ * kOffsetAlignment and offset + size may not be greater than
103
+ * 'vertexStride'. At least one attribute is required.
104
+ * @param vertexStride The offset between successive attribute values. This must be aligned to
105
+ * kStrideAlignment.
106
+ * @param varyings The varyings that will be written by 'vs' and read by 'fs'. This may
107
+ * be empty.
108
+ * @param vs The vertex shader code that computes a vertex position and the varyings
109
+ * from the attributes.
110
+ * @param fs The fragment code that computes a local coordinate and optionally a
111
+ * color from the varyings. The local coordinate is used to sample
112
+ * SkShader.
113
+ * @param cs The colorspace of the color produced by 'fs'. Ignored if 'fs's main()
114
+ * function does not have a color out param.
115
+ * @param at The alpha type of the color produced by 'fs'. Ignored if 'fs's main()
116
+ * function does not have a color out param. Cannot be kUnknown.
117
+ */
118
+ static Result Make(SkSpan<const Attribute> attributes,
119
+ size_t vertexStride,
120
+ SkSpan<const Varying> varyings,
121
+ const SkString& vs,
122
+ const SkString& fs);
123
+ static Result Make(SkSpan<const Attribute> attributes,
124
+ size_t vertexStride,
125
+ SkSpan<const Varying> varyings,
126
+ const SkString& vs,
127
+ const SkString& fs,
128
+ sk_sp<SkColorSpace> cs);
129
+ static Result Make(SkSpan<const Attribute> attributes,
130
+ size_t vertexStride,
131
+ SkSpan<const Varying> varyings,
132
+ const SkString& vs,
133
+ const SkString& fs,
134
+ sk_sp<SkColorSpace> cs,
135
+ SkAlphaType at);
136
+
137
+ SkSpan<const Attribute> attributes() const { return SkMakeSpan(fAttributes); }
138
+
139
+ size_t stride() const { return fStride; }
140
+
141
+ private:
142
+ friend struct SkMeshSpecificationPriv;
143
+
144
+ enum class ColorType {
145
+ kNone,
146
+ kHalf4,
147
+ kFloat4,
148
+ };
149
+
150
+ static Result MakeFromSourceWithStructs(SkSpan<const Attribute> attributes,
151
+ size_t stride,
152
+ SkSpan<const Varying> varyings,
153
+ const SkString& vs,
154
+ const SkString& fs,
155
+ sk_sp<SkColorSpace> cs,
156
+ SkAlphaType at);
157
+
158
+ SkMeshSpecification(SkSpan<const Attribute>,
159
+ size_t,
160
+ SkSpan<const Varying>,
161
+ std::unique_ptr<SkSL::Program>,
162
+ std::unique_ptr<SkSL::Program>,
163
+ ColorType,
164
+ bool hasLocalCoords,
165
+ sk_sp<SkColorSpace>,
166
+ SkAlphaType);
167
+
168
+ SkMeshSpecification(const SkMeshSpecification&) = delete;
169
+ SkMeshSpecification(SkMeshSpecification&&) = delete;
170
+
171
+ SkMeshSpecification& operator=(const SkMeshSpecification&) = delete;
172
+ SkMeshSpecification& operator=(SkMeshSpecification&&) = delete;
173
+
174
+ const std::vector<Attribute> fAttributes;
175
+ const std::vector<Varying> fVaryings;
176
+ std::unique_ptr<SkSL::Program> fVS;
177
+ std::unique_ptr<SkSL::Program> fFS;
178
+ size_t fStride;
179
+ uint32_t fHash;
180
+ ColorType fColorType;
181
+ bool fHasLocalCoords;
182
+ sk_sp<SkColorSpace> fColorSpace;
183
+ SkAlphaType fAlphaType;
184
+ };
185
+
186
+ /**
187
+ * A vertex buffer, a topology, optionally an index buffer, and a compatible SkMeshSpecification.
188
+ *
189
+ * The data in the vertex buffer is expected to contain the attributes described by the spec
190
+ * for vertexCount vertices beginning at vertexOffset. vertexOffset must be aligned to the
191
+ * SkMeshSpecification's vertex stride. The size of the buffer must be at least vertexOffset +
192
+ * spec->stride()*vertexCount (even if vertex attributes contains pad at the end of the stride). If
193
+ * the specified bounds does not contain all the points output by the spec's vertex program when
194
+ * applied to the vertices in the custom mesh then the result is undefined.
195
+ *
196
+ * MakeIndexed may be used to create an indexed mesh. indexCount indices are read from the index
197
+ * buffer at the specified offset which must be aligned to 2. The indices are always unsigned 16bit
198
+ * integers. The index count must be at least 3.
199
+ *
200
+ * If Make() is used the implicit index sequence is 0, 1, 2, 3, ... and vertexCount must be at least
201
+ * 3.
202
+ */
203
+ class SkMesh {
204
+ public:
205
+ class IndexBuffer : public SkRefCnt {};
206
+ class VertexBuffer : public SkRefCnt {};
207
+
208
+ SkMesh();
209
+ ~SkMesh();
210
+
211
+ SkMesh(const SkMesh&);
212
+ SkMesh(SkMesh&&);
213
+
214
+ SkMesh& operator=(const SkMesh&);
215
+ SkMesh& operator=(SkMesh&&);
216
+
217
+ /**
218
+ * Makes an index buffer to be used with SkMeshes. The SkData is used to determine the
219
+ * size and contents of the buffer. The buffer may be CPU- or GPU-backed depending on whether
220
+ * GrDirectContext* is nullptr.
221
+ *
222
+ * @param GrDirectContext* If nullptr a CPU-backed object is returned that owns the SkData.
223
+ * Otherwise, the data is uploaded to the GPU and a GPU-backed buffer
224
+ * is returned. It may only be used to draw into SkSurfaces that
225
+ * are backed by the passed GrDirectContext.
226
+ * @param sk_sp<SkData> required. The data used to populate the buffer.
227
+ */
228
+ static sk_sp<IndexBuffer> MakeIndexBuffer(GrDirectContext*, sk_sp<const SkData>);
229
+
230
+ /**
231
+ * Makes a vertex buffer to be used with SkMeshes. The SkData is used to determine the
232
+ * size and contents of the buffer.The buffer may be CPU- or GPU-backed depending on whether
233
+ * GrDirectContext* is nullptr.
234
+ *
235
+ * @param GrDirectContext* If nullptr a CPU-backed object is returned that owns the SkData.
236
+ * Otherwise, the data is uploaded to the GPU and a GPU-backed buffer
237
+ * is returned. It may only be used to draw into SkSurfaces that
238
+ * are backed by the passed GrDirectContext.
239
+ * @param sk_sp<SkData> required. The data used to populate the buffer.
240
+ */
241
+ static sk_sp<VertexBuffer> MakeVertexBuffer(GrDirectContext*, sk_sp<const SkData>);
242
+
243
+ enum class Mode { kTriangles, kTriangleStrip };
244
+
245
+ static SkMesh Make(sk_sp<SkMeshSpecification>,
246
+ Mode,
247
+ sk_sp<VertexBuffer>,
248
+ size_t vertexCount,
249
+ size_t vertexOffset,
250
+ const SkRect& bounds);
251
+
252
+ static SkMesh MakeIndexed(sk_sp<SkMeshSpecification>,
253
+ Mode,
254
+ sk_sp<VertexBuffer>,
255
+ size_t vertexCount,
256
+ size_t vertexOffset,
257
+ sk_sp<IndexBuffer>,
258
+ size_t indexCount,
259
+ size_t indexOffset,
260
+ const SkRect& bounds);
261
+
262
+ sk_sp<SkMeshSpecification> spec() const { return fSpec; }
263
+
264
+ Mode mode() const { return fMode; }
265
+
266
+ sk_sp<VertexBuffer> vertexBuffer() const { return fVB; }
267
+
268
+ size_t vertexOffset() const { return fVOffset; }
269
+ size_t vertexCount() const { return fVCount; }
270
+
271
+ sk_sp<IndexBuffer> indexBuffer() const { return fIB; }
272
+
273
+ size_t indexOffset() const { return fIOffset; }
274
+ size_t indexCount() const { return fICount; }
275
+
276
+ SkRect bounds() const { return fBounds; }
277
+
278
+ bool isValid() const;
279
+
280
+ private:
281
+ friend struct SkMeshPriv;
282
+
283
+ bool validate() const;
284
+
285
+ sk_sp<SkMeshSpecification> fSpec;
286
+
287
+ sk_sp<VertexBuffer> fVB;
288
+ sk_sp<IndexBuffer> fIB;
289
+
290
+ size_t fVOffset = 0; // Must be a multiple of spec->stride()
291
+ size_t fVCount = 0;
292
+
293
+ size_t fIOffset = 0; // Must be a multiple of sizeof(uint16_t)
294
+ size_t fICount = 0;
295
+
296
+ Mode fMode = Mode::kTriangles;
297
+
298
+ SkRect fBounds = SkRect::MakeEmpty();
299
+ };
300
+
301
+ #endif // SK_ENABLE_SKSL
302
+
303
+ #endif
@@ -5,5 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
  #ifndef SK_MILESTONE
8
- #define SK_MILESTONE 99
8
+ #define SK_MILESTONE 103
9
9
  #endif
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright 2022 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 SkOpenTypeSVGDecoder_DEFINED
9
+ #define SkOpenTypeSVGDecoder_DEFINED
10
+
11
+ #include "include/core/SkColor.h"
12
+ #include "include/core/SkSpan.h"
13
+ #include "include/core/SkTypes.h"
14
+
15
+ #include <memory>
16
+
17
+ class SkCanvas;
18
+
19
+ class SkOpenTypeSVGDecoder {
20
+ public:
21
+ /** Each instance probably owns an SVG DOM.
22
+ * The instance may be cached so needs to report how much memory it retains.
23
+ */
24
+ virtual size_t approximateSize() = 0;
25
+ virtual bool render(SkCanvas&, int upem, SkGlyphID glyphId,
26
+ SkColor foregroundColor, SkSpan<SkColor> palette) = 0;
27
+ virtual ~SkOpenTypeSVGDecoder() = default;
28
+ };
29
+
30
+ #endif // SkOpenTypeSVGDecoder_DEFINED
@@ -11,9 +11,10 @@
11
11
  #include "include/core/SkBlendMode.h"
12
12
  #include "include/core/SkColor.h"
13
13
  #include "include/core/SkRefCnt.h"
14
- #include "include/private/SkTOptional.h"
15
14
  #include "include/private/SkTo.h"
16
15
 
16
+ #include <optional>
17
+
17
18
  class SkBlender;
18
19
  class SkColorFilter;
19
20
  class SkColorSpace;
@@ -470,7 +471,7 @@ public:
470
471
  * enum in the optional's value(). If it cannot, then the returned optional does not
471
472
  * contain a value.
472
473
  */
473
- skstd::optional<SkBlendMode> asBlendMode() const;
474
+ std::optional<SkBlendMode> asBlendMode() const;
474
475
 
475
476
  /**
476
477
  * Queries the blender, and if it can be represented as a SkBlendMode, return that mode,
@@ -649,23 +650,7 @@ public:
649
650
  @param storage computed bounds of geometry; may not be nullptr
650
651
  @return fast computed bounds
651
652
  */
652
- const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const {
653
- // Things like stroking, etc... will do math on the bounds rect, assuming that it's sorted.
654
- SkASSERT(orig.isSorted());
655
- SkPaint::Style style = this->getStyle();
656
- // ultra fast-case: filling with no effects that affect geometry
657
- if (kFill_Style == style) {
658
- uintptr_t effects = 0;
659
- effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter());
660
- effects |= reinterpret_cast<uintptr_t>(this->getPathEffect());
661
- effects |= reinterpret_cast<uintptr_t>(this->getImageFilter());
662
- if (!effects) {
663
- return orig;
664
- }
665
- }
666
-
667
- return this->doComputeFastBounds(orig, storage, style);
668
- }
653
+ const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const;
669
654
 
670
655
  /** (to be made private)
671
656
 
@@ -10,16 +10,21 @@
10
10
 
11
11
  #include "include/core/SkMatrix.h"
12
12
  #include "include/core/SkPathTypes.h"
13
- #include "include/private/SkPathRef.h"
13
+ #include "include/core/SkRefCnt.h"
14
14
  #include "include/private/SkTo.h"
15
15
 
16
16
  #include <initializer_list>
17
+ #include <tuple>
17
18
 
18
19
  class SkAutoPathBoundsUpdate;
19
20
  class SkData;
21
+ class SkPathRef;
20
22
  class SkRRect;
21
23
  class SkWStream;
22
24
 
25
+ enum class SkPathConvexity;
26
+ enum class SkPathFirstDirection;
27
+
23
28
  // WIP -- define this locally, and fix call-sites to use SkPathBuilder (skbug.com/9000)
24
29
  //#define SK_HIDE_PATH_EDIT_METHODS
25
30
 
@@ -225,9 +230,7 @@ public:
225
230
 
226
231
  /** Returns true if the path is convex. If necessary, it will first compute the convexity.
227
232
  */
228
- bool isConvex() const {
229
- return SkPathConvexity::kConvex == this->getConvexity();
230
- }
233
+ bool isConvex() const;
231
234
 
232
235
  /** Returns true if this path is recognized as an oval or circle.
233
236
 
@@ -285,10 +288,7 @@ public:
285
288
 
286
289
  @return true if the path contains no SkPath::Verb array
287
290
  */
288
- bool isEmpty() const {
289
- SkDEBUGCODE(this->validate();)
290
- return 0 == fPathRef->countVerbs();
291
- }
291
+ bool isEmpty() const;
292
292
 
293
293
  /** Returns if contour is closed.
294
294
  Contour is closed if SkPath SkPath::Verb array was last modified by close(). When stroked,
@@ -306,10 +306,7 @@ public:
306
306
 
307
307
  @return true if all SkPoint values are finite
308
308
  */
309
- bool isFinite() const {
310
- SkDEBUGCODE(this->validate();)
311
- return fPathRef->isFinite();
312
- }
309
+ bool isFinite() const;
313
310
 
314
311
  /** Returns true if the path is volatile; it will not be altered or discarded
315
312
  by the caller after it is drawn. SkPath by default have volatile set false, allowing
@@ -482,9 +479,7 @@ public:
482
479
 
483
480
  @return bounds of all SkPoint in SkPoint array
484
481
  */
485
- const SkRect& getBounds() const {
486
- return fPathRef->getBounds();
487
- }
482
+ const SkRect& getBounds() const;
488
483
 
489
484
  /** Updates internal bounds so that subsequent calls to getBounds() are instantaneous.
490
485
  Unaltered copies of SkPath may also access cached bounds through getBounds().
@@ -1409,7 +1404,7 @@ public:
1409
1404
 
1410
1405
  @return SegmentMask bits or zero
1411
1406
  */
1412
- uint32_t getSegmentMasks() const { return fPathRef->getSegmentMasks(); }
1407
+ uint32_t getSegmentMasks() const;
1413
1408
 
1414
1409
  /** \enum SkPath::Verb
1415
1410
  Verb instructs SkPath how to interpret one or more SkPoint and optional conic weight;
@@ -1759,7 +1754,7 @@ public:
1759
1754
 
1760
1755
  @return true if SkPath data is consistent
1761
1756
  */
1762
- bool isValid() const { return this->isValidImpl() && fPathRef->isValid(); }
1757
+ bool isValid() const;
1763
1758
 
1764
1759
  private:
1765
1760
  SkPath(sk_sp<SkPathRef>, SkPathFillType, bool isVolatile, SkPathConvexity,
@@ -1810,12 +1805,14 @@ private:
1810
1805
 
1811
1806
  SkPathConvexity computeConvexity() const;
1812
1807
 
1808
+ bool isValidImpl() const;
1813
1809
  /** Asserts if SkPath data is inconsistent.
1814
1810
  Debugging check intended for internal use only.
1815
1811
  */
1816
- SkDEBUGCODE(void validate() const { SkASSERT(this->isValidImpl()); } )
1817
- bool isValidImpl() const;
1818
- SkDEBUGCODE(void validateRef() const { fPathRef->validate(); } )
1812
+ #ifdef SK_DEBUG
1813
+ void validate() const;
1814
+ void validateRef() const;
1815
+ #endif
1819
1816
 
1820
1817
  // called by stroker to see if all points (in the last contour) are equal and worthy of a cap
1821
1818
  bool isZeroLengthSincePoint(int startPtIndex) const;
@@ -1823,18 +1820,10 @@ private:
1823
1820
  /** Returns if the path can return a bound at no cost (true) or will have to
1824
1821
  perform some computation (false).
1825
1822
  */
1826
- bool hasComputedBounds() const {
1827
- SkDEBUGCODE(this->validate();)
1828
- return fPathRef->hasComputedBounds();
1829
- }
1830
-
1823
+ bool hasComputedBounds() const;
1831
1824
 
1832
1825
  // 'rect' needs to be sorted
1833
- void setBounds(const SkRect& rect) {
1834
- SkPathRef::Editor ed(&fPathRef);
1835
-
1836
- ed.setBounds(rect);
1837
- }
1826
+ void setBounds(const SkRect& rect);
1838
1827
 
1839
1828
  void setPt(int index, SkScalar x, SkScalar y);
1840
1829
 
@@ -1852,9 +1841,7 @@ private:
1852
1841
  */
1853
1842
  SkPathConvexity getConvexity() const;
1854
1843
 
1855
- SkPathConvexity getConvexityOrUnknown() const {
1856
- return (SkPathConvexity)fConvexity.load(std::memory_order_relaxed);
1857
- }
1844
+ SkPathConvexity getConvexityOrUnknown() const;
1858
1845
 
1859
1846
  // Compares the cached value with a freshly computed one (computeConvexity())
1860
1847
  bool isConvexityAccurate() const;
@@ -11,6 +11,7 @@
11
11
  #include "include/core/SkMatrix.h"
12
12
  #include "include/core/SkPath.h"
13
13
  #include "include/core/SkPathTypes.h"
14
+ #include "include/core/SkRefCnt.h"
14
15
  #include "include/private/SkTDArray.h"
15
16
 
16
17
  class SK_API SkPathBuilder {
@@ -241,9 +242,6 @@ private:
241
242
  int fIsAStart = -1; // tracks direction iff fIsA is not unknown
242
243
  bool fIsACCW = false; // tracks direction iff fIsA is not unknown
243
244
 
244
- // for testing
245
- SkPathConvexity fOverrideConvexity = SkPathConvexity::kUnknown;
246
-
247
245
  int countVerbs() const { return fVerbs.count(); }
248
246
 
249
247
  // called right before we add a (non-move) verb
@@ -258,9 +256,6 @@ private:
258
256
 
259
257
  SkPathBuilder& privateReverseAddPath(const SkPath&);
260
258
 
261
- // For testing
262
- void privateSetConvexity(SkPathConvexity c) { fOverrideConvexity = c; }
263
-
264
259
  friend class SkPathPriv;
265
260
  };
266
261
 
@@ -112,7 +112,7 @@ private:
112
112
 
113
113
  void setTemporarilyImmutable();
114
114
  void restoreMutability();
115
- friend class SkSurface_Raster; // For the two methods above.
115
+ friend class SkSurface_Raster; // For temporary immutable methods above.
116
116
 
117
117
  void setImmutableWithID(uint32_t genID);
118
118
  friend void SkBitmapCache_setImmutableWithID(SkPixelRef*, uint32_t);
@@ -12,6 +12,7 @@
12
12
  #include "include/core/SkImageInfo.h"
13
13
  #include "include/core/SkSamplingOptions.h"
14
14
 
15
+ class SkColorSpace;
15
16
  class SkData;
16
17
  struct SkMask;
17
18
 
@@ -170,7 +171,7 @@ public:
170
171
 
171
172
  @return SkColorSpace in SkImageInfo, or nullptr
172
173
  */
173
- SkColorSpace* colorSpace() const { return fInfo.colorSpace(); }
174
+ SkColorSpace* colorSpace() const;
174
175
 
175
176
  /** Returns smart pointer to SkColorSpace, the range of colors, associated with
176
177
  SkImageInfo. The smart pointer tracks the number of objects sharing this
@@ -180,7 +181,7 @@ public:
180
181
 
181
182
  @return SkColorSpace in SkImageInfo wrapped in a smart pointer
182
183
  */
183
- sk_sp<SkColorSpace> refColorSpace() const { return fInfo.refColorSpace(); }
184
+ sk_sp<SkColorSpace> refColorSpace() const;
184
185
 
185
186
  /** Returns true if SkAlphaType is kOpaque_SkAlphaType.
186
187
  Does not check if SkColorType allows alpha, or if any pixel value has
@@ -18,7 +18,7 @@
18
18
  * [ fSSin fSCos fTy ]
19
19
  * [ 0 0 1 ]
20
20
  */
21
- struct SkRSXform {
21
+ struct SK_API SkRSXform {
22
22
  static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty) {
23
23
  SkRSXform xform = { scos, ssin, tx, ty };
24
24
  return xform;
@@ -9,6 +9,8 @@
9
9
  #define SkImageSampling_DEFINED
10
10
 
11
11
  #include "include/core/SkTypes.h"
12
+
13
+ #include <algorithm>
12
14
  #include <new>
13
15
 
14
16
  enum class SkFilterMode {
@@ -52,6 +54,7 @@ struct SkCubicResampler {
52
54
  };
53
55
 
54
56
  struct SK_API SkSamplingOptions {
57
+ const int maxAniso = 0;
55
58
  const bool useCubic = false;
56
59
  const SkCubicResampler cubic = {0, 0};
57
60
  const SkFilterMode filter = SkFilterMode::kNearest;
@@ -66,27 +69,35 @@ struct SK_API SkSamplingOptions {
66
69
  }
67
70
 
68
71
  SkSamplingOptions(SkFilterMode fm, SkMipmapMode mm)
69
- : useCubic(false)
70
- , filter(fm)
72
+ : filter(fm)
71
73
  , mipmap(mm) {}
72
74
 
73
75
  explicit SkSamplingOptions(SkFilterMode fm)
74
- : useCubic(false)
75
- , filter(fm)
76
+ : filter(fm)
76
77
  , mipmap(SkMipmapMode::kNone) {}
77
78
 
78
79
  explicit SkSamplingOptions(const SkCubicResampler& c)
79
80
  : useCubic(true)
80
81
  , cubic(c) {}
81
82
 
83
+ static SkSamplingOptions Aniso(int maxAniso) {
84
+ return SkSamplingOptions{std::max(maxAniso, 1)};
85
+ }
86
+
82
87
  bool operator==(const SkSamplingOptions& other) const {
83
- return useCubic == other.useCubic
88
+ return maxAniso == other.maxAniso
89
+ && useCubic == other.useCubic
84
90
  && cubic.B == other.cubic.B
85
91
  && cubic.C == other.cubic.C
86
92
  && filter == other.filter
87
93
  && mipmap == other.mipmap;
88
94
  }
89
95
  bool operator!=(const SkSamplingOptions& other) const { return !(*this == other); }
96
+
97
+ bool isAniso() const { return maxAniso != 0; }
98
+
99
+ private:
100
+ SkSamplingOptions(int maxAniso) : maxAniso(maxAniso) {}
90
101
  };
91
102
 
92
103
  #endif
@@ -33,11 +33,8 @@ public:
33
33
  constexpr SkSpan(const SkSpan<U>& that) : fPtr(that.data()), fSize{that.size()} {}
34
34
  constexpr SkSpan(const SkSpan& o) = default;
35
35
 
36
- constexpr SkSpan& operator=(const SkSpan& that) {
37
- fPtr = that.fPtr;
38
- fSize = that.fSize;
39
- return *this;
40
- }
36
+ constexpr SkSpan& operator=(const SkSpan& that) = default;
37
+
41
38
  constexpr T& operator [] (size_t i) const {
42
39
  SkASSERT(i < this->size());
43
40
  return fPtr[i];
@@ -60,6 +57,9 @@ public:
60
57
  SkASSERT(postfixLen <= this->size());
61
58
  return SkSpan{fPtr + (this->size() - postfixLen), postfixLen};
62
59
  }
60
+ constexpr SkSpan<T> subspan(size_t offset) const {
61
+ return this->subspan(offset, this->size() - offset);
62
+ }
63
63
  constexpr SkSpan<T> subspan(size_t offset, size_t count) const {
64
64
  SkASSERT(offset <= this->size());
65
65
  SkASSERT(count <= this->size() - offset);