@shopify/react-native-skia 0.1.154 → 0.1.156

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/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
@@ -16,42 +16,45 @@
16
16
 
17
17
  namespace RNSkia {
18
18
 
19
- using namespace facebook;
20
-
21
- class JsiSkImageInfo : public JsiSkWrappingSharedPtrHostObject<SkImageInfo> {
22
- public:
23
- JsiSkImageInfo(std::shared_ptr<RNSkPlatformContext> context, const SkImageInfo &imageInfo)
24
- : JsiSkWrappingSharedPtrHostObject<SkImageInfo>(
25
- std::move(context), std::make_shared<SkImageInfo>(imageInfo)){}
26
-
27
- /**
28
- Returns the underlying object from a host object of this type
29
- */
30
- static std::shared_ptr<SkImageInfo> fromValue(jsi::Runtime &runtime,
31
- const jsi::Value &obj) {
32
- const auto& object = obj.asObject(runtime);
33
- if (object.isHostObject(runtime)) {
34
- return object
35
- .asHostObject<JsiSkImageInfo>(runtime)
36
- ->getObject();
37
- } else {
38
- auto width = object.getProperty(runtime, "width").asNumber();
39
- auto height = object.getProperty(runtime, "height").asNumber();
40
- auto colorType = static_cast<SkColorType>(object.getProperty(runtime, "colorType").asNumber());
41
- auto alphaType = static_cast<SkAlphaType>(object.getProperty(runtime, "alphaType").asNumber());
42
- // TODO: color space not supported yet
43
- return std::make_shared<SkImageInfo>(SkImageInfo::Make(width, height, colorType, alphaType));
44
- }
45
- }
46
-
47
- /**
48
- Returns the jsi object from a host object of this type
49
- */
50
- static jsi::Value toValue(jsi::Runtime &runtime,
51
- std::shared_ptr<RNSkPlatformContext> context,
52
- const SkImageInfo &imageInfo) {
53
- return jsi::Object::createFromHostObject(
54
- runtime, std::make_shared<JsiSkImageInfo>(std::move(context), imageInfo));
55
- }
56
- };
19
+ namespace jsi = facebook::jsi;
20
+
21
+ class JsiSkImageInfo : public JsiSkWrappingSharedPtrHostObject<SkImageInfo> {
22
+ public:
23
+ JsiSkImageInfo(std::shared_ptr<RNSkPlatformContext> context,
24
+ const SkImageInfo &imageInfo)
25
+ : JsiSkWrappingSharedPtrHostObject<SkImageInfo>(
26
+ std::move(context), std::make_shared<SkImageInfo>(imageInfo)) {}
27
+
28
+ /**
29
+ Returns the underlying object from a host object of this type
30
+ */
31
+ static std::shared_ptr<SkImageInfo> fromValue(jsi::Runtime &runtime,
32
+ const jsi::Value &obj) {
33
+ const auto &object = obj.asObject(runtime);
34
+ if (object.isHostObject(runtime)) {
35
+ return object.asHostObject<JsiSkImageInfo>(runtime)->getObject();
36
+ } else {
37
+ auto width = object.getProperty(runtime, "width").asNumber();
38
+ auto height = object.getProperty(runtime, "height").asNumber();
39
+ auto colorType = static_cast<SkColorType>(
40
+ object.getProperty(runtime, "colorType").asNumber());
41
+ auto alphaType = static_cast<SkAlphaType>(
42
+ object.getProperty(runtime, "alphaType").asNumber());
43
+ // TODO: color space not supported yet
44
+ return std::make_shared<SkImageInfo>(
45
+ SkImageInfo::Make(width, height, colorType, alphaType));
46
+ }
47
+ }
48
+
49
+ /**
50
+ Returns the jsi object from a host object of this type
51
+ */
52
+ static jsi::Value toValue(jsi::Runtime &runtime,
53
+ std::shared_ptr<RNSkPlatformContext> context,
54
+ const SkImageInfo &imageInfo) {
55
+ return jsi::Object::createFromHostObject(
56
+ runtime,
57
+ std::make_shared<JsiSkImageInfo>(std::move(context), imageInfo));
58
+ }
59
+ };
57
60
  } // namespace RNSkia
@@ -16,20 +16,22 @@
16
16
 
17
17
  namespace RNSkia {
18
18
 
19
- using namespace facebook;
19
+ namespace jsi = facebook::jsi;
20
20
 
21
21
  class JsiSkMaskFilter : public JsiSkWrappingSkPtrHostObject<SkMaskFilter> {
22
22
  public:
23
23
  JsiSkMaskFilter(std::shared_ptr<RNSkPlatformContext> context,
24
24
  sk_sp<SkMaskFilter> maskFilter)
25
- : JsiSkWrappingSkPtrHostObject<SkMaskFilter>(std::move(context), std::move(maskFilter)) {}
25
+ : JsiSkWrappingSkPtrHostObject<SkMaskFilter>(std::move(context),
26
+ std::move(maskFilter)) {}
26
27
 
27
28
  // TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
28
29
  JSI_PROPERTY_GET(__typename__) {
29
30
  return jsi::String::createFromUtf8(runtime, "MaskFilter");
30
31
  }
31
32
 
32
- JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkMaskFilter, __typename__))
33
+ JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkMaskFilter,
34
+ __typename__))
33
35
 
34
36
  /**
35
37
  Returns the underlying object from a host object of this type
@@ -15,10 +15,9 @@
15
15
 
16
16
  #pragma clang diagnostic pop
17
17
 
18
-
19
18
  namespace RNSkia {
20
19
 
21
- using namespace facebook;
20
+ namespace jsi = facebook::jsi;
22
21
 
23
22
  class JsiSkMaskFilterFactory : public JsiSkHostObject {
24
23
  public:
@@ -35,7 +34,7 @@ public:
35
34
 
36
35
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkMaskFilterFactory, MakeBlur))
37
36
 
38
- JsiSkMaskFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
37
+ explicit JsiSkMaskFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
39
38
  : JsiSkHostObject(std::move(context)) {}
40
39
  };
41
40
 
@@ -16,35 +16,29 @@
16
16
 
17
17
  namespace RNSkia {
18
18
 
19
- using namespace facebook;
20
-
19
+ namespace jsi = facebook::jsi;
21
20
 
22
21
  class JsiSkMatrix : public JsiSkWrappingSharedPtrHostObject<SkMatrix> {
23
22
  public:
24
-
25
23
  JsiSkMatrix(std::shared_ptr<RNSkPlatformContext> context, SkMatrix m)
26
24
  : JsiSkWrappingSharedPtrHostObject<SkMatrix>(
27
25
  context, std::make_shared<SkMatrix>(std::move(m))) {}
28
26
 
29
-
30
- static SkMatrix getMatrix(jsi::Runtime &runtime, const jsi::Value& value) {
31
- const auto& object = value.asObject(runtime);
32
- const auto& array = object.asArray(runtime);
33
- auto scaleX = array.getValueAtIndex(runtime, 0).asNumber();
34
- auto skewX = array.getValueAtIndex(runtime, 1).asNumber();
35
- auto transX = array.getValueAtIndex(runtime, 2).asNumber();
36
- auto skewY = array.getValueAtIndex(runtime, 3).asNumber();
37
- auto scaleY = array.getValueAtIndex(runtime, 4).asNumber();
38
- auto transY = array.getValueAtIndex(runtime, 5).asNumber();
39
- auto pers0 = array.getValueAtIndex(runtime, 6).asNumber();
40
- auto pers1 = array.getValueAtIndex(runtime, 7).asNumber();
41
- auto pers2 = array.getValueAtIndex(runtime, 8).asNumber();
42
- return SkMatrix::MakeAll(
43
- scaleX, skewX, transX,
44
- skewY, scaleY, transY,
45
- pers0, pers1, pers2
46
- );
47
- }
27
+ static SkMatrix getMatrix(jsi::Runtime &runtime, const jsi::Value &value) {
28
+ const auto &object = value.asObject(runtime);
29
+ const auto &array = object.asArray(runtime);
30
+ auto scaleX = array.getValueAtIndex(runtime, 0).asNumber();
31
+ auto skewX = array.getValueAtIndex(runtime, 1).asNumber();
32
+ auto transX = array.getValueAtIndex(runtime, 2).asNumber();
33
+ auto skewY = array.getValueAtIndex(runtime, 3).asNumber();
34
+ auto scaleY = array.getValueAtIndex(runtime, 4).asNumber();
35
+ auto transY = array.getValueAtIndex(runtime, 5).asNumber();
36
+ auto pers0 = array.getValueAtIndex(runtime, 6).asNumber();
37
+ auto pers1 = array.getValueAtIndex(runtime, 7).asNumber();
38
+ auto pers2 = array.getValueAtIndex(runtime, 8).asNumber();
39
+ return SkMatrix::MakeAll(scaleX, skewX, transX, skewY, scaleY, transY,
40
+ pers0, pers1, pers2);
41
+ }
48
42
 
49
43
  JSI_PROPERTY_GET(__typename__) {
50
44
  return jsi::String::createFromUtf8(runtime, "Matrix");
@@ -82,7 +76,7 @@ public:
82
76
  getObject()->preRotate(SkRadiansToDegrees(a));
83
77
  return jsi::Value::undefined();
84
78
  }
85
-
79
+
86
80
  JSI_HOST_FUNCTION(identity) {
87
81
  getObject()->setIdentity();
88
82
  return jsi::Value::undefined();
@@ -98,26 +92,22 @@ public:
98
92
 
99
93
  JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkMatrix, __typename__))
100
94
 
101
- JSI_EXPORT_FUNCTIONS(
102
- JSI_EXPORT_FUNC(JsiSkMatrix, concat),
103
- JSI_EXPORT_FUNC(JsiSkMatrix, translate),
104
- JSI_EXPORT_FUNC(JsiSkMatrix, scale),
105
- JSI_EXPORT_FUNC(JsiSkMatrix, skew),
106
- JSI_EXPORT_FUNC(JsiSkMatrix, rotate),
107
- JSI_EXPORT_FUNC(JsiSkMatrix, identity),
108
- JSI_EXPORT_FUNC(JsiSkMatrix, get),
109
- )
95
+ JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkMatrix, concat),
96
+ JSI_EXPORT_FUNC(JsiSkMatrix, translate),
97
+ JSI_EXPORT_FUNC(JsiSkMatrix, scale),
98
+ JSI_EXPORT_FUNC(JsiSkMatrix, skew),
99
+ JSI_EXPORT_FUNC(JsiSkMatrix, rotate),
100
+ JSI_EXPORT_FUNC(JsiSkMatrix, identity),
101
+ JSI_EXPORT_FUNC(JsiSkMatrix, get), )
110
102
 
111
103
  /**
112
104
  * Returns the underlying object from a host object of this type
113
105
  */
114
106
  static std::shared_ptr<SkMatrix> fromValue(jsi::Runtime &runtime,
115
107
  const jsi::Value &obj) {
116
- const auto& object = obj.asObject(runtime);
108
+ const auto &object = obj.asObject(runtime);
117
109
  if (object.isHostObject(runtime)) {
118
- return object
119
- .asHostObject<JsiSkMatrix>(runtime)
120
- ->getObject();
110
+ return object.asHostObject<JsiSkMatrix>(runtime)->getObject();
121
111
  } else {
122
112
  return std::make_shared<SkMatrix>(JsiSkMatrix::getMatrix(runtime, obj));
123
113
  }
@@ -5,13 +5,13 @@
5
5
 
6
6
  #include <jsi/jsi.h>
7
7
 
8
+ #include <JsiSkColor.h>
9
+ #include <JsiSkColorFilter.h>
8
10
  #include <JsiSkHostObjects.h>
9
11
  #include <JsiSkImageFilter.h>
10
12
  #include <JsiSkMaskFilter.h>
11
- #include <JsiSkColorFilter.h>
12
13
  #include <JsiSkPathEffect.h>
13
14
  #include <JsiSkShader.h>
14
- #include <JsiSkColor.h>
15
15
 
16
16
  #pragma clang diagnostic push
17
17
  #pragma clang diagnostic ignored "-Wdocumentation"
@@ -21,11 +21,10 @@
21
21
  #pragma clang diagnostic pop
22
22
 
23
23
  namespace RNSkia {
24
- using namespace facebook;
24
+ namespace jsi = facebook::jsi;
25
25
 
26
26
  class JsiSkPaint : public JsiSkWrappingSharedPtrHostObject<SkPaint> {
27
27
  public:
28
-
29
28
  // TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
30
29
  JSI_PROPERTY_GET(__typename__) {
31
30
  return jsi::String::createFromUtf8(runtime, "Paint");
@@ -34,7 +33,7 @@ public:
34
33
  JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPaint, __typename__))
35
34
 
36
35
  JSI_HOST_FUNCTION(copy) {
37
- const auto* paint = getObject().get();
36
+ const auto *paint = getObject().get();
38
37
  return jsi::Object::createFromHostObject(
39
38
  runtime, std::make_shared<JsiSkPaint>(getContext(), SkPaint(*paint)));
40
39
  }
@@ -119,31 +118,41 @@ public:
119
118
  }
120
119
 
121
120
  JSI_HOST_FUNCTION(setMaskFilter) {
122
- auto maskFilter = arguments[0].isNull() || arguments[0].isUndefined() ? nullptr : JsiSkMaskFilter::fromValue(runtime, arguments[0]);
121
+ auto maskFilter = arguments[0].isNull() || arguments[0].isUndefined()
122
+ ? nullptr
123
+ : JsiSkMaskFilter::fromValue(runtime, arguments[0]);
123
124
  getObject()->setMaskFilter(std::move(maskFilter));
124
125
  return jsi::Value::undefined();
125
126
  }
126
127
 
127
128
  JSI_HOST_FUNCTION(setImageFilter) {
128
- auto imageFilter = arguments[0].isNull() || arguments[0].isUndefined() ? nullptr : JsiSkImageFilter::fromValue(runtime, arguments[0]);
129
+ auto imageFilter = arguments[0].isNull() || arguments[0].isUndefined()
130
+ ? nullptr
131
+ : JsiSkImageFilter::fromValue(runtime, arguments[0]);
129
132
  getObject()->setImageFilter(std::move(imageFilter));
130
133
  return jsi::Value::undefined();
131
134
  }
132
135
 
133
136
  JSI_HOST_FUNCTION(setColorFilter) {
134
- auto colorFilter = arguments[0].isNull() || arguments[0].isUndefined() ? nullptr : JsiSkColorFilter::fromValue(runtime, arguments[0]);
137
+ auto colorFilter = arguments[0].isNull() || arguments[0].isUndefined()
138
+ ? nullptr
139
+ : JsiSkColorFilter::fromValue(runtime, arguments[0]);
135
140
  getObject()->setColorFilter(std::move(colorFilter));
136
141
  return jsi::Value::undefined();
137
142
  }
138
143
 
139
144
  JSI_HOST_FUNCTION(setShader) {
140
- auto shader = arguments[0].isNull() || arguments[0].isUndefined() ? nullptr : JsiSkShader::fromValue(runtime, arguments[0]);
145
+ auto shader = arguments[0].isNull() || arguments[0].isUndefined()
146
+ ? nullptr
147
+ : JsiSkShader::fromValue(runtime, arguments[0]);
141
148
  getObject()->setShader(std::move(shader));
142
149
  return jsi::Value::undefined();
143
150
  }
144
151
 
145
152
  JSI_HOST_FUNCTION(setPathEffect) {
146
- auto pathEffect = arguments[0].isNull() || arguments[0].isUndefined() ? nullptr : JsiSkPathEffect::fromValue(runtime, arguments[0]);
153
+ auto pathEffect = arguments[0].isNull() || arguments[0].isUndefined()
154
+ ? nullptr
155
+ : JsiSkPathEffect::fromValue(runtime, arguments[0]);
147
156
  getObject()->setPathEffect(std::move(pathEffect));
148
157
  return jsi::Value::undefined();
149
158
  }
@@ -179,9 +188,7 @@ Returns the underlying object from a host object of this type
179
188
  */
180
189
  static std::shared_ptr<SkPaint> fromValue(jsi::Runtime &runtime,
181
190
  const jsi::Value &obj) {
182
- return obj.asObject(runtime)
183
- .asHostObject<JsiSkPaint>(runtime)
184
- ->getObject();
191
+ return obj.asObject(runtime).asHostObject<JsiSkPaint>(runtime)->getObject();
185
192
  }
186
193
 
187
194
  /**
@@ -19,16 +19,18 @@
19
19
  #include <SkPath.h>
20
20
  #include <SkPathOps.h>
21
21
  #include <SkPathTypes.h>
22
+ #include <SkString.h>
22
23
  #include <SkStrokeRec.h>
23
24
  #include <SkTextUtils.h>
24
25
  #include <SkTrimPathEffect.h>
25
26
 
27
+ #include "JsiSkMatrix.h"
28
+
26
29
  #pragma clang diagnostic pop
27
30
 
28
31
  namespace RNSkia {
29
32
 
30
- using namespace facebook;
31
-
33
+ namespace jsi = facebook::jsi;
32
34
 
33
35
  class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPath> {
34
36
 
@@ -68,7 +70,7 @@ public:
68
70
  runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
69
71
  points.push_back(*point.get());
70
72
  }
71
- getObject()->addPoly(points.data(), (int)points.size(), close);
73
+ getObject()->addPoly(points.data(), static_cast<int>(points.size()), close);
72
74
  return thisValue.getObject(runtime);
73
75
  }
74
76
 
@@ -313,8 +315,8 @@ public:
313
315
  JSI_HOST_FUNCTION(makeAsWinding) {
314
316
  SkPath out;
315
317
  if (AsWinding(*getObject(), &out)) {
316
- getObject()->swap(out);
317
- return thisValue.getObject(runtime);
318
+ getObject()->swap(out);
319
+ return thisValue.getObject(runtime);
318
320
  }
319
321
  return jsi::Value::null();
320
322
  }
@@ -442,7 +444,7 @@ public:
442
444
  }
443
445
 
444
446
  JSI_HOST_FUNCTION(copy) {
445
- const auto* path = getObject().get();
447
+ const auto *path = getObject().get();
446
448
  return jsi::Object::createFromHostObject(
447
449
  runtime, std::make_shared<JsiSkPath>(getContext(), SkPath(*path)));
448
450
  }
@@ -472,16 +474,17 @@ public:
472
474
  return nullptr;
473
475
  }
474
476
  return jsi::Object::createFromHostObject(
475
- runtime, std::make_shared<JsiSkPath>(getContext(), std::move(result)));
477
+ runtime, std::make_shared<JsiSkPath>(getContext(), std::move(result)));
476
478
  }
477
479
 
478
480
  JSI_HOST_FUNCTION(toCmds) {
479
481
  auto path = *getObject();
480
482
  auto cmds = jsi::Array(runtime, path.countVerbs());
481
483
  auto it = SkPath::Iter(path, false);
482
- // { "Move", "Line", "Quad", "Conic", "Cubic", "Close", "Done" };
483
- const int pointCount[] = { 1 , 1 , 2 , 2 , 3 , 0 , 0 };
484
- const int cmdCount[] = { 3 , 3 , 5 , 6 , 7 , 1 , 0 };
484
+ // { "Move", "Line", "Quad", "Conic", "Cubic",
485
+ // "Close", "Done" };
486
+ const int pointCount[] = {1, 1, 2, 2, 3, 0, 0};
487
+ const int cmdCount[] = {3, 3, 5, 6, 7, 1, 0};
485
488
  SkPoint points[4];
486
489
  SkPath::Verb verb;
487
490
  auto k = 0;
@@ -491,11 +494,14 @@ public:
491
494
  auto j = 0;
492
495
  cmd.setValueAtIndex(runtime, j++, jsi::Value(verbVal));
493
496
  for (int i = 0; i < pointCount[verbVal]; ++i) {
494
- cmd.setValueAtIndex(runtime, j++, jsi::Value(static_cast<double>(points[1 + i].fX)));
495
- cmd.setValueAtIndex(runtime, j++, jsi::Value(static_cast<double>(points[1 + i].fY)));
497
+ cmd.setValueAtIndex(runtime, j++,
498
+ jsi::Value(static_cast<double>(points[1 + i].fX)));
499
+ cmd.setValueAtIndex(runtime, j++,
500
+ jsi::Value(static_cast<double>(points[1 + i].fY)));
496
501
  }
497
502
  if (SkPath::kConic_Verb == verb) {
498
- cmd.setValueAtIndex(runtime, j, jsi::Value(static_cast<double>(it.conicWeight())));
503
+ cmd.setValueAtIndex(runtime, j,
504
+ jsi::Value(static_cast<double>(it.conicWeight())));
499
505
  }
500
506
  cmds.setValueAtIndex(runtime, k++, cmd);
501
507
  }
@@ -505,88 +511,67 @@ public:
505
511
  JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPath, __typename__))
506
512
 
507
513
  JSI_EXPORT_FUNCTIONS(
508
- JSI_EXPORT_FUNC(JsiSkPath, addArc),
509
- JSI_EXPORT_FUNC(JsiSkPath, addOval),
510
- JSI_EXPORT_FUNC(JsiSkPath, addPoly),
511
- JSI_EXPORT_FUNC(JsiSkPath, addRect),
512
- JSI_EXPORT_FUNC(JsiSkPath, addRRect),
513
- JSI_EXPORT_FUNC(JsiSkPath, arcToOval),
514
- JSI_EXPORT_FUNC(JsiSkPath, arcToRotated),
515
- JSI_EXPORT_FUNC(JsiSkPath, rArcTo),
516
- JSI_EXPORT_FUNC(JsiSkPath, arcToTangent),
517
- JSI_EXPORT_FUNC(JsiSkPath, computeTightBounds),
518
- JSI_EXPORT_FUNC(JsiSkPath, getBounds),
519
- JSI_EXPORT_FUNC(JsiSkPath, conicTo),
520
- JSI_EXPORT_FUNC(JsiSkPath, rConicTo),
521
- JSI_EXPORT_FUNC(JsiSkPath, contains),
522
- JSI_EXPORT_FUNC(JsiSkPath, dash),
523
- JSI_EXPORT_FUNC(JsiSkPath, equals),
524
- JSI_EXPORT_FUNC(JsiSkPath, getFillType),
525
- JSI_EXPORT_FUNC(JsiSkPath, setFillType),
526
- JSI_EXPORT_FUNC(JsiSkPath, setIsVolatile),
527
- JSI_EXPORT_FUNC(JsiSkPath, isVolatile),
528
- JSI_EXPORT_FUNC(JsiSkPath, transform),
529
- JSI_EXPORT_FUNC(JsiSkPath, stroke),
530
- JSI_EXPORT_FUNC(JsiSkPath, trim),
531
- JSI_EXPORT_FUNC(JsiSkPath, getPoint),
532
- JSI_EXPORT_FUNC(JsiSkPath, toSVGString),
533
- JSI_EXPORT_FUNC(JsiSkPath, makeAsWinding),
534
- JSI_EXPORT_FUNC(JsiSkPath, isEmpty),
535
- JSI_EXPORT_FUNC(JsiSkPath, offset),
536
- JSI_EXPORT_FUNC(JsiSkPath, moveTo),
537
- JSI_EXPORT_FUNC(JsiSkPath, rMoveTo),
538
- JSI_EXPORT_FUNC(JsiSkPath, lineTo),
539
- JSI_EXPORT_FUNC(JsiSkPath, rLineTo),
540
- JSI_EXPORT_FUNC(JsiSkPath, cubicTo),
541
- JSI_EXPORT_FUNC(JsiSkPath, rCubicTo),
542
- JSI_EXPORT_FUNC(JsiSkPath, reset),
543
- JSI_EXPORT_FUNC(JsiSkPath, rewind),
544
- JSI_EXPORT_FUNC(JsiSkPath, quadTo),
545
- JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
546
- JSI_EXPORT_FUNC(JsiSkPath, addCircle),
547
- JSI_EXPORT_FUNC(JsiSkPath, getLastPt),
548
- JSI_EXPORT_FUNC(JsiSkPath, close),
549
- JSI_EXPORT_FUNC(JsiSkPath, simplify),
550
- JSI_EXPORT_FUNC(JsiSkPath, countPoints),
551
- JSI_EXPORT_FUNC(JsiSkPath, copy),
552
- JSI_EXPORT_FUNC(JsiSkPath, op),
553
- JSI_EXPORT_FUNC(JsiSkPath, isInterpolatable),
554
- JSI_EXPORT_FUNC(JsiSkPath, interpolate),
555
- JSI_EXPORT_FUNC(JsiSkPath, toCmds),
556
- )
514
+ JSI_EXPORT_FUNC(JsiSkPath, addArc), JSI_EXPORT_FUNC(JsiSkPath, addOval),
515
+ JSI_EXPORT_FUNC(JsiSkPath, addPoly), JSI_EXPORT_FUNC(JsiSkPath, addRect),
516
+ JSI_EXPORT_FUNC(JsiSkPath, addRRect),
517
+ JSI_EXPORT_FUNC(JsiSkPath, arcToOval),
518
+ JSI_EXPORT_FUNC(JsiSkPath, arcToRotated),
519
+ JSI_EXPORT_FUNC(JsiSkPath, rArcTo),
520
+ JSI_EXPORT_FUNC(JsiSkPath, arcToTangent),
521
+ JSI_EXPORT_FUNC(JsiSkPath, computeTightBounds),
522
+ JSI_EXPORT_FUNC(JsiSkPath, getBounds),
523
+ JSI_EXPORT_FUNC(JsiSkPath, conicTo), JSI_EXPORT_FUNC(JsiSkPath, rConicTo),
524
+ JSI_EXPORT_FUNC(JsiSkPath, contains), JSI_EXPORT_FUNC(JsiSkPath, dash),
525
+ JSI_EXPORT_FUNC(JsiSkPath, equals),
526
+ JSI_EXPORT_FUNC(JsiSkPath, getFillType),
527
+ JSI_EXPORT_FUNC(JsiSkPath, setFillType),
528
+ JSI_EXPORT_FUNC(JsiSkPath, setIsVolatile),
529
+ JSI_EXPORT_FUNC(JsiSkPath, isVolatile),
530
+ JSI_EXPORT_FUNC(JsiSkPath, transform), JSI_EXPORT_FUNC(JsiSkPath, stroke),
531
+ JSI_EXPORT_FUNC(JsiSkPath, trim), JSI_EXPORT_FUNC(JsiSkPath, getPoint),
532
+ JSI_EXPORT_FUNC(JsiSkPath, toSVGString),
533
+ JSI_EXPORT_FUNC(JsiSkPath, makeAsWinding),
534
+ JSI_EXPORT_FUNC(JsiSkPath, isEmpty), JSI_EXPORT_FUNC(JsiSkPath, offset),
535
+ JSI_EXPORT_FUNC(JsiSkPath, moveTo), JSI_EXPORT_FUNC(JsiSkPath, rMoveTo),
536
+ JSI_EXPORT_FUNC(JsiSkPath, lineTo), JSI_EXPORT_FUNC(JsiSkPath, rLineTo),
537
+ JSI_EXPORT_FUNC(JsiSkPath, cubicTo), JSI_EXPORT_FUNC(JsiSkPath, rCubicTo),
538
+ JSI_EXPORT_FUNC(JsiSkPath, reset), JSI_EXPORT_FUNC(JsiSkPath, rewind),
539
+ JSI_EXPORT_FUNC(JsiSkPath, quadTo), JSI_EXPORT_FUNC(JsiSkPath, rQuadTo),
540
+ JSI_EXPORT_FUNC(JsiSkPath, addCircle),
541
+ JSI_EXPORT_FUNC(JsiSkPath, getLastPt), JSI_EXPORT_FUNC(JsiSkPath, close),
542
+ JSI_EXPORT_FUNC(JsiSkPath, simplify),
543
+ JSI_EXPORT_FUNC(JsiSkPath, countPoints), JSI_EXPORT_FUNC(JsiSkPath, copy),
544
+ JSI_EXPORT_FUNC(JsiSkPath, op),
545
+ JSI_EXPORT_FUNC(JsiSkPath, isInterpolatable),
546
+ JSI_EXPORT_FUNC(JsiSkPath, interpolate),
547
+ JSI_EXPORT_FUNC(JsiSkPath, toCmds), )
557
548
 
558
549
  JsiSkPath(std::shared_ptr<RNSkPlatformContext> context, SkPath path)
559
550
  : JsiSkWrappingSharedPtrHostObject<SkPath>(
560
- std::move(context), std::make_shared<SkPath>(std::move(path))) {
561
- }
551
+ std::move(context), std::make_shared<SkPath>(std::move(path))) {}
562
552
 
563
553
  /**
564
554
  Returns the underlying object from a host object of this type
565
555
  */
566
556
  static std::shared_ptr<SkPath> fromValue(jsi::Runtime &runtime,
567
557
  const jsi::Value &obj) {
568
- return obj.asObject(runtime)
569
- .asHostObject<JsiSkPath>(runtime)
570
- ->getObject();
571
- }
572
-
573
- static jsi::Value toValue(jsi::Runtime &runtime,
574
- std::shared_ptr<RNSkPlatformContext> context,
575
- const SkPath &path) {
576
- return jsi::Object::createFromHostObject(
577
- runtime,
578
- std::make_shared<JsiSkPath>(std::move(context), path)
579
- );
580
- }
558
+ return obj.asObject(runtime).asHostObject<JsiSkPath>(runtime)->getObject();
559
+ }
581
560
 
582
- static jsi::Value toValue(jsi::Runtime &runtime,
583
- std::shared_ptr<RNSkPlatformContext> context,
584
- SkPath&& path) {
585
- return jsi::Object::createFromHostObject(
586
- runtime,
587
- std::make_shared<JsiSkPath>(std::move(context), std::move(path))
588
- );
589
- }
561
+ static jsi::Value toValue(jsi::Runtime &runtime,
562
+ std::shared_ptr<RNSkPlatformContext> context,
563
+ const SkPath &path) {
564
+ return jsi::Object::createFromHostObject(
565
+ runtime, std::make_shared<JsiSkPath>(std::move(context), path));
566
+ }
567
+
568
+ static jsi::Value toValue(jsi::Runtime &runtime,
569
+ std::shared_ptr<RNSkPlatformContext> context,
570
+ SkPath &&path) {
571
+ return jsi::Object::createFromHostObject(
572
+ runtime,
573
+ std::make_shared<JsiSkPath>(std::move(context), std::move(path)));
574
+ }
590
575
  };
591
576
 
592
577
  } // namespace RNSkia
@@ -16,20 +16,22 @@
16
16
 
17
17
  namespace RNSkia {
18
18
 
19
- using namespace facebook;
19
+ namespace jsi = facebook::jsi;
20
20
 
21
21
  class JsiSkPathEffect : public JsiSkWrappingSkPtrHostObject<SkPathEffect> {
22
22
  public:
23
23
  JsiSkPathEffect(std::shared_ptr<RNSkPlatformContext> context,
24
24
  sk_sp<SkPathEffect> pathEffect)
25
- : JsiSkWrappingSkPtrHostObject<SkPathEffect>(std::move(context), std::move(pathEffect)) {}
25
+ : JsiSkWrappingSkPtrHostObject<SkPathEffect>(std::move(context),
26
+ std::move(pathEffect)) {}
26
27
 
27
28
  // TODO: declare in JsiSkWrappingSkPtrHostObject via extra template parameter?
28
29
  JSI_PROPERTY_GET(__typename__) {
29
30
  return jsi::String::createFromUtf8(runtime, "PathEffect");
30
31
  }
31
32
 
32
- JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPathEffect, __typename__))
33
+ JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPathEffect,
34
+ __typename__))
33
35
 
34
36
  /**
35
37
  Returns the underlying object from a host object of this type