@shopify/react-native-skia 0.1.129 → 0.1.130

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +1 -0
  2. package/cpp/api/JsiSkRuntimeEffect.h +7 -9
  3. package/cpp/api/JsiSkVertices.h +0 -2
  4. package/cpp/rnskia/values/RNSkValue.h +1 -1
  5. package/cpp/skia/include/codec/SkCodec.h +7 -1
  6. package/cpp/skia/include/core/SkAlphaType.h +45 -0
  7. package/cpp/skia/include/core/SkBitmap.h +4 -2
  8. package/cpp/skia/include/core/SkCanvas.h +31 -20
  9. package/cpp/skia/include/core/SkColor.h +1 -1
  10. package/cpp/skia/include/core/SkColorFilter.h +1 -0
  11. package/cpp/skia/include/core/SkColorType.h +66 -0
  12. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +1 -1
  13. package/cpp/skia/include/core/SkDrawable.h +7 -0
  14. package/cpp/skia/include/core/SkEncodedImageFormat.h +1 -0
  15. package/cpp/skia/include/core/SkFont.h +4 -3
  16. package/cpp/skia/include/core/SkFontArguments.h +33 -1
  17. package/cpp/skia/include/core/SkGraphics.h +13 -0
  18. package/cpp/skia/include/core/SkImage.h +67 -22
  19. package/cpp/skia/include/core/SkImageEncoder.h +0 -3
  20. package/cpp/skia/include/core/SkImageGenerator.h +4 -3
  21. package/cpp/skia/include/core/SkImageInfo.h +35 -142
  22. package/cpp/skia/include/core/SkMesh.h +303 -0
  23. package/cpp/skia/include/core/SkMilestone.h +1 -1
  24. package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +30 -0
  25. package/cpp/skia/include/core/SkPaint.h +4 -19
  26. package/cpp/skia/include/core/SkPath.h +20 -33
  27. package/cpp/skia/include/core/SkPathBuilder.h +1 -6
  28. package/cpp/skia/include/core/SkPixelRef.h +1 -1
  29. package/cpp/skia/include/core/SkPixmap.h +3 -2
  30. package/cpp/skia/include/core/SkRSXform.h +1 -1
  31. package/cpp/skia/include/core/SkSamplingOptions.h +16 -5
  32. package/cpp/skia/include/core/SkSpan.h +5 -5
  33. package/cpp/skia/include/core/SkString.h +5 -8
  34. package/cpp/skia/include/core/SkSurface.h +21 -0
  35. package/cpp/skia/include/core/SkTypeface.h +20 -4
  36. package/cpp/skia/include/core/SkTypes.h +9 -5
  37. package/cpp/skia/include/effects/SkGradientShader.h +9 -18
  38. package/cpp/skia/include/effects/SkRuntimeEffect.h +16 -12
  39. package/cpp/skia/include/gpu/GpuTypes.h +32 -0
  40. package/cpp/skia/include/gpu/GrBackendSemaphore.h +1 -1
  41. package/cpp/skia/include/gpu/GrBackendSurface.h +6 -5
  42. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +1 -1
  43. package/cpp/skia/include/gpu/GrContextOptions.h +11 -20
  44. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +7 -0
  45. package/cpp/skia/include/gpu/GrDirectContext.h +16 -11
  46. package/cpp/skia/include/gpu/GrDriverBugWorkaroundsAutogen.h +0 -2
  47. package/cpp/skia/include/gpu/GrRecordingContext.h +14 -7
  48. package/cpp/skia/include/gpu/GrSurfaceInfo.h +6 -6
  49. package/cpp/skia/include/gpu/dawn/GrDawnTypes.h +1 -1
  50. package/cpp/skia/include/gpu/gl/GrGLFunctions.h +3 -1
  51. package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -2
  52. package/cpp/skia/include/gpu/graphite/BackendTexture.h +64 -0
  53. package/cpp/skia/include/gpu/graphite/Context.h +124 -0
  54. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +71 -0
  55. package/cpp/skia/include/gpu/graphite/Recorder.h +104 -0
  56. package/cpp/skia/include/gpu/graphite/Recording.h +39 -0
  57. package/cpp/skia/include/gpu/graphite/SkStuff.h +47 -0
  58. package/cpp/skia/include/gpu/graphite/TextureInfo.h +91 -0
  59. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +24 -0
  60. package/cpp/skia/include/gpu/graphite/mtl/MtlTypes.h +68 -0
  61. package/cpp/skia/include/gpu/mock/GrMockTypes.h +1 -2
  62. package/cpp/skia/include/ports/SkCFObject.h +0 -4
  63. package/cpp/skia/include/ports/SkTypeface_win.h +2 -2
  64. package/cpp/skia/include/private/{GrSingleOwner.h → SingleOwner.h} +17 -10
  65. package/cpp/skia/include/private/SkChecksum.h +11 -0
  66. package/cpp/skia/include/private/SkEncodedInfo.h +22 -5
  67. package/cpp/skia/include/private/SkFloatingPoint.h +0 -53
  68. package/cpp/skia/include/private/SkImageInfoPriv.h +8 -2
  69. package/cpp/skia/include/private/SkMacros.h +13 -18
  70. package/cpp/skia/include/private/SkMutex.h +8 -0
  71. package/cpp/skia/include/private/SkPathRef.h +2 -16
  72. package/cpp/skia/include/private/SkSLDefines.h +9 -1
  73. package/cpp/skia/include/private/SkSLIRNode.h +6 -5
  74. package/cpp/skia/include/private/SkSLLayout.h +11 -10
  75. package/cpp/skia/include/private/SkSLModifiers.h +4 -3
  76. package/cpp/skia/include/private/SkSLProgramElement.h +2 -2
  77. package/cpp/skia/include/private/SkSLProgramKind.h +8 -5
  78. package/cpp/skia/include/private/SkSLStatement.h +2 -3
  79. package/cpp/skia/include/private/SkSLString.h +17 -56
  80. package/cpp/skia/include/private/SkSLSymbol.h +4 -4
  81. package/cpp/skia/include/private/SkShadowFlags.h +3 -1
  82. package/cpp/skia/include/private/SkStringView.h +47 -0
  83. package/cpp/skia/include/private/SkTArray.h +4 -3
  84. package/cpp/skia/include/private/SkTHash.h +66 -24
  85. package/cpp/skia/include/private/SkTLogic.h +2 -32
  86. package/cpp/skia/include/private/SkTemplates.h +2 -2
  87. package/cpp/skia/include/private/SkThreadAnnotations.h +4 -4
  88. package/cpp/skia/include/private/SkVx.h +28 -28
  89. package/cpp/skia/include/private/chromium/GrSlug.h +40 -3
  90. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +12 -6
  91. package/cpp/skia/include/private/{GrContext_Base.h → gpu/ganesh/GrContext_Base.h} +7 -0
  92. package/cpp/skia/include/private/{GrD3DTypesMinimal.h → gpu/ganesh/GrD3DTypesMinimal.h} +0 -0
  93. package/cpp/skia/include/private/{GrDawnTypesPriv.h → gpu/ganesh/GrDawnTypesPriv.h} +0 -0
  94. package/cpp/skia/include/private/{GrGLTypesPriv.h → gpu/ganesh/GrGLTypesPriv.h} +1 -0
  95. package/cpp/skia/include/private/{GrImageContext.h → gpu/ganesh/GrImageContext.h} +4 -4
  96. package/cpp/skia/include/private/{GrMockTypesPriv.h → gpu/ganesh/GrMockTypesPriv.h} +0 -0
  97. package/cpp/skia/include/private/{GrMtlTypesPriv.h → gpu/ganesh/GrMtlTypesPriv.h} +0 -0
  98. package/cpp/skia/include/private/{GrTypesPriv.h → gpu/ganesh/GrTypesPriv.h} +25 -367
  99. package/cpp/skia/include/private/{GrVkTypesPriv.h → gpu/ganesh/GrVkTypesPriv.h} +0 -0
  100. package/cpp/skia/include/private/gpu/graphite/MtlTypesPriv.h +74 -0
  101. package/cpp/skia/include/sksl/DSL.h +4 -0
  102. package/cpp/skia/include/sksl/DSLBlock.h +8 -3
  103. package/cpp/skia/include/sksl/DSLCase.h +6 -6
  104. package/cpp/skia/include/sksl/DSLCore.h +89 -78
  105. package/cpp/skia/include/sksl/DSLExpression.h +78 -45
  106. package/cpp/skia/include/sksl/DSLFunction.h +23 -18
  107. package/cpp/skia/include/sksl/DSLLayout.h +14 -16
  108. package/cpp/skia/include/sksl/DSLModifiers.h +7 -5
  109. package/cpp/skia/include/sksl/DSLRuntimeEffects.h +1 -1
  110. package/cpp/skia/include/sksl/DSLStatement.h +16 -10
  111. package/cpp/skia/include/sksl/DSLSymbols.h +7 -7
  112. package/cpp/skia/include/sksl/DSLType.h +27 -23
  113. package/cpp/skia/include/sksl/DSLVar.h +72 -61
  114. package/cpp/skia/include/sksl/SkSLErrorReporter.h +12 -49
  115. package/cpp/skia/include/sksl/SkSLOperator.h +151 -0
  116. package/cpp/skia/include/sksl/SkSLPosition.h +102 -0
  117. package/cpp/skia/include/svg/SkSVGCanvas.h +5 -1
  118. package/cpp/skia/include/utils/SkAnimCodecPlayer.h +7 -0
  119. package/cpp/skia/include/utils/SkCamera.h +2 -0
  120. package/cpp/skia/include/utils/SkCanvasStateUtils.h +4 -1
  121. package/cpp/skia/include/utils/SkCustomTypeface.h +6 -4
  122. package/cpp/skia/include/utils/SkNWayCanvas.h +34 -0
  123. package/cpp/skia/include/utils/SkNullCanvas.h +5 -1
  124. package/cpp/skia/include/utils/SkOrderedFontMgr.h +12 -0
  125. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +30 -1
  126. package/cpp/skia/include/utils/SkParse.h +2 -0
  127. package/cpp/skia/include/utils/SkShadowUtils.h +3 -2
  128. package/cpp/skia/include/utils/SkTextUtils.h +8 -4
  129. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +27 -1
  130. package/cpp/skia/modules/svg/include/SkSVGDOM.h +4 -0
  131. package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +32 -0
  132. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
  133. package/cpp/skia/modules/svg/include/SkSVGSVG.h +2 -0
  134. package/cpp/skia/modules/svg/include/SkSVGTypes.h +48 -9
  135. package/ios/RNSkia-iOS/PlatformContext.h +1 -1
  136. package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +1 -0
  137. package/ios/RNSkia-iOS/SkiaDrawView.mm +1 -1
  138. package/lib/commonjs/renderer/components/shaders/Shader.js +1 -2
  139. package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
  140. package/lib/module/renderer/components/shaders/Shader.js +1 -2
  141. package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
  142. package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +0 -1
  143. package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +2 -4
  144. package/libs/android/arm64-v8a/libskia.a +0 -0
  145. package/libs/android/arm64-v8a/libsvg.a +0 -0
  146. package/libs/android/armeabi-v7a/libskia.a +0 -0
  147. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  148. package/libs/android/x86/libskia.a +0 -0
  149. package/libs/android/x86/libsvg.a +0 -0
  150. package/libs/android/x86_64/libskia.a +0 -0
  151. package/libs/android/x86_64/libsvg.a +0 -0
  152. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  153. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  154. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  155. package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
  156. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  157. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  158. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  159. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  160. package/package.json +2 -2
  161. package/src/renderer/components/shaders/Shader.tsx +1 -3
  162. package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -8
  163. package/cpp/skia/include/core/SkCustomMesh.h +0 -202
  164. package/cpp/skia/include/core/SkStringView.h +0 -185
  165. package/cpp/skia/include/private/SkPaintParamsKey.h +0 -110
  166. package/cpp/skia/include/private/SkShaderCodeDictionary.h +0 -63
  167. package/cpp/skia/include/private/SkTOptional.h +0 -362
@@ -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(skstd::string_view name);
91
+ DSLType(std::string_view name, Position pos = {});
89
92
 
90
- DSLType(skstd::string_view name,
93
+ DSLType(std::string_view name,
91
94
  DSLModifiers* modifiers,
92
- PositionInfo pos = PositionInfo::Capture());
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, PositionInfo pos);
176
- friend DSLType Struct(skstd::string_view name, SkSpan<DSLField> fields, PositionInfo pos);
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, PositionInfo pos = PositionInfo::Capture());
225
+ DSLType Array(const DSLType& base, int count, Position pos = {});
222
226
 
223
227
  class DSLField {
224
228
  public:
225
- DSLField(const DSLType type, skstd::string_view name,
226
- PositionInfo pos = PositionInfo::Capture())
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, skstd::string_view name,
230
- PositionInfo pos = PositionInfo::Capture())
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
- skstd::string_view fName;
240
- PositionInfo fPosition;
243
+ std::string_view fName;
244
+ Position fPosition;
241
245
 
242
246
  friend class DSLCore;
243
- friend DSLType Struct(skstd::string_view name, SkSpan<DSLField> fields, PositionInfo pos);
247
+ friend DSLType Struct(std::string_view name, SkSpan<DSLField> fields, Position pos);
244
248
  };
245
249
 
246
- DSLType Struct(skstd::string_view name, SkSpan<DSLField> fields,
247
- PositionInfo pos = PositionInfo::Capture());
250
+ DSLType Struct(std::string_view name, SkSpan<DSLField> fields,
251
+ Position pos = {});
248
252
 
249
253
  template<typename... Field>
250
- DSLType Struct(skstd::string_view name, Field... fields) {
254
+ DSLType Struct(std::string_view name, Field... fields) {
251
255
  DSLField fieldTypes[] = {std::move(fields)...};
252
- return Struct(name, SkMakeSpan(fieldTypes), PositionInfo());
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, skstd::string_view name, DSLExpression initialValue, PositionInfo pos);
46
+ DSLVarBase(DSLType type, std::string_view name, DSLExpression initialValue, Position pos,
47
+ Position namePos);
39
48
 
40
- DSLVarBase(DSLType type, DSLExpression initialValue, PositionInfo pos);
49
+ DSLVarBase(DSLType type, DSLExpression initialValue, Position pos, Position namePos);
41
50
 
42
- DSLVarBase(const DSLModifiers& modifiers, DSLType type, skstd::string_view name,
43
- DSLExpression initialValue, PositionInfo pos);
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
- PositionInfo pos);
55
+ Position pos, Position namePos);
47
56
 
48
57
  DSLVarBase(DSLVarBase&&) = default;
49
58
 
50
59
  virtual ~DSLVarBase();
51
60
 
52
- skstd::string_view name() const {
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, PositionInfo()).x();
72
+ return DSLExpression(*this, Position()).x();
64
73
  }
65
74
 
66
75
  DSLExpression y() {
67
- return DSLExpression(*this, PositionInfo()).y();
76
+ return DSLExpression(*this, Position()).y();
68
77
  }
69
78
 
70
79
  DSLExpression z() {
71
- return DSLExpression(*this, PositionInfo()).z();
80
+ return DSLExpression(*this, Position()).z();
72
81
  }
73
82
 
74
83
  DSLExpression w() {
75
- return DSLExpression(*this, PositionInfo()).w();
84
+ return DSLExpression(*this, Position()).w();
76
85
  }
77
86
 
78
87
  DSLExpression r() {
79
- return DSLExpression(*this, PositionInfo()).r();
88
+ return DSLExpression(*this, Position()).r();
80
89
  }
81
90
 
82
91
  DSLExpression g() {
83
- return DSLExpression(*this, PositionInfo()).g();
92
+ return DSLExpression(*this, Position()).g();
84
93
  }
85
94
 
86
95
  DSLExpression b() {
87
- return DSLExpression(*this, PositionInfo()).b();
96
+ return DSLExpression(*this, Position()).b();
88
97
  }
89
98
 
90
99
  DSLExpression a() {
91
- return DSLExpression(*this, PositionInfo()).a();
100
+ return DSLExpression(*this, Position()).a();
92
101
  }
93
102
 
94
- DSLExpression field(skstd::string_view name) {
95
- return DSLExpression(*this, PositionInfo()).field(name);
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, PositionInfo());
110
+ return ++DSLExpression(*this, Position());
102
111
  }
103
112
 
104
113
  DSLPossibleExpression operator++(int) {
105
- return DSLExpression(*this, PositionInfo())++;
114
+ return DSLExpression(*this, Position())++;
106
115
  }
107
116
 
108
117
  DSLPossibleExpression operator--() {
109
- return --DSLExpression(*this, PositionInfo());
118
+ return --DSLExpression(*this, Position());
110
119
  }
111
120
 
112
121
  DSLPossibleExpression operator--(int) {
113
- return DSLExpression(*this, PositionInfo())--;
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
- skstd::string_view fRawName; // for error reporting
131
- skstd::string_view fName;
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
- PositionInfo fPosition;
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, skstd::string_view name = "var",
163
+ DSLVar(DSLType type, std::string_view name = "var",
154
164
  DSLExpression initialValue = DSLExpression(),
155
- PositionInfo pos = PositionInfo::Capture())
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
- PositionInfo pos = PositionInfo::Capture())
160
- : DSLVar(type, skstd::string_view(name), std::move(initialValue), pos) {}
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, PositionInfo pos = PositionInfo::Capture())
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, skstd::string_view name = "var",
166
- DSLExpression initialValue = DSLExpression(), PositionInfo pos = PositionInfo::Capture())
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(), PositionInfo pos = PositionInfo::Capture())
171
- : DSLVar(modifiers, type, skstd::string_view(name), std::move(initialValue), pos) {}
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, skstd::string_view name = "var",
202
- DSLExpression initialValue = DSLExpression(), PositionInfo pos = PositionInfo::Capture())
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
- PositionInfo pos = PositionInfo::Capture())
207
- : DSLGlobalVar(type, skstd::string_view(name), std::move(initialValue), pos) {}
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
- PositionInfo pos = PositionInfo::Capture())
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, skstd::string_view name = "var",
214
- DSLExpression initialValue = DSLExpression(), PositionInfo pos = PositionInfo::Capture())
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(), PositionInfo pos = PositionInfo::Capture())
219
- : DSLGlobalVar(modifiers, type, skstd::string_view(name), std::move(initialValue), pos) {}
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, PositionInfo pos = PositionInfo::Capture());
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
- PositionInfo pos = PositionInfo::Capture());
263
+ Position pos = {});
253
264
 
254
265
  private:
255
- DSLExpression eval(ExpressionArray args, PositionInfo pos);
266
+ DSLExpression eval(ExpressionArray args, Position pos);
256
267
 
257
- std::unique_ptr<SkSL::Expression> methodCall(skstd::string_view methodName, PositionInfo pos);
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, skstd::string_view name = "var",
270
- PositionInfo pos = PositionInfo::Capture())
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, PositionInfo pos = PositionInfo::Capture())
274
- : DSLParameter(type, skstd::string_view(name), pos) {}
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, skstd::string_view name = "var",
277
- PositionInfo pos = PositionInfo::Capture())
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
- PositionInfo pos = PositionInfo::Capture())
282
- : DSLParameter(modifiers, type, skstd::string_view(name), pos) {}
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
- #ifndef __has_builtin
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(skstd::string_view msg, PositionInfo position);
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(int line, skstd::string_view msg);
38
+ void error(Position pos, std::string_view msg);
69
39
 
70
- const char* source() const { return fSource; }
40
+ std::string_view source() const { return fSource; }
71
41
 
72
- void setSource(const char* source) { fSource = source; }
42
+ void setSource(std::string_view source) { fSource = source; }
73
43
 
74
- void reportPendingErrors(PositionInfo pos) {
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(skstd::string_view msg, PositionInfo position) = 0;
58
+ virtual void handleError(std::string_view msg, Position position) = 0;
94
59
 
95
60
  private:
96
- PositionInfo position(int offset) const;
61
+ Position position(int offset) const;
97
62
 
98
- const char* fSource = nullptr;
99
- std::vector<String> fPendingErrors;
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(skstd::string_view msg, PositionInfo pos) override {
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