@shopify/react-native-skia 0.1.155 → 0.1.157

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) 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/types/NodeType.js +1 -0
  95. package/lib/commonjs/dom/types/NodeType.js.map +1 -1
  96. package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
  97. package/lib/commonjs/renderer/Canvas.js +1 -1
  98. package/lib/commonjs/renderer/Canvas.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/HostConfig.js +10 -1
  102. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  103. package/lib/commonjs/renderer/components/Group.js +19 -4
  104. package/lib/commonjs/renderer/components/Group.js.map +1 -1
  105. package/lib/commonjs/renderer/components/Paint.js +6 -1
  106. package/lib/commonjs/renderer/components/Paint.js.map +1 -1
  107. package/lib/commonjs/views/SkiaPictureView.js +3 -2
  108. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  109. package/lib/commonjs/views/SkiaView.js +6 -3
  110. package/lib/commonjs/views/SkiaView.js.map +1 -1
  111. package/lib/module/animation/spring/runSpring.js +1 -1
  112. package/lib/module/animation/spring/runSpring.js.map +1 -1
  113. package/lib/module/animation/spring/useSpring.js +1 -1
  114. package/lib/module/animation/spring/useSpring.js.map +1 -1
  115. package/lib/module/animation/timing/createTiming.js +6 -2
  116. package/lib/module/animation/timing/createTiming.js.map +1 -1
  117. package/lib/module/animation/timing/functions/getResolvedParams.js +10 -6
  118. package/lib/module/animation/timing/functions/getResolvedParams.js.map +1 -1
  119. package/lib/module/animation/timing/useTiming.js +3 -1
  120. package/lib/module/animation/timing/useTiming.js.map +1 -1
  121. package/lib/module/dom/nodes/JsiSkDOM.js +6 -1
  122. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  123. package/lib/module/dom/nodes/LayerNode.js +32 -0
  124. package/lib/module/dom/nodes/LayerNode.js.map +1 -0
  125. package/lib/module/dom/nodes/datatypes/Gradient.js +2 -2
  126. package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
  127. package/lib/module/dom/nodes/paint/Shaders.js +4 -2
  128. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  129. package/lib/module/dom/types/NodeType.js +1 -0
  130. package/lib/module/dom/types/NodeType.js.map +1 -1
  131. package/lib/module/dom/types/SkDOM.js.map +1 -1
  132. package/lib/module/mock/index.js +10 -6
  133. package/lib/module/mock/index.js.map +1 -1
  134. package/lib/module/renderer/Canvas.js +1 -1
  135. package/lib/module/renderer/Canvas.js.map +1 -1
  136. package/lib/module/renderer/HostComponents.js +3 -0
  137. package/lib/module/renderer/HostComponents.js.map +1 -1
  138. package/lib/module/renderer/HostConfig.js +9 -1
  139. package/lib/module/renderer/HostConfig.js.map +1 -1
  140. package/lib/module/renderer/components/Group.js +16 -3
  141. package/lib/module/renderer/components/Group.js.map +1 -1
  142. package/lib/module/renderer/components/Paint.js +7 -1
  143. package/lib/module/renderer/components/Paint.js.map +1 -1
  144. package/lib/module/skia/core/Vector.js +1 -1
  145. package/lib/module/skia/core/Vector.js.map +1 -1
  146. package/lib/module/skia/web/Host.js +1 -1
  147. package/lib/module/skia/web/Host.js.map +1 -1
  148. package/lib/module/skia/web/JsiSkMatrix.js +1 -1
  149. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  150. package/lib/module/values/web/RNSkAnimation.js +2 -2
  151. package/lib/module/values/web/RNSkAnimation.js.map +1 -1
  152. package/lib/module/views/SkiaBaseWebView.js +3 -1
  153. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  154. package/lib/module/views/SkiaPictureView.js +2 -2
  155. package/lib/module/views/SkiaPictureView.js.map +1 -1
  156. package/lib/module/views/SkiaView.js +4 -2
  157. package/lib/module/views/SkiaView.js.map +1 -1
  158. package/lib/module/views/useTouchHandler.js +6 -6
  159. package/lib/module/views/useTouchHandler.js.map +1 -1
  160. package/lib/module/web/WithSkiaWeb.js +1 -1
  161. package/lib/module/web/WithSkiaWeb.js.map +1 -1
  162. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -0
  163. package/lib/typescript/src/dom/nodes/LayerNode.d.ts +8 -0
  164. package/lib/typescript/src/dom/types/NodeType.d.ts +1 -0
  165. package/lib/typescript/src/dom/types/SkDOM.d.ts +1 -0
  166. package/lib/typescript/src/renderer/HostComponents.d.ts +2 -1
  167. package/lib/typescript/src/renderer/components/Group.d.ts +5 -1
  168. package/lib/typescript/src/views/SkiaView.d.ts +3 -0
  169. package/libs/android/arm64-v8a/libskottie.a +0 -0
  170. package/libs/android/arm64-v8a/libsksg.a +0 -0
  171. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  172. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  173. package/libs/android/x86/libskottie.a +0 -0
  174. package/libs/android/x86/libsksg.a +0 -0
  175. package/libs/android/x86_64/libskottie.a +0 -0
  176. package/libs/android/x86_64/libsksg.a +0 -0
  177. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  178. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  179. package/libs/ios/libskottie.xcframework/Info.plist +42 -0
  180. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  181. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  182. package/libs/ios/libsksg.xcframework/Info.plist +42 -0
  183. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  184. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  185. package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
  186. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  187. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  188. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  189. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  190. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  191. package/package.json +14 -6
  192. package/src/dom/nodes/JsiSkDOM.ts +5 -0
  193. package/src/dom/nodes/LayerNode.ts +35 -0
  194. package/src/dom/types/NodeType.ts +1 -0
  195. package/src/dom/types/SkDOM.ts +1 -0
  196. package/src/renderer/Canvas.tsx +11 -1
  197. package/src/renderer/HostComponents.ts +3 -0
  198. package/src/renderer/HostConfig.ts +8 -1
  199. package/src/renderer/components/Group.tsx +16 -3
  200. package/src/renderer/components/Paint.tsx +7 -1
  201. package/src/views/SkiaPictureView.tsx +2 -3
  202. package/src/views/SkiaView.tsx +2 -2
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
2
 
3
+ #include <algorithm>
3
4
  #include <memory>
4
5
  #include <utility>
5
6
 
@@ -17,67 +18,68 @@
17
18
 
18
19
  namespace RNSkia {
19
20
 
20
- using namespace facebook;
21
+ namespace jsi = facebook::jsi;
21
22
 
22
- class JsiSkColor : public JsiHostObject {
23
- public:
23
+ class JsiSkColor : public RNJsi::JsiHostObject {
24
+ public:
25
+ JsiSkColor() : JsiHostObject() {}
24
26
 
25
- JsiSkColor(): JsiHostObject() {}
27
+ ~JsiSkColor() {}
26
28
 
27
- ~JsiSkColor() {}
29
+ static jsi::Object toValue(jsi::Runtime &runtime, SkColor color) {
30
+ auto result = runtime.global()
31
+ .getPropertyAsFunction(runtime, "Float32Array")
32
+ .callAsConstructor(runtime, 4)
33
+ .getObject(runtime);
34
+ jsi::ArrayBuffer buffer =
35
+ result
36
+ .getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
37
+ .asObject(runtime)
38
+ .getArrayBuffer(runtime);
39
+ auto bfrPtr = reinterpret_cast<float *>(buffer.data(runtime));
40
+ auto color4f = SkColor4f::FromColor(color).array();
41
+ std::copy(color4f.begin(), color4f.end(), bfrPtr);
42
+ return result;
43
+ }
28
44
 
29
- static jsi::Object toValue(jsi::Runtime &runtime, SkColor color) {
30
- auto result = runtime
31
- .global()
32
- .getPropertyAsFunction(runtime, "Float32Array")
33
- .callAsConstructor(runtime, 4)
34
- .getObject(runtime);
35
- jsi::ArrayBuffer buffer = result
36
- .getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
37
- .asObject(runtime)
38
- .getArrayBuffer(runtime);
39
- auto bfrPtr = reinterpret_cast<float *>(buffer.data(runtime));
40
- auto color4f = SkColor4f::FromColor(color).array();
41
- std::copy(color4f.begin(), color4f.end(), bfrPtr);
42
- return result;
43
- }
44
-
45
- static SkColor fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
46
- const auto& object = obj.asObject(runtime);
47
- jsi::ArrayBuffer buffer = object
48
- .getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
49
- .asObject(runtime)
50
- .getArrayBuffer(runtime);
51
- auto bfrPtr = reinterpret_cast<float *>(buffer.data(runtime));
52
- if (bfrPtr[0] > 1 || bfrPtr[1] > 1 || bfrPtr[2] > 1 || bfrPtr[3] > 1) {
53
- return SK_ColorBLACK;
54
- }
55
- return SkColorSetARGB(bfrPtr[3] * 255, bfrPtr[0] * 255, bfrPtr[1] * 255, bfrPtr[2] * 255);
56
- }
45
+ static SkColor fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
46
+ const auto &object = obj.asObject(runtime);
47
+ jsi::ArrayBuffer buffer =
48
+ object
49
+ .getProperty(runtime, jsi::PropNameID::forAscii(runtime, "buffer"))
50
+ .asObject(runtime)
51
+ .getArrayBuffer(runtime);
52
+ auto bfrPtr = reinterpret_cast<float *>(buffer.data(runtime));
53
+ if (bfrPtr[0] > 1 || bfrPtr[1] > 1 || bfrPtr[2] > 1 || bfrPtr[3] > 1) {
54
+ return SK_ColorBLACK;
55
+ }
56
+ return SkColorSetARGB(bfrPtr[3] * 255, bfrPtr[0] * 255, bfrPtr[1] * 255,
57
+ bfrPtr[2] * 255);
58
+ }
57
59
 
58
- /**
59
- * Creates the function for construction a new instance of the SkColor
60
- * wrapper
61
- * @return A function for creating a new host object wrapper for the SkColor
62
- * class
63
- */
64
- static const jsi::HostFunctionType
65
- createCtor() {
66
- return JSI_HOST_FUNCTION_LAMBDA {
67
- if (arguments[0].isNumber()) {
68
- return JsiSkColor::toValue(runtime, arguments[0].getNumber());
69
- } else if(arguments[0].isString()) {
70
- auto text = arguments[0].asString(runtime).utf8(runtime);
71
- auto color = CSSColorParser::parse(text);
72
- if (color.a == -1.0f) {
73
- return JsiSkColor::toValue(runtime, SK_ColorBLACK);
74
- }
75
- return JsiSkColor::toValue(runtime, SkColorSetARGB(color.a * 255, color.r, color.g, color.b));
76
- } else if (arguments[0].isObject()) {
77
- return arguments[0].getObject(runtime);
78
- }
79
- return jsi::Value::undefined();
80
- };
60
+ /**
61
+ * Creates the function for construction a new instance of the SkColor
62
+ * wrapper
63
+ * @return A function for creating a new host object wrapper for the SkColor
64
+ * class
65
+ */
66
+ static const jsi::HostFunctionType createCtor() {
67
+ return JSI_HOST_FUNCTION_LAMBDA {
68
+ if (arguments[0].isNumber()) {
69
+ return JsiSkColor::toValue(runtime, arguments[0].getNumber());
70
+ } else if (arguments[0].isString()) {
71
+ auto text = arguments[0].asString(runtime).utf8(runtime);
72
+ auto color = CSSColorParser::parse(text);
73
+ if (color.a == -1.0f) {
74
+ return JsiSkColor::toValue(runtime, SK_ColorBLACK);
81
75
  }
76
+ return JsiSkColor::toValue(
77
+ runtime, SkColorSetARGB(color.a * 255, color.r, color.g, color.b));
78
+ } else if (arguments[0].isObject()) {
79
+ return arguments[0].getObject(runtime);
80
+ }
81
+ return jsi::Value::undefined();
82
82
  };
83
+ }
84
+ };
83
85
  } // namespace RNSkia
@@ -14,20 +14,22 @@
14
14
 
15
15
  namespace RNSkia {
16
16
 
17
- using namespace facebook;
17
+ namespace jsi = facebook::jsi;
18
18
 
19
19
  class JsiSkColorFilter : public JsiSkWrappingSkPtrHostObject<SkColorFilter> {
20
20
  public:
21
21
  JsiSkColorFilter(std::shared_ptr<RNSkPlatformContext> context,
22
22
  sk_sp<SkColorFilter> colorFilter)
23
- : JsiSkWrappingSkPtrHostObject<SkColorFilter>(std::move(context), std::move(colorFilter)) {}
23
+ : JsiSkWrappingSkPtrHostObject<SkColorFilter>(std::move(context),
24
+ std::move(colorFilter)) {}
24
25
 
25
26
  // TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
26
27
  JSI_PROPERTY_GET(__typename__) {
27
28
  return jsi::String::createFromUtf8(runtime, "ColorFilter");
28
29
  }
29
30
 
30
- JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkColorFilter, __typename__))
31
+ JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkColorFilter,
32
+ __typename__))
31
33
 
32
34
  /**
33
35
  Returns the underlying object from a host object of this type
@@ -1,9 +1,10 @@
1
1
  #pragma once
2
2
 
3
+ #include "JsiSkColor.h"
3
4
  #include "JsiSkColorFilter.h"
4
5
  #include "JsiSkHostObjects.h"
5
- #include "JsiSkColor.h"
6
6
  #include <jsi/jsi.h>
7
+ #include <memory>
7
8
  #include <utility>
8
9
 
9
10
  #pragma clang diagnostic push
@@ -16,7 +17,7 @@
16
17
 
17
18
  namespace RNSkia {
18
19
 
19
- using namespace facebook;
20
+ namespace jsi = facebook::jsi;
20
21
 
21
22
  class JsiSkColorFilterFactory : public JsiSkHostObject {
22
23
  public:
@@ -49,7 +50,8 @@ public:
49
50
  // Return the newly constructed object
50
51
  return jsi::Object::createFromHostObject(
51
52
  runtime, std::make_shared<JsiSkColorFilter>(
52
- getContext(), SkColorFilters::Compose(std::move(outer), std::move(inner))));
53
+ getContext(), SkColorFilters::Compose(std::move(outer),
54
+ std::move(inner))));
53
55
  }
54
56
 
55
57
  JSI_HOST_FUNCTION(MakeLerp) {
@@ -59,15 +61,16 @@ public:
59
61
  // Return the newly constructed object
60
62
  return jsi::Object::createFromHostObject(
61
63
  runtime, std::make_shared<JsiSkColorFilter>(
62
- getContext(), SkColorFilters::Lerp(t, std::move(dst), std::move(src))));
64
+ getContext(),
65
+ SkColorFilters::Lerp(t, std::move(dst), std::move(src))));
63
66
  }
64
67
 
65
- JSI_HOST_FUNCTION(MakeSRGBToLinearGamma) {
66
- // Return the newly constructed object
67
- return jsi::Object::createFromHostObject(
68
- runtime, std::make_shared<JsiSkColorFilter>(
69
- getContext(), SkColorFilters::SRGBToLinearGamma()));
70
- }
68
+ JSI_HOST_FUNCTION(MakeSRGBToLinearGamma) {
69
+ // Return the newly constructed object
70
+ return jsi::Object::createFromHostObject(
71
+ runtime, std::make_shared<JsiSkColorFilter>(
72
+ getContext(), SkColorFilters::SRGBToLinearGamma()));
73
+ }
71
74
 
72
75
  JSI_HOST_FUNCTION(MakeLinearToSRGBGamma) {
73
76
  // Return the newly constructed object
@@ -79,21 +82,20 @@ public:
79
82
  JSI_HOST_FUNCTION(MakeLumaColorFilter) {
80
83
  // Return the newly constructed object
81
84
  return jsi::Object::createFromHostObject(
82
- runtime, std::make_shared<JsiSkColorFilter>(
83
- getContext(), SkLumaColorFilter::Make()));
85
+ runtime, std::make_shared<JsiSkColorFilter>(getContext(),
86
+ SkLumaColorFilter::Make()));
84
87
  }
85
88
 
86
89
  JSI_EXPORT_FUNCTIONS(
87
- JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeMatrix),
88
- JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeBlend),
89
- JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeCompose),
90
- JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLerp),
91
- JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeSRGBToLinearGamma),
92
- JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLinearToSRGBGamma),
93
- JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLumaColorFilter)
94
- )
90
+ JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeMatrix),
91
+ JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeBlend),
92
+ JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeCompose),
93
+ JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLerp),
94
+ JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeSRGBToLinearGamma),
95
+ JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLinearToSRGBGamma),
96
+ JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeLumaColorFilter))
95
97
 
96
- JsiSkColorFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
98
+ explicit JsiSkColorFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
97
99
  : JsiSkHostObject(std::move(context)) {}
98
100
  };
99
101
  } // namespace RNSkia
@@ -12,91 +12,80 @@
12
12
 
13
13
  #include <SkContourMeasure.h>
14
14
 
15
- #pragma clang diagnostic pop
15
+ #include "JsiSkPath.h"
16
16
 
17
+ #pragma clang diagnostic pop
17
18
 
18
- namespace RNSkia
19
- {
20
-
21
- using namespace facebook;
22
-
23
- class JsiSkContourMeasure : public JsiSkWrappingSkPtrHostObject<SkContourMeasure>
24
- {
25
- public:
26
- JsiSkContourMeasure(std::shared_ptr<RNSkPlatformContext> context,
27
- const sk_sp<SkContourMeasure> contourMeasure)
28
- : JsiSkWrappingSkPtrHostObject(std::move(context), std::move(contourMeasure))
29
- {
30
- if (contourMeasure == nullptr)
31
- {
32
- throw jsi::JSError(*context->getJsRuntime(), "Contour measure is null");
33
- }
34
- };
35
-
36
- JSI_HOST_FUNCTION(getPosTan)
37
- {
38
- auto dist = arguments[0].asNumber();
39
- SkPoint position;
40
- SkPoint tangent;
41
- auto result = getObject()->getPosTan(dist, &position, &tangent);
42
- if (!result)
43
- {
44
- throw jsi::JSError(runtime, "getSegment() failed");
45
- }
46
- auto posTan = jsi::Object(runtime);
47
- posTan.setProperty(runtime, "px", position.x());
48
- posTan.setProperty(runtime, "py", position.y());
49
- posTan.setProperty(runtime, "tx", tangent.x());
50
- posTan.setProperty(runtime, "ty", tangent.y());
51
- return posTan;
52
- }
53
-
54
- JSI_HOST_FUNCTION(length)
55
- {
56
- return jsi::Value(SkScalarToDouble(getObject()->length()));
57
- }
58
-
59
- JSI_HOST_FUNCTION(isClosed)
60
- {
61
- return jsi::Value(getObject()->isClosed());
62
- }
63
-
64
- JSI_HOST_FUNCTION(getSegment)
65
- {
66
- auto start = arguments[0].asNumber();
67
- auto end = arguments[1].asNumber();
68
- auto startWithMoveTo = arguments[2].getBool();
69
- SkPath path;
70
- auto result = getObject()->getSegment(start, end, &path, startWithMoveTo);
71
- if (!result)
72
- {
73
- throw jsi::JSError(runtime, "getSegment() failed");
74
- }
75
- return JsiSkPath::toValue(runtime, getContext(), std::move(path));
76
- }
77
-
78
- JSI_PROPERTY_GET(__typename__)
79
- {
80
- return jsi::String::createFromUtf8(runtime, "ContourMeasure");
81
- }
82
-
83
- JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkContourMeasure, __typename__))
84
-
85
- JSI_EXPORT_FUNCTIONS(
86
- JSI_EXPORT_FUNC(JsiSkContourMeasure, getPosTan),
87
- JSI_EXPORT_FUNC(JsiSkContourMeasure, length),
88
- JSI_EXPORT_FUNC(JsiSkContourMeasure, isClosed),
89
- JSI_EXPORT_FUNC(JsiSkContourMeasure, getSegment))
90
-
91
- /**
92
- Returns the underlying object from a host object of this type
93
- */
94
- static sk_sp<SkContourMeasure> fromValue(jsi::Runtime &runtime,
95
- const jsi::Value &obj)
96
- {
97
- return obj.asObject(runtime)
98
- .asHostObject<JsiSkContourMeasure>(runtime)
99
- ->getObject();
100
- }
101
- };
19
+ namespace RNSkia {
20
+
21
+ namespace jsi = facebook::jsi;
22
+
23
+ class JsiSkContourMeasure
24
+ : public JsiSkWrappingSkPtrHostObject<SkContourMeasure> {
25
+ public:
26
+ JsiSkContourMeasure(std::shared_ptr<RNSkPlatformContext> context,
27
+ const sk_sp<SkContourMeasure> contourMeasure)
28
+ : JsiSkWrappingSkPtrHostObject(std::move(context),
29
+ std::move(contourMeasure)) {
30
+ if (contourMeasure == nullptr) {
31
+ throw jsi::JSError(*context->getJsRuntime(), "Contour measure is null");
32
+ }
33
+ }
34
+
35
+ JSI_HOST_FUNCTION(getPosTan) {
36
+ auto dist = arguments[0].asNumber();
37
+ SkPoint position;
38
+ SkPoint tangent;
39
+ auto result = getObject()->getPosTan(dist, &position, &tangent);
40
+ if (!result) {
41
+ throw jsi::JSError(runtime, "getSegment() failed");
42
+ }
43
+ auto posTan = jsi::Object(runtime);
44
+ posTan.setProperty(runtime, "px", position.x());
45
+ posTan.setProperty(runtime, "py", position.y());
46
+ posTan.setProperty(runtime, "tx", tangent.x());
47
+ posTan.setProperty(runtime, "ty", tangent.y());
48
+ return posTan;
49
+ }
50
+
51
+ JSI_HOST_FUNCTION(length) {
52
+ return jsi::Value(SkScalarToDouble(getObject()->length()));
53
+ }
54
+
55
+ JSI_HOST_FUNCTION(isClosed) { return jsi::Value(getObject()->isClosed()); }
56
+
57
+ JSI_HOST_FUNCTION(getSegment) {
58
+ auto start = arguments[0].asNumber();
59
+ auto end = arguments[1].asNumber();
60
+ auto startWithMoveTo = arguments[2].getBool();
61
+ SkPath path;
62
+ auto result = getObject()->getSegment(start, end, &path, startWithMoveTo);
63
+ if (!result) {
64
+ throw jsi::JSError(runtime, "getSegment() failed");
65
+ }
66
+ return JsiSkPath::toValue(runtime, getContext(), std::move(path));
67
+ }
68
+
69
+ JSI_PROPERTY_GET(__typename__) {
70
+ return jsi::String::createFromUtf8(runtime, "ContourMeasure");
71
+ }
72
+
73
+ JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkContourMeasure,
74
+ __typename__))
75
+
76
+ JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkContourMeasure, getPosTan),
77
+ JSI_EXPORT_FUNC(JsiSkContourMeasure, length),
78
+ JSI_EXPORT_FUNC(JsiSkContourMeasure, isClosed),
79
+ JSI_EXPORT_FUNC(JsiSkContourMeasure, getSegment))
80
+
81
+ /**
82
+ Returns the underlying object from a host object of this type
83
+ */
84
+ static sk_sp<SkContourMeasure> fromValue(jsi::Runtime &runtime,
85
+ const jsi::Value &obj) {
86
+ return obj.asObject(runtime)
87
+ .asHostObject<JsiSkContourMeasure>(runtime)
88
+ ->getObject();
89
+ }
90
+ };
102
91
  } // namespace RNSkia
@@ -3,88 +3,81 @@
3
3
  #include <memory>
4
4
  #include <utility>
5
5
 
6
- #include "JsiSkHostObjects.h"
7
6
  #include "JsiSkContourMeasure.h"
7
+ #include "JsiSkHostObjects.h"
8
8
 
9
9
  #pragma clang diagnostic push
10
10
  #pragma clang diagnostic ignored "-Wdocumentation"
11
11
 
12
12
  #include <SkContourMeasure.h>
13
13
 
14
+ #include "JsiSkPath.h"
15
+
14
16
  #pragma clang diagnostic pop
15
17
 
16
- namespace RNSkia
17
- {
18
-
19
- using namespace facebook;
20
-
21
- class JsiSkContourMeasureIter : public JsiSkWrappingSharedPtrHostObject<SkContourMeasureIter>
22
- {
23
- public:
24
- JsiSkContourMeasureIter(
25
- std::shared_ptr<RNSkPlatformContext> context,
26
- const SkPath &path,
27
- bool forceClosed,
28
- SkScalar resScale = 1) : JsiSkWrappingSharedPtrHostObject<SkContourMeasureIter>(std::move(context), std::make_shared<SkContourMeasureIter>(path, forceClosed, resScale)) {}
29
-
30
- // TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
31
- JSI_PROPERTY_GET(__typename__)
32
- {
33
- return jsi::String::createFromUtf8(runtime, "ContourMeasureIter");
34
- }
35
-
36
- JSI_EXPORT_PROPERTY_GETTERS(
37
- JSI_EXPORT_PROP_GET(JsiSkContourMeasureIter, __typename__), )
38
-
39
- JSI_HOST_FUNCTION(next)
40
- {
41
- auto next = getObject()->next();
42
- if (next == nullptr)
43
- {
44
- return jsi::Value::undefined();
45
- }
46
- auto nextObject = std::make_shared<JsiSkContourMeasure>(getContext(), std::move(next));
47
-
48
- return jsi::Object::createFromHostObject(runtime, std::move(nextObject));
49
- }
50
-
51
- JSI_EXPORT_FUNCTIONS(
52
- JSI_EXPORT_FUNC(JsiSkContourMeasureIter, next))
53
-
54
- /**
55
- Returns the underlying object from a host object of this type
56
- */
57
- static std::shared_ptr<SkContourMeasureIter> fromValue(jsi::Runtime &runtime,
58
- const jsi::Value &obj)
59
- {
60
- return obj.asObject(runtime)
61
- .asHostObject<JsiSkContourMeasureIter>(runtime)
62
- ->getObject();
63
- }
64
-
65
- /**
66
- * Creates the function for construction a new instance of the SkContourMeasureIter
67
- * wrapper
68
- * @param context platform context
69
- * @return A function for creating a new host object wrapper for the SkContourMeasureIter
70
- * class
71
- */
72
- static const jsi::HostFunctionType
73
- createCtor(std::shared_ptr<RNSkPlatformContext> context)
74
- {
75
- return JSI_HOST_FUNCTION_LAMBDA
76
- {
77
- auto path = JsiSkPath::fromValue(runtime, arguments[0]);
78
- auto forceClosed = arguments[1].getBool();
79
- auto resScale = arguments[2].asNumber();
80
- // Return the newly constructed object
81
- return jsi::Object::createFromHostObject(
82
- runtime, std::make_shared<JsiSkContourMeasureIter>(
83
- std::move(context),
84
- *path,
85
- forceClosed,
86
- resScale));
87
- };
88
- }
89
- };
18
+ namespace RNSkia {
19
+
20
+ namespace jsi = facebook::jsi;
21
+
22
+ class JsiSkContourMeasureIter
23
+ : public JsiSkWrappingSharedPtrHostObject<SkContourMeasureIter> {
24
+ public:
25
+ JsiSkContourMeasureIter(std::shared_ptr<RNSkPlatformContext> context,
26
+ const SkPath &path, bool forceClosed,
27
+ SkScalar resScale = 1)
28
+ : JsiSkWrappingSharedPtrHostObject<SkContourMeasureIter>(
29
+ std::move(context), std::make_shared<SkContourMeasureIter>(
30
+ path, forceClosed, resScale)) {}
31
+
32
+ // TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
33
+ JSI_PROPERTY_GET(__typename__) {
34
+ return jsi::String::createFromUtf8(runtime, "ContourMeasureIter");
35
+ }
36
+
37
+ JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkContourMeasureIter,
38
+ __typename__), )
39
+
40
+ JSI_HOST_FUNCTION(next) {
41
+ auto next = getObject()->next();
42
+ if (next == nullptr) {
43
+ return jsi::Value::undefined();
44
+ }
45
+ auto nextObject =
46
+ std::make_shared<JsiSkContourMeasure>(getContext(), std::move(next));
47
+
48
+ return jsi::Object::createFromHostObject(runtime, std::move(nextObject));
49
+ }
50
+
51
+ JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkContourMeasureIter, next))
52
+
53
+ /**
54
+ Returns the underlying object from a host object of this type
55
+ */
56
+ static std::shared_ptr<SkContourMeasureIter>
57
+ fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
58
+ return obj.asObject(runtime)
59
+ .asHostObject<JsiSkContourMeasureIter>(runtime)
60
+ ->getObject();
61
+ }
62
+
63
+ /**
64
+ * Creates the function for construction a new instance of the
65
+ * SkContourMeasureIter wrapper
66
+ * @param context platform context
67
+ * @return A function for creating a new host object wrapper for the
68
+ * SkContourMeasureIter class
69
+ */
70
+ static const jsi::HostFunctionType
71
+ createCtor(std::shared_ptr<RNSkPlatformContext> context) {
72
+ return JSI_HOST_FUNCTION_LAMBDA {
73
+ auto path = JsiSkPath::fromValue(runtime, arguments[0]);
74
+ auto forceClosed = arguments[1].getBool();
75
+ auto resScale = arguments[2].asNumber();
76
+ // Return the newly constructed object
77
+ return jsi::Object::createFromHostObject(
78
+ runtime, std::make_shared<JsiSkContourMeasureIter>(
79
+ std::move(context), *path, forceClosed, resScale));
80
+ };
81
+ }
82
+ };
90
83
  } // namespace RNSkia
@@ -15,32 +15,26 @@
15
15
 
16
16
  #pragma clang diagnostic pop
17
17
 
18
-
19
18
  namespace RNSkia {
20
19
 
21
- using namespace facebook;
22
-
23
- class JsiSkData : public JsiSkWrappingSkPtrHostObject<SkData> {
24
- public:
25
- JsiSkData(std::shared_ptr<RNSkPlatformContext> context,
26
- sk_sp<SkData> asset)
27
- : JsiSkWrappingSkPtrHostObject(std::move(context), std::move(asset)){}
20
+ namespace jsi = facebook::jsi;
28
21
 
22
+ class JsiSkData : public JsiSkWrappingSkPtrHostObject<SkData> {
23
+ public:
24
+ JsiSkData(std::shared_ptr<RNSkPlatformContext> context, sk_sp<SkData> asset)
25
+ : JsiSkWrappingSkPtrHostObject(std::move(context), std::move(asset)) {}
29
26
 
30
- JSI_PROPERTY_GET(__typename__) {
31
- return jsi::String::createFromUtf8(runtime, "Data");
32
- }
27
+ JSI_PROPERTY_GET(__typename__) {
28
+ return jsi::String::createFromUtf8(runtime, "Data");
29
+ }
33
30
 
34
- JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkData, __typename__))
31
+ JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkData, __typename__))
35
32
 
36
- /**
37
- Returns the underlying object from a host object of this type
38
- */
39
- static sk_sp<SkData> fromValue(jsi::Runtime &runtime,
40
- const jsi::Value &obj) {
41
- return obj.asObject(runtime)
42
- .asHostObject<JsiSkData>(runtime)
43
- ->getObject();
44
- }
45
- };
33
+ /**
34
+ Returns the underlying object from a host object of this type
35
+ */
36
+ static sk_sp<SkData> fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
37
+ return obj.asObject(runtime).asHostObject<JsiSkData>(runtime)->getObject();
38
+ }
39
+ };
46
40
  } // namespace RNSkia