@shopify/react-native-skia 2.0.0-next.1 → 2.0.0-next.2

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 (306) hide show
  1. package/android/build.gradle +11 -1
  2. package/android/cpp/jni/JniPlatformContext.cpp +1 -0
  3. package/{ios/RNSkia-iOS → apple}/MetalContext.h +0 -5
  4. package/{ios/RNSkia-iOS → apple}/MetalWindowContext.mm +4 -0
  5. package/{ios/RNSkia-iOS/RNSkiOSPlatformContext.h → apple/RNSkApplePlatformContext.h} +7 -3
  6. package/{ios/RNSkia-iOS/RNSkiOSPlatformContext.mm → apple/RNSkApplePlatformContext.mm} +19 -19
  7. package/{ios/RNSkia-iOS/RNSkiOSVideo.h → apple/RNSkAppleVideo.h} +3 -3
  8. package/{ios/RNSkia-iOS/RNSkiOSVideo.mm → apple/RNSkAppleVideo.mm} +14 -14
  9. package/{ios/RNSkia-iOS/RNSkiOSView.h → apple/RNSkAppleView.h} +4 -4
  10. package/{ios/RNSkia-iOS/RNSkiOSView.mm → apple/RNSkAppleView.mm} +4 -4
  11. package/{ios/RNSkia-iOS → apple}/RNSkMetalCanvasProvider.mm +6 -1
  12. package/{ios/RNSkia-iOS → apple}/SkiaManager.mm +2 -2
  13. package/{ios/RNSkia-iOS → apple}/SkiaPictureView.mm +2 -2
  14. package/{ios/RNSkia-iOS → apple}/SkiaPictureViewManager.mm +6 -2
  15. package/{ios/RNSkia-iOS → apple}/SkiaUIView.h +12 -4
  16. package/{ios/RNSkia-iOS → apple}/SkiaUIView.mm +11 -7
  17. package/{ios/RNSkia-iOS → apple}/ViewScreenshotService.h +4 -0
  18. package/{ios/RNSkia-iOS → apple}/ViewScreenshotService.mm +4 -0
  19. package/cpp/api/JsiSkContourMeasure.h +1 -1
  20. package/cpp/api/JsiSkHostObjects.h +21 -10
  21. package/cpp/api/JsiSkParagraph.h +17 -27
  22. package/cpp/api/JsiSkPathEffect.h +1 -1
  23. package/cpp/api/JsiSkPictureFactory.h +1 -1
  24. package/cpp/api/JsiSkShaderFactory.h +43 -8
  25. package/cpp/api/JsiSkVertices.h +14 -3
  26. package/cpp/api/recorder/Drawings.h +4 -3
  27. package/cpp/rnskia/DawnContext.h +1 -1
  28. package/cpp/skia/include/codec/SkCodec.h +7 -2
  29. package/cpp/skia/include/config/SkUserConfig.h +11 -0
  30. package/cpp/skia/include/core/SkCanvas.h +11 -7
  31. package/cpp/skia/include/core/SkColor.h +10 -0
  32. package/cpp/skia/include/core/SkColorSpace.h +184 -2
  33. package/cpp/skia/include/core/SkColorType.h +114 -32
  34. package/cpp/skia/include/core/SkFontScanner.h +5 -8
  35. package/cpp/skia/include/core/SkFontStyle.h +1 -1
  36. package/cpp/skia/include/core/SkMaskFilter.h +0 -8
  37. package/cpp/skia/include/core/SkMilestone.h +1 -1
  38. package/cpp/skia/include/core/SkPath.h +1 -1
  39. package/cpp/skia/include/core/SkRRect.h +3 -1
  40. package/cpp/skia/include/core/SkShader.h +3 -3
  41. package/cpp/skia/include/core/SkString.h +8 -8
  42. package/cpp/skia/include/core/SkSurface.h +14 -0
  43. package/cpp/skia/include/core/SkTypeface.h +24 -7
  44. package/cpp/skia/include/effects/SkGradientShader.h +6 -1
  45. package/cpp/skia/include/effects/SkRuntimeEffect.h +1 -0
  46. package/cpp/skia/include/encode/SkPngEncoder.h +14 -0
  47. package/cpp/skia/include/gpu/GpuTypes.h +9 -0
  48. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +135 -133
  49. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +5 -0
  50. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +3 -3
  51. package/cpp/skia/include/gpu/ganesh/GrTypes.h +14 -9
  52. package/cpp/skia/include/gpu/graphite/Context.h +25 -2
  53. package/cpp/skia/include/gpu/graphite/ContextOptions.h +23 -5
  54. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +20 -1
  55. package/cpp/skia/include/gpu/graphite/Image.h +1 -0
  56. package/cpp/skia/include/gpu/graphite/LogPriority.h +36 -0
  57. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +52 -0
  58. package/cpp/skia/include/gpu/graphite/Recorder.h +6 -0
  59. package/cpp/skia/include/gpu/graphite/Recording.h +3 -1
  60. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +4 -36
  61. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +48 -0
  62. package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +3 -2
  63. package/cpp/skia/include/pathops/SkPathOps.h +9 -1
  64. package/cpp/skia/include/ports/SkFontMgr_FontConfigInterface.h +3 -0
  65. package/cpp/skia/include/private/SkPathRef.h +15 -21
  66. package/cpp/skia/include/private/base/SkAttributes.h +16 -10
  67. package/cpp/skia/include/private/base/SkMutex.h +8 -0
  68. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  69. package/cpp/skia/include/private/base/SkTDArray.h +1 -1
  70. package/cpp/skia/include/private/base/SkTemplates.h +24 -11
  71. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  72. package/cpp/skia/include/sksl/SkSLDebugTrace.h +0 -3
  73. package/cpp/skia/modules/skcms/src/Transform_inl.h +20 -20
  74. package/cpp/skia/modules/skcms/src/skcms_Transform.h +4 -3
  75. package/cpp/skia/modules/skcms/src/skcms_public.h +19 -15
  76. package/cpp/skia/modules/skresources/include/SkResources.h +3 -1
  77. package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
  78. package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
  79. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  80. package/cpp/skia/modules/svg/include/SkSVGImage.h +2 -2
  81. package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
  82. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  83. package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
  84. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +2 -0
  85. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -0
  86. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  87. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +4 -0
  88. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  89. package/cpp/skia/src/core/SkLRUCache.h +19 -13
  90. package/cpp/skia/src/core/SkTHash.h +50 -4
  91. package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +1 -0
  92. package/lib/commonjs/__tests__/setup.d.ts +18 -0
  93. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +4 -3
  94. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
  95. package/lib/commonjs/headless/index.d.ts +1 -0
  96. package/lib/commonjs/headless/index.js +12 -0
  97. package/lib/commonjs/headless/index.js.map +1 -1
  98. package/lib/commonjs/mock/index.js +1 -2
  99. package/lib/commonjs/mock/index.js.map +1 -1
  100. package/lib/commonjs/renderer/Canvas.js +3 -1
  101. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  102. package/lib/commonjs/skia/web/Host.d.ts +4 -6
  103. package/lib/commonjs/skia/web/Host.js +23 -10
  104. package/lib/commonjs/skia/web/Host.js.map +1 -1
  105. package/lib/commonjs/skia/web/JsiSkCanvas.js +15 -15
  106. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  107. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
  108. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  109. package/lib/commonjs/skia/web/JsiSkFont.js +3 -3
  110. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  111. package/lib/commonjs/skia/web/JsiSkFontMgr.js +1 -1
  112. package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +1 -1
  113. package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
  114. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  115. package/lib/commonjs/skia/web/JsiSkImageFactory.js +3 -3
  116. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  117. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +9 -9
  118. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  119. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
  120. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  121. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
  122. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  123. package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
  124. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  125. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +3 -3
  126. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  127. package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +1 -1
  128. package/lib/commonjs/skia/web/JsiSkPathFactory.js +2 -2
  129. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  130. package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
  131. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  132. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
  133. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  134. package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js +1 -1
  135. package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
  136. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +1 -1
  137. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  138. package/lib/commonjs/skia/web/JsiSkia.js +4 -3
  139. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  140. package/lib/commonjs/skia/web/JsiVideo.js +2 -1
  141. package/lib/commonjs/skia/web/JsiVideo.js.map +1 -1
  142. package/lib/commonjs/sksg/HostConfig.js +3 -1
  143. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  144. package/lib/commonjs/sksg/Recorder/Core.d.ts +1 -5
  145. package/lib/commonjs/sksg/Recorder/Core.js +12 -4
  146. package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
  147. package/lib/commonjs/sksg/Recorder/Player.js +4 -5
  148. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  149. package/lib/commonjs/sksg/Recorder/commands/Box.js +2 -4
  150. package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -1
  151. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +2 -0
  152. package/lib/commonjs/specs/NativeSkiaModule.web.js +10 -1
  153. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  154. package/lib/module/__tests__/setup.d.ts +18 -0
  155. package/lib/module/external/reanimated/useAnimatedImageValue.js +4 -3
  156. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
  157. package/lib/module/headless/index.d.ts +1 -0
  158. package/lib/module/headless/index.js +1 -0
  159. package/lib/module/headless/index.js.map +1 -1
  160. package/lib/module/mock/index.js +1 -2
  161. package/lib/module/mock/index.js.map +1 -1
  162. package/lib/module/renderer/Canvas.js +3 -1
  163. package/lib/module/renderer/Canvas.js.map +1 -1
  164. package/lib/module/skia/web/Host.d.ts +4 -6
  165. package/lib/module/skia/web/Host.js +21 -8
  166. package/lib/module/skia/web/Host.js.map +1 -1
  167. package/lib/module/skia/web/JsiSkCanvas.js +15 -15
  168. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  169. package/lib/module/skia/web/JsiSkColorFilterFactory.js +1 -1
  170. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  171. package/lib/module/skia/web/JsiSkFont.js +4 -4
  172. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  173. package/lib/module/skia/web/JsiSkFontMgr.js +2 -2
  174. package/lib/module/skia/web/JsiSkFontMgr.js.map +1 -1
  175. package/lib/module/skia/web/JsiSkImage.js +6 -6
  176. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  177. package/lib/module/skia/web/JsiSkImageFactory.js +4 -4
  178. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  179. package/lib/module/skia/web/JsiSkImageFilterFactory.js +10 -10
  180. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  181. package/lib/module/skia/web/JsiSkMaskFilterFactory.js +1 -1
  182. package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  183. package/lib/module/skia/web/JsiSkPaint.js +3 -3
  184. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  185. package/lib/module/skia/web/JsiSkPath.js +4 -4
  186. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  187. package/lib/module/skia/web/JsiSkPathEffectFactory.js +4 -4
  188. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  189. package/lib/module/skia/web/JsiSkPathFactory.d.ts +1 -1
  190. package/lib/module/skia/web/JsiSkPathFactory.js +3 -3
  191. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  192. package/lib/module/skia/web/JsiSkPicture.js +1 -1
  193. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  194. package/lib/module/skia/web/JsiSkShaderFactory.js +5 -5
  195. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  196. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js +2 -2
  197. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
  198. package/lib/module/skia/web/JsiSkVerticesFactory.js +1 -1
  199. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  200. package/lib/module/skia/web/JsiSkia.js +4 -3
  201. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  202. package/lib/module/skia/web/JsiVideo.js +2 -1
  203. package/lib/module/skia/web/JsiVideo.js.map +1 -1
  204. package/lib/module/sksg/HostConfig.js +3 -1
  205. package/lib/module/sksg/HostConfig.js.map +1 -1
  206. package/lib/module/sksg/Recorder/Core.d.ts +1 -5
  207. package/lib/module/sksg/Recorder/Core.js +10 -2
  208. package/lib/module/sksg/Recorder/Core.js.map +1 -1
  209. package/lib/module/sksg/Recorder/Player.js +5 -6
  210. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  211. package/lib/module/sksg/Recorder/commands/Box.js +3 -5
  212. package/lib/module/sksg/Recorder/commands/Box.js.map +1 -1
  213. package/lib/module/specs/NativeSkiaModule.web.d.ts +2 -0
  214. package/lib/module/specs/NativeSkiaModule.web.js +10 -1
  215. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  216. package/lib/typescript/lib/commonjs/mock/index.d.ts +2 -2
  217. package/lib/typescript/lib/commonjs/skia/index.d.ts +1 -1
  218. package/lib/typescript/lib/commonjs/skia/web/Host.d.ts +3 -5
  219. package/lib/typescript/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
  220. package/lib/typescript/lib/commonjs/skia/web/JsiSkFontMgr.d.ts +1 -1
  221. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +1 -1
  222. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +1 -1
  223. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathEffectFactory.d.ts +2 -2
  224. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +1 -1
  225. package/lib/typescript/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -1
  226. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +3 -3
  227. package/lib/typescript/lib/commonjs/skia/web/JsiVideo.d.ts +1 -1
  228. package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +1 -1
  229. package/lib/typescript/lib/module/headless/index.d.ts +1 -0
  230. package/lib/typescript/lib/module/mock/index.d.ts +5 -5
  231. package/lib/typescript/lib/module/skia/Skia.d.ts +1 -1
  232. package/lib/typescript/lib/module/skia/Skia.web.d.ts +3 -3
  233. package/lib/typescript/lib/module/skia/web/Host.d.ts +3 -5
  234. package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -1
  235. package/lib/typescript/lib/module/skia/web/JsiSkFontMgr.d.ts +1 -1
  236. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +1 -1
  237. package/lib/typescript/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +1 -1
  238. package/lib/typescript/lib/module/skia/web/JsiSkPathEffectFactory.d.ts +2 -2
  239. package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +1 -1
  240. package/lib/typescript/lib/module/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -1
  241. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +3 -3
  242. package/lib/typescript/lib/module/skia/web/JsiVideo.d.ts +1 -1
  243. package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +1 -1
  244. package/lib/typescript/src/__tests__/setup.d.ts +18 -0
  245. package/lib/typescript/src/headless/index.d.ts +1 -0
  246. package/lib/typescript/src/skia/web/Host.d.ts +4 -6
  247. package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +1 -1
  248. package/lib/typescript/src/sksg/Recorder/Core.d.ts +1 -5
  249. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +2 -0
  250. package/package.json +6 -5
  251. package/react-native-skia.podspec +3 -3
  252. package/src/__tests__/setup.ts +67 -1
  253. package/src/external/reanimated/useAnimatedImageValue.ts +4 -3
  254. package/src/headless/index.ts +2 -1
  255. package/src/mock/index.ts +1 -2
  256. package/src/renderer/Canvas.tsx +2 -1
  257. package/src/renderer/__tests__/e2e/Matrix4.spec.tsx +1 -2
  258. package/src/renderer/__tests__/e2e/Paths.spec.tsx +13 -11
  259. package/src/skia/__tests__/Enums.spec.ts +24 -2
  260. package/src/skia/__tests__/Path.spec.ts +2 -2
  261. package/src/skia/web/Host.ts +29 -11
  262. package/src/skia/web/JsiSkCanvas.ts +17 -17
  263. package/src/skia/web/JsiSkColorFilterFactory.ts +1 -1
  264. package/src/skia/web/JsiSkFont.ts +5 -5
  265. package/src/skia/web/JsiSkFontMgr.ts +3 -3
  266. package/src/skia/web/JsiSkImage.ts +14 -10
  267. package/src/skia/web/JsiSkImageFactory.ts +5 -5
  268. package/src/skia/web/JsiSkImageFilterFactory.ts +12 -22
  269. package/src/skia/web/JsiSkMaskFilterFactory.ts +1 -1
  270. package/src/skia/web/JsiSkPaint.ts +3 -3
  271. package/src/skia/web/JsiSkPath.ts +4 -4
  272. package/src/skia/web/JsiSkPathEffectFactory.ts +6 -6
  273. package/src/skia/web/JsiSkPathFactory.ts +4 -9
  274. package/src/skia/web/JsiSkPicture.ts +3 -3
  275. package/src/skia/web/JsiSkShaderFactory.ts +5 -5
  276. package/src/skia/web/JsiSkTypefaceFontProvider.ts +3 -3
  277. package/src/skia/web/JsiSkVerticesFactory.ts +1 -1
  278. package/src/skia/web/JsiSkia.ts +7 -4
  279. package/src/skia/web/JsiVideo.ts +2 -1
  280. package/src/sksg/HostConfig.ts +1 -1
  281. package/src/sksg/Recorder/Core.ts +5 -7
  282. package/src/sksg/Recorder/Player.ts +5 -6
  283. package/src/sksg/Recorder/commands/Box.ts +3 -5
  284. package/src/specs/NativeSkiaModule.web.ts +12 -2
  285. package/ios/Rnskia.xcodeproj/project.pbxproj +0 -281
  286. package/ios/Rnskia.xcworkspace/contents.xcworkspacedata +0 -7
  287. package/lib/commonjs/skia/types/Image/ColorType.web.d.ts +0 -19
  288. package/lib/commonjs/skia/types/Image/ColorType.web.js +0 -43
  289. package/lib/commonjs/skia/types/Image/ColorType.web.js.map +0 -1
  290. package/lib/module/skia/types/Image/ColorType.web.d.ts +0 -19
  291. package/lib/module/skia/types/Image/ColorType.web.js +0 -37
  292. package/lib/module/skia/types/Image/ColorType.web.js.map +0 -1
  293. package/lib/typescript/lib/commonjs/skia/types/Image/ColorType.web.d.ts +0 -2
  294. package/lib/typescript/lib/module/skia/types/Image/ColorType.web.d.ts +0 -1
  295. package/lib/typescript/src/skia/types/Image/ColorType.web.d.ts +0 -19
  296. package/src/skia/types/Image/ColorType.web.ts +0 -19
  297. /package/{ios/RNSkia-iOS → apple}/MetalContext.mm +0 -0
  298. /package/{ios/RNSkia-iOS → apple}/MetalWindowContext.h +0 -0
  299. /package/{ios/RNSkia-iOS → apple}/RNSkMetalCanvasProvider.h +0 -0
  300. /package/{ios → apple}/RNSkiaModule.h +0 -0
  301. /package/{ios → apple}/RNSkiaModule.mm +0 -0
  302. /package/{ios/RNSkia-iOS → apple}/SkiaCVPixelBufferUtils.h +0 -0
  303. /package/{ios/RNSkia-iOS → apple}/SkiaCVPixelBufferUtils.mm +0 -0
  304. /package/{ios/RNSkia-iOS → apple}/SkiaManager.h +0 -0
  305. /package/{ios/RNSkia-iOS → apple}/SkiaPictureView.h +0 -0
  306. /package/{ios/RNSkia-iOS → apple}/SkiaPictureViewManager.h +0 -0
@@ -19,7 +19,7 @@ import java.nio.file.Paths
19
19
  // the minimum React Native version supported.
20
20
  def DEFAULT_COMPILE_SDK_VERSION = 28
21
21
  def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
22
- def DEFAULT_MIN_SDK_VERSION = 26
22
+ def DEFAULT_MIN_SDK_VERSION = 21
23
23
  def DEFAULT_TARGET_SDK_VERSION = 28
24
24
 
25
25
  def safeExtGet(prop, fallback) {
@@ -132,6 +132,16 @@ android {
132
132
 
133
133
  compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
134
134
  buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
135
+
136
+ // Used to override the NDK path/version on internal CI or by allowing
137
+ // users to customize the NDK path/version from their root project.
138
+ if (rootProject.hasProperty("ndkPath")) {
139
+ ndkPath rootProject.ext.ndkPath
140
+ }
141
+ if (rootProject.hasProperty("ndkVersion")) {
142
+ ndkVersion rootProject.ext.ndkVersion
143
+ }
144
+
135
145
  defaultConfig {
136
146
  minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
137
147
  targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
@@ -162,6 +162,7 @@ void JniPlatformContext::performStreamOperation(
162
162
  jni::Environment::current()->GetByteArrayElements(array.get(), nullptr);
163
163
  if (!elements) {
164
164
  printf("Element Fail\n");
165
+ free(buffer);
165
166
  return;
166
167
  }
167
168
 
@@ -14,10 +14,6 @@
14
14
  #import <include/gpu/ganesh/mtl/GrMtlDirectContext.h>
15
15
  #import <include/gpu/ganesh/mtl/SkSurfaceMetal.h>
16
16
 
17
- // namespace RNSkia {
18
- // class RNSkiOSPlatformContext;
19
- // }
20
-
21
17
  class MetalSharedContext {
22
18
  public:
23
19
  static MetalSharedContext &getInstance() {
@@ -126,7 +122,6 @@ public:
126
122
  GrDirectContext *getDirectContext() { return _directContext.get(); }
127
123
 
128
124
  private:
129
- // friend class RNSkia::RNSkiOSPlatformContext;
130
125
  id<MTLCommandQueue> _commandQueue = nullptr;
131
126
  sk_sp<GrDirectContext> _directContext = nullptr;
132
127
 
@@ -15,7 +15,11 @@ MetalWindowContext::MetalWindowContext(GrDirectContext *directContext,
15
15
  _layer.framebufferOnly = NO;
16
16
  _layer.device = device;
17
17
  _layer.opaque = false;
18
+ #if !TARGET_OS_OSX
18
19
  _layer.contentsScale = [UIScreen mainScreen].scale;
20
+ #else
21
+ _layer.contentsScale = [NSScreen mainScreen].backingScaleFactor;
22
+ #endif // !TARGET_OS_OSX
19
23
  _layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
20
24
  _layer.contentsGravity = kCAGravityBottomLeft;
21
25
  _layer.drawableSize = CGSizeMake(width, height);
@@ -18,19 +18,23 @@ class CallInvoker;
18
18
 
19
19
  namespace RNSkia {
20
20
 
21
- class RNSkiOSPlatformContext : public RNSkPlatformContext {
21
+ class RNSkApplePlatformContext : public RNSkPlatformContext {
22
22
  public:
23
- RNSkiOSPlatformContext(
23
+ RNSkApplePlatformContext(
24
24
  RCTBridge *bridge,
25
25
  std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker)
26
+ #if !TARGET_OS_OSX
26
27
  : RNSkPlatformContext(jsCallInvoker, [[UIScreen mainScreen] scale]) {
28
+ #else
29
+ : RNSkPlatformContext(jsCallInvoker, [[NSScreen mainScreen] backingScaleFactor]) {
30
+ #endif // !TARGET_OS_OSX
27
31
 
28
32
  // Create screenshot manager
29
33
  _screenshotService =
30
34
  [[ViewScreenshotService alloc] initWithUiManager:bridge.uiManager];
31
35
  }
32
36
 
33
- ~RNSkiOSPlatformContext() = default;
37
+ ~RNSkApplePlatformContext() = default;
34
38
 
35
39
  void runOnMainThread(std::function<void()>) override;
36
40
 
@@ -1,4 +1,4 @@
1
- #import "RNSkiOSPlatformContext.h"
1
+ #import "RNSkApplePlatformContext.h"
2
2
 
3
3
  #import <CoreMedia/CMSampleBuffer.h>
4
4
  #include <Metal/Metal.h>
@@ -11,7 +11,7 @@
11
11
  #else
12
12
  #include "MetalContext.h"
13
13
  #endif
14
- #include "RNSkiOSVideo.h"
14
+ #include "RNSkAppleVideo.h"
15
15
 
16
16
  #pragma clang diagnostic push
17
17
  #pragma clang diagnostic ignored "-Wdocumentation"
@@ -26,7 +26,7 @@
26
26
 
27
27
  namespace RNSkia {
28
28
 
29
- void RNSkiOSPlatformContext::performStreamOperation(
29
+ void RNSkApplePlatformContext::performStreamOperation(
30
30
  const std::string &sourceUri,
31
31
  const std::function<void(std::unique_ptr<SkStreamAsset>)> &op) {
32
32
 
@@ -64,14 +64,14 @@ void RNSkiOSPlatformContext::performStreamOperation(
64
64
  std::thread(loader).detach();
65
65
  }
66
66
 
67
- void RNSkiOSPlatformContext::releaseNativeBuffer(uint64_t pointer) {
67
+ void RNSkApplePlatformContext::releaseNativeBuffer(uint64_t pointer) {
68
68
  CVPixelBufferRef pixelBuffer = reinterpret_cast<CVPixelBufferRef>(pointer);
69
69
  if (pixelBuffer) {
70
70
  CFRelease(pixelBuffer);
71
71
  }
72
72
  }
73
73
 
74
- uint64_t RNSkiOSPlatformContext::makeNativeBuffer(sk_sp<SkImage> image) {
74
+ uint64_t RNSkApplePlatformContext::makeNativeBuffer(sk_sp<SkImage> image) {
75
75
  // 0. If Image is not in BGRA, convert to BGRA as only BGRA is supported.
76
76
  if (image->colorType() != kBGRA_8888_SkColorType) {
77
77
  #if defined(SK_GRAPHITE)
@@ -156,7 +156,7 @@ uint64_t RNSkiOSPlatformContext::makeNativeBuffer(sk_sp<SkImage> image) {
156
156
  return reinterpret_cast<uint64_t>(pixelBuffer);
157
157
  }
158
158
 
159
- const TextureInfo RNSkiOSPlatformContext::getTexture(sk_sp<SkImage> image) {
159
+ const TextureInfo RNSkApplePlatformContext::getTexture(sk_sp<SkImage> image) {
160
160
  GrBackendTexture texture;
161
161
  TextureInfo result;
162
162
  if (!SkImages::GetBackendTextureFromImage(image, &texture, true)) {
@@ -173,7 +173,7 @@ const TextureInfo RNSkiOSPlatformContext::getTexture(sk_sp<SkImage> image) {
173
173
  return result;
174
174
  }
175
175
 
176
- const TextureInfo RNSkiOSPlatformContext::getTexture(sk_sp<SkSurface> surface) {
176
+ const TextureInfo RNSkApplePlatformContext::getTexture(sk_sp<SkSurface> surface) {
177
177
  GrBackendTexture texture = SkSurfaces::GetBackendTexture(
178
178
  surface.get(), SkSurfaces::BackendHandleAccess::kFlushRead);
179
179
  TextureInfo result;
@@ -189,12 +189,12 @@ const TextureInfo RNSkiOSPlatformContext::getTexture(sk_sp<SkSurface> surface) {
189
189
  }
190
190
 
191
191
  std::shared_ptr<RNSkVideo>
192
- RNSkiOSPlatformContext::createVideo(const std::string &url) {
193
- return std::make_shared<RNSkiOSVideo>(url, this);
192
+ RNSkApplePlatformContext::createVideo(const std::string &url) {
193
+ return std::make_shared<RNSkAppleVideo>(url, this);
194
194
  }
195
195
 
196
196
  std::shared_ptr<WindowContext>
197
- RNSkiOSPlatformContext::makeContextFromNativeSurface(void *surface, int width,
197
+ RNSkApplePlatformContext::makeContextFromNativeSurface(void *surface, int width,
198
198
  int height) {
199
199
  #if defined(SK_GRAPHITE)
200
200
  return DawnContext::getInstance().MakeWindow(surface, width, height);
@@ -204,11 +204,11 @@ RNSkiOSPlatformContext::makeContextFromNativeSurface(void *surface, int width,
204
204
  #endif
205
205
  }
206
206
 
207
- void RNSkiOSPlatformContext::raiseError(const std::exception &err) {
207
+ void RNSkApplePlatformContext::raiseError(const std::exception &err) {
208
208
  RCTFatal(RCTErrorWithMessage([NSString stringWithUTF8String:err.what()]));
209
209
  }
210
210
 
211
- sk_sp<SkSurface> RNSkiOSPlatformContext::makeOffscreenSurface(int width,
211
+ sk_sp<SkSurface> RNSkApplePlatformContext::makeOffscreenSurface(int width,
212
212
  int height) {
213
213
  #if defined(SK_GRAPHITE)
214
214
  return DawnContext::getInstance().MakeOffscreen(width, height);
@@ -217,7 +217,7 @@ sk_sp<SkSurface> RNSkiOSPlatformContext::makeOffscreenSurface(int width,
217
217
  #endif
218
218
  }
219
219
 
220
- sk_sp<SkImage> RNSkiOSPlatformContext::makeImageFromNativeBuffer(void *buffer) {
220
+ sk_sp<SkImage> RNSkApplePlatformContext::makeImageFromNativeBuffer(void *buffer) {
221
221
  #if defined(SK_GRAPHITE)
222
222
  return DawnContext::getInstance().MakeImageFromBuffer(buffer);
223
223
  #else
@@ -225,7 +225,7 @@ sk_sp<SkImage> RNSkiOSPlatformContext::makeImageFromNativeBuffer(void *buffer) {
225
225
  #endif
226
226
  }
227
227
 
228
- sk_sp<SkImage> RNSkiOSPlatformContext::makeImageFromNativeTexture(
228
+ sk_sp<SkImage> RNSkApplePlatformContext::makeImageFromNativeTexture(
229
229
  const TextureInfo &texInfo, int width, int height, bool mipMapped) {
230
230
  id<MTLTexture> mtlTexture = (__bridge id<MTLTexture>)(texInfo.mtlTexture);
231
231
 
@@ -246,7 +246,7 @@ sk_sp<SkImage> RNSkiOSPlatformContext::makeImageFromNativeTexture(
246
246
  kPremul_SkAlphaType, nullptr);
247
247
  }
248
248
 
249
- SkColorType RNSkiOSPlatformContext::mtlPixelFormatToSkColorType(
249
+ SkColorType RNSkApplePlatformContext::mtlPixelFormatToSkColorType(
250
250
  MTLPixelFormat pixelFormat) {
251
251
  switch (pixelFormat) {
252
252
  case MTLPixelFormatRGBA8Unorm:
@@ -279,23 +279,23 @@ SkColorType RNSkiOSPlatformContext::mtlPixelFormatToSkColorType(
279
279
  }
280
280
 
281
281
  #if !defined(SK_GRAPHITE)
282
- GrDirectContext *RNSkiOSPlatformContext::getDirectContext() {
282
+ GrDirectContext *RNSkApplePlatformContext::getDirectContext() {
283
283
  return MetalContext::getInstance().getDirectContext();
284
284
  }
285
285
  #endif
286
286
 
287
- sk_sp<SkFontMgr> RNSkiOSPlatformContext::createFontMgr() {
287
+ sk_sp<SkFontMgr> RNSkApplePlatformContext::createFontMgr() {
288
288
  return SkFontMgr_New_CoreText(nullptr);
289
289
  }
290
290
 
291
- void RNSkiOSPlatformContext::runOnMainThread(std::function<void()> func) {
291
+ void RNSkApplePlatformContext::runOnMainThread(std::function<void()> func) {
292
292
  dispatch_async(dispatch_get_main_queue(), ^{
293
293
  func();
294
294
  });
295
295
  }
296
296
 
297
297
  sk_sp<SkImage>
298
- RNSkiOSPlatformContext::takeScreenshotFromViewTag(size_t viewTag) {
298
+ RNSkApplePlatformContext::takeScreenshotFromViewTag(size_t viewTag) {
299
299
  return [_screenshotService
300
300
  screenshotOfViewWithTag:[NSNumber numberWithLong:viewTag]];
301
301
  }
@@ -18,7 +18,7 @@
18
18
 
19
19
  namespace RNSkia {
20
20
 
21
- class RNSkiOSVideo : public RNSkVideo {
21
+ class RNSkAppleVideo : public RNSkVideo {
22
22
  private:
23
23
  std::string _url;
24
24
  AVPlayer *_player = nullptr;
@@ -35,8 +35,8 @@ private:
35
35
  NSDictionary *getOutputSettings();
36
36
 
37
37
  public:
38
- RNSkiOSVideo(std::string url, RNSkPlatformContext *context);
39
- ~RNSkiOSVideo();
38
+ RNSkAppleVideo(std::string url, RNSkPlatformContext *context);
39
+ ~RNSkAppleVideo();
40
40
  sk_sp<SkImage> nextImage(double *timeStamp = nullptr) override;
41
41
  double duration() override;
42
42
  double framerate() override;
@@ -8,24 +8,24 @@
8
8
 
9
9
  #pragma clang diagnostic pop
10
10
 
11
- #include "RNSkiOSVideo.h"
11
+ #include "RNSkAppleVideo.h"
12
12
  #include <AVFoundation/AVFoundation.h>
13
13
  #include <CoreVideo/CoreVideo.h>
14
14
 
15
15
  namespace RNSkia {
16
16
 
17
- RNSkiOSVideo::RNSkiOSVideo(std::string url, RNSkPlatformContext *context)
17
+ RNSkAppleVideo::RNSkAppleVideo(std::string url, RNSkPlatformContext *context)
18
18
  : _url(std::move(url)), _context(context) {
19
19
  setupPlayer();
20
20
  }
21
21
 
22
- RNSkiOSVideo::~RNSkiOSVideo() {
22
+ RNSkAppleVideo::~RNSkAppleVideo() {
23
23
  if (_player) {
24
24
  [_player pause];
25
25
  }
26
26
  }
27
27
 
28
- void RNSkiOSVideo::setupPlayer() {
28
+ void RNSkAppleVideo::setupPlayer() {
29
29
  NSURL *videoURL = [NSURL URLWithString:@(_url.c_str())];
30
30
  AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:videoURL];
31
31
  _player = [AVPlayer playerWithPlayerItem:playerItem];
@@ -53,7 +53,7 @@ void RNSkiOSVideo::setupPlayer() {
53
53
  play();
54
54
  }
55
55
 
56
- sk_sp<SkImage> RNSkiOSVideo::nextImage(double *timeStamp) {
56
+ sk_sp<SkImage> RNSkAppleVideo::nextImage(double *timeStamp) {
57
57
  CMTime currentTime = [_player currentTime];
58
58
  CVPixelBufferRef pixelBuffer =
59
59
  [_videoOutput copyPixelBufferForItemTime:currentTime
@@ -73,14 +73,14 @@ sk_sp<SkImage> RNSkiOSVideo::nextImage(double *timeStamp) {
73
73
  return skImage;
74
74
  }
75
75
 
76
- NSDictionary *RNSkiOSVideo::getOutputSettings() {
76
+ NSDictionary *RNSkAppleVideo::getOutputSettings() {
77
77
  return @{
78
78
  (id)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_32BGRA),
79
79
  (id)kCVPixelBufferMetalCompatibilityKey : @YES
80
80
  };
81
81
  }
82
82
 
83
- float RNSkiOSVideo::getRotationInDegrees() {
83
+ float RNSkAppleVideo::getRotationInDegrees() {
84
84
  CGFloat rotationAngle = 0.0;
85
85
  auto transform = _preferredTransform;
86
86
  // Determine the rotation angle in radians
@@ -97,7 +97,7 @@ float RNSkiOSVideo::getRotationInDegrees() {
97
97
  return rotationAngle;
98
98
  }
99
99
 
100
- void RNSkiOSVideo::seek(double timeInMilliseconds) {
100
+ void RNSkAppleVideo::seek(double timeInMilliseconds) {
101
101
  CMTime seekTime =
102
102
  CMTimeMakeWithSeconds(timeInMilliseconds / 1000.0, NSEC_PER_SEC);
103
103
  [_player seekToTime:seekTime
@@ -110,28 +110,28 @@ void RNSkiOSVideo::seek(double timeInMilliseconds) {
110
110
  }];
111
111
  }
112
112
 
113
- void RNSkiOSVideo::play() {
113
+ void RNSkAppleVideo::play() {
114
114
  if (_player) {
115
115
  [_player play];
116
116
  _isPlaying = true;
117
117
  }
118
118
  }
119
119
 
120
- void RNSkiOSVideo::pause() {
120
+ void RNSkAppleVideo::pause() {
121
121
  if (_player) {
122
122
  [_player pause];
123
123
  _isPlaying = false;
124
124
  }
125
125
  }
126
126
 
127
- double RNSkiOSVideo::duration() { return _duration; }
127
+ double RNSkAppleVideo::duration() { return _duration; }
128
128
 
129
- double RNSkiOSVideo::framerate() { return _framerate; }
129
+ double RNSkAppleVideo::framerate() { return _framerate; }
130
130
 
131
- SkISize RNSkiOSVideo::getSize() {
131
+ SkISize RNSkAppleVideo::getSize() {
132
132
  return SkISize::Make(_videoWidth, _videoHeight);
133
133
  }
134
134
 
135
- void RNSkiOSVideo::setVolume(float volume) { _player.volume = volume; }
135
+ void RNSkAppleVideo::setVolume(float volume) { _player.volume = volume; }
136
136
 
137
137
  } // namespace RNSkia
@@ -4,18 +4,18 @@
4
4
 
5
5
  #import "RNSkMetalCanvasProvider.h"
6
6
  #import "RNSkView.h"
7
- #import "RNSkiOSPlatformContext.h"
7
+ #import "RNSkApplePlatformContext.h"
8
8
 
9
- class RNSkBaseiOSView {
9
+ class RNSkBaseAppleView {
10
10
  public:
11
11
  virtual CALayer *getLayer() = 0;
12
12
  virtual void setSize(int width, int height) = 0;
13
13
  virtual std::shared_ptr<RNSkia::RNSkView> getDrawView() = 0;
14
14
  };
15
15
 
16
- template <class T> class RNSkiOSView : public RNSkBaseiOSView, public T {
16
+ template <class T> class RNSkAppleView : public RNSkBaseAppleView, public T {
17
17
  public:
18
- RNSkiOSView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
18
+ RNSkAppleView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
19
19
  : T(context,
20
20
  std::make_shared<RNSkMetalCanvasProvider>(
21
21
  std::bind(&RNSkia::RNSkView::requestRedraw, this), context)) {}
@@ -2,18 +2,18 @@
2
2
 
3
3
  #import "RNSkMetalCanvasProvider.h"
4
4
  #import "RNSkView.h"
5
- #import "RNSkiOSPlatformContext.h"
5
+ #import "RNSkApplePlatformContext.h"
6
6
 
7
- class RNSkBaseiOSView {
7
+ class RNSkBaseAppleView {
8
8
  public:
9
9
  virtual CALayer *getLayer() = 0;
10
10
  virtual void setSize(int width, int height) = 0;
11
11
  virtual std::shared_ptr<RNSkia::RNSkView> getDrawView() = 0;
12
12
  };
13
13
 
14
- template <class T> class RNSkiOSView : public RNSkBaseiOSView, public T {
14
+ template <class T> class RNSkAppleView : public RNSkBaseAppleView, public T {
15
15
  public:
16
- RNSkiOSView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
16
+ RNSkAppleView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
17
17
  : T(context,
18
18
  std::make_shared<RNSkMetalCanvasProvider>(
19
19
  std::bind(&RNSkia::RNSkView::requestRedraw, this), context)) {}
@@ -63,8 +63,13 @@ bool RNSkMetalCanvasProvider::renderToCanvas(
63
63
  // NOTE: UIApplication.sharedApplication.applicationState can only be
64
64
  // accessed from the main thread so we need to check here.
65
65
  if ([[NSThread currentThread] isMainThread]) {
66
+ #if !TARGET_OS_OSX
66
67
  auto state = UIApplication.sharedApplication.applicationState;
67
- if (state == UIApplicationStateBackground) {
68
+ bool appIsBackgrounded = (state == UIApplicationStateBackground);
69
+ #else
70
+ bool appIsBackgrounded = !NSApplication.sharedApplication.isActive;
71
+ #endif // !TARGET_OS_OSX
72
+ if (appIsBackgrounded) {
68
73
  // Request a redraw in the next run loop callback
69
74
  _requestRedraw();
70
75
  // and don't draw now since it might cause errors in the metal renderer if
@@ -6,7 +6,7 @@
6
6
  #import <React/RCTBridge.h>
7
7
  #import <React/RCTUIManager.h>
8
8
 
9
- #import "RNSkiOSPlatformContext.h"
9
+ #import "RNSkApplePlatformContext.h"
10
10
 
11
11
  static __weak SkiaManager *sharedInstance = nil;
12
12
 
@@ -41,7 +41,7 @@ static __weak SkiaManager *sharedInstance = nil;
41
41
  // Create the RNSkiaManager (cross platform)
42
42
  _skManager = std::make_shared<RNSkia::RNSkManager>(
43
43
  jsRuntime, jsInvoker,
44
- std::make_shared<RNSkia::RNSkiOSPlatformContext>(bridge, jsInvoker));
44
+ std::make_shared<RNSkia::RNSkApplePlatformContext>(bridge, jsInvoker));
45
45
  }
46
46
  }
47
47
  return self;
@@ -1,7 +1,7 @@
1
1
  #ifdef RCT_NEW_ARCH_ENABLED
2
2
  #import "SkiaPictureView.h"
3
3
 
4
- #import "RNSkIOSView.h"
4
+ #import "RNSkAppleView.h"
5
5
  #import "RNSkPictureView.h"
6
6
  #import "RNSkPlatformContext.h"
7
7
 
@@ -28,7 +28,7 @@ using namespace facebook::react;
28
28
  auto skManager = [SkiaManager latestActiveSkManager].get();
29
29
  [self initCommon:skManager
30
30
  factory:[](std::shared_ptr<RNSkia::RNSkPlatformContext> context) {
31
- return std::make_shared<RNSkiOSView<RNSkia::RNSkPictureView>>(
31
+ return std::make_shared<RNSkAppleView<RNSkia::RNSkPictureView>>(
32
32
  context);
33
33
  }];
34
34
  static const auto defaultProps =
@@ -2,7 +2,7 @@
2
2
  #include "SkiaPictureViewManager.h"
3
3
  #include <React/RCTBridge+Private.h>
4
4
 
5
- #include "RNSkIOSView.h"
5
+ #include "RNSkAppleView.h"
6
6
  #include "RNSkPictureView.h"
7
7
  #include "RNSkPlatformContext.h"
8
8
 
@@ -37,13 +37,17 @@ RCT_CUSTOM_VIEW_PROPERTY(opaque, BOOL, SkiaUIView) {
37
37
  [(SkiaUIView *)view setOpaque:opaque];
38
38
  }
39
39
 
40
+ #if !TARGET_OS_OSX
40
41
  - (UIView *)view {
42
+ #else
43
+ - (RCTUIView *)view {
44
+ #endif // !TARGET_OS_OSX
41
45
  auto skManager = [[self skiaManager] skManager];
42
46
  // Pass SkManager as a raw pointer to avoid circular dependenciesr
43
47
  return [[SkiaUIView alloc]
44
48
  initWithManager:skManager.get()
45
49
  factory:[](std::shared_ptr<RNSkia::RNSkPlatformContext> context) {
46
- return std::make_shared<RNSkiOSView<RNSkia::RNSkPictureView>>(
50
+ return std::make_shared<RNSkAppleView<RNSkia::RNSkPictureView>>(
47
51
  context);
48
52
  }];
49
53
  }
@@ -4,10 +4,14 @@
4
4
  #import <string>
5
5
 
6
6
  #import <CoreFoundation/CoreFoundation.h>
7
+ #if !TARGET_OS_OSX
7
8
  #import <UIKit/UIKit.h>
9
+ #else
10
+ #import <React/RCTUIKit.h>
11
+ #endif // !TARGET_OS_OSX
8
12
 
9
13
  #import "RNSkManager.h"
10
- #import "RNSkiOSView.h"
14
+ #import "RNSkAppleView.h"
11
15
  #import "SkiaManager.h"
12
16
 
13
17
  #if RCT_NEW_ARCH_ENABLED
@@ -18,17 +22,21 @@
18
22
  #if RCT_NEW_ARCH_ENABLED
19
23
  RCTViewComponentView
20
24
  #else
25
+ #if !TARGET_OS_OSX
21
26
  UIView
27
+ #else
28
+ RCTUIView
29
+ #endif // !TARGET_OS_OSX
22
30
  #endif // RCT_NEW_ARCH_ENABLED
23
31
 
24
32
  - (instancetype)
25
33
  initWithManager:(RNSkia::RNSkManager *)manager
26
- factory:(std::function<std::shared_ptr<RNSkBaseiOSView>(
34
+ factory:(std::function<std::shared_ptr<RNSkBaseAppleView>(
27
35
  std::shared_ptr<RNSkia::RNSkPlatformContext>)>)factory;
28
36
  - (void)initCommon:(RNSkia::RNSkManager *)manager
29
- factory:(std::function<std::shared_ptr<RNSkBaseiOSView>(
37
+ factory:(std::function<std::shared_ptr<RNSkBaseAppleView>(
30
38
  std::shared_ptr<RNSkia::RNSkPlatformContext>)>)factory;
31
- - (std::shared_ptr<RNSkBaseiOSView>)impl;
39
+ - (std::shared_ptr<RNSkBaseAppleView>)impl;
32
40
 
33
41
  - (void)setDebugMode:(bool)debugMode;
34
42
  - (void)setOpaque:(bool)opaque;
@@ -9,9 +9,9 @@
9
9
  #import "RNSkManager.h"
10
10
 
11
11
  @implementation SkiaUIView {
12
- std::shared_ptr<RNSkBaseiOSView> _impl;
12
+ std::shared_ptr<RNSkBaseAppleView> _impl;
13
13
  RNSkia::RNSkManager *_manager;
14
- std::function<std::shared_ptr<RNSkBaseiOSView>(
14
+ std::function<std::shared_ptr<RNSkBaseAppleView>(
15
15
  std::shared_ptr<RNSkia::RNSkPlatformContext>)>
16
16
  _factory;
17
17
  bool _debugMode;
@@ -23,7 +23,7 @@
23
23
 
24
24
  - (instancetype)initWithManager:(RNSkia::RNSkManager *)manager
25
25
  factory:
26
- (std::function<std::shared_ptr<RNSkBaseiOSView>(
26
+ (std::function<std::shared_ptr<RNSkBaseAppleView>(
27
27
  std::shared_ptr<RNSkia::RNSkPlatformContext>)>)
28
28
  factory {
29
29
  self = [super init];
@@ -40,7 +40,7 @@
40
40
  }
41
41
 
42
42
  - (void)initCommon:(RNSkia::RNSkManager *)manager
43
- factory:(std::function<std::shared_ptr<RNSkBaseiOSView>(
43
+ factory:(std::function<std::shared_ptr<RNSkBaseAppleView>(
44
44
  std::shared_ptr<RNSkia::RNSkPlatformContext>)>)factory {
45
45
  _manager = manager;
46
46
  _nativeId = 0;
@@ -55,8 +55,12 @@
55
55
 
56
56
  #pragma mark Lifecycle
57
57
 
58
- - (void)willMoveToSuperview:(UIView *)newWindow {
59
- if (newWindow != nullptr) {
58
+ #if !TARGET_OS_OSX
59
+ - (void)willMoveToSuperview:(UIView *)newSuperView {
60
+ #else
61
+ - (void)viewWillMoveToSuperview:(NSView *)newSuperView {
62
+ #endif // !TARGET_OS_OSX
63
+ if (newSuperView != nullptr) {
60
64
  // Create implementation view when the parent view is set
61
65
  if (_impl == nullptr && _manager != nullptr) {
62
66
  _impl = _factory(_manager->getPlatformContext());
@@ -161,7 +165,7 @@
161
165
 
162
166
  #pragma mark External API
163
167
 
164
- - (std::shared_ptr<RNSkBaseiOSView>)impl {
168
+ - (std::shared_ptr<RNSkBaseAppleView>)impl {
165
169
  return _impl;
166
170
  }
167
171
 
@@ -1,7 +1,11 @@
1
1
  #pragma once
2
2
 
3
3
  #import <CoreFoundation/CoreFoundation.h>
4
+ #if !TARGET_OS_OSX
4
5
  #import <UIKit/UIKit.h>
6
+ #else
7
+ #import <Appkit/Appkit.h>
8
+ #endif // !TARGET_OS_OSX
5
9
 
6
10
  #import <React/RCTUIManager.h>
7
11
 
@@ -20,6 +20,7 @@
20
20
  }
21
21
 
22
22
  - (sk_sp<SkImage>)screenshotOfViewWithTag:(NSNumber *)viewTag {
23
+ #if !TARGET_OS_OSX
23
24
  // Find view corresponding to the tag
24
25
  auto view = [_uiManager viewForReactTag:viewTag];
25
26
  if (view == NULL) {
@@ -80,6 +81,9 @@
80
81
 
81
82
  // ... and then create the SkImage itself!
82
83
  return SkImages::RasterFromData(info, skData, bytesPerRow);
84
+ #else
85
+ return nullptr;
86
+ #endif // !TARGET_OS_OSX
83
87
  }
84
88
 
85
89
  @end
@@ -34,7 +34,7 @@ public:
34
34
  SkPoint tangent;
35
35
  auto result = getObject()->getPosTan(dist, &position, &tangent);
36
36
  if (!result) {
37
- throw jsi::JSError(runtime, "getSegment() failed");
37
+ throw jsi::JSError(runtime, "getPosTan() failed");
38
38
  }
39
39
  auto posTan = jsi::Array(runtime, 2);
40
40
  auto pos = jsi::Object::createFromHostObject(