@shopify/react-native-skia 0.1.154 → 0.1.156

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/android/cpp/jni/JniLoad.cpp +5 -5
  2. package/android/cpp/jni/JniPlatformContext.cpp +107 -119
  3. package/android/cpp/jni/JniSkiaManager.cpp +18 -20
  4. package/android/cpp/jni/include/JniPlatformContext.h +41 -45
  5. package/android/cpp/jni/include/JniSkiaBaseView.h +52 -55
  6. package/android/cpp/jni/include/JniSkiaDrawView.h +72 -77
  7. package/android/cpp/jni/include/JniSkiaManager.h +51 -53
  8. package/android/cpp/jni/include/JniSkiaPictureView.h +74 -78
  9. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +36 -45
  10. package/android/cpp/rnskia-android/RNSkAndroidView.h +87 -92
  11. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +62 -65
  12. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +20 -17
  13. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +257 -313
  14. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +107 -110
  15. package/cpp/api/JsiSkApi.h +66 -62
  16. package/cpp/api/JsiSkCanvas.h +38 -30
  17. package/cpp/api/JsiSkColor.h +58 -56
  18. package/cpp/api/JsiSkColorFilter.h +5 -3
  19. package/cpp/api/JsiSkColorFilterFactory.h +23 -21
  20. package/cpp/api/JsiSkContourMeasure.h +74 -85
  21. package/cpp/api/JsiSkContourMeasureIter.h +68 -75
  22. package/cpp/api/JsiSkData.h +16 -22
  23. package/cpp/api/JsiSkDataFactory.h +86 -79
  24. package/cpp/api/JsiSkFont.h +286 -311
  25. package/cpp/api/JsiSkHostObjects.h +15 -16
  26. package/cpp/api/JsiSkImage.h +107 -103
  27. package/cpp/api/JsiSkImageFactory.h +34 -36
  28. package/cpp/api/JsiSkImageFilter.h +5 -3
  29. package/cpp/api/JsiSkImageFilterFactory.h +71 -68
  30. package/cpp/api/JsiSkImageInfo.h +41 -38
  31. package/cpp/api/JsiSkMaskFilter.h +5 -3
  32. package/cpp/api/JsiSkMaskFilterFactory.h +2 -3
  33. package/cpp/api/JsiSkMatrix.h +26 -36
  34. package/cpp/api/JsiSkPaint.h +20 -13
  35. package/cpp/api/JsiSkPath.h +70 -85
  36. package/cpp/api/JsiSkPathEffect.h +5 -3
  37. package/cpp/api/JsiSkPathEffectFactory.h +33 -28
  38. package/cpp/api/JsiSkPathFactory.h +68 -67
  39. package/cpp/api/JsiSkPicture.h +28 -22
  40. package/cpp/api/JsiSkPictureFactory.h +13 -12
  41. package/cpp/api/JsiSkPictureRecorder.h +21 -19
  42. package/cpp/api/JsiSkPoint.h +6 -8
  43. package/cpp/api/JsiSkRRect.h +11 -7
  44. package/cpp/api/JsiSkRSXform.h +82 -85
  45. package/cpp/api/JsiSkRect.h +9 -9
  46. package/cpp/api/JsiSkRuntimeEffect.h +182 -186
  47. package/cpp/api/JsiSkRuntimeEffectFactory.h +10 -11
  48. package/cpp/api/JsiSkRuntimeShaderBuilder.h +64 -61
  49. package/cpp/api/JsiSkSVG.h +4 -5
  50. package/cpp/api/JsiSkSVGFactory.h +28 -27
  51. package/cpp/api/JsiSkShader.h +3 -2
  52. package/cpp/api/JsiSkShaderFactory.h +37 -25
  53. package/cpp/api/JsiSkSurface.h +44 -40
  54. package/cpp/api/JsiSkSurfaceFactory.h +22 -22
  55. package/cpp/api/JsiSkTextBlob.h +28 -31
  56. package/cpp/api/JsiSkTextBlobFactory.h +88 -87
  57. package/cpp/api/JsiSkTypeface.h +6 -5
  58. package/cpp/api/JsiSkTypefaceFactory.h +22 -21
  59. package/cpp/api/JsiSkVertices.h +137 -124
  60. package/cpp/api/third_party/CSSColorParser.cpp +161 -174
  61. package/cpp/api/third_party/CSSColorParser.h +172 -96
  62. package/cpp/jsi/JsiHostObject.cpp +11 -9
  63. package/cpp/jsi/JsiHostObject.h +31 -24
  64. package/cpp/jsi/JsiSimpleValueWrapper.h +74 -83
  65. package/cpp/jsi/JsiValueWrapper.h +52 -54
  66. package/cpp/rnskia/RNSkAnimation.h +26 -29
  67. package/cpp/rnskia/RNSkDispatchQueue.cpp +50 -61
  68. package/cpp/rnskia/RNSkDispatchQueue.h +3 -1
  69. package/cpp/rnskia/RNSkInfoParameter.h +12 -12
  70. package/cpp/rnskia/RNSkJsView.cpp +82 -81
  71. package/cpp/rnskia/RNSkJsView.h +45 -41
  72. package/cpp/rnskia/RNSkJsiViewApi.h +99 -89
  73. package/cpp/rnskia/RNSkManager.cpp +8 -7
  74. package/cpp/rnskia/RNSkManager.h +8 -6
  75. package/cpp/rnskia/RNSkPictureView.h +44 -37
  76. package/cpp/rnskia/RNSkPlatformContext.h +39 -28
  77. package/cpp/rnskia/RNSkValueApi.h +33 -34
  78. package/cpp/rnskia/RNSkView.h +108 -93
  79. package/cpp/rnskia/values/RNSkClockValue.h +63 -64
  80. package/cpp/rnskia/values/RNSkComputedValue.h +32 -30
  81. package/cpp/rnskia/values/RNSkReadonlyValue.h +60 -59
  82. package/cpp/rnskia/values/RNSkValue.h +38 -40
  83. package/cpp/utils/RNSkLog.h +9 -7
  84. package/cpp/utils/RNSkMeasureTime.h +7 -7
  85. package/cpp/utils/RNSkTimingInfo.h +27 -24
  86. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +8 -9
  87. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +24 -23
  88. package/ios/RNSkia-iOS/RNSkiOSView.h +16 -13
  89. package/ios/RNSkia-iOS/SkiaUIView.h +9 -8
  90. package/lib/commonjs/dom/nodes/JsiSkDOM.js +6 -0
  91. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  92. package/lib/commonjs/dom/nodes/LayerNode.js +43 -0
  93. package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -0
  94. package/lib/commonjs/dom/nodes/RenderNode.js +1 -1
  95. package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
  96. package/lib/commonjs/dom/types/NodeType.js +1 -0
  97. package/lib/commonjs/dom/types/NodeType.js.map +1 -1
  98. package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
  99. package/lib/commonjs/renderer/HostComponents.js +3 -0
  100. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  101. package/lib/commonjs/renderer/components/Group.js +19 -4
  102. package/lib/commonjs/renderer/components/Group.js.map +1 -1
  103. package/lib/commonjs/renderer/components/Paint.js +6 -1
  104. package/lib/commonjs/renderer/components/Paint.js.map +1 -1
  105. package/lib/commonjs/views/SkiaPictureView.js +3 -2
  106. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  107. package/lib/commonjs/views/SkiaView.js +6 -3
  108. package/lib/commonjs/views/SkiaView.js.map +1 -1
  109. package/lib/module/dom/nodes/JsiSkDOM.js +5 -0
  110. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  111. package/lib/module/dom/nodes/LayerNode.js +32 -0
  112. package/lib/module/dom/nodes/LayerNode.js.map +1 -0
  113. package/lib/module/dom/nodes/RenderNode.js +1 -1
  114. package/lib/module/dom/nodes/RenderNode.js.map +1 -1
  115. package/lib/module/dom/types/NodeType.js +1 -0
  116. package/lib/module/dom/types/NodeType.js.map +1 -1
  117. package/lib/module/dom/types/SkDOM.js.map +1 -1
  118. package/lib/module/renderer/HostComponents.js +3 -0
  119. package/lib/module/renderer/HostComponents.js.map +1 -1
  120. package/lib/module/renderer/components/Group.js +16 -3
  121. package/lib/module/renderer/components/Group.js.map +1 -1
  122. package/lib/module/renderer/components/Paint.js +7 -1
  123. package/lib/module/renderer/components/Paint.js.map +1 -1
  124. package/lib/module/views/SkiaPictureView.js +2 -2
  125. package/lib/module/views/SkiaPictureView.js.map +1 -1
  126. package/lib/module/views/SkiaView.js +4 -2
  127. package/lib/module/views/SkiaView.js.map +1 -1
  128. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -0
  129. package/lib/typescript/src/dom/nodes/LayerNode.d.ts +8 -0
  130. package/lib/typescript/src/dom/types/NodeType.d.ts +1 -0
  131. package/lib/typescript/src/dom/types/SkDOM.d.ts +1 -0
  132. package/lib/typescript/src/renderer/HostComponents.d.ts +2 -1
  133. package/lib/typescript/src/renderer/components/Group.d.ts +5 -1
  134. package/lib/typescript/src/views/SkiaView.d.ts +3 -0
  135. package/libs/android/arm64-v8a/libskottie.a +0 -0
  136. package/libs/android/arm64-v8a/libsksg.a +0 -0
  137. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  138. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  139. package/libs/android/x86/libskottie.a +0 -0
  140. package/libs/android/x86/libsksg.a +0 -0
  141. package/libs/android/x86_64/libskottie.a +0 -0
  142. package/libs/android/x86_64/libsksg.a +0 -0
  143. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  144. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  145. package/libs/ios/libskottie.xcframework/Info.plist +42 -0
  146. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  147. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  148. package/libs/ios/libsksg.xcframework/Info.plist +42 -0
  149. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  150. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  151. package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
  152. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  153. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  154. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  155. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  156. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  157. package/package.json +3 -1
  158. package/src/dom/nodes/JsiSkDOM.ts +5 -0
  159. package/src/dom/nodes/LayerNode.ts +35 -0
  160. package/src/dom/nodes/RenderNode.ts +4 -3
  161. package/src/dom/types/NodeType.ts +1 -0
  162. package/src/dom/types/SkDOM.ts +1 -0
  163. package/src/renderer/HostComponents.ts +3 -0
  164. package/src/renderer/components/Group.tsx +16 -3
  165. package/src/renderer/components/Paint.tsx +7 -1
  166. package/src/views/SkiaPictureView.tsx +2 -3
  167. package/src/views/SkiaView.tsx +2 -2
@@ -12,18 +12,18 @@
12
12
  #pragma clang diagnostic push
13
13
  #pragma clang diagnostic ignored "-Wdocumentation"
14
14
 
15
+ #include "include/effects/Sk1DPathEffect.h"
16
+ #include "include/effects/Sk2DPathEffect.h"
15
17
  #include <SkCornerPathEffect.h>
16
18
  #include <SkDashPathEffect.h>
17
19
  #include <SkDiscretePathEffect.h>
18
20
  #include <SkPathEffect.h>
19
- #include "include/effects/Sk1DPathEffect.h"
20
- #include "include/effects/Sk2DPathEffect.h"
21
21
 
22
22
  #pragma clang diagnostic pop
23
23
 
24
24
  namespace RNSkia {
25
25
 
26
- using namespace facebook;
26
+ namespace jsi = facebook::jsi;
27
27
 
28
28
  class JsiSkPathEffectFactory : public JsiSkHostObject {
29
29
  public:
@@ -36,14 +36,17 @@ public:
36
36
 
37
37
  JSI_HOST_FUNCTION(MakeDash) {
38
38
  auto jsiIntervals = arguments[0].asObject(runtime).asArray(runtime);
39
- auto size = (int)jsiIntervals.size(runtime);
39
+ auto size = static_cast<int>(jsiIntervals.size(runtime));
40
40
  std::vector<SkScalar> intervals;
41
41
  intervals.reserve(size);
42
42
  for (int i = 0; i < size; i++) {
43
43
  SkScalar interval = jsiIntervals.getValueAtIndex(runtime, i).asNumber();
44
44
  intervals.push_back(interval);
45
45
  }
46
- int phase = count >= 2 && !arguments[1].isUndefined() && !arguments[1].isNull() ? arguments[1].asNumber() : 0;
46
+ int phase =
47
+ count >= 2 && !arguments[1].isUndefined() && !arguments[1].isNull()
48
+ ? arguments[1].asNumber()
49
+ : 0;
47
50
  return jsi::Object::createFromHostObject(
48
51
  runtime, std::make_shared<JsiSkPathEffect>(
49
52
  getContext(),
@@ -65,8 +68,9 @@ public:
65
68
  auto inner = JsiSkPathEffect::fromValue(runtime, arguments[1]);
66
69
 
67
70
  return jsi::Object::createFromHostObject(
68
- runtime, std::make_shared<JsiSkPathEffect>(
69
- getContext(), SkPathEffect::MakeCompose(std::move(outer), std::move(inner))));
71
+ runtime, std::make_shared<JsiSkPathEffect>(
72
+ getContext(), SkPathEffect::MakeCompose(
73
+ std::move(outer), std::move(inner))));
70
74
  }
71
75
 
72
76
  JSI_HOST_FUNCTION(MakeSum) {
@@ -74,26 +78,29 @@ public:
74
78
  auto inner = JsiSkPathEffect::fromValue(runtime, arguments[1]);
75
79
 
76
80
  return jsi::Object::createFromHostObject(
77
- runtime, std::make_shared<JsiSkPathEffect>(
78
- getContext(), SkPathEffect::MakeSum(std::move(outer), std::move(inner))));
81
+ runtime, std::make_shared<JsiSkPathEffect>(
82
+ getContext(), SkPathEffect::MakeSum(std::move(outer),
83
+ std::move(inner))));
79
84
  }
80
85
 
81
86
  JSI_HOST_FUNCTION(MakePath1D) {
82
87
  auto path = JsiSkPath::fromValue(runtime, arguments[0]);
83
88
  auto advance = arguments[1].asNumber();
84
89
  auto phase = arguments[2].asNumber();
85
- auto style = static_cast<SkPath1DPathEffect::Style>(arguments[3].asNumber());
90
+ auto style =
91
+ static_cast<SkPath1DPathEffect::Style>(arguments[3].asNumber());
86
92
  return jsi::Object::createFromHostObject(
87
- runtime, std::make_shared<JsiSkPathEffect>(
88
- getContext(), SkPath1DPathEffect::Make(*path, advance, phase, style)));
93
+ runtime, std::make_shared<JsiSkPathEffect>(
94
+ getContext(),
95
+ SkPath1DPathEffect::Make(*path, advance, phase, style)));
89
96
  }
90
97
 
91
98
  JSI_HOST_FUNCTION(MakePath2D) {
92
99
  auto matrix = JsiSkMatrix::fromValue(runtime, arguments[0]);
93
100
  auto path = JsiSkPath::fromValue(runtime, arguments[1]);
94
101
  return jsi::Object::createFromHostObject(
95
- runtime, std::make_shared<JsiSkPathEffect>(
96
- getContext(), SkPath2DPathEffect::Make(*matrix, *path)));
102
+ runtime, std::make_shared<JsiSkPathEffect>(
103
+ getContext(), SkPath2DPathEffect::Make(*matrix, *path)));
97
104
  }
98
105
 
99
106
  JSI_HOST_FUNCTION(MakeLine2D) {
@@ -101,22 +108,20 @@ public:
101
108
  auto matrix = JsiSkMatrix::fromValue(runtime, arguments[1]);
102
109
 
103
110
  return jsi::Object::createFromHostObject(
104
- runtime, std::make_shared<JsiSkPathEffect>(
105
- getContext(), SkLine2DPathEffect::Make(width, *matrix)));
111
+ runtime, std::make_shared<JsiSkPathEffect>(
112
+ getContext(), SkLine2DPathEffect::Make(width, *matrix)));
106
113
  }
107
114
 
108
- JSI_EXPORT_FUNCTIONS(
109
- JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeCorner),
110
- JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeDash),
111
- JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeDiscrete),
112
- JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeCompose),
113
- JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeSum),
114
- JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeLine2D),
115
- JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakePath1D),
116
- JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakePath2D),
117
- )
118
-
119
- JsiSkPathEffectFactory(std::shared_ptr<RNSkPlatformContext> context)
115
+ JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeCorner),
116
+ JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeDash),
117
+ JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeDiscrete),
118
+ JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeCompose),
119
+ JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeSum),
120
+ JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakeLine2D),
121
+ JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakePath1D),
122
+ JSI_EXPORT_FUNC(JsiSkPathEffectFactory, MakePath2D), )
123
+
124
+ explicit JsiSkPathEffectFactory(std::shared_ptr<RNSkPlatformContext> context)
120
125
  : JsiSkHostObject(std::move(context)) {}
121
126
  };
122
127
 
@@ -11,15 +11,15 @@
11
11
  #pragma clang diagnostic push
12
12
  #pragma clang diagnostic ignored "-Wdocumentation"
13
13
 
14
+ #include <RNSkLog.h>
14
15
  #include <SkPath.h>
15
16
  #include <SkPathOps.h>
16
- #include <RNSkLog.h>
17
17
 
18
18
  #pragma clang diagnostic pop
19
19
 
20
20
  namespace RNSkia {
21
21
 
22
- using namespace facebook;
22
+ namespace jsi = facebook::jsi;
23
23
 
24
24
  class JsiSkPathFactory : public JsiSkHostObject {
25
25
 
@@ -67,84 +67,85 @@ public:
67
67
  auto cmds = arguments[0].asObject(runtime).asArray(runtime);
68
68
  auto cmdCount = cmds.size(runtime);
69
69
  for (int i = 0; i < cmdCount; i++) {
70
- auto cmd = cmds.getValueAtIndex(runtime, i).asObject(runtime).asArray(runtime);
70
+ auto cmd =
71
+ cmds.getValueAtIndex(runtime, i).asObject(runtime).asArray(runtime);
71
72
  if (cmd.size(runtime) < 1) {
72
73
  RNSkLogger::logToConsole("Invalid command found (got an empty array)");
73
74
  return jsi::Value::null();
74
75
  }
75
76
  auto verb = static_cast<int>(cmd.getValueAtIndex(runtime, 0).asNumber());
76
77
  switch (verb) {
77
- case MOVE: {
78
- if (cmd.size(runtime) < 3) {
79
- RNSkLogger::logToConsole( "Invalid move command found");
80
- return jsi::Value::null();
81
- }
82
- auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
83
- auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
84
- path.moveTo(x, y);
85
- break;
86
- }
87
- case LINE: {
88
- if (cmd.size(runtime) < 3) {
89
- RNSkLogger::logToConsole("Invalid line command found");
90
- return jsi::Value::null();
91
- }
92
- auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
93
- auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
94
- path.lineTo(x, y);
95
- break;
96
- }
97
- case QUAD: {
98
- if (cmd.size(runtime) < 5) {
99
- RNSkLogger::logToConsole("Invalid line command found");
100
- return jsi::Value::null();
101
- }
102
- auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
103
- auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
104
- auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
105
- auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
106
- path.quadTo(x1, y1, x2, y2);
107
- break;
78
+ case MOVE: {
79
+ if (cmd.size(runtime) < 3) {
80
+ RNSkLogger::logToConsole("Invalid move command found");
81
+ return jsi::Value::null();
108
82
  }
109
- case CONIC: {
110
- if (cmd.size(runtime) < 6) {
111
- RNSkLogger::logToConsole("Invalid line command found");
112
- return jsi::Value::null();
113
- }
114
- auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
115
- auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
116
- auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
117
- auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
118
- auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
119
- path.conicTo(x1, y1, x2, y2, w);
120
- break;
83
+ auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
84
+ auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
85
+ path.moveTo(x, y);
86
+ break;
87
+ }
88
+ case LINE: {
89
+ if (cmd.size(runtime) < 3) {
90
+ RNSkLogger::logToConsole("Invalid line command found");
91
+ return jsi::Value::null();
121
92
  }
122
- case CUBIC: {
123
- if (cmd.size(runtime) < 7) {
124
- RNSkLogger::logToConsole("Invalid line command found");
125
- return jsi::Value::null();
126
- }
127
- auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
128
- auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
129
- auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
130
- auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
131
- auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
132
- auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
133
- path.cubicTo(x1, y1, x2, y2, x3, y3);
134
- break;
93
+ auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
94
+ auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
95
+ path.lineTo(x, y);
96
+ break;
97
+ }
98
+ case QUAD: {
99
+ if (cmd.size(runtime) < 5) {
100
+ RNSkLogger::logToConsole("Invalid line command found");
101
+ return jsi::Value::null();
135
102
  }
136
- case CLOSE: {
137
- path.close();
138
- break;
103
+ auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
104
+ auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
105
+ auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
106
+ auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
107
+ path.quadTo(x1, y1, x2, y2);
108
+ break;
109
+ }
110
+ case CONIC: {
111
+ if (cmd.size(runtime) < 6) {
112
+ RNSkLogger::logToConsole("Invalid line command found");
113
+ return jsi::Value::null();
139
114
  }
140
- default: {
141
- RNSkLogger::logToConsole("Found an unknown command");
115
+ auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
116
+ auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
117
+ auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
118
+ auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
119
+ auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
120
+ path.conicTo(x1, y1, x2, y2, w);
121
+ break;
122
+ }
123
+ case CUBIC: {
124
+ if (cmd.size(runtime) < 7) {
125
+ RNSkLogger::logToConsole("Invalid line command found");
142
126
  return jsi::Value::null();
143
127
  }
128
+ auto x1 = cmd.getValueAtIndex(runtime, 1).asNumber();
129
+ auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
130
+ auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
131
+ auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
132
+ auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
133
+ auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
134
+ path.cubicTo(x1, y1, x2, y2, x3, y3);
135
+ break;
136
+ }
137
+ case CLOSE: {
138
+ path.close();
139
+ break;
140
+ }
141
+ default: {
142
+ RNSkLogger::logToConsole("Found an unknown command");
143
+ return jsi::Value::null();
144
+ }
144
145
  }
145
146
  }
146
147
  return jsi::Object::createFromHostObject(
147
- runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));
148
+ runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));
148
149
  }
149
150
 
150
151
  JSI_HOST_FUNCTION(MakeFromText) {
@@ -156,7 +157,7 @@ public:
156
157
  SkTextUtils::GetPath(text.c_str(), strlen(text.c_str()),
157
158
  SkTextEncoding::kUTF8, x, y, *font, &path);
158
159
  return jsi::Object::createFromHostObject(
159
- runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));;
160
+ runtime, std::make_shared<JsiSkPath>(getContext(), std::move(path)));
160
161
  }
161
162
 
162
163
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPathFactory, Make),
@@ -165,7 +166,7 @@ public:
165
166
  JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromCmds),
166
167
  JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromText))
167
168
 
168
- JsiSkPathFactory(std::shared_ptr<RNSkPlatformContext> context)
169
+ explicit JsiSkPathFactory(std::shared_ptr<RNSkPlatformContext> context)
169
170
  : JsiSkHostObject(std::move(context)) {}
170
171
  };
171
172
 
@@ -1,6 +1,7 @@
1
-
2
1
  #pragma once
3
2
 
3
+ #include <memory>
4
+
4
5
  #include "JsiSkHostObjects.h"
5
6
  #include <JsiSkData.h>
6
7
  #include <JsiSkShader.h>
@@ -14,13 +15,13 @@
14
15
 
15
16
  namespace RNSkia {
16
17
 
17
- using namespace facebook;
18
+ namespace jsi = facebook::jsi;
18
19
 
19
20
  class JsiSkPicture : public JsiSkWrappingSkPtrHostObject<SkPicture> {
20
21
  public:
21
-
22
- JsiSkPicture(std::shared_ptr<RNSkPlatformContext> context, const sk_sp<SkPicture> picture)
23
- : JsiSkWrappingSkPtrHostObject<SkPicture>(context, picture) {};
22
+ JsiSkPicture(std::shared_ptr<RNSkPlatformContext> context,
23
+ const sk_sp<SkPicture> picture)
24
+ : JsiSkWrappingSkPtrHostObject<SkPicture>(context, picture) {}
24
25
 
25
26
  JSI_PROPERTY_GET(__typename__) {
26
27
  return jsi::String::createFromUtf8(runtime, "Picture");
@@ -32,34 +33,39 @@ public:
32
33
  auto tmx = (SkTileMode)arguments[0].asNumber();
33
34
  auto tmy = (SkTileMode)arguments[1].asNumber();
34
35
  auto fm = (SkFilterMode)arguments[2].asNumber();
35
- auto m = count > 3 && !arguments[3].isUndefined() ?
36
- JsiSkMatrix::fromValue(runtime, arguments[3]).get() : nullptr;
37
-
38
- auto tr = count > 4 && !arguments[4].isUndefined() ?
39
- JsiSkRect::fromValue(runtime, arguments[4]).get() : nullptr;
40
-
36
+ auto m = count > 3 && !arguments[3].isUndefined()
37
+ ? JsiSkMatrix::fromValue(runtime, arguments[3]).get()
38
+ : nullptr;
39
+
40
+ auto tr = count > 4 && !arguments[4].isUndefined()
41
+ ? JsiSkRect::fromValue(runtime, arguments[4]).get()
42
+ : nullptr;
43
+
41
44
  // Create shader
42
45
  auto shader = getObject()->makeShader(tmx, tmy, fm, m, tr);
43
46
  return jsi::Object::createFromHostObject(
44
47
  runtime, std::make_shared<JsiSkShader>(getContext(), shader));
45
48
  }
46
-
49
+
47
50
  JSI_HOST_FUNCTION(serialize) {
48
51
  auto data = getObject()->serialize();
49
- auto arrayCtor = runtime.global().getPropertyAsFunction(runtime, "Uint8Array");
52
+ auto arrayCtor =
53
+ runtime.global().getPropertyAsFunction(runtime, "Uint8Array");
50
54
  size_t size = data->size();
51
55
 
52
- jsi::Object array = arrayCtor.callAsConstructor(runtime, static_cast<double>(size)).getObject(runtime);
53
- jsi::ArrayBuffer buffer = array
54
- .getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
55
- .asObject(runtime)
56
- .getArrayBuffer(runtime);
56
+ jsi::Object array =
57
+ arrayCtor.callAsConstructor(runtime, static_cast<double>(size))
58
+ .getObject(runtime);
59
+ jsi::ArrayBuffer buffer =
60
+ array.getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
61
+ .asObject(runtime)
62
+ .getArrayBuffer(runtime);
57
63
 
58
64
  auto bfrPtr = reinterpret_cast<uint8_t *>(buffer.data(runtime));
59
65
  memcpy(bfrPtr, data->bytes(), size);
60
- return array;
66
+ return array;
61
67
  }
62
-
68
+
63
69
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPicture, makeShader),
64
70
  JSI_EXPORT_FUNC(JsiSkPicture, serialize))
65
71
 
@@ -67,11 +73,11 @@ public:
67
73
  Returns the underlying object from a host object of this type
68
74
  */
69
75
  static sk_sp<SkPicture> fromValue(jsi::Runtime &runtime,
70
- const jsi::Value &obj) {
76
+ const jsi::Value &obj) {
71
77
  return obj.asObject(runtime)
72
78
  .asHostObject<JsiSkPicture>(runtime)
73
79
  .get()
74
80
  ->getObject();
75
- }
81
+ }
76
82
  };
77
83
  } // namespace RNSkia
@@ -1,41 +1,42 @@
1
-
2
1
  #pragma once
3
2
 
3
+ #include <memory>
4
+
4
5
  #include "JsiSkColorFilter.h"
5
- #include "JsiSkHostObjects.h"
6
6
  #include "JsiSkData.h"
7
+ #include "JsiSkHostObjects.h"
7
8
  #include "JsiSkPicture.h"
8
9
 
9
10
  #pragma clang diagnostic push
10
11
  #pragma clang diagnostic ignored "-Wdocumentation"
11
12
 
12
- #include <SkPicture.h>
13
13
  #include <SkData.h>
14
+ #include <SkPicture.h>
14
15
 
15
16
  #pragma clang diagnostic pop
16
17
 
17
18
  namespace RNSkia {
18
19
 
19
- using namespace facebook;
20
+ namespace jsi = facebook::jsi;
20
21
 
21
22
  class JsiSkPictureFactory : public JsiSkHostObject {
22
23
  public:
23
24
  JSI_HOST_FUNCTION(MakePicture) {
24
- if(!arguments[0].isObject()) {
25
+ if (!arguments[0].isObject()) {
25
26
  throw jsi::JSError(runtime, "Expected arraybuffer as first parameter");
26
27
  }
27
28
  auto array = arguments[0].asObject(runtime);
28
- jsi::ArrayBuffer buffer = array
29
- .getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
29
+ jsi::ArrayBuffer buffer =
30
+ array.getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
30
31
  .asObject(runtime)
31
32
  .getArrayBuffer(runtime);
32
33
 
33
- sk_sp<SkData> data = SkData::MakeWithCopy(buffer.data(runtime), buffer.size(runtime));
34
+ sk_sp<SkData> data =
35
+ SkData::MakeWithCopy(buffer.data(runtime), buffer.size(runtime));
34
36
  auto picture = SkPicture::MakeFromData(data.get());
35
- if(picture != nullptr) {
37
+ if (picture != nullptr) {
36
38
  return jsi::Object::createFromHostObject(
37
- runtime,
38
- std::make_shared<JsiSkPicture>(getContext(), picture));
39
+ runtime, std::make_shared<JsiSkPicture>(getContext(), picture));
39
40
  } else {
40
41
  return jsi::Value::undefined();
41
42
  }
@@ -43,7 +44,7 @@ public:
43
44
 
44
45
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPictureFactory, MakePicture))
45
46
 
46
- JsiSkPictureFactory(std::shared_ptr<RNSkPlatformContext> context)
47
+ explicit JsiSkPictureFactory(std::shared_ptr<RNSkPlatformContext> context)
47
48
  : JsiSkHostObject(context) {}
48
49
  };
49
50
 
@@ -1,53 +1,55 @@
1
-
2
1
  #pragma once
3
2
 
3
+ #include <memory>
4
+
5
+ #include "JsiSkCanvas.h"
4
6
  #include "JsiSkHostObjects.h"
5
- #include "JsiSkRect.h"
6
7
  #include "JsiSkPicture.h"
7
- #include "JsiSkCanvas.h"
8
+ #include "JsiSkRect.h"
8
9
 
9
10
  #pragma clang diagnostic push
10
11
  #pragma clang diagnostic ignored "-Wdocumentation"
11
12
 
12
- #include <SkPictureRecorder.h>
13
13
  #include <SkBBHFactory.h>
14
+ #include <SkPictureRecorder.h>
14
15
 
15
16
  #pragma clang diagnostic pop
16
17
 
17
18
  namespace RNSkia {
18
19
 
19
- using namespace facebook;
20
+ namespace jsi = facebook::jsi;
20
21
 
21
- class JsiSkPictureRecorder : public JsiSkWrappingSharedPtrHostObject<SkPictureRecorder> {
22
+ class JsiSkPictureRecorder
23
+ : public JsiSkWrappingSharedPtrHostObject<SkPictureRecorder> {
22
24
  public:
23
-
24
- JsiSkPictureRecorder(std::shared_ptr<RNSkPlatformContext> context)
25
+ explicit JsiSkPictureRecorder(std::shared_ptr<RNSkPlatformContext> context)
25
26
  : JsiSkWrappingSharedPtrHostObject<SkPictureRecorder>(
26
- context, std::make_shared<SkPictureRecorder>()){};
27
+ context, std::make_shared<SkPictureRecorder>()) {}
27
28
 
28
29
  JSI_HOST_FUNCTION(beginRecording) {
29
30
  auto rect = JsiSkRect::fromValue(runtime, arguments[0]);
30
31
  SkRTreeFactory factory;
31
32
  auto canvas = getObject()->beginRecording(*rect, &factory);
32
33
  return jsi::Object::createFromHostObject(
33
- runtime, std::make_shared<JsiSkCanvas>(getContext(), canvas));
34
+ runtime, std::make_shared<JsiSkCanvas>(getContext(), canvas));
34
35
  }
35
-
36
+
36
37
  JSI_HOST_FUNCTION(finishRecordingAsPicture) {
37
38
  auto picture = getObject()->finishRecordingAsPicture();
38
39
  return jsi::Object::createFromHostObject(
39
- runtime, std::make_shared<JsiSkPicture>(getContext(), picture));
40
+ runtime, std::make_shared<JsiSkPicture>(getContext(), picture));
40
41
  }
41
-
42
+
42
43
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPictureRecorder, beginRecording),
43
- JSI_EXPORT_FUNC(JsiSkPictureRecorder, finishRecordingAsPicture))
44
-
44
+ JSI_EXPORT_FUNC(JsiSkPictureRecorder,
45
+ finishRecordingAsPicture))
46
+
45
47
  static const jsi::HostFunctionType
46
48
  createCtor(std::shared_ptr<RNSkPlatformContext> context) {
47
- return JSI_HOST_FUNCTION_LAMBDA {
48
- return jsi::Object::createFromHostObject(
49
- runtime, std::make_shared<JsiSkPictureRecorder>(context));
50
- };
49
+ return JSI_HOST_FUNCTION_LAMBDA {
50
+ return jsi::Object::createFromHostObject(
51
+ runtime, std::make_shared<JsiSkPictureRecorder>(context));
52
+ };
51
53
  }
52
54
  };
53
55
  } // namespace RNSkia
@@ -16,11 +16,10 @@
16
16
 
17
17
  namespace RNSkia {
18
18
 
19
- using namespace facebook;
19
+ namespace jsi = facebook::jsi;
20
20
 
21
21
  class JsiSkPoint : public JsiSkWrappingSharedPtrHostObject<SkPoint> {
22
22
  public:
23
-
24
23
  JSI_PROPERTY_GET(x) { return static_cast<double>(getObject()->x()); }
25
24
 
26
25
  JSI_PROPERTY_GET(y) { return static_cast<double>(getObject()->y()); }
@@ -30,18 +29,16 @@ public:
30
29
 
31
30
  JsiSkPoint(std::shared_ptr<RNSkPlatformContext> context, const SkPoint &point)
32
31
  : JsiSkWrappingSharedPtrHostObject<SkPoint>(
33
- std::move(context), std::make_shared<SkPoint>(point)){}
32
+ std::move(context), std::make_shared<SkPoint>(point)) {}
34
33
 
35
34
  /**
36
35
  Returns the underlying object from a host object of this type
37
36
  */
38
37
  static std::shared_ptr<SkPoint> fromValue(jsi::Runtime &runtime,
39
38
  const jsi::Value &obj) {
40
- const auto& object = obj.asObject(runtime);
39
+ const auto &object = obj.asObject(runtime);
41
40
  if (object.isHostObject(runtime)) {
42
- return object
43
- .asHostObject<JsiSkPoint>(runtime)
44
- ->getObject();
41
+ return object.asHostObject<JsiSkPoint>(runtime)->getObject();
45
42
  } else {
46
43
  auto x = object.getProperty(runtime, "x").asNumber();
47
44
  auto y = object.getProperty(runtime, "y").asNumber();
@@ -74,7 +71,8 @@ public:
74
71
 
75
72
  // Return the newly constructed object
76
73
  return jsi::Object::createFromHostObject(
77
- runtime, std::make_shared<JsiSkPoint>(std::move(context), std::move(point)));
74
+ runtime,
75
+ std::make_shared<JsiSkPoint>(std::move(context), std::move(point)));
78
76
  };
79
77
  }
80
78
  };
@@ -12,11 +12,13 @@
12
12
 
13
13
  #include <SkRRect.h>
14
14
 
15
+ #include "JsiSkRect.h"
16
+
15
17
  #pragma clang diagnostic pop
16
18
 
17
19
  namespace RNSkia {
18
20
 
19
- using namespace facebook;
21
+ namespace jsi = facebook::jsi;
20
22
 
21
23
  class JsiSkRRect : public JsiSkWrappingSharedPtrHostObject<SkRRect> {
22
24
  public:
@@ -38,7 +40,7 @@ public:
38
40
 
39
41
  JsiSkRRect(std::shared_ptr<RNSkPlatformContext> context, const SkRRect &rect)
40
42
  : JsiSkWrappingSharedPtrHostObject<SkRRect>(
41
- std::move(context), std::make_shared<SkRRect>(rect)){}
43
+ std::move(context), std::make_shared<SkRRect>(rect)) {}
42
44
 
43
45
  /**
44
46
  Returns the underlying object from a host object of this type
@@ -46,13 +48,14 @@ public:
46
48
  static std::shared_ptr<SkRRect> fromValue(jsi::Runtime &runtime,
47
49
  const jsi::Value &obj) {
48
50
 
49
- const auto& object = obj.asObject(runtime);
51
+ const auto &object = obj.asObject(runtime);
50
52
  if (object.isHostObject(runtime)) {
51
53
  return obj.asObject(runtime)
52
- .asHostObject<JsiSkRRect>(runtime)
53
- ->getObject();
54
+ .asHostObject<JsiSkRRect>(runtime)
55
+ ->getObject();
54
56
  } else {
55
- auto rect = JsiSkRect::fromValue(runtime, object.getProperty(runtime, "rect"));
57
+ auto rect =
58
+ JsiSkRect::fromValue(runtime, object.getProperty(runtime, "rect"));
56
59
  auto rx = object.getProperty(runtime, "rx").asNumber();
57
60
  auto ry = object.getProperty(runtime, "ry").asNumber();
58
61
  return std::make_shared<SkRRect>(SkRRect::MakeRectXY(*rect, rx, ry));
@@ -86,7 +89,8 @@ public:
86
89
  auto rrect = SkRRect::MakeRectXY(*rect, rx, ry);
87
90
  // Return the newly constructed object
88
91
  return jsi::Object::createFromHostObject(
89
- runtime, std::make_shared<JsiSkRRect>(std::move(context), std::move(rrect)));
92
+ runtime,
93
+ std::make_shared<JsiSkRRect>(std::move(context), std::move(rrect)));
90
94
  };
91
95
  }
92
96
  };