@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.
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +1 -0
- package/cpp/api/JsiSkRuntimeEffect.h +7 -9
- package/cpp/api/JsiSkVertices.h +0 -2
- package/cpp/rnskia/values/RNSkValue.h +1 -1
- package/cpp/skia/include/codec/SkCodec.h +7 -1
- package/cpp/skia/include/core/SkAlphaType.h +45 -0
- package/cpp/skia/include/core/SkBitmap.h +4 -2
- package/cpp/skia/include/core/SkCanvas.h +31 -20
- package/cpp/skia/include/core/SkColor.h +1 -1
- package/cpp/skia/include/core/SkColorFilter.h +1 -0
- package/cpp/skia/include/core/SkColorType.h +66 -0
- package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +1 -1
- package/cpp/skia/include/core/SkDrawable.h +7 -0
- package/cpp/skia/include/core/SkEncodedImageFormat.h +1 -0
- package/cpp/skia/include/core/SkFont.h +4 -3
- package/cpp/skia/include/core/SkFontArguments.h +33 -1
- package/cpp/skia/include/core/SkGraphics.h +13 -0
- package/cpp/skia/include/core/SkImage.h +67 -22
- package/cpp/skia/include/core/SkImageEncoder.h +0 -3
- package/cpp/skia/include/core/SkImageGenerator.h +4 -3
- package/cpp/skia/include/core/SkImageInfo.h +35 -142
- package/cpp/skia/include/core/SkMesh.h +303 -0
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +30 -0
- package/cpp/skia/include/core/SkPaint.h +4 -19
- package/cpp/skia/include/core/SkPath.h +20 -33
- package/cpp/skia/include/core/SkPathBuilder.h +1 -6
- package/cpp/skia/include/core/SkPixelRef.h +1 -1
- package/cpp/skia/include/core/SkPixmap.h +3 -2
- package/cpp/skia/include/core/SkRSXform.h +1 -1
- package/cpp/skia/include/core/SkSamplingOptions.h +16 -5
- package/cpp/skia/include/core/SkSpan.h +5 -5
- package/cpp/skia/include/core/SkString.h +5 -8
- package/cpp/skia/include/core/SkSurface.h +21 -0
- package/cpp/skia/include/core/SkTypeface.h +20 -4
- package/cpp/skia/include/core/SkTypes.h +9 -5
- package/cpp/skia/include/effects/SkGradientShader.h +9 -18
- package/cpp/skia/include/effects/SkRuntimeEffect.h +16 -12
- package/cpp/skia/include/gpu/GpuTypes.h +32 -0
- package/cpp/skia/include/gpu/GrBackendSemaphore.h +1 -1
- package/cpp/skia/include/gpu/GrBackendSurface.h +6 -5
- package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +1 -1
- package/cpp/skia/include/gpu/GrContextOptions.h +11 -20
- package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +7 -0
- package/cpp/skia/include/gpu/GrDirectContext.h +16 -11
- package/cpp/skia/include/gpu/GrDriverBugWorkaroundsAutogen.h +0 -2
- package/cpp/skia/include/gpu/GrRecordingContext.h +14 -7
- package/cpp/skia/include/gpu/GrSurfaceInfo.h +6 -6
- package/cpp/skia/include/gpu/dawn/GrDawnTypes.h +1 -1
- package/cpp/skia/include/gpu/gl/GrGLFunctions.h +3 -1
- package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -2
- package/cpp/skia/include/gpu/graphite/BackendTexture.h +64 -0
- package/cpp/skia/include/gpu/graphite/Context.h +124 -0
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +71 -0
- package/cpp/skia/include/gpu/graphite/Recorder.h +104 -0
- package/cpp/skia/include/gpu/graphite/Recording.h +39 -0
- package/cpp/skia/include/gpu/graphite/SkStuff.h +47 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +91 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +24 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlTypes.h +68 -0
- package/cpp/skia/include/gpu/mock/GrMockTypes.h +1 -2
- package/cpp/skia/include/ports/SkCFObject.h +0 -4
- package/cpp/skia/include/ports/SkTypeface_win.h +2 -2
- package/cpp/skia/include/private/{GrSingleOwner.h → SingleOwner.h} +17 -10
- package/cpp/skia/include/private/SkChecksum.h +11 -0
- package/cpp/skia/include/private/SkEncodedInfo.h +22 -5
- package/cpp/skia/include/private/SkFloatingPoint.h +0 -53
- package/cpp/skia/include/private/SkImageInfoPriv.h +8 -2
- package/cpp/skia/include/private/SkMacros.h +13 -18
- package/cpp/skia/include/private/SkMutex.h +8 -0
- package/cpp/skia/include/private/SkPathRef.h +2 -16
- package/cpp/skia/include/private/SkSLDefines.h +9 -1
- package/cpp/skia/include/private/SkSLIRNode.h +6 -5
- package/cpp/skia/include/private/SkSLLayout.h +11 -10
- package/cpp/skia/include/private/SkSLModifiers.h +4 -3
- package/cpp/skia/include/private/SkSLProgramElement.h +2 -2
- package/cpp/skia/include/private/SkSLProgramKind.h +8 -5
- package/cpp/skia/include/private/SkSLStatement.h +2 -3
- package/cpp/skia/include/private/SkSLString.h +17 -56
- package/cpp/skia/include/private/SkSLSymbol.h +4 -4
- package/cpp/skia/include/private/SkShadowFlags.h +3 -1
- package/cpp/skia/include/private/SkStringView.h +47 -0
- package/cpp/skia/include/private/SkTArray.h +4 -3
- package/cpp/skia/include/private/SkTHash.h +66 -24
- package/cpp/skia/include/private/SkTLogic.h +2 -32
- package/cpp/skia/include/private/SkTemplates.h +2 -2
- package/cpp/skia/include/private/SkThreadAnnotations.h +4 -4
- package/cpp/skia/include/private/SkVx.h +28 -28
- package/cpp/skia/include/private/chromium/GrSlug.h +40 -3
- package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +12 -6
- package/cpp/skia/include/private/{GrContext_Base.h → gpu/ganesh/GrContext_Base.h} +7 -0
- package/cpp/skia/include/private/{GrD3DTypesMinimal.h → gpu/ganesh/GrD3DTypesMinimal.h} +0 -0
- package/cpp/skia/include/private/{GrDawnTypesPriv.h → gpu/ganesh/GrDawnTypesPriv.h} +0 -0
- package/cpp/skia/include/private/{GrGLTypesPriv.h → gpu/ganesh/GrGLTypesPriv.h} +1 -0
- package/cpp/skia/include/private/{GrImageContext.h → gpu/ganesh/GrImageContext.h} +4 -4
- package/cpp/skia/include/private/{GrMockTypesPriv.h → gpu/ganesh/GrMockTypesPriv.h} +0 -0
- package/cpp/skia/include/private/{GrMtlTypesPriv.h → gpu/ganesh/GrMtlTypesPriv.h} +0 -0
- package/cpp/skia/include/private/{GrTypesPriv.h → gpu/ganesh/GrTypesPriv.h} +25 -367
- package/cpp/skia/include/private/{GrVkTypesPriv.h → gpu/ganesh/GrVkTypesPriv.h} +0 -0
- package/cpp/skia/include/private/gpu/graphite/MtlTypesPriv.h +74 -0
- package/cpp/skia/include/sksl/DSL.h +4 -0
- package/cpp/skia/include/sksl/DSLBlock.h +8 -3
- package/cpp/skia/include/sksl/DSLCase.h +6 -6
- package/cpp/skia/include/sksl/DSLCore.h +89 -78
- package/cpp/skia/include/sksl/DSLExpression.h +78 -45
- package/cpp/skia/include/sksl/DSLFunction.h +23 -18
- package/cpp/skia/include/sksl/DSLLayout.h +14 -16
- package/cpp/skia/include/sksl/DSLModifiers.h +7 -5
- package/cpp/skia/include/sksl/DSLRuntimeEffects.h +1 -1
- package/cpp/skia/include/sksl/DSLStatement.h +16 -10
- package/cpp/skia/include/sksl/DSLSymbols.h +7 -7
- package/cpp/skia/include/sksl/DSLType.h +27 -23
- package/cpp/skia/include/sksl/DSLVar.h +72 -61
- package/cpp/skia/include/sksl/SkSLErrorReporter.h +12 -49
- package/cpp/skia/include/sksl/SkSLOperator.h +151 -0
- package/cpp/skia/include/sksl/SkSLPosition.h +102 -0
- package/cpp/skia/include/svg/SkSVGCanvas.h +5 -1
- package/cpp/skia/include/utils/SkAnimCodecPlayer.h +7 -0
- package/cpp/skia/include/utils/SkCamera.h +2 -0
- package/cpp/skia/include/utils/SkCanvasStateUtils.h +4 -1
- package/cpp/skia/include/utils/SkCustomTypeface.h +6 -4
- package/cpp/skia/include/utils/SkNWayCanvas.h +34 -0
- package/cpp/skia/include/utils/SkNullCanvas.h +5 -1
- package/cpp/skia/include/utils/SkOrderedFontMgr.h +12 -0
- package/cpp/skia/include/utils/SkPaintFilterCanvas.h +30 -1
- package/cpp/skia/include/utils/SkParse.h +2 -0
- package/cpp/skia/include/utils/SkShadowUtils.h +3 -2
- package/cpp/skia/include/utils/SkTextUtils.h +8 -4
- package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +27 -1
- package/cpp/skia/modules/svg/include/SkSVGDOM.h +4 -0
- package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +32 -0
- package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
- package/cpp/skia/modules/svg/include/SkSVGSVG.h +2 -0
- package/cpp/skia/modules/svg/include/SkSVGTypes.h +48 -9
- package/ios/RNSkia-iOS/PlatformContext.h +1 -1
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +1 -0
- package/ios/RNSkia-iOS/SkiaDrawView.mm +1 -1
- package/lib/commonjs/renderer/components/shaders/Shader.js +1 -2
- package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/module/renderer/components/shaders/Shader.js +1 -2
- package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
- package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +0 -1
- package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +2 -4
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/arm64-v8a/libsvg.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libsvg.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86/libsvg.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/android/x86_64/libsvg.a +0 -0
- package/libs/ios/libskia.xcframework/Info.plist +5 -5
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +2 -2
- package/src/renderer/components/shaders/Shader.tsx +1 -3
- package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -8
- package/cpp/skia/include/core/SkCustomMesh.h +0 -202
- package/cpp/skia/include/core/SkStringView.h +0 -185
- package/cpp/skia/include/private/SkPaintParamsKey.h +0 -110
- package/cpp/skia/include/private/SkShaderCodeDictionary.h +0 -63
- package/cpp/skia/include/private/SkTOptional.h +0 -362
@@ -61,9 +61,9 @@ struct Layout {
|
|
61
61
|
return result;
|
62
62
|
}
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
auto separator = [firstSeparator = true]() mutable ->
|
64
|
+
std::string description() const {
|
65
|
+
std::string result;
|
66
|
+
auto separator = [firstSeparator = true]() mutable -> std::string {
|
67
67
|
if (firstSeparator) {
|
68
68
|
firstSeparator = false;
|
69
69
|
return "";
|
@@ -71,25 +71,26 @@ struct Layout {
|
|
71
71
|
return ", ";
|
72
72
|
}};
|
73
73
|
if (fLocation >= 0) {
|
74
|
-
result += separator() + "location = " + to_string(fLocation);
|
74
|
+
result += separator() + "location = " + std::to_string(fLocation);
|
75
75
|
}
|
76
76
|
if (fOffset >= 0) {
|
77
|
-
result += separator() + "offset = " + to_string(fOffset);
|
77
|
+
result += separator() + "offset = " + std::to_string(fOffset);
|
78
78
|
}
|
79
79
|
if (fBinding >= 0) {
|
80
|
-
result += separator() + "binding = " + to_string(fBinding);
|
80
|
+
result += separator() + "binding = " + std::to_string(fBinding);
|
81
81
|
}
|
82
82
|
if (fIndex >= 0) {
|
83
|
-
result += separator() + "index = " + to_string(fIndex);
|
83
|
+
result += separator() + "index = " + std::to_string(fIndex);
|
84
84
|
}
|
85
85
|
if (fSet >= 0) {
|
86
|
-
result += separator() + "set = " + to_string(fSet);
|
86
|
+
result += separator() + "set = " + std::to_string(fSet);
|
87
87
|
}
|
88
88
|
if (fBuiltin >= 0) {
|
89
|
-
result += separator() + "builtin = " + to_string(fBuiltin);
|
89
|
+
result += separator() + "builtin = " + std::to_string(fBuiltin);
|
90
90
|
}
|
91
91
|
if (fInputAttachmentIndex >= 0) {
|
92
|
-
result += separator() + "input_attachment_index = " +
|
92
|
+
result += separator() + "input_attachment_index = " +
|
93
|
+
std::to_string(fInputAttachmentIndex);
|
93
94
|
}
|
94
95
|
if (fFlags & kOriginUpperLeft_Flag) {
|
95
96
|
result += separator() + "origin_upper_left";
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#define SKSL_MODIFIERS
|
10
10
|
|
11
11
|
#include "include/private/SkSLLayout.h"
|
12
|
+
#include "include/sksl/SkSLPosition.h"
|
12
13
|
|
13
14
|
#include <vector>
|
14
15
|
|
@@ -58,8 +59,8 @@ struct Modifiers {
|
|
58
59
|
: fLayout(layout)
|
59
60
|
, fFlags(flags) {}
|
60
61
|
|
61
|
-
|
62
|
-
|
62
|
+
std::string description() const {
|
63
|
+
std::string result = fLayout.description();
|
63
64
|
|
64
65
|
// SkSL extensions
|
65
66
|
if (fFlags & kES3_Flag) {
|
@@ -117,7 +118,7 @@ struct Modifiers {
|
|
117
118
|
* Verifies that only permitted modifiers and layout flags are included. Reports errors and
|
118
119
|
* returns false in the event of a violation.
|
119
120
|
*/
|
120
|
-
bool checkPermitted(const Context& context,
|
121
|
+
bool checkPermitted(const Context& context, Position pos, int permittedModifierFlags,
|
121
122
|
int permittedLayoutFlags) const;
|
122
123
|
|
123
124
|
Layout fLayout;
|
@@ -32,8 +32,8 @@ public:
|
|
32
32
|
kLast = kStructDefinition
|
33
33
|
};
|
34
34
|
|
35
|
-
ProgramElement(
|
36
|
-
: INHERITED(
|
35
|
+
ProgramElement(Position pos, Kind kind)
|
36
|
+
: INHERITED(pos, (int) kind) {
|
37
37
|
SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast);
|
38
38
|
}
|
39
39
|
|
@@ -18,11 +18,14 @@ namespace SkSL {
|
|
18
18
|
enum class ProgramKind : int8_t {
|
19
19
|
kFragment,
|
20
20
|
kVertex,
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
kGraphiteFragment,
|
22
|
+
kGraphiteVertex,
|
23
|
+
kRuntimeColorFilter, // Runtime effect only suitable as SkColorFilter
|
24
|
+
kRuntimeShader, // " " " " " SkShader
|
25
|
+
kRuntimeBlender, // " " " " " SkBlender
|
26
|
+
kPrivateRuntimeShader, // Runtime shader with public restrictions lifted
|
27
|
+
kMeshVertex, // Vertex portion of a custom mesh
|
28
|
+
kMeshFragment, // Fragment " " " " "
|
26
29
|
kGeneric,
|
27
30
|
};
|
28
31
|
|
@@ -27,7 +27,6 @@ public:
|
|
27
27
|
kExpression,
|
28
28
|
kFor,
|
29
29
|
kIf,
|
30
|
-
kInlineMarker,
|
31
30
|
kNop,
|
32
31
|
kReturn,
|
33
32
|
kSwitch,
|
@@ -38,8 +37,8 @@ public:
|
|
38
37
|
kLast = kVarDeclaration,
|
39
38
|
};
|
40
39
|
|
41
|
-
Statement(
|
42
|
-
: INHERITED(
|
40
|
+
Statement(Position pos, Kind kind)
|
41
|
+
: INHERITED(pos, (int) kind) {
|
43
42
|
SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast);
|
44
43
|
}
|
45
44
|
|
@@ -8,73 +8,34 @@
|
|
8
8
|
#ifndef SKSL_STRING
|
9
9
|
#define SKSL_STRING
|
10
10
|
|
11
|
-
#include "include/core/
|
11
|
+
#include "include/core/SkTypes.h"
|
12
12
|
#include "include/private/SkSLDefines.h"
|
13
|
-
|
13
|
+
|
14
14
|
#include <stdarg.h>
|
15
15
|
#include <string>
|
16
|
-
|
17
|
-
#ifndef SKSL_STANDALONE
|
18
|
-
#include "include/core/SkString.h"
|
19
|
-
#endif
|
16
|
+
#include <string_view>
|
20
17
|
|
21
18
|
namespace SkSL {
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
class SK_API String : public std::string {
|
26
|
-
public:
|
27
|
-
using std::string::string;
|
28
|
-
|
29
|
-
explicit String(std::string s) : INHERITED(std::move(s)) {}
|
30
|
-
explicit String(skstd::string_view s) : INHERITED(s.data(), s.length()) {}
|
31
|
-
// TODO(johnstiles): add operator skstd::string_view
|
32
|
-
|
33
|
-
static String printf(const char* fmt, ...) SK_PRINTF_LIKE(1, 2);
|
34
|
-
void appendf(const char* fmt, ...) SK_PRINTF_LIKE(2, 3);
|
35
|
-
void vappendf(const char* fmt, va_list va);
|
36
|
-
|
37
|
-
bool starts_with(const char prefix[]) const {
|
38
|
-
return skstd::string_view(data(), size()).starts_with(prefix);
|
39
|
-
}
|
40
|
-
bool ends_with(const char suffix[]) const {
|
41
|
-
return skstd::string_view(data(), size()).ends_with(suffix);
|
42
|
-
}
|
43
|
-
|
44
|
-
bool consumeSuffix(const char suffix[]);
|
45
|
-
|
46
|
-
String operator+(const char* s) const;
|
47
|
-
String operator+(const String& s) const;
|
48
|
-
String operator+(skstd::string_view s) const;
|
49
|
-
String& operator+=(char c);
|
50
|
-
String& operator+=(const char* s);
|
51
|
-
String& operator+=(const String& s);
|
52
|
-
String& operator+=(skstd::string_view s);
|
53
|
-
friend String operator+(const char* s1, const String& s2);
|
20
|
+
bool stod(std::string_view s, SKSL_FLOAT* value);
|
21
|
+
bool stoi(std::string_view s, SKSL_INT* value);
|
54
22
|
|
55
|
-
|
56
|
-
using INHERITED = std::string;
|
57
|
-
};
|
23
|
+
namespace String {
|
58
24
|
|
59
|
-
|
25
|
+
std::string printf(const char* fmt, ...) SK_PRINTF_LIKE(1, 2);
|
26
|
+
void appendf(std::string* str, const char* fmt, ...) SK_PRINTF_LIKE(2, 3);
|
27
|
+
void vappendf(std::string* str, const char* fmt, va_list va) SK_PRINTF_LIKE(2, 0);
|
60
28
|
|
61
|
-
|
62
|
-
|
63
|
-
String to_string(uint32_t value);
|
64
|
-
String to_string(int64_t value);
|
65
|
-
String to_string(uint64_t value);
|
29
|
+
} // namespace String
|
30
|
+
} // namespace SkSL
|
66
31
|
|
67
|
-
|
68
|
-
bool stoi(skstd::string_view s, SKSL_INT* value);
|
32
|
+
namespace skstd {
|
69
33
|
|
70
|
-
|
34
|
+
// We use a custom to_string(float|double) which ignores locale settings and writes `1.0` instead
|
35
|
+
// of `1.00000`.
|
36
|
+
std::string to_string(float value);
|
37
|
+
std::string to_string(double value);
|
71
38
|
|
72
|
-
namespace
|
73
|
-
template<> struct hash<SkSL::String> {
|
74
|
-
size_t operator()(const SkSL::String& s) const {
|
75
|
-
return hash<std::string>{}(s);
|
76
|
-
}
|
77
|
-
};
|
78
|
-
} // namespace std
|
39
|
+
} // namespace skstd
|
79
40
|
|
80
41
|
#endif
|
@@ -30,8 +30,8 @@ public:
|
|
30
30
|
kLast = kVariable
|
31
31
|
};
|
32
32
|
|
33
|
-
Symbol(
|
34
|
-
: INHERITED(
|
33
|
+
Symbol(Position pos, Kind kind, std::string_view name, const Type* type = nullptr)
|
34
|
+
: INHERITED(pos, (int) kind)
|
35
35
|
, fName(name)
|
36
36
|
, fType(type) {
|
37
37
|
SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast);
|
@@ -48,7 +48,7 @@ public:
|
|
48
48
|
return (Kind) fKind;
|
49
49
|
}
|
50
50
|
|
51
|
-
|
51
|
+
std::string_view name() const {
|
52
52
|
return fName;
|
53
53
|
}
|
54
54
|
|
@@ -77,7 +77,7 @@ public:
|
|
77
77
|
}
|
78
78
|
|
79
79
|
private:
|
80
|
-
|
80
|
+
std::string_view fName;
|
81
81
|
const Type* fType;
|
82
82
|
|
83
83
|
using INHERITED = IRNode;
|
@@ -18,8 +18,10 @@ enum SkShadowFlags {
|
|
18
18
|
kGeometricOnly_ShadowFlag = 0x02,
|
19
19
|
/** Light position represents a direction, light radius is blur radius at elevation 1 */
|
20
20
|
kDirectionalLight_ShadowFlag = 0x04,
|
21
|
+
/** Concave paths will only use blur to generate the shadow */
|
22
|
+
kConcaveBlurOnly_ShadowFlag = 0x08,
|
21
23
|
/** mask for all shadow flags */
|
22
|
-
kAll_ShadowFlag =
|
24
|
+
kAll_ShadowFlag = 0x0F
|
23
25
|
};
|
24
26
|
|
25
27
|
#endif
|
@@ -0,0 +1,47 @@
|
|
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 <string.h>
|
12
|
+
#include <string_view>
|
13
|
+
|
14
|
+
namespace skstd {
|
15
|
+
|
16
|
+
// C++20 additions
|
17
|
+
inline constexpr bool starts_with(std::string_view str, std::string_view prefix) {
|
18
|
+
if (prefix.length() > str.length()) {
|
19
|
+
return false;
|
20
|
+
}
|
21
|
+
return prefix.length() == 0 || !memcmp(str.data(), prefix.data(), prefix.length());
|
22
|
+
}
|
23
|
+
|
24
|
+
inline constexpr bool starts_with(std::string_view str, std::string_view::value_type c) {
|
25
|
+
return !str.empty() && str.front() == c;
|
26
|
+
}
|
27
|
+
|
28
|
+
inline constexpr bool ends_with(std::string_view str, std::string_view suffix) {
|
29
|
+
if (suffix.length() > str.length()) {
|
30
|
+
return false;
|
31
|
+
}
|
32
|
+
return suffix.length() == 0 || !memcmp(str.data() + str.length() - suffix.length(),
|
33
|
+
suffix.data(), suffix.length());
|
34
|
+
}
|
35
|
+
|
36
|
+
inline constexpr bool ends_with(std::string_view str, std::string_view::value_type c) {
|
37
|
+
return !str.empty() && str.back() == c;
|
38
|
+
}
|
39
|
+
|
40
|
+
// C++23 additions
|
41
|
+
inline constexpr bool contains(std::string_view str, std::string_view needle) {
|
42
|
+
return str.find(needle) != std::string_view::npos;
|
43
|
+
}
|
44
|
+
|
45
|
+
} // namespace skstd
|
46
|
+
|
47
|
+
#endif
|
@@ -16,6 +16,7 @@
|
|
16
16
|
#include "include/private/SkTemplates.h"
|
17
17
|
#include "include/private/SkTo.h"
|
18
18
|
|
19
|
+
#include <algorithm>
|
19
20
|
#include <string.h>
|
20
21
|
#include <initializer_list>
|
21
22
|
#include <memory>
|
@@ -477,15 +478,15 @@ private:
|
|
477
478
|
SkASSERT(count >= 0);
|
478
479
|
SkASSERT(preallocCount > 0);
|
479
480
|
SkASSERT(preallocStorage);
|
480
|
-
fCount = count;
|
481
|
+
fCount = SkToU32(count);
|
481
482
|
fItemArray = nullptr;
|
482
483
|
fReserved = false;
|
483
484
|
if (count > preallocCount) {
|
484
|
-
fAllocCount = std::max(count, kMinHeapAllocCount);
|
485
|
+
fAllocCount = SkToU32(std::max(count, kMinHeapAllocCount));
|
485
486
|
fItemArray = (T*)sk_malloc_throw(fAllocCount, sizeof(T));
|
486
487
|
fOwnMemory = true;
|
487
488
|
} else {
|
488
|
-
fAllocCount = preallocCount;
|
489
|
+
fAllocCount = SkToU32(preallocCount);
|
489
490
|
fItemArray = (T*)preallocStorage;
|
490
491
|
fOwnMemory = false;
|
491
492
|
}
|
@@ -11,6 +11,8 @@
|
|
11
11
|
#include "include/core/SkTypes.h"
|
12
12
|
#include "include/private/SkChecksum.h"
|
13
13
|
#include "include/private/SkTemplates.h"
|
14
|
+
|
15
|
+
#include <initializer_list>
|
14
16
|
#include <new>
|
15
17
|
#include <utility>
|
16
18
|
|
@@ -134,6 +136,27 @@ public:
|
|
134
136
|
}
|
135
137
|
}
|
136
138
|
|
139
|
+
// Hash tables will automatically resize themselves when set() and remove() are called, but
|
140
|
+
// resize() can be called to manually grow capacity before a bulk insertion.
|
141
|
+
void resize(int capacity) {
|
142
|
+
SkASSERT(capacity >= fCount);
|
143
|
+
int oldCapacity = fCapacity;
|
144
|
+
SkDEBUGCODE(int oldCount = fCount);
|
145
|
+
|
146
|
+
fCount = 0;
|
147
|
+
fCapacity = capacity;
|
148
|
+
SkAutoTArray<Slot> oldSlots = std::move(fSlots);
|
149
|
+
fSlots = SkAutoTArray<Slot>(capacity);
|
150
|
+
|
151
|
+
for (int i = 0; i < oldCapacity; i++) {
|
152
|
+
Slot& s = oldSlots[i];
|
153
|
+
if (s.has_value()) {
|
154
|
+
this->uncheckedSet(*std::move(s));
|
155
|
+
}
|
156
|
+
}
|
157
|
+
SkASSERT(fCount == oldCount);
|
158
|
+
}
|
159
|
+
|
137
160
|
// Call fn on every entry in the table. You may mutate the entries, but be very careful.
|
138
161
|
template <typename Fn> // f(T*)
|
139
162
|
void foreach(Fn&& fn) {
|
@@ -259,24 +282,6 @@ private:
|
|
259
282
|
return nullptr;
|
260
283
|
}
|
261
284
|
|
262
|
-
void resize(int capacity) {
|
263
|
-
int oldCapacity = fCapacity;
|
264
|
-
SkDEBUGCODE(int oldCount = fCount);
|
265
|
-
|
266
|
-
fCount = 0;
|
267
|
-
fCapacity = capacity;
|
268
|
-
SkAutoTArray<Slot> oldSlots = std::move(fSlots);
|
269
|
-
fSlots = SkAutoTArray<Slot>(capacity);
|
270
|
-
|
271
|
-
for (int i = 0; i < oldCapacity; i++) {
|
272
|
-
Slot& s = oldSlots[i];
|
273
|
-
if (s.has_value()) {
|
274
|
-
this->uncheckedSet(*std::move(s));
|
275
|
-
}
|
276
|
-
}
|
277
|
-
SkASSERT(fCount == oldCount);
|
278
|
-
}
|
279
|
-
|
280
285
|
void removeSlot(int index) {
|
281
286
|
fCount--;
|
282
287
|
|
@@ -413,12 +418,38 @@ private:
|
|
413
418
|
template <typename K, typename V, typename HashK = SkGoodHash>
|
414
419
|
class SkTHashMap {
|
415
420
|
public:
|
421
|
+
// Allow default construction and assignment.
|
422
|
+
SkTHashMap() = default;
|
423
|
+
|
424
|
+
SkTHashMap(SkTHashMap<K, V, HashK>&& that) = default;
|
425
|
+
SkTHashMap(const SkTHashMap<K, V, HashK>& that) = default;
|
426
|
+
|
427
|
+
SkTHashMap<K, V, HashK>& operator=(SkTHashMap<K, V, HashK>&& that) = default;
|
428
|
+
SkTHashMap<K, V, HashK>& operator=(const SkTHashMap<K, V, HashK>& that) = default;
|
429
|
+
|
430
|
+
// Construct with an initializer list of key-value pairs.
|
431
|
+
struct Pair : public std::pair<K, V> {
|
432
|
+
using std::pair<K, V>::pair;
|
433
|
+
static const K& GetKey(const Pair& p) { return p.first; }
|
434
|
+
static auto Hash(const K& key) { return HashK()(key); }
|
435
|
+
};
|
436
|
+
|
437
|
+
SkTHashMap(std::initializer_list<Pair> pairs) {
|
438
|
+
fTable.resize(pairs.size() * 5 / 3);
|
439
|
+
for (const Pair& p : pairs) {
|
440
|
+
fTable.set(p);
|
441
|
+
}
|
442
|
+
}
|
443
|
+
|
416
444
|
// Clear the map.
|
417
445
|
void reset() { fTable.reset(); }
|
418
446
|
|
419
447
|
// How many key/value pairs are in the table?
|
420
448
|
int count() const { return fTable.count(); }
|
421
449
|
|
450
|
+
// Is empty?
|
451
|
+
bool empty() const { return fTable.count() == 0; }
|
452
|
+
|
422
453
|
// Approximately how many bytes of memory do we use beyond sizeof(*this)?
|
423
454
|
size_t approxBytesUsed() const { return fTable.approxBytesUsed(); }
|
424
455
|
|
@@ -466,12 +497,6 @@ public:
|
|
466
497
|
}
|
467
498
|
|
468
499
|
// Dereferencing an iterator gives back a key-value pair, suitable for structured binding.
|
469
|
-
struct Pair : public std::pair<K, V> {
|
470
|
-
using std::pair<K, V>::pair;
|
471
|
-
static const K& GetKey(const Pair& p) { return p.first; }
|
472
|
-
static auto Hash(const K& key) { return HashK()(key); }
|
473
|
-
};
|
474
|
-
|
475
500
|
using Iter = typename SkTHashTable<Pair, K>::template Iter<std::pair<K, V>>;
|
476
501
|
|
477
502
|
Iter begin() const {
|
@@ -490,6 +515,23 @@ private:
|
|
490
515
|
template <typename T, typename HashT = SkGoodHash>
|
491
516
|
class SkTHashSet {
|
492
517
|
public:
|
518
|
+
// Allow default construction and assignment.
|
519
|
+
SkTHashSet() = default;
|
520
|
+
|
521
|
+
SkTHashSet(SkTHashSet<T, HashT>&& that) = default;
|
522
|
+
SkTHashSet(const SkTHashSet<T, HashT>& that) = default;
|
523
|
+
|
524
|
+
SkTHashSet<T, HashT>& operator=(SkTHashSet<T, HashT>&& that) = default;
|
525
|
+
SkTHashSet<T, HashT>& operator=(const SkTHashSet<T, HashT>& that) = default;
|
526
|
+
|
527
|
+
// Construct with an initializer list of Ts.
|
528
|
+
SkTHashSet(std::initializer_list<T> vals) {
|
529
|
+
fTable.resize(vals.size() * 5 / 3);
|
530
|
+
for (const T& val : vals) {
|
531
|
+
fTable.set(val);
|
532
|
+
}
|
533
|
+
}
|
534
|
+
|
493
535
|
// Clear the set.
|
494
536
|
void reset() { fTable.reset(); }
|
495
537
|
|
@@ -12,40 +12,10 @@
|
|
12
12
|
#ifndef SkTLogic_DEFINED
|
13
13
|
#define SkTLogic_DEFINED
|
14
14
|
|
15
|
-
#include <
|
15
|
+
#include <iterator>
|
16
16
|
#include <type_traits>
|
17
|
-
#include <utility>
|
18
17
|
#include "include/private/SkTo.h"
|
19
18
|
|
20
|
-
namespace skstd {
|
21
|
-
|
22
|
-
// C++17, <variant>
|
23
|
-
struct monostate {};
|
24
|
-
|
25
|
-
// C++17, <type_traits>
|
26
|
-
template<typename...> struct conjunction : std::true_type { };
|
27
|
-
template<typename T> struct conjunction<T> : T { };
|
28
|
-
template<typename T, typename... Ts>
|
29
|
-
struct conjunction<T, Ts...> : std::conditional<bool(T::value), conjunction<Ts...>, T>::type { };
|
30
|
-
|
31
|
-
// C++17, std::data, std::size
|
32
|
-
template<typename Container>
|
33
|
-
constexpr auto data(Container& c) -> decltype(c.data()) { return c.data(); }
|
34
|
-
template<typename Container>
|
35
|
-
constexpr auto data(const Container& c) -> decltype(c.data()) { return c.data(); }
|
36
|
-
template<typename Array, size_t N>
|
37
|
-
constexpr auto data(Array(&a)[N]) -> decltype(a) { return a; }
|
38
|
-
template<typename T>
|
39
|
-
constexpr const T* data(std::initializer_list<T> i) { return i.begin(); }
|
40
|
-
|
41
|
-
template<typename Container>
|
42
|
-
constexpr auto size(Container& c) -> decltype(c.size()) { return c.size(); }
|
43
|
-
template<typename Array, size_t N>
|
44
|
-
constexpr size_t size(Array(&)[N]) { return N; }
|
45
|
-
template<typename T>
|
46
|
-
constexpr const T* size(std::initializer_list<T> i) { return i.end() - i.begin(); }
|
47
|
-
} // namespace skstd
|
48
|
-
|
49
19
|
// The sknonstd namespace contains things we would like to be proposed and feel std-ish.
|
50
20
|
namespace sknonstd {
|
51
21
|
|
@@ -81,6 +51,6 @@ template <typename D, typename S> using same_cv_t = typename same_cv<D, S>::type
|
|
81
51
|
} // namespace sknonstd
|
82
52
|
|
83
53
|
template <typename Container>
|
84
|
-
constexpr int SkCount(const Container& c) { return SkTo<int>(
|
54
|
+
constexpr int SkCount(const Container& c) { return SkTo<int>(std::size(c)); }
|
85
55
|
|
86
56
|
#endif
|
@@ -35,14 +35,14 @@ template<typename T> inline void sk_ignore_unused_variable(const T&) { }
|
|
35
35
|
/**
|
36
36
|
* Returns a pointer to a D which comes immediately after S[count].
|
37
37
|
*/
|
38
|
-
template <typename D, typename S>
|
38
|
+
template <typename D, typename S> inline D* SkTAfter(S* ptr, size_t count = 1) {
|
39
39
|
return reinterpret_cast<D*>(ptr + count);
|
40
40
|
}
|
41
41
|
|
42
42
|
/**
|
43
43
|
* Returns a pointer to a D which comes byteOffset bytes after S.
|
44
44
|
*/
|
45
|
-
template <typename D, typename S>
|
45
|
+
template <typename D, typename S> inline D* SkTAddOffset(S* ptr, ptrdiff_t byteOffset) {
|
46
46
|
// The intermediate char* has the same cv-ness as D as this produces better error messages.
|
47
47
|
// This relies on the fact that reinterpret_cast can add constness, but cannot remove it.
|
48
48
|
return reinterpret_cast<D*>(reinterpret_cast<sknonstd::same_cv_t<char, D>*>(ptr) + byteOffset);
|
@@ -78,11 +78,11 @@
|
|
78
78
|
|
79
79
|
#if defined(SK_BUILD_FOR_GOOGLE3) && !defined(SK_BUILD_FOR_WASM_IN_GOOGLE3)
|
80
80
|
extern "C" {
|
81
|
-
void
|
82
|
-
void
|
81
|
+
void __google_cxa_guard_acquire_begin(void);
|
82
|
+
void __google_cxa_guard_acquire_end (void);
|
83
83
|
}
|
84
|
-
#define SK_POTENTIALLY_BLOCKING_REGION_BEGIN
|
85
|
-
#define SK_POTENTIALLY_BLOCKING_REGION_END
|
84
|
+
#define SK_POTENTIALLY_BLOCKING_REGION_BEGIN __google_cxa_guard_acquire_begin()
|
85
|
+
#define SK_POTENTIALLY_BLOCKING_REGION_END __google_cxa_guard_acquire_end()
|
86
86
|
#else
|
87
87
|
#define SK_POTENTIALLY_BLOCKING_REGION_BEGIN
|
88
88
|
#define SK_POTENTIALLY_BLOCKING_REGION_END
|
@@ -858,20 +858,20 @@ SI void strided_load4(const T* v, \
|
|
858
858
|
c = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[2]); \
|
859
859
|
d = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[3]); \
|
860
860
|
}
|
861
|
-
IMPL_LOAD4_TRANSPOSED(2, uint32_t, vld4_u32)
|
862
|
-
IMPL_LOAD4_TRANSPOSED(4, uint16_t, vld4_u16)
|
863
|
-
IMPL_LOAD4_TRANSPOSED(8, uint8_t, vld4_u8)
|
864
|
-
IMPL_LOAD4_TRANSPOSED(2, int32_t, vld4_s32)
|
865
|
-
IMPL_LOAD4_TRANSPOSED(4, int16_t, vld4_s16)
|
866
|
-
IMPL_LOAD4_TRANSPOSED(8, int8_t, vld4_s8)
|
867
|
-
IMPL_LOAD4_TRANSPOSED(2, float, vld4_f32)
|
868
|
-
IMPL_LOAD4_TRANSPOSED(4, uint32_t, vld4q_u32)
|
869
|
-
IMPL_LOAD4_TRANSPOSED(8, uint16_t, vld4q_u16)
|
870
|
-
IMPL_LOAD4_TRANSPOSED(16, uint8_t, vld4q_u8)
|
871
|
-
IMPL_LOAD4_TRANSPOSED(4, int32_t, vld4q_s32)
|
872
|
-
IMPL_LOAD4_TRANSPOSED(8, int16_t, vld4q_s16)
|
873
|
-
IMPL_LOAD4_TRANSPOSED(16, int8_t, vld4q_s8)
|
874
|
-
IMPL_LOAD4_TRANSPOSED(4, float, vld4q_f32)
|
861
|
+
IMPL_LOAD4_TRANSPOSED(2, uint32_t, vld4_u32)
|
862
|
+
IMPL_LOAD4_TRANSPOSED(4, uint16_t, vld4_u16)
|
863
|
+
IMPL_LOAD4_TRANSPOSED(8, uint8_t, vld4_u8)
|
864
|
+
IMPL_LOAD4_TRANSPOSED(2, int32_t, vld4_s32)
|
865
|
+
IMPL_LOAD4_TRANSPOSED(4, int16_t, vld4_s16)
|
866
|
+
IMPL_LOAD4_TRANSPOSED(8, int8_t, vld4_s8)
|
867
|
+
IMPL_LOAD4_TRANSPOSED(2, float, vld4_f32)
|
868
|
+
IMPL_LOAD4_TRANSPOSED(4, uint32_t, vld4q_u32)
|
869
|
+
IMPL_LOAD4_TRANSPOSED(8, uint16_t, vld4q_u16)
|
870
|
+
IMPL_LOAD4_TRANSPOSED(16, uint8_t, vld4q_u8)
|
871
|
+
IMPL_LOAD4_TRANSPOSED(4, int32_t, vld4q_s32)
|
872
|
+
IMPL_LOAD4_TRANSPOSED(8, int16_t, vld4q_s16)
|
873
|
+
IMPL_LOAD4_TRANSPOSED(16, int8_t, vld4q_s8)
|
874
|
+
IMPL_LOAD4_TRANSPOSED(4, float, vld4q_f32)
|
875
875
|
#undef IMPL_LOAD4_TRANSPOSED
|
876
876
|
|
877
877
|
#elif SKVX_USE_SIMD && defined(__SSE__)
|
@@ -913,20 +913,20 @@ SI void strided_load2(const T* v, skvx::Vec<N,T>& a, skvx::Vec<N,T>& b) { \
|
|
913
913
|
a = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[0]); \
|
914
914
|
b = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[1]); \
|
915
915
|
}
|
916
|
-
IMPL_LOAD2_TRANSPOSED(2, uint32_t, vld2_u32)
|
917
|
-
IMPL_LOAD2_TRANSPOSED(4, uint16_t, vld2_u16)
|
918
|
-
IMPL_LOAD2_TRANSPOSED(8, uint8_t, vld2_u8)
|
919
|
-
IMPL_LOAD2_TRANSPOSED(2, int32_t, vld2_s32)
|
920
|
-
IMPL_LOAD2_TRANSPOSED(4, int16_t, vld2_s16)
|
921
|
-
IMPL_LOAD2_TRANSPOSED(8, int8_t, vld2_s8)
|
922
|
-
IMPL_LOAD2_TRANSPOSED(2, float, vld2_f32)
|
923
|
-
IMPL_LOAD2_TRANSPOSED(4, uint32_t, vld2q_u32)
|
924
|
-
IMPL_LOAD2_TRANSPOSED(8, uint16_t, vld2q_u16)
|
925
|
-
IMPL_LOAD2_TRANSPOSED(16, uint8_t, vld2q_u8)
|
926
|
-
IMPL_LOAD2_TRANSPOSED(4, int32_t, vld2q_s32)
|
927
|
-
IMPL_LOAD2_TRANSPOSED(8, int16_t, vld2q_s16)
|
928
|
-
IMPL_LOAD2_TRANSPOSED(16, int8_t, vld2q_s8)
|
929
|
-
IMPL_LOAD2_TRANSPOSED(4, float, vld2q_f32)
|
916
|
+
IMPL_LOAD2_TRANSPOSED(2, uint32_t, vld2_u32)
|
917
|
+
IMPL_LOAD2_TRANSPOSED(4, uint16_t, vld2_u16)
|
918
|
+
IMPL_LOAD2_TRANSPOSED(8, uint8_t, vld2_u8)
|
919
|
+
IMPL_LOAD2_TRANSPOSED(2, int32_t, vld2_s32)
|
920
|
+
IMPL_LOAD2_TRANSPOSED(4, int16_t, vld2_s16)
|
921
|
+
IMPL_LOAD2_TRANSPOSED(8, int8_t, vld2_s8)
|
922
|
+
IMPL_LOAD2_TRANSPOSED(2, float, vld2_f32)
|
923
|
+
IMPL_LOAD2_TRANSPOSED(4, uint32_t, vld2q_u32)
|
924
|
+
IMPL_LOAD2_TRANSPOSED(8, uint16_t, vld2q_u16)
|
925
|
+
IMPL_LOAD2_TRANSPOSED(16, uint8_t, vld2q_u8)
|
926
|
+
IMPL_LOAD2_TRANSPOSED(4, int32_t, vld2q_s32)
|
927
|
+
IMPL_LOAD2_TRANSPOSED(8, int16_t, vld2q_s16)
|
928
|
+
IMPL_LOAD2_TRANSPOSED(16, int8_t, vld2q_s8)
|
929
|
+
IMPL_LOAD2_TRANSPOSED(4, float, vld2q_f32)
|
930
930
|
#undef IMPL_LOAD2_TRANSPOSED
|
931
931
|
#endif
|
932
932
|
|