@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.
- 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
|
@@ -9,19 +9,21 @@
|
|
|
9
9
|
#define SKSL_DSL_TYPE
|
|
10
10
|
|
|
11
11
|
#include "include/core/SkSpan.h"
|
|
12
|
-
#include "include/private/SkSLString.h"
|
|
13
12
|
#include "include/sksl/DSLExpression.h"
|
|
14
13
|
#include "include/sksl/DSLModifiers.h"
|
|
14
|
+
#include "include/sksl/SkSLPosition.h"
|
|
15
15
|
|
|
16
16
|
#include <cstdint>
|
|
17
|
+
#include <string_view>
|
|
18
|
+
#include <utility>
|
|
17
19
|
|
|
18
20
|
namespace SkSL {
|
|
19
21
|
|
|
22
|
+
class Compiler;
|
|
20
23
|
class Type;
|
|
21
24
|
|
|
22
25
|
namespace dsl {
|
|
23
26
|
|
|
24
|
-
class DSLExpression;
|
|
25
27
|
class DSLField;
|
|
26
28
|
class DSLVarBase;
|
|
27
29
|
|
|
@@ -80,16 +82,17 @@ enum TypeConstant : uint8_t {
|
|
|
80
82
|
|
|
81
83
|
class DSLType {
|
|
82
84
|
public:
|
|
83
|
-
DSLType(TypeConstant tc)
|
|
84
|
-
: fTypeConstant(tc)
|
|
85
|
+
DSLType(TypeConstant tc, Position pos = {})
|
|
86
|
+
: fTypeConstant(tc)
|
|
87
|
+
, fPosition(pos) {}
|
|
85
88
|
|
|
86
|
-
DSLType(const SkSL::Type* type);
|
|
89
|
+
DSLType(const SkSL::Type* type, Position pos = {});
|
|
87
90
|
|
|
88
|
-
DSLType(
|
|
91
|
+
DSLType(std::string_view name, Position pos = {});
|
|
89
92
|
|
|
90
|
-
DSLType(
|
|
93
|
+
DSLType(std::string_view name,
|
|
91
94
|
DSLModifiers* modifiers,
|
|
92
|
-
|
|
95
|
+
Position pos = {});
|
|
93
96
|
|
|
94
97
|
/**
|
|
95
98
|
* Returns true if this type is a bool.
|
|
@@ -169,15 +172,16 @@ private:
|
|
|
169
172
|
const SkSL::Type& skslType() const;
|
|
170
173
|
|
|
171
174
|
const SkSL::Type* fSkSLType = nullptr;
|
|
172
|
-
|
|
173
175
|
TypeConstant fTypeConstant = kPoison_Type;
|
|
176
|
+
Position fPosition;
|
|
174
177
|
|
|
175
|
-
friend DSLType Array(const DSLType& base, int count,
|
|
176
|
-
friend DSLType Struct(
|
|
178
|
+
friend DSLType Array(const DSLType& base, int count, Position pos);
|
|
179
|
+
friend DSLType Struct(std::string_view name, SkSpan<DSLField> fields, Position pos);
|
|
177
180
|
friend class DSLCore;
|
|
178
181
|
friend class DSLFunction;
|
|
179
182
|
friend class DSLVarBase;
|
|
180
183
|
friend class DSLWriter;
|
|
184
|
+
friend class SkSL::Compiler;
|
|
181
185
|
};
|
|
182
186
|
|
|
183
187
|
#define TYPE(T) \
|
|
@@ -218,16 +222,16 @@ MATRIX_TYPE(Half)
|
|
|
218
222
|
#undef VECTOR_TYPE
|
|
219
223
|
#undef MATRIX_TYPE
|
|
220
224
|
|
|
221
|
-
DSLType Array(const DSLType& base, int count,
|
|
225
|
+
DSLType Array(const DSLType& base, int count, Position pos = {});
|
|
222
226
|
|
|
223
227
|
class DSLField {
|
|
224
228
|
public:
|
|
225
|
-
DSLField(const DSLType type,
|
|
226
|
-
|
|
229
|
+
DSLField(const DSLType type, std::string_view name,
|
|
230
|
+
Position pos = {})
|
|
227
231
|
: DSLField(DSLModifiers(), type, name, pos) {}
|
|
228
232
|
|
|
229
|
-
DSLField(const DSLModifiers& modifiers, const DSLType type,
|
|
230
|
-
|
|
233
|
+
DSLField(const DSLModifiers& modifiers, const DSLType type, std::string_view name,
|
|
234
|
+
Position pos = {})
|
|
231
235
|
: fModifiers(modifiers)
|
|
232
236
|
, fType(type)
|
|
233
237
|
, fName(name)
|
|
@@ -236,20 +240,20 @@ public:
|
|
|
236
240
|
private:
|
|
237
241
|
DSLModifiers fModifiers;
|
|
238
242
|
const DSLType fType;
|
|
239
|
-
|
|
240
|
-
|
|
243
|
+
std::string_view fName;
|
|
244
|
+
Position fPosition;
|
|
241
245
|
|
|
242
246
|
friend class DSLCore;
|
|
243
|
-
friend DSLType Struct(
|
|
247
|
+
friend DSLType Struct(std::string_view name, SkSpan<DSLField> fields, Position pos);
|
|
244
248
|
};
|
|
245
249
|
|
|
246
|
-
DSLType Struct(
|
|
247
|
-
|
|
250
|
+
DSLType Struct(std::string_view name, SkSpan<DSLField> fields,
|
|
251
|
+
Position pos = {});
|
|
248
252
|
|
|
249
253
|
template<typename... Field>
|
|
250
|
-
DSLType Struct(
|
|
254
|
+
DSLType Struct(std::string_view name, Field... fields) {
|
|
251
255
|
DSLField fieldTypes[] = {std::move(fields)...};
|
|
252
|
-
return Struct(name, SkMakeSpan(fieldTypes),
|
|
256
|
+
return Struct(name, SkMakeSpan(fieldTypes), Position());
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
} // namespace dsl
|
|
@@ -11,12 +11,20 @@
|
|
|
11
11
|
#include "include/sksl/DSLExpression.h"
|
|
12
12
|
#include "include/sksl/DSLModifiers.h"
|
|
13
13
|
#include "include/sksl/DSLType.h"
|
|
14
|
+
#include "include/sksl/SkSLPosition.h"
|
|
15
|
+
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
#include <memory>
|
|
18
|
+
#include <string_view>
|
|
19
|
+
#include <utility>
|
|
14
20
|
|
|
15
21
|
namespace SkSL {
|
|
16
22
|
|
|
17
23
|
class Expression;
|
|
24
|
+
class ExpressionArray;
|
|
18
25
|
class IRGenerator;
|
|
19
26
|
class SPIRVCodeGenerator;
|
|
27
|
+
class Statement;
|
|
20
28
|
class Variable;
|
|
21
29
|
enum class VariableStorage : int8_t;
|
|
22
30
|
|
|
@@ -35,21 +43,22 @@ public:
|
|
|
35
43
|
* name conflicts and the variable's name is only important when debugging shaders, the name
|
|
36
44
|
* parameter is optional.
|
|
37
45
|
*/
|
|
38
|
-
DSLVarBase(DSLType type,
|
|
46
|
+
DSLVarBase(DSLType type, std::string_view name, DSLExpression initialValue, Position pos,
|
|
47
|
+
Position namePos);
|
|
39
48
|
|
|
40
|
-
DSLVarBase(DSLType type, DSLExpression initialValue,
|
|
49
|
+
DSLVarBase(DSLType type, DSLExpression initialValue, Position pos, Position namePos);
|
|
41
50
|
|
|
42
|
-
DSLVarBase(const DSLModifiers& modifiers, DSLType type,
|
|
43
|
-
DSLExpression initialValue,
|
|
51
|
+
DSLVarBase(const DSLModifiers& modifiers, DSLType type, std::string_view name,
|
|
52
|
+
DSLExpression initialValue, Position pos, Position namePos);
|
|
44
53
|
|
|
45
54
|
DSLVarBase(const DSLModifiers& modifiers, DSLType type, DSLExpression initialValue,
|
|
46
|
-
|
|
55
|
+
Position pos, Position namePos);
|
|
47
56
|
|
|
48
57
|
DSLVarBase(DSLVarBase&&) = default;
|
|
49
58
|
|
|
50
59
|
virtual ~DSLVarBase();
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
std::string_view name() const {
|
|
53
62
|
return fName;
|
|
54
63
|
}
|
|
55
64
|
|
|
@@ -60,57 +69,57 @@ public:
|
|
|
60
69
|
virtual VariableStorage storage() const = 0;
|
|
61
70
|
|
|
62
71
|
DSLExpression x() {
|
|
63
|
-
return DSLExpression(*this,
|
|
72
|
+
return DSLExpression(*this, Position()).x();
|
|
64
73
|
}
|
|
65
74
|
|
|
66
75
|
DSLExpression y() {
|
|
67
|
-
return DSLExpression(*this,
|
|
76
|
+
return DSLExpression(*this, Position()).y();
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
DSLExpression z() {
|
|
71
|
-
return DSLExpression(*this,
|
|
80
|
+
return DSLExpression(*this, Position()).z();
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
DSLExpression w() {
|
|
75
|
-
return DSLExpression(*this,
|
|
84
|
+
return DSLExpression(*this, Position()).w();
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
DSLExpression r() {
|
|
79
|
-
return DSLExpression(*this,
|
|
88
|
+
return DSLExpression(*this, Position()).r();
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
DSLExpression g() {
|
|
83
|
-
return DSLExpression(*this,
|
|
92
|
+
return DSLExpression(*this, Position()).g();
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
DSLExpression b() {
|
|
87
|
-
return DSLExpression(*this,
|
|
96
|
+
return DSLExpression(*this, Position()).b();
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
DSLExpression a() {
|
|
91
|
-
return DSLExpression(*this,
|
|
100
|
+
return DSLExpression(*this, Position()).a();
|
|
92
101
|
}
|
|
93
102
|
|
|
94
|
-
DSLExpression field(
|
|
95
|
-
return DSLExpression(*this,
|
|
103
|
+
DSLExpression field(std::string_view name) {
|
|
104
|
+
return DSLExpression(*this, Position()).field(name);
|
|
96
105
|
}
|
|
97
106
|
|
|
98
107
|
DSLPossibleExpression operator[](DSLExpression&& index);
|
|
99
108
|
|
|
100
109
|
DSLPossibleExpression operator++() {
|
|
101
|
-
return ++DSLExpression(*this,
|
|
110
|
+
return ++DSLExpression(*this, Position());
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
DSLPossibleExpression operator++(int) {
|
|
105
|
-
return DSLExpression(*this,
|
|
114
|
+
return DSLExpression(*this, Position())++;
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
DSLPossibleExpression operator--() {
|
|
109
|
-
return --DSLExpression(*this,
|
|
118
|
+
return --DSLExpression(*this, Position());
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
DSLPossibleExpression operator--(int) {
|
|
113
|
-
return DSLExpression(*this,
|
|
122
|
+
return DSLExpression(*this, Position())--;
|
|
114
123
|
}
|
|
115
124
|
|
|
116
125
|
protected:
|
|
@@ -127,13 +136,14 @@ protected:
|
|
|
127
136
|
int fUniformHandle = -1;
|
|
128
137
|
std::unique_ptr<SkSL::Statement> fDeclaration;
|
|
129
138
|
const SkSL::Variable* fVar = nullptr;
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
Position fNamePosition;
|
|
140
|
+
std::string_view fRawName; // for error reporting
|
|
141
|
+
std::string_view fName;
|
|
132
142
|
DSLExpression fInitialValue;
|
|
133
143
|
// true if we have attempted to create the SkSL var
|
|
134
144
|
bool fInitialized = false;
|
|
135
145
|
bool fDeclared = false;
|
|
136
|
-
|
|
146
|
+
Position fPosition;
|
|
137
147
|
|
|
138
148
|
friend class DSLCore;
|
|
139
149
|
friend class DSLExpression;
|
|
@@ -150,25 +160,25 @@ class DSLVar : public DSLVarBase {
|
|
|
150
160
|
public:
|
|
151
161
|
DSLVar() = default;
|
|
152
162
|
|
|
153
|
-
DSLVar(DSLType type,
|
|
163
|
+
DSLVar(DSLType type, std::string_view name = "var",
|
|
154
164
|
DSLExpression initialValue = DSLExpression(),
|
|
155
|
-
|
|
156
|
-
: INHERITED(type, name, std::move(initialValue), pos) {}
|
|
165
|
+
Position pos = {}, Position namePos = {})
|
|
166
|
+
: INHERITED(type, name, std::move(initialValue), pos, namePos) {}
|
|
157
167
|
|
|
158
168
|
DSLVar(DSLType type, const char* name, DSLExpression initialValue = DSLExpression(),
|
|
159
|
-
|
|
160
|
-
: DSLVar(type,
|
|
169
|
+
Position pos = {}, Position namePos = {})
|
|
170
|
+
: DSLVar(type, std::string_view(name), std::move(initialValue), pos, namePos) {}
|
|
161
171
|
|
|
162
|
-
DSLVar(DSLType type, DSLExpression initialValue,
|
|
163
|
-
: INHERITED(type, std::move(initialValue), pos) {}
|
|
172
|
+
DSLVar(DSLType type, DSLExpression initialValue, Position pos = {}, Position namePos = {})
|
|
173
|
+
: INHERITED(type, std::move(initialValue), pos, namePos) {}
|
|
164
174
|
|
|
165
|
-
DSLVar(const DSLModifiers& modifiers, DSLType type,
|
|
166
|
-
DSLExpression initialValue = DSLExpression(),
|
|
167
|
-
: INHERITED(modifiers, type, name, std::move(initialValue), pos) {}
|
|
175
|
+
DSLVar(const DSLModifiers& modifiers, DSLType type, std::string_view name = "var",
|
|
176
|
+
DSLExpression initialValue = DSLExpression(), Position pos = {}, Position namePos = {})
|
|
177
|
+
: INHERITED(modifiers, type, name, std::move(initialValue), pos, namePos) {}
|
|
168
178
|
|
|
169
179
|
DSLVar(const DSLModifiers& modifiers, DSLType type, const char* name,
|
|
170
|
-
DSLExpression initialValue = DSLExpression(),
|
|
171
|
-
: DSLVar(modifiers, type,
|
|
180
|
+
DSLExpression initialValue = DSLExpression(), Position pos = {}, Position namePos = {})
|
|
181
|
+
: DSLVar(modifiers, type, std::string_view(name), std::move(initialValue), pos, namePos) {}
|
|
172
182
|
|
|
173
183
|
DSLVar(DSLVar&&) = default;
|
|
174
184
|
|
|
@@ -198,25 +208,26 @@ class DSLGlobalVar : public DSLVarBase {
|
|
|
198
208
|
public:
|
|
199
209
|
DSLGlobalVar() = default;
|
|
200
210
|
|
|
201
|
-
DSLGlobalVar(DSLType type,
|
|
202
|
-
DSLExpression initialValue = DSLExpression(),
|
|
203
|
-
: INHERITED(type, name, std::move(initialValue), pos) {}
|
|
211
|
+
DSLGlobalVar(DSLType type, std::string_view name = "var",
|
|
212
|
+
DSLExpression initialValue = DSLExpression(), Position pos = {}, Position namePos = {})
|
|
213
|
+
: INHERITED(type, name, std::move(initialValue), pos, namePos) {}
|
|
204
214
|
|
|
205
215
|
DSLGlobalVar(DSLType type, const char* name, DSLExpression initialValue = DSLExpression(),
|
|
206
|
-
|
|
207
|
-
: DSLGlobalVar(type,
|
|
216
|
+
Position pos = {}, Position namePos = {})
|
|
217
|
+
: DSLGlobalVar(type, std::string_view(name), std::move(initialValue), pos, namePos) {}
|
|
208
218
|
|
|
209
219
|
DSLGlobalVar(DSLType type, DSLExpression initialValue,
|
|
210
|
-
|
|
211
|
-
: INHERITED(type, std::move(initialValue), pos) {}
|
|
220
|
+
Position pos = {}, Position namePos = {})
|
|
221
|
+
: INHERITED(type, std::move(initialValue), pos, namePos) {}
|
|
212
222
|
|
|
213
|
-
DSLGlobalVar(const DSLModifiers& modifiers, DSLType type,
|
|
214
|
-
DSLExpression initialValue = DSLExpression(),
|
|
215
|
-
: INHERITED(modifiers, type, name, std::move(initialValue), pos) {}
|
|
223
|
+
DSLGlobalVar(const DSLModifiers& modifiers, DSLType type, std::string_view name = "var",
|
|
224
|
+
DSLExpression initialValue = DSLExpression(), Position pos = {}, Position namePos = {})
|
|
225
|
+
: INHERITED(modifiers, type, name, std::move(initialValue), pos, namePos) {}
|
|
216
226
|
|
|
217
227
|
DSLGlobalVar(const DSLModifiers& modifiers, DSLType type, const char* name,
|
|
218
|
-
DSLExpression initialValue = DSLExpression(),
|
|
219
|
-
: DSLGlobalVar(modifiers, type,
|
|
228
|
+
DSLExpression initialValue = DSLExpression(), Position pos = {}, Position namePos = {})
|
|
229
|
+
: DSLGlobalVar(modifiers, type, std::string_view(name), std::move(initialValue), pos,
|
|
230
|
+
namePos) {}
|
|
220
231
|
|
|
221
232
|
DSLGlobalVar(const char* name);
|
|
222
233
|
|
|
@@ -242,19 +253,19 @@ public:
|
|
|
242
253
|
* half4 shader::eval(float2 coords);
|
|
243
254
|
* half4 colorFilter::eval(half4 input);
|
|
244
255
|
*/
|
|
245
|
-
DSLExpression eval(DSLExpression x,
|
|
256
|
+
DSLExpression eval(DSLExpression x, Position pos = {});
|
|
246
257
|
|
|
247
258
|
/**
|
|
248
259
|
* Implements the following method call:
|
|
249
260
|
* half4 blender::eval(half4 src, half4 dst);
|
|
250
261
|
*/
|
|
251
262
|
DSLExpression eval(DSLExpression x, DSLExpression y,
|
|
252
|
-
|
|
263
|
+
Position pos = {});
|
|
253
264
|
|
|
254
265
|
private:
|
|
255
|
-
DSLExpression eval(ExpressionArray args,
|
|
266
|
+
DSLExpression eval(ExpressionArray args, Position pos);
|
|
256
267
|
|
|
257
|
-
std::unique_ptr<SkSL::Expression> methodCall(
|
|
268
|
+
std::unique_ptr<SkSL::Expression> methodCall(std::string_view methodName, Position pos);
|
|
258
269
|
|
|
259
270
|
using INHERITED = DSLVarBase;
|
|
260
271
|
};
|
|
@@ -266,20 +277,20 @@ class DSLParameter : public DSLVarBase {
|
|
|
266
277
|
public:
|
|
267
278
|
DSLParameter() = default;
|
|
268
279
|
|
|
269
|
-
DSLParameter(DSLType type,
|
|
270
|
-
|
|
271
|
-
: INHERITED(type, name, DSLExpression(), pos) {}
|
|
280
|
+
DSLParameter(DSLType type, std::string_view name = "var",
|
|
281
|
+
Position pos = {}, Position namePos = {})
|
|
282
|
+
: INHERITED(type, name, DSLExpression(), pos, namePos) {}
|
|
272
283
|
|
|
273
|
-
DSLParameter(DSLType type, const char* name,
|
|
274
|
-
: DSLParameter(type,
|
|
284
|
+
DSLParameter(DSLType type, const char* name, Position pos = {}, Position namePos = {})
|
|
285
|
+
: DSLParameter(type, std::string_view(name), pos, namePos) {}
|
|
275
286
|
|
|
276
|
-
DSLParameter(const DSLModifiers& modifiers, DSLType type,
|
|
277
|
-
|
|
278
|
-
: INHERITED(modifiers, type, name, DSLExpression(), pos) {}
|
|
287
|
+
DSLParameter(const DSLModifiers& modifiers, DSLType type, std::string_view name = "var",
|
|
288
|
+
Position pos = {}, Position namePos = {})
|
|
289
|
+
: INHERITED(modifiers, type, name, DSLExpression(), pos, namePos) {}
|
|
279
290
|
|
|
280
291
|
DSLParameter(const DSLModifiers& modifiers, DSLType type, const char* name,
|
|
281
|
-
|
|
282
|
-
: DSLParameter(modifiers, type,
|
|
292
|
+
Position pos = {}, Position namePos = {})
|
|
293
|
+
: DSLParameter(modifiers, type, std::string_view(name), pos, namePos) {}
|
|
283
294
|
|
|
284
295
|
DSLParameter(DSLParameter&&) = default;
|
|
285
296
|
|
|
@@ -8,45 +8,15 @@
|
|
|
8
8
|
#ifndef SKSL_ERROR_REPORTER
|
|
9
9
|
#define SKSL_ERROR_REPORTER
|
|
10
10
|
|
|
11
|
-
#include "include/core/SkStringView.h"
|
|
12
11
|
#include "include/core/SkTypes.h"
|
|
13
|
-
#include "include/private/SkSLString.h"
|
|
14
12
|
|
|
15
13
|
#include <string>
|
|
14
|
+
#include <string_view>
|
|
16
15
|
#include <vector>
|
|
17
16
|
|
|
18
17
|
namespace SkSL {
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
#define __has_builtin(x) 0
|
|
22
|
-
#endif
|
|
23
|
-
|
|
24
|
-
class PositionInfo {
|
|
25
|
-
public:
|
|
26
|
-
PositionInfo(const char* file = nullptr, int line = -1)
|
|
27
|
-
: fFile(file)
|
|
28
|
-
, fLine(line) {}
|
|
29
|
-
|
|
30
|
-
#if __has_builtin(__builtin_FILE) && __has_builtin(__builtin_LINE)
|
|
31
|
-
static PositionInfo Capture(const char* file = __builtin_FILE(), int line = __builtin_LINE()) {
|
|
32
|
-
return PositionInfo(file, line);
|
|
33
|
-
}
|
|
34
|
-
#else
|
|
35
|
-
static PositionInfo Capture() { return PositionInfo(); }
|
|
36
|
-
#endif // __has_builtin(__builtin_FILE) && __has_builtin(__builtin_LINE)
|
|
37
|
-
|
|
38
|
-
const char* file_name() const {
|
|
39
|
-
return fFile;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
int line() const {
|
|
43
|
-
return fLine;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private:
|
|
47
|
-
const char* fFile = nullptr;
|
|
48
|
-
int32_t fLine = -1;
|
|
49
|
-
};
|
|
19
|
+
class Position;
|
|
50
20
|
|
|
51
21
|
/**
|
|
52
22
|
* Class which is notified in the event of an error.
|
|
@@ -59,24 +29,19 @@ public:
|
|
|
59
29
|
SkASSERT(fPendingErrors.empty());
|
|
60
30
|
}
|
|
61
31
|
|
|
62
|
-
void error(
|
|
32
|
+
void error(std::string_view msg, Position position);
|
|
63
33
|
|
|
64
34
|
/**
|
|
65
35
|
* Reports an error message at the given line of the source text. Errors reported
|
|
66
36
|
* with a line of -1 will be queued until line number information can be determined.
|
|
67
37
|
*/
|
|
68
|
-
void error(
|
|
38
|
+
void error(Position pos, std::string_view msg);
|
|
69
39
|
|
|
70
|
-
|
|
40
|
+
std::string_view source() const { return fSource; }
|
|
71
41
|
|
|
72
|
-
void setSource(
|
|
42
|
+
void setSource(std::string_view source) { fSource = source; }
|
|
73
43
|
|
|
74
|
-
void reportPendingErrors(
|
|
75
|
-
for (const String& msg : fPendingErrors) {
|
|
76
|
-
this->handleError(msg, pos);
|
|
77
|
-
}
|
|
78
|
-
fPendingErrors.clear();
|
|
79
|
-
}
|
|
44
|
+
void reportPendingErrors(Position pos);
|
|
80
45
|
|
|
81
46
|
int errorCount() const {
|
|
82
47
|
return fErrorCount;
|
|
@@ -90,13 +55,13 @@ protected:
|
|
|
90
55
|
/**
|
|
91
56
|
* Called when an error is reported.
|
|
92
57
|
*/
|
|
93
|
-
virtual void handleError(
|
|
58
|
+
virtual void handleError(std::string_view msg, Position position) = 0;
|
|
94
59
|
|
|
95
60
|
private:
|
|
96
|
-
|
|
61
|
+
Position position(int offset) const;
|
|
97
62
|
|
|
98
|
-
|
|
99
|
-
std::vector<
|
|
63
|
+
std::string_view fSource;
|
|
64
|
+
std::vector<std::string> fPendingErrors;
|
|
100
65
|
int fErrorCount = 0;
|
|
101
66
|
};
|
|
102
67
|
|
|
@@ -105,9 +70,7 @@ private:
|
|
|
105
70
|
*/
|
|
106
71
|
class TestingOnly_AbortErrorReporter : public ErrorReporter {
|
|
107
72
|
public:
|
|
108
|
-
void handleError(
|
|
109
|
-
SK_ABORT("%.*s", (int)msg.length(), msg.data());
|
|
110
|
-
}
|
|
73
|
+
void handleError(std::string_view msg, Position pos) override;
|
|
111
74
|
};
|
|
112
75
|
|
|
113
76
|
} // namespace SkSL
|
|
@@ -0,0 +1,151 @@
|
|
|
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 SKSL_OPERATOR
|
|
9
|
+
#define SKSL_OPERATOR
|
|
10
|
+
|
|
11
|
+
#include <string_view>
|
|
12
|
+
|
|
13
|
+
namespace SkSL {
|
|
14
|
+
|
|
15
|
+
class Context;
|
|
16
|
+
class Type;
|
|
17
|
+
|
|
18
|
+
class Operator {
|
|
19
|
+
public:
|
|
20
|
+
enum class Kind {
|
|
21
|
+
PLUS,
|
|
22
|
+
MINUS,
|
|
23
|
+
STAR,
|
|
24
|
+
SLASH,
|
|
25
|
+
PERCENT,
|
|
26
|
+
SHL,
|
|
27
|
+
SHR,
|
|
28
|
+
LOGICALNOT,
|
|
29
|
+
LOGICALAND,
|
|
30
|
+
LOGICALOR,
|
|
31
|
+
LOGICALXOR,
|
|
32
|
+
BITWISENOT,
|
|
33
|
+
BITWISEAND,
|
|
34
|
+
BITWISEOR,
|
|
35
|
+
BITWISEXOR,
|
|
36
|
+
EQ,
|
|
37
|
+
EQEQ,
|
|
38
|
+
NEQ,
|
|
39
|
+
LT,
|
|
40
|
+
GT,
|
|
41
|
+
LTEQ,
|
|
42
|
+
GTEQ,
|
|
43
|
+
PLUSEQ,
|
|
44
|
+
MINUSEQ,
|
|
45
|
+
STAREQ,
|
|
46
|
+
SLASHEQ,
|
|
47
|
+
PERCENTEQ,
|
|
48
|
+
SHLEQ,
|
|
49
|
+
SHREQ,
|
|
50
|
+
BITWISEANDEQ,
|
|
51
|
+
BITWISEOREQ,
|
|
52
|
+
BITWISEXOREQ,
|
|
53
|
+
PLUSPLUS,
|
|
54
|
+
MINUSMINUS,
|
|
55
|
+
COMMA
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
enum class Precedence {
|
|
59
|
+
kParentheses = 1,
|
|
60
|
+
kPostfix = 2,
|
|
61
|
+
kPrefix = 3,
|
|
62
|
+
kMultiplicative = 4,
|
|
63
|
+
kAdditive = 5,
|
|
64
|
+
kShift = 6,
|
|
65
|
+
kRelational = 7,
|
|
66
|
+
kEquality = 8,
|
|
67
|
+
kBitwiseAnd = 9,
|
|
68
|
+
kBitwiseXor = 10,
|
|
69
|
+
kBitwiseOr = 11,
|
|
70
|
+
kLogicalAnd = 12,
|
|
71
|
+
kLogicalXor = 13,
|
|
72
|
+
kLogicalOr = 14,
|
|
73
|
+
kTernary = 15,
|
|
74
|
+
kAssignment = 16,
|
|
75
|
+
kSequence = 17,
|
|
76
|
+
kTopLevel = kSequence
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
Operator(Kind op) : fKind(op) {}
|
|
80
|
+
|
|
81
|
+
Kind kind() const { return fKind; }
|
|
82
|
+
|
|
83
|
+
bool isEquality() const {
|
|
84
|
+
return fKind == Kind::EQEQ || fKind == Kind::NEQ;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
Precedence getBinaryPrecedence() const;
|
|
88
|
+
|
|
89
|
+
// Returns the operator name surrounded by the expected whitespace for a tidy binary expression.
|
|
90
|
+
const char* operatorName() const;
|
|
91
|
+
|
|
92
|
+
// Returns the operator name without any surrounding whitespace.
|
|
93
|
+
std::string_view tightOperatorName() const;
|
|
94
|
+
|
|
95
|
+
// Returns true if op is '=' or any compound assignment operator ('+=', '-=', etc.)
|
|
96
|
+
bool isAssignment() const;
|
|
97
|
+
|
|
98
|
+
// Given a compound assignment operator, returns the non-assignment version of the operator
|
|
99
|
+
// (e.g. '+=' becomes '+')
|
|
100
|
+
Operator removeAssignment() const;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Defines the set of relational (comparison) operators:
|
|
104
|
+
* < <= > >=
|
|
105
|
+
*/
|
|
106
|
+
bool isRelational() const;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Defines the set of operators which are only valid on integral types:
|
|
110
|
+
* << <<= >> >>= & &= | |= ^ ^= % %=
|
|
111
|
+
*/
|
|
112
|
+
bool isOnlyValidForIntegralTypes() const;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Defines the set of operators which perform vector/matrix math.
|
|
116
|
+
* + += - -= * *= / /= % %= << <<= >> >>= & &= | |= ^ ^=
|
|
117
|
+
*/
|
|
118
|
+
bool isValidForMatrixOrVector() const;
|
|
119
|
+
|
|
120
|
+
/*
|
|
121
|
+
* Defines the set of operators allowed by The OpenGL ES Shading Language 1.00, Section 5.1.
|
|
122
|
+
* The set of illegal (reserved) operators are the ones that only make sense with integral
|
|
123
|
+
* types. This is not a coincidence: It's because ES2 doesn't require 'int' to be anything but
|
|
124
|
+
* syntactic sugar for floats with truncation after each operation.
|
|
125
|
+
*/
|
|
126
|
+
bool isAllowedInStrictES2Mode() const {
|
|
127
|
+
return !this->isOnlyValidForIntegralTypes();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Determines the operand and result types of a binary expression. Returns true if the
|
|
132
|
+
* expression is legal, false otherwise. If false, the values of the out parameters are
|
|
133
|
+
* undefined.
|
|
134
|
+
*/
|
|
135
|
+
bool determineBinaryType(const Context& context,
|
|
136
|
+
const Type& left,
|
|
137
|
+
const Type& right,
|
|
138
|
+
const Type** outLeftType,
|
|
139
|
+
const Type** outRightType,
|
|
140
|
+
const Type** outResultType) const;
|
|
141
|
+
|
|
142
|
+
private:
|
|
143
|
+
bool isOperator() const;
|
|
144
|
+
bool isMatrixMultiply(const Type& left, const Type& right) const;
|
|
145
|
+
|
|
146
|
+
Kind fKind;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
} // namespace SkSL
|
|
150
|
+
|
|
151
|
+
#endif
|