@shopify/react-native-skia 2.6.0 → 2.6.1
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.
- package/android/CMakeLists.txt +0 -1
- package/android/cpp/jni/JniWebGPUView.cpp +3 -3
- package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
- package/apple/MetalContext.h +5 -6
- package/apple/MetalWindowContext.mm +3 -4
- package/apple/RNSkApplePlatformContext.h +1 -1
- package/apple/RNSkApplePlatformContext.mm +4 -3
- package/apple/SkiaCVPixelBufferUtils.h +1 -1
- package/apple/SkiaCVPixelBufferUtils.mm +31 -30
- package/apple/SkiaPlatformContext.mm +2 -2
- package/apple/SkiaUIView.mm +1 -1
- package/apple/SkiaWebGPUView.mm +8 -4
- package/apple/WebGPUMetalView.h +1 -1
- package/apple/WebGPUMetalView.mm +1 -1
- package/cpp/api/JsiSkColor.h +8 -4
- package/cpp/api/JsiSkContourMeasure.h +4 -3
- package/cpp/api/JsiSkImage.h +17 -9
- package/cpp/api/JsiSkParagraphBuilder.h +14 -1
- package/cpp/api/JsiSkPath.h +71 -81
- package/cpp/api/JsiSkPathEffectFactory.h +2 -1
- package/cpp/api/JsiSkPathFactory.h +48 -52
- package/cpp/api/JsiSkShader.h +1 -1
- package/cpp/api/JsiSkShaderFactory.h +50 -26
- package/cpp/api/JsiSkSurfaceFactory.h +2 -1
- package/cpp/api/recorder/Drawings.h +5 -7
- package/cpp/api/recorder/Shaders.h +77 -22
- package/cpp/jsi2/JSIConverter.h +1 -1
- package/cpp/rnskia/RNDawnContext.h +14 -15
- package/cpp/rnskia/RNDawnUtils.h +14 -17
- package/cpp/rnskia/RNDawnWindowContext.h +1 -1
- package/cpp/rnskia/RNSkManager.cpp +5 -4
- package/cpp/rnskia/RNSkPlatformContext.h +2 -2
- package/cpp/rnwgpu/api/GPU.cpp +21 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
- package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
- package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
- package/cpp/rnwgpu/api/GPUTexture.h +14 -2
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
- package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
- package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
- package/cpp/skia/include/android/SkImageAndroid.h +7 -2
- package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
- package/cpp/skia/include/codec/SkCodec.h +42 -15
- package/cpp/skia/include/config/SkUserConfig.h +8 -0
- package/cpp/skia/include/core/SkBitmap.h +0 -5
- package/cpp/skia/include/core/SkCanvas.h +2 -39
- package/cpp/skia/include/core/SkColor.h +12 -0
- package/cpp/skia/include/core/SkColorSpace.h +9 -0
- package/cpp/skia/include/core/SkContourMeasure.h +1 -5
- package/cpp/skia/include/core/SkData.h +8 -0
- package/cpp/skia/include/core/SkFont.h +1 -55
- package/cpp/skia/include/core/SkFontArguments.h +15 -0
- package/cpp/skia/include/core/SkGraphics.h +0 -5
- package/cpp/skia/include/core/SkImage.h +0 -4
- package/cpp/skia/include/core/SkImageGenerator.h +1 -4
- package/cpp/skia/include/core/SkMatrix.h +0 -37
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPath.h +11 -911
- package/cpp/skia/include/core/SkPathBuilder.h +42 -32
- package/cpp/skia/include/core/SkPathEffect.h +0 -9
- package/cpp/skia/include/core/SkPathMeasure.h +1 -4
- package/cpp/skia/include/core/SkPathUtils.h +0 -10
- package/cpp/skia/include/core/SkRect.h +0 -12
- package/cpp/skia/include/core/SkRegion.h +1 -6
- package/cpp/skia/include/core/SkSerialProcs.h +4 -5
- package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
- package/cpp/skia/include/core/SkTextBlob.h +0 -22
- package/cpp/skia/include/core/SkTypeface.h +14 -32
- package/cpp/skia/include/core/SkTypes.h +0 -8
- package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
- package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
- package/cpp/skia/include/effects/SkGradient.h +206 -0
- package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
- package/cpp/skia/include/gpu/GpuTypes.h +2 -0
- package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
- package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
- package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
- package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
- package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
- package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
- package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
- package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
- package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
- package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
- package/cpp/skia/include/private/SkPathRef.h +0 -457
- package/cpp/skia/include/private/base/SkFeatures.h +4 -0
- package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
- package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
- package/cpp/skia/include/private/base/SkLog.h +68 -0
- package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
- package/cpp/skia/include/private/base/SkMacros.h +9 -0
- package/cpp/skia/include/private/base/SkTArray.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
- package/cpp/skia/include/utils/SkEventTracer.h +5 -7
- package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
- package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
- package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
- package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
- package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
- package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
- package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
- package/cpp/skia/src/base/SkMathPriv.h +27 -132
- package/package.json +5 -5
- package/cpp/skia/include/effects/SkGradientShader.h +0 -359
- package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
#define SkHdrMetadata_DEFINED
|
|
10
10
|
|
|
11
11
|
#include "include/core/SkColorSpace.h"
|
|
12
|
-
#include "include/core/
|
|
12
|
+
#include "include/core/SkData.h"
|
|
13
13
|
#include "include/private/base/SkAPI.h"
|
|
14
14
|
|
|
15
|
+
#include <memory>
|
|
15
16
|
#include <optional>
|
|
17
|
+
#include <vector>
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
class SkColorFilter;
|
|
18
20
|
class SkData;
|
|
19
21
|
class SkString;
|
|
20
22
|
|
|
@@ -121,6 +123,131 @@ struct SK_API MasteringDisplayColorVolume {
|
|
|
121
123
|
}
|
|
122
124
|
};
|
|
123
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Adaptive Global Tone Map
|
|
128
|
+
* This structure contains the metadata items from the ColorVolumeTransform metadata group
|
|
129
|
+
* in Clause 7.1: Metadata set of SMPTE ST 2094-50: Dynamic metadata for color volume transform
|
|
130
|
+
* Application #5
|
|
131
|
+
* https://github.com/SMPTE/st2094-50
|
|
132
|
+
* WARNING: This specification is still a DRAFT and is subject to change before publication.
|
|
133
|
+
*/
|
|
134
|
+
struct SK_API AdaptiveGlobalToneMap {
|
|
135
|
+
// A GainCurve metadata group.
|
|
136
|
+
struct SK_API GainCurve {
|
|
137
|
+
// Structure holding one entry of the GainCurveControlPointX, GainCurveControlPointY, and
|
|
138
|
+
// GainCurveControlPointM metadata items.
|
|
139
|
+
struct ControlPoint {
|
|
140
|
+
float fX = 0.f;
|
|
141
|
+
float fY = 0.f;
|
|
142
|
+
float fM = 0.f;
|
|
143
|
+
|
|
144
|
+
bool operator==(const ControlPoint& other) const {
|
|
145
|
+
return fX == other.fX && fY == other.fY && fM == other.fM;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// The size of this vector is the value of the GainCurveNumControlPoints metadata item.
|
|
150
|
+
static constexpr size_t kMinNumControlPoints = 1u;
|
|
151
|
+
static constexpr size_t kMaxNumControlPoints = 32u;
|
|
152
|
+
std::vector<ControlPoint> fControlPoints = {};
|
|
153
|
+
|
|
154
|
+
bool operator==(const GainCurve& other) const {
|
|
155
|
+
return fControlPoints == other.fControlPoints;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// A ComponentMix metadata group.
|
|
160
|
+
struct SK_API ComponentMixingFunction {
|
|
161
|
+
// The ComponentMixRed/Green/Blue/Max/Min/Component metadata items.
|
|
162
|
+
float fRed = 0.f;
|
|
163
|
+
float fGreen = 0.f;
|
|
164
|
+
float fBlue = 0.f;
|
|
165
|
+
float fMax = 0.f;
|
|
166
|
+
float fMin = 0.f;
|
|
167
|
+
float fComponent = 0.f;
|
|
168
|
+
|
|
169
|
+
bool operator==(const ComponentMixingFunction& other) const {
|
|
170
|
+
return fRed == other.fRed && fGreen == other.fGreen && fBlue == other.fBlue &&
|
|
171
|
+
fMax == other.fMax && fMin == other.fMin && fComponent == other.fComponent;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// A ColorGainFunction metadata group.
|
|
176
|
+
struct SK_API ColorGainFunction {
|
|
177
|
+
// The ComponentMix metadata group.
|
|
178
|
+
ComponentMixingFunction fComponentMixing = {};
|
|
179
|
+
|
|
180
|
+
// The GainCurve metadata group.
|
|
181
|
+
GainCurve fGainCurve = {};
|
|
182
|
+
|
|
183
|
+
bool operator==(const ColorGainFunction& other) const {
|
|
184
|
+
return fComponentMixing == other.fComponentMixing && fGainCurve == other.fGainCurve;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Structure holding the metadata items and groups for an alternate image.
|
|
189
|
+
struct SK_API AlternateImage {
|
|
190
|
+
// The AlternateHdrHeadroom metadata item.
|
|
191
|
+
float fHdrHeadroom = 0.f;
|
|
192
|
+
|
|
193
|
+
// The ColorGainFunction metadata group.
|
|
194
|
+
ColorGainFunction fColorGainFunction = {};
|
|
195
|
+
|
|
196
|
+
bool operator==(const AlternateImage& other) const {
|
|
197
|
+
return fHdrHeadroom == other.fHdrHeadroom && fColorGainFunction == other.fColorGainFunction;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// HeadroomAdaptiveToneMap metadata group.
|
|
202
|
+
struct SK_API HeadroomAdaptiveToneMap {
|
|
203
|
+
// The BaselineHdrHeadroom metadata item.
|
|
204
|
+
float fBaselineHdrHeadroom = 0.f;
|
|
205
|
+
|
|
206
|
+
// The GainApplicationSpaceColorPrimaries metadata item.
|
|
207
|
+
SkColorSpacePrimaries fGainApplicationSpacePrimaries =
|
|
208
|
+
{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
|
|
209
|
+
|
|
210
|
+
// The size of this vector is the NumAlternateImages metadata item.
|
|
211
|
+
static constexpr size_t kMaxNumAlternateImages = 4u;
|
|
212
|
+
std::vector<AlternateImage> fAlternateImages = {};
|
|
213
|
+
|
|
214
|
+
bool operator==(const HeadroomAdaptiveToneMap& other) const {
|
|
215
|
+
return fBaselineHdrHeadroom == other.fBaselineHdrHeadroom &&
|
|
216
|
+
fGainApplicationSpacePrimaries == other.fGainApplicationSpacePrimaries &&
|
|
217
|
+
fAlternateImages == other.fAlternateImages;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// The default value for the HdrReferenceWhite metadata item.
|
|
222
|
+
static constexpr float kDefaultHdrReferenceWhite = 203.f;
|
|
223
|
+
|
|
224
|
+
// The HdrReferenceWhite metadata item.
|
|
225
|
+
float fHdrReferenceWhite = kDefaultHdrReferenceWhite;
|
|
226
|
+
|
|
227
|
+
// The HeadroomAdaptiveToneMap metadata group.
|
|
228
|
+
std::optional<HeadroomAdaptiveToneMap> fHeadroomAdaptiveToneMap = std::nullopt;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Decode from the binary encoding in Annex C.
|
|
232
|
+
*/
|
|
233
|
+
bool parse(const SkData* data);
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Serialize to the encoding used by parse().
|
|
237
|
+
*/
|
|
238
|
+
sk_sp<SkData> serialize() const;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Return a human-readable description.
|
|
242
|
+
*/
|
|
243
|
+
SkString toString() const;
|
|
244
|
+
|
|
245
|
+
bool operator==(const AdaptiveGlobalToneMap& other) const {
|
|
246
|
+
return fHdrReferenceWhite == other.fHdrReferenceWhite &&
|
|
247
|
+
fHeadroomAdaptiveToneMap == other.fHeadroomAdaptiveToneMap;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
124
251
|
/**
|
|
125
252
|
* Structure containing all HDR metadata that can be attached to an image or video frame.
|
|
126
253
|
*/
|
|
@@ -153,11 +280,46 @@ class SK_API Metadata {
|
|
|
153
280
|
*/
|
|
154
281
|
void setMasteringDisplayColorVolume(const MasteringDisplayColorVolume& mdcv);
|
|
155
282
|
|
|
283
|
+
/**
|
|
284
|
+
* If there does not exists Adaptive Global Tone Map metadata, then return false.
|
|
285
|
+
* Otherwise return true and if `agtm` is non-nullptr then write the metadata to `agtm`.
|
|
286
|
+
*/
|
|
287
|
+
bool getAdaptiveGlobalToneMap(AdaptiveGlobalToneMap* agtm) const;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Set the Adaptive Global Tone Map metadata.
|
|
291
|
+
*/
|
|
292
|
+
void setAdaptiveGlobalToneMap(const AdaptiveGlobalToneMap& agtm);
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Return the serialized Adaptive Global Tone Mapping metadata, or nullptr if none has been set.
|
|
296
|
+
*/
|
|
297
|
+
sk_sp<const SkData> getSerializedAgtm() const;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Set the serialized Adaptive Global Tone Mapping metadata.
|
|
301
|
+
*/
|
|
302
|
+
void setSerializedAgtm(sk_sp<const SkData>);
|
|
303
|
+
|
|
156
304
|
/**
|
|
157
305
|
* Return a human-readable description.
|
|
158
306
|
*/
|
|
159
307
|
SkString toString() const;
|
|
160
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Return the SkColorFilter to tone map to the specified targeted HDR headroom.
|
|
311
|
+
*
|
|
312
|
+
* The `inputColorSpace` parameter is the color space of the input image that will be
|
|
313
|
+
* used with the image. If it is PQ or HLG, then the color filter will effectively
|
|
314
|
+
* reinterpret the image as having the HDR reference white parameter indicated in the
|
|
315
|
+
* metadata.
|
|
316
|
+
*
|
|
317
|
+
* If `inputColorSpace` is PQ or HLG, then a default tone mapping will be provided,
|
|
318
|
+
* inferring the baseline HDR headroom from the CLLI or MDCV metadata, if present.
|
|
319
|
+
*/
|
|
320
|
+
sk_sp<SkColorFilter> makeToneMapColorFilter(
|
|
321
|
+
float targetedHdrHeadroom, const SkColorSpace* inputColorSpace = nullptr) const;
|
|
322
|
+
|
|
161
323
|
bool operator==(const Metadata& other) const;
|
|
162
324
|
bool operator!=(const Metadata& other) const {
|
|
163
325
|
return !(*this == other);
|
|
@@ -166,6 +328,7 @@ class SK_API Metadata {
|
|
|
166
328
|
private:
|
|
167
329
|
std::optional<ContentLightLevelInformation> fContentLightLevelInformation;
|
|
168
330
|
std::optional<MasteringDisplayColorVolume> fMasteringDisplayColorVolume;
|
|
331
|
+
std::optional<AdaptiveGlobalToneMap> fAdaptiveGlobalToneMap;
|
|
169
332
|
};
|
|
170
333
|
|
|
171
334
|
} // namespace skhdr
|
|
@@ -87,461 +87,4 @@ struct SkPathIsAData {
|
|
|
87
87
|
SkPathDirection fDirection;
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
/**
|
|
91
|
-
* Holds the path verbs and points. It is versioned by a generation ID. None of its public methods
|
|
92
|
-
* modify the contents. To modify or append to the verbs/points wrap the SkPathRef in an
|
|
93
|
-
* SkPathRef::Editor object. Installing the editor resets the generation ID. It also performs
|
|
94
|
-
* copy-on-write if the SkPathRef is shared by multiple SkPaths. The caller passes the Editor's
|
|
95
|
-
* constructor a pointer to a sk_sp<SkPathRef>, which may be updated to point to a new SkPathRef
|
|
96
|
-
* after the editor's constructor returns.
|
|
97
|
-
*
|
|
98
|
-
* The points and verbs are stored in a single allocation. The points are at the begining of the
|
|
99
|
-
* allocation while the verbs are stored at end of the allocation, in reverse order. Thus the points
|
|
100
|
-
* and verbs both grow into the middle of the allocation until the meet. To access verb i in the
|
|
101
|
-
* verb array use ref.verbs()[~i] (because verbs() returns a pointer just beyond the first
|
|
102
|
-
* logical verb or the last verb in memory).
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
class SK_API SkPathRef final : public SkNVRefCnt<SkPathRef> {
|
|
106
|
-
public:
|
|
107
|
-
// See https://bugs.chromium.org/p/skia/issues/detail?id=13817 for how these sizes were
|
|
108
|
-
// determined.
|
|
109
|
-
using PointsArray = skia_private::STArray<4, SkPoint>;
|
|
110
|
-
using VerbsArray = skia_private::STArray<4, SkPathVerb>;
|
|
111
|
-
using ConicWeightsArray = skia_private::STArray<2, float>;
|
|
112
|
-
|
|
113
|
-
SkPathRef(SkSpan<const SkPoint> points, SkSpan<const SkPathVerb> verbs,
|
|
114
|
-
SkSpan<const SkScalar> weights, unsigned segmentMask, const SkMatrix* mx)
|
|
115
|
-
: fPoints(points)
|
|
116
|
-
, fVerbs(verbs)
|
|
117
|
-
, fConicWeights(weights)
|
|
118
|
-
{
|
|
119
|
-
fBoundsIsDirty = true; // this also invalidates fIsFinite
|
|
120
|
-
fGenerationID = 0; // recompute
|
|
121
|
-
fSegmentMask = SkToU8(segmentMask);
|
|
122
|
-
fType = SkPathIsAType::kGeneral;
|
|
123
|
-
SkDEBUGCODE(fEditorsAttached.store(0);)
|
|
124
|
-
if (mx && !mx->isIdentity()) {
|
|
125
|
-
mx->mapPoints(fPoints);
|
|
126
|
-
}
|
|
127
|
-
this->computeBounds(); // do this now, before we worry about multiple owners/threads
|
|
128
|
-
SkDEBUGCODE(this->validate();)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
class Editor {
|
|
132
|
-
public:
|
|
133
|
-
Editor(sk_sp<SkPathRef>* pathRef,
|
|
134
|
-
int incReserveVerbs = 0,
|
|
135
|
-
int incReservePoints = 0,
|
|
136
|
-
int incReserveConics = 0);
|
|
137
|
-
|
|
138
|
-
~Editor() { SkDEBUGCODE(fPathRef->fEditorsAttached--;) }
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Returns the array of points.
|
|
142
|
-
*/
|
|
143
|
-
SkPoint* writablePoints() { return fPathRef->getWritablePoints(); }
|
|
144
|
-
const SkPoint* points() const { return fPathRef->points(); }
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Gets the ith point. Shortcut for this->points() + i
|
|
148
|
-
*/
|
|
149
|
-
SkPoint* atPoint(int i) { return fPathRef->getWritablePoints() + i; }
|
|
150
|
-
const SkPoint* atPoint(int i) const { return &fPathRef->fPoints[i]; }
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Adds the verb and allocates space for the number of points indicated by the verb. The
|
|
154
|
-
* return value is a pointer to where the points for the verb should be written.
|
|
155
|
-
* 'weight' is only used if 'verb' is kConic_Verb
|
|
156
|
-
*/
|
|
157
|
-
SkPoint* growForVerb(SkPathVerb verb, SkScalar weight = 0) {
|
|
158
|
-
SkDEBUGCODE(fPathRef->validate();)
|
|
159
|
-
return fPathRef->growForVerb(verb, weight);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Allocates space for multiple instances of a particular verb and the
|
|
164
|
-
* requisite points & weights.
|
|
165
|
-
* The return pointer points at the first new point (indexed normally [<i>]).
|
|
166
|
-
* If 'verb' is kConic_Verb, 'weights' will return a pointer to the
|
|
167
|
-
* space for the conic weights (indexed normally).
|
|
168
|
-
*/
|
|
169
|
-
SkPoint* growForRepeatedVerb(SkPathVerb verb,
|
|
170
|
-
int numVbs,
|
|
171
|
-
SkScalar** weights = nullptr) {
|
|
172
|
-
return fPathRef->growForRepeatedVerb(verb, numVbs, weights);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Concatenates all verbs from 'path' onto the pathRef's verbs array. Increases the point
|
|
177
|
-
* count by the number of points in 'path', and the conic weight count by the number of
|
|
178
|
-
* conics in 'path'.
|
|
179
|
-
*
|
|
180
|
-
* Returns pointers to the uninitialized points and conic weights data.
|
|
181
|
-
*/
|
|
182
|
-
std::tuple<SkPoint*, SkScalar*> growForVerbsInPath(const SkPathRef& path) {
|
|
183
|
-
return fPathRef->growForVerbsInPath(path);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Resets the path ref to a new verb and point count. The new verbs and points are
|
|
188
|
-
* uninitialized.
|
|
189
|
-
*/
|
|
190
|
-
void resetToSize(int newVerbCnt, int newPointCnt, int newConicCount) {
|
|
191
|
-
fPathRef->resetToSize(newVerbCnt, newPointCnt, newConicCount);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Gets the path ref that is wrapped in the Editor.
|
|
196
|
-
*/
|
|
197
|
-
SkPathRef* pathRef() { return fPathRef; }
|
|
198
|
-
|
|
199
|
-
void setIsOval(SkPathDirection dir, unsigned start) {
|
|
200
|
-
fPathRef->setIsOval(dir, start);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
void setIsRRect(SkPathDirection dir, unsigned start) {
|
|
204
|
-
fPathRef->setIsRRect(dir, start);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
void setBounds(const SkRect& rect) { fPathRef->setBounds(rect); }
|
|
208
|
-
|
|
209
|
-
private:
|
|
210
|
-
SkPathRef* fPathRef;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
public:
|
|
214
|
-
/**
|
|
215
|
-
* Gets a path ref with no verbs or points.
|
|
216
|
-
*/
|
|
217
|
-
static SkPathRef* CreateEmpty();
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Returns true if all of the points in this path are finite, meaning there
|
|
221
|
-
* are no infinities and no NaNs.
|
|
222
|
-
*/
|
|
223
|
-
bool isFinite() const {
|
|
224
|
-
if (fBoundsIsDirty) {
|
|
225
|
-
this->computeBounds();
|
|
226
|
-
}
|
|
227
|
-
return SkToBool(fIsFinite);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Returns a mask, where each bit corresponding to a SegmentMask is
|
|
232
|
-
* set if the path contains 1 or more segments of that type.
|
|
233
|
-
* Returns 0 for an empty path (no segments).
|
|
234
|
-
*/
|
|
235
|
-
uint32_t getSegmentMasks() const { return fSegmentMask; }
|
|
236
|
-
|
|
237
|
-
/** Returns Info struct if the path is an oval, else return {}.
|
|
238
|
-
* Tracking whether a path is an oval is considered an
|
|
239
|
-
* optimization for performance and so some paths that are in
|
|
240
|
-
* fact ovals can report {}.
|
|
241
|
-
*/
|
|
242
|
-
std::optional<SkPathOvalInfo> isOval() const {
|
|
243
|
-
if (fType == SkPathIsAType::kOval) {
|
|
244
|
-
return {{
|
|
245
|
-
this->getBounds(),
|
|
246
|
-
fIsA.fDirection,
|
|
247
|
-
fIsA.fStartIndex,
|
|
248
|
-
}};
|
|
249
|
-
}
|
|
250
|
-
return {};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
std::optional<SkPathRRectInfo> isRRect() const;
|
|
254
|
-
|
|
255
|
-
bool hasComputedBounds() const {
|
|
256
|
-
return !fBoundsIsDirty;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/** Returns the bounds of the path's points. If the path contains 0 or 1
|
|
260
|
-
points, the bounds is set to (0,0,0,0), and isEmpty() will return true.
|
|
261
|
-
Note: this bounds may be larger than the actual shape, since curves
|
|
262
|
-
do not extend as far as their control points.
|
|
263
|
-
*/
|
|
264
|
-
const SkRect& getBounds() const {
|
|
265
|
-
if (fBoundsIsDirty) {
|
|
266
|
-
this->computeBounds();
|
|
267
|
-
}
|
|
268
|
-
return fBounds;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
SkRRect getRRect() const;
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Transforms a path ref by a matrix, allocating a new one only if necessary.
|
|
275
|
-
*/
|
|
276
|
-
static void CreateTransformedCopy(sk_sp<SkPathRef>* dst,
|
|
277
|
-
const SkPathRef& src,
|
|
278
|
-
const SkMatrix& matrix);
|
|
279
|
-
|
|
280
|
-
// static SkPathRef* CreateFromBuffer(SkRBuffer* buffer);
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Rollsback a path ref to zero verbs and points with the assumption that the path ref will be
|
|
284
|
-
* repopulated with approximately the same number of verbs and points. A new path ref is created
|
|
285
|
-
* only if necessary.
|
|
286
|
-
*/
|
|
287
|
-
static void Rewind(sk_sp<SkPathRef>* pathRef);
|
|
288
|
-
|
|
289
|
-
~SkPathRef();
|
|
290
|
-
int countPoints() const { return fPoints.size(); }
|
|
291
|
-
int countVerbs() const { return fVerbs.size(); }
|
|
292
|
-
int countWeights() const { return fConicWeights.size(); }
|
|
293
|
-
|
|
294
|
-
size_t approximateBytesUsed() const;
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Returns a pointer one beyond the first logical verb (last verb in memory order).
|
|
298
|
-
*/
|
|
299
|
-
const SkPathVerb* verbsBegin() const { return fVerbs.begin(); }
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Returns a const pointer to the first verb in memory (which is the last logical verb).
|
|
303
|
-
*/
|
|
304
|
-
const SkPathVerb* verbsEnd() const { return fVerbs.end(); }
|
|
305
|
-
|
|
306
|
-
SkSpan<const SkPathVerb> verbs() const { return fVerbs; }
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Returns a const pointer to the first point.
|
|
310
|
-
*/
|
|
311
|
-
const SkPoint* points() const { return fPoints.begin(); }
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Shortcut for this->points() + this->countPoints()
|
|
315
|
-
*/
|
|
316
|
-
const SkPoint* pointsEnd() const { return this->points() + this->countPoints(); }
|
|
317
|
-
|
|
318
|
-
SkSpan<const SkPoint> pointSpan() const { return fPoints; }
|
|
319
|
-
SkSpan<const float> conicSpan() const { return fConicWeights; }
|
|
320
|
-
|
|
321
|
-
const SkScalar* conicWeights() const { return fConicWeights.begin(); }
|
|
322
|
-
const SkScalar* conicWeightsEnd() const { return fConicWeights.end(); }
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Convenience methods for getting to a verb or point by index.
|
|
327
|
-
*/
|
|
328
|
-
SkPathVerb atVerb(int index) const { return fVerbs[index]; }
|
|
329
|
-
SkPoint atPoint(int index) const { return fPoints[index]; }
|
|
330
|
-
|
|
331
|
-
bool operator== (const SkPathRef& ref) const;
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the
|
|
335
|
-
* same ID then they have the same verbs and points. However, two path refs may have the same
|
|
336
|
-
* contents but different genIDs.
|
|
337
|
-
* skbug.com/40032862 for background on why fillType is necessary (for now).
|
|
338
|
-
*/
|
|
339
|
-
uint32_t genID(SkPathFillType fillType) const;
|
|
340
|
-
|
|
341
|
-
void addGenIDChangeListener(sk_sp<SkIDChangeListener>); // Threadsafe.
|
|
342
|
-
int genIDChangeListenerCount(); // Threadsafe
|
|
343
|
-
|
|
344
|
-
bool dataMatchesVerbs() const;
|
|
345
|
-
bool isValid() const;
|
|
346
|
-
SkDEBUGCODE(void validate() const { SkASSERT(this->isValid()); } )
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Resets this SkPathRef to a clean state.
|
|
350
|
-
*/
|
|
351
|
-
void reset();
|
|
352
|
-
|
|
353
|
-
bool isInitialEmptyPathRef() const {
|
|
354
|
-
return fGenerationID == kEmptyGenID;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
private:
|
|
358
|
-
enum SerializationOffsets {
|
|
359
|
-
kLegacyRRectOrOvalStartIdx_SerializationShift = 28, // requires 3 bits, ignored.
|
|
360
|
-
kLegacyRRectOrOvalIsCCW_SerializationShift = 27, // requires 1 bit, ignored.
|
|
361
|
-
kLegacyIsRRect_SerializationShift = 26, // requires 1 bit, ignored.
|
|
362
|
-
kIsFinite_SerializationShift = 25, // requires 1 bit
|
|
363
|
-
kLegacyIsOval_SerializationShift = 24, // requires 1 bit, ignored.
|
|
364
|
-
kSegmentMask_SerializationShift = 0 // requires 4 bits (deprecated)
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
SkPathRef(int numVerbs = 0, int numPoints = 0, int numConics = 0) {
|
|
368
|
-
fBoundsIsDirty = true; // this also invalidates fIsFinite
|
|
369
|
-
fGenerationID = kEmptyGenID;
|
|
370
|
-
fSegmentMask = 0;
|
|
371
|
-
fType = SkPathIsAType::kGeneral;
|
|
372
|
-
|
|
373
|
-
if (numPoints > 0) {
|
|
374
|
-
fPoints.reserve_exact(numPoints);
|
|
375
|
-
}
|
|
376
|
-
if (numVerbs > 0) {
|
|
377
|
-
fVerbs.reserve_exact(numVerbs);
|
|
378
|
-
}
|
|
379
|
-
if (numConics > 0) {
|
|
380
|
-
fConicWeights.reserve_exact(numConics);
|
|
381
|
-
}
|
|
382
|
-
SkDEBUGCODE(fEditorsAttached.store(0);)
|
|
383
|
-
SkDEBUGCODE(this->validate();)
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
void copy(const SkPathRef& ref, int additionalReserveVerbs, int additionalReservePoints, int additionalReserveConics);
|
|
387
|
-
|
|
388
|
-
// Return true if the computed bounds are finite.
|
|
389
|
-
static bool ComputePtBounds(SkRect* bounds, const SkPathRef& ref) {
|
|
390
|
-
return bounds->setBoundsCheck(ref.pointSpan());
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// called, if dirty, by getBounds()
|
|
394
|
-
void computeBounds() const {
|
|
395
|
-
SkDEBUGCODE(this->validate();)
|
|
396
|
-
// TODO: remove fBoundsIsDirty and fIsFinite,
|
|
397
|
-
// using an inverted rect instead of fBoundsIsDirty and always recalculating fIsFinite.
|
|
398
|
-
SkASSERT(fBoundsIsDirty);
|
|
399
|
-
|
|
400
|
-
fIsFinite = ComputePtBounds(&fBounds, *this);
|
|
401
|
-
fBoundsIsDirty = false;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
void setBounds(const SkRect& rect) {
|
|
405
|
-
SkASSERT(rect.fLeft <= rect.fRight && rect.fTop <= rect.fBottom);
|
|
406
|
-
fBounds = rect;
|
|
407
|
-
fBoundsIsDirty = false;
|
|
408
|
-
fIsFinite = fBounds.isFinite();
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/** Makes additional room but does not change the counts or change the genID */
|
|
412
|
-
void incReserve(int additionalVerbs, int additionalPoints, int additionalConics) {
|
|
413
|
-
SkDEBUGCODE(this->validate();)
|
|
414
|
-
// Use reserve() so that if there is not enough space, the array will grow with some
|
|
415
|
-
// additional space. This ensures repeated calls to grow won't always allocate.
|
|
416
|
-
if (additionalPoints > 0) {
|
|
417
|
-
fPoints.reserve(fPoints.size() + additionalPoints);
|
|
418
|
-
}
|
|
419
|
-
if (additionalVerbs > 0) {
|
|
420
|
-
fVerbs.reserve(fVerbs.size() + additionalVerbs);
|
|
421
|
-
}
|
|
422
|
-
if (additionalConics > 0) {
|
|
423
|
-
fConicWeights.reserve(fConicWeights.size() + additionalConics);
|
|
424
|
-
}
|
|
425
|
-
SkDEBUGCODE(this->validate();)
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Resets all state except that of the verbs, points, and conic-weights.
|
|
430
|
-
* Intended to be called from other functions that reset state.
|
|
431
|
-
*/
|
|
432
|
-
void commonReset() {
|
|
433
|
-
SkDEBUGCODE(this->validate();)
|
|
434
|
-
this->callGenIDChangeListeners();
|
|
435
|
-
fBoundsIsDirty = true; // this also invalidates fIsFinite
|
|
436
|
-
fGenerationID = 0;
|
|
437
|
-
|
|
438
|
-
fSegmentMask = 0;
|
|
439
|
-
fType = SkPathIsAType::kGeneral;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/** Resets the path ref with verbCount verbs and pointCount points, all uninitialized. Also
|
|
443
|
-
* allocates space for reserveVerb additional verbs and reservePoints additional points.*/
|
|
444
|
-
void resetToSize(int verbCount, int pointCount, int conicCount,
|
|
445
|
-
int reserveVerbs = 0, int reservePoints = 0,
|
|
446
|
-
int reserveConics = 0) {
|
|
447
|
-
this->commonReset();
|
|
448
|
-
// Use reserve_exact() so the arrays are sized to exactly fit the data.
|
|
449
|
-
fPoints.reserve_exact(pointCount + reservePoints);
|
|
450
|
-
fPoints.resize_back(pointCount);
|
|
451
|
-
|
|
452
|
-
fVerbs.reserve_exact(verbCount + reserveVerbs);
|
|
453
|
-
fVerbs.resize_back(verbCount);
|
|
454
|
-
|
|
455
|
-
fConicWeights.reserve_exact(conicCount + reserveConics);
|
|
456
|
-
fConicWeights.resize_back(conicCount);
|
|
457
|
-
SkDEBUGCODE(this->validate();)
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Increases the verb count by numVbs and point count by the required amount.
|
|
462
|
-
* The new points are uninitialized. All the new verbs are set to the specified
|
|
463
|
-
* verb. If 'verb' is kConic_Verb, 'weights' will return a pointer to the
|
|
464
|
-
* uninitialized conic weights.
|
|
465
|
-
*/
|
|
466
|
-
SkPoint* growForRepeatedVerb(SkPathVerb, int numVbs, SkScalar** weights);
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Increases the verb count 1, records the new verb, and creates room for the requisite number
|
|
470
|
-
* of additional points. A pointer to the first point is returned. Any new points are
|
|
471
|
-
* uninitialized.
|
|
472
|
-
*/
|
|
473
|
-
SkPoint* growForVerb(SkPathVerb, SkScalar weight);
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Concatenates all verbs from 'path' onto our own verbs array. Increases the point count by the
|
|
477
|
-
* number of points in 'path', and the conic weight count by the number of conics in 'path'.
|
|
478
|
-
*
|
|
479
|
-
* Returns pointers to the uninitialized points and conic weights data.
|
|
480
|
-
*/
|
|
481
|
-
std::tuple<SkPoint*, SkScalar*> growForVerbsInPath(const SkPathRef& path);
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* Private, non-const-ptr version of the public function verbsMemBegin().
|
|
485
|
-
*/
|
|
486
|
-
uint8_t* verbsBeginWritable() { return (uint8_t*)fVerbs.begin(); }
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Called the first time someone calls CreateEmpty to actually create the singleton.
|
|
490
|
-
*/
|
|
491
|
-
friend SkPathRef* sk_create_empty_pathref();
|
|
492
|
-
|
|
493
|
-
void setIsOval(SkPathDirection dir, unsigned start) {
|
|
494
|
-
fType = SkPathIsAType::kOval;
|
|
495
|
-
fIsA.fDirection = dir;
|
|
496
|
-
fIsA.fStartIndex = SkToU8(start);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
void setIsRRect(SkPathDirection dir, unsigned start) {
|
|
500
|
-
fType = SkPathIsAType::kRRect;
|
|
501
|
-
fIsA.fDirection = dir;
|
|
502
|
-
fIsA.fStartIndex = SkToU8(start);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
// called only by the editor. Note that this is not a const function.
|
|
506
|
-
SkPoint* getWritablePoints() {
|
|
507
|
-
SkDEBUGCODE(this->validate();)
|
|
508
|
-
fType = SkPathIsAType::kGeneral;
|
|
509
|
-
return fPoints.begin();
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
const SkPoint* getPoints() const {
|
|
513
|
-
SkDEBUGCODE(this->validate();)
|
|
514
|
-
return fPoints.begin();
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
void callGenIDChangeListeners();
|
|
518
|
-
|
|
519
|
-
PointsArray fPoints;
|
|
520
|
-
VerbsArray fVerbs;
|
|
521
|
-
ConicWeightsArray fConicWeights;
|
|
522
|
-
|
|
523
|
-
mutable SkRect fBounds;
|
|
524
|
-
|
|
525
|
-
enum {
|
|
526
|
-
kEmptyGenID = 1, // GenID reserved for path ref with zero points and zero verbs.
|
|
527
|
-
};
|
|
528
|
-
mutable uint32_t fGenerationID;
|
|
529
|
-
SkIDChangeListener::List fGenIDChangeListeners;
|
|
530
|
-
|
|
531
|
-
SkDEBUGCODE(std::atomic<int> fEditorsAttached;) // assert only one editor in use at any time.
|
|
532
|
-
|
|
533
|
-
// based on fType
|
|
534
|
-
SkPathIsAData fIsA {};
|
|
535
|
-
|
|
536
|
-
SkPathIsAType fType;
|
|
537
|
-
uint8_t fSegmentMask;
|
|
538
|
-
mutable bool fBoundsIsDirty;
|
|
539
|
-
mutable bool fIsFinite; // only meaningful if bounds are valid
|
|
540
|
-
|
|
541
|
-
friend class PathRefTest_Private;
|
|
542
|
-
friend class SkPath;
|
|
543
|
-
friend class SkPathBuilder;
|
|
544
|
-
friend class SkPathPriv;
|
|
545
|
-
};
|
|
546
|
-
|
|
547
90
|
#endif
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
#define SK_BUILD_FOR_WIN
|
|
20
20
|
#elif defined(ANDROID) || defined(__ANDROID__)
|
|
21
21
|
#define SK_BUILD_FOR_ANDROID
|
|
22
|
+
#elif defined(__EMSCRIPTEN__)
|
|
23
|
+
// WASM toolchains expose a Unix-like compilation environment, but it is
|
|
24
|
+
// not Unix (e.g. posix signals are not supported).
|
|
25
|
+
#define SK_BUILD_FOR_WASM
|
|
22
26
|
#elif defined(linux) || defined(__linux) || defined(__FreeBSD__) || \
|
|
23
27
|
defined(__OpenBSD__) || defined(__sun) || defined(__NetBSD__) || \
|
|
24
28
|
defined(__DragonFly__) || defined(__Fuchsia__) || \
|
|
@@ -148,8 +148,7 @@ static constexpr float sk_float_midpoint(float a, float b) {
|
|
|
148
148
|
return static_cast<float>(0.5 * (static_cast<double>(a) + b));
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
static inline float
|
|
152
|
-
static inline float sk_float_rsqrt (float x) { return 1.0f / std::sqrt(x); }
|
|
151
|
+
static inline float sk_float_rsqrt (float x) { return 1.0f / std::sqrt(x); }
|
|
153
152
|
|
|
154
153
|
// IEEE defines how float divide behaves for non-finite values and zero-denoms, but C does not,
|
|
155
154
|
// so we have a helper that suppresses the possible undefined-behavior warnings.
|