@shopify/react-native-skia 0.1.196 → 0.1.199

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. package/android/CMakeLists.txt +32 -31
  2. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +4 -2
  3. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -0
  4. package/cpp/api/JsiSkImage.h +1 -1
  5. package/cpp/api/JsiSkShaderFactory.h +4 -4
  6. package/cpp/api/JsiSkSurface.h +0 -1
  7. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  8. package/cpp/rnskia/RNSkView.h +20 -40
  9. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +2 -2
  10. package/cpp/rnskia/values/RNSkReadonlyValue.h +6 -7
  11. package/cpp/skia/include/android/SkCanvasAndroid.h +20 -0
  12. package/cpp/skia/include/android/SkHeifDecoder.h +43 -0
  13. package/cpp/skia/include/android/SkSurfaceAndroid.h +50 -0
  14. package/cpp/skia/include/codec/SkAvifDecoder.h +43 -0
  15. package/cpp/skia/include/codec/SkBmpDecoder.h +43 -0
  16. package/cpp/skia/include/codec/SkCodec.h +25 -1
  17. package/cpp/skia/include/codec/SkGifDecoder.h +43 -0
  18. package/cpp/skia/include/codec/SkIcoDecoder.h +43 -0
  19. package/cpp/skia/include/codec/SkJpegDecoder.h +43 -0
  20. package/cpp/skia/include/codec/SkJpegxlDecoder.h +43 -0
  21. package/cpp/skia/include/codec/SkPngDecoder.h +43 -0
  22. package/cpp/skia/include/codec/SkRawDecoder.h +49 -0
  23. package/cpp/skia/include/codec/SkWbmpDecoder.h +43 -0
  24. package/cpp/skia/include/codec/SkWebpDecoder.h +43 -0
  25. package/cpp/skia/include/core/SkBBHFactory.h +5 -1
  26. package/cpp/skia/include/core/SkBlender.h +0 -2
  27. package/cpp/skia/include/core/SkCanvas.h +4 -23
  28. package/cpp/skia/include/core/SkColorFilter.h +14 -1
  29. package/cpp/skia/include/core/SkColorTable.h +59 -0
  30. package/cpp/skia/include/core/SkContourMeasure.h +3 -0
  31. package/cpp/skia/include/core/SkDeferredDisplayList.h +8 -104
  32. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +8 -91
  33. package/cpp/skia/include/core/SkDrawable.h +5 -2
  34. package/cpp/skia/include/core/SkGraphics.h +7 -19
  35. package/cpp/skia/include/core/SkImage.h +157 -249
  36. package/cpp/skia/include/core/SkImageGenerator.h +0 -31
  37. package/cpp/skia/include/core/SkMilestone.h +1 -1
  38. package/cpp/skia/include/core/SkPathMeasure.h +3 -3
  39. package/cpp/skia/include/core/SkPictureRecorder.h +1 -1
  40. package/cpp/skia/include/core/SkPoint.h +5 -563
  41. package/cpp/skia/include/core/SkPoint3.h +1 -0
  42. package/cpp/skia/include/core/SkPromiseImageTexture.h +4 -30
  43. package/cpp/skia/include/core/SkRect.h +8 -8
  44. package/cpp/skia/include/core/SkSamplingOptions.h +4 -2
  45. package/cpp/skia/include/core/SkScalar.h +1 -1
  46. package/cpp/skia/include/core/SkSerialProcs.h +5 -1
  47. package/cpp/skia/include/core/SkShader.h +14 -21
  48. package/cpp/skia/include/core/SkString.h +2 -0
  49. package/cpp/skia/include/core/SkSurface.h +169 -701
  50. package/cpp/skia/include/core/SkSurfaceCharacterization.h +8 -256
  51. package/cpp/skia/include/core/SkTiledImageUtils.h +97 -0
  52. package/cpp/skia/include/core/SkTypes.h +4 -2
  53. package/cpp/skia/include/core/SkYUVAPixmaps.h +0 -5
  54. package/cpp/skia/include/effects/SkGradientShader.h +10 -1
  55. package/cpp/skia/include/effects/SkImageFilters.h +62 -37
  56. package/cpp/skia/include/effects/SkPerlinNoiseShader.h +28 -29
  57. package/cpp/skia/include/effects/SkRuntimeEffect.h +17 -12
  58. package/cpp/skia/include/gpu/GrBackendSurface.h +12 -39
  59. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +6 -0
  60. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +3 -3
  61. package/cpp/skia/include/gpu/GrDirectContext.h +103 -3
  62. package/cpp/skia/include/gpu/GrRecordingContext.h +10 -19
  63. package/cpp/skia/include/gpu/MutableTextureState.h +4 -0
  64. package/cpp/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +54 -0
  65. package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +20 -76
  66. package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +217 -0
  67. package/cpp/skia/include/gpu/ganesh/mtl/SkSurfaceMetal.h +73 -0
  68. package/cpp/skia/include/gpu/gl/GrGLTypes.h +13 -2
  69. package/cpp/skia/include/gpu/graphite/BackendSemaphore.h +78 -0
  70. package/cpp/skia/include/gpu/graphite/BackendTexture.h +1 -0
  71. package/cpp/skia/include/gpu/graphite/Image.h +277 -0
  72. package/cpp/skia/include/gpu/graphite/ImageProvider.h +1 -1
  73. package/cpp/skia/include/gpu/graphite/Recording.h +1 -4
  74. package/cpp/skia/include/gpu/graphite/Surface.h +81 -0
  75. package/cpp/skia/include/gpu/graphite/TextureInfo.h +5 -7
  76. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +2 -2
  77. package/cpp/skia/include/gpu/mock/GrMockTypes.h +23 -8
  78. package/cpp/skia/include/ports/SkTypeface_fontations.h +21 -0
  79. package/cpp/skia/include/private/SkGainmapInfo.h +2 -0
  80. package/cpp/skia/include/private/SkGainmapShader.h +1 -0
  81. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +19 -1
  82. package/cpp/skia/include/private/SkPathRef.h +13 -15
  83. package/cpp/skia/include/private/SkXmp.h +53 -0
  84. package/cpp/skia/include/private/base/SkFeatures.h +0 -4
  85. package/cpp/skia/include/private/base/SkFloatingPoint.h +11 -5
  86. package/cpp/skia/include/private/base/SkPoint_impl.h +569 -0
  87. package/cpp/skia/include/private/base/SkSpan_impl.h +3 -7
  88. package/cpp/skia/include/private/base/SkTArray.h +11 -11
  89. package/cpp/skia/include/private/chromium/GrDeferredDisplayList.h +120 -0
  90. package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +98 -0
  91. package/cpp/skia/include/private/chromium/GrPromiseImageTexture.h +43 -0
  92. package/cpp/skia/include/private/chromium/GrSurfaceCharacterization.h +215 -0
  93. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +6 -6
  94. package/cpp/skia/include/private/chromium/SkImageChromium.h +104 -0
  95. package/cpp/skia/include/private/chromium/Slug.h +7 -3
  96. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +7 -3
  97. package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +2 -0
  98. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +3 -2
  99. package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +10 -2
  100. package/cpp/skia/include/{gpu → private/gpu}/ganesh/GrTextureGenerator.h +2 -13
  101. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  102. package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +7 -0
  103. package/cpp/skia/include/private/gpu/graphite/MtlGraphiteTypesPriv.h +19 -6
  104. package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +13 -0
  105. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +0 -1
  106. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +14 -1
  107. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +999 -79
  108. package/cpp/skia/modules/skcms/src/Transform_inl.h +36 -236
  109. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -0
  110. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +16 -0
  111. package/cpp/skia/modules/skparagraph/include/TextStyle.h +6 -2
  112. package/cpp/skia/modules/skresources/include/SkResources.h +1 -1
  113. package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
  114. package/cpp/skia/modules/svg/include/SkSVGClipPath.h +1 -1
  115. package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
  116. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -1
  117. package/cpp/skia/modules/svg/include/SkSVGDefs.h +1 -1
  118. package/cpp/skia/modules/svg/include/SkSVGEllipse.h +1 -1
  119. package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
  120. package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
  121. package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
  122. package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
  123. package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
  124. package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
  125. package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
  126. package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
  127. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  128. package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
  129. package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
  130. package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
  131. package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
  132. package/cpp/skia/modules/svg/include/SkSVGG.h +1 -1
  133. package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
  134. package/cpp/skia/modules/svg/include/SkSVGHiddenContainer.h +1 -1
  135. package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
  136. package/cpp/skia/modules/svg/include/SkSVGLine.h +1 -1
  137. package/cpp/skia/modules/svg/include/SkSVGLinearGradient.h +1 -1
  138. package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
  139. package/cpp/skia/modules/svg/include/SkSVGNode.h +1 -1
  140. package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
  141. package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
  142. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  143. package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
  144. package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
  145. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
  146. package/cpp/skia/modules/svg/include/SkSVGSVG.h +1 -1
  147. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -1
  148. package/cpp/skia/modules/svg/include/SkSVGStop.h +1 -1
  149. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  150. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +1 -1
  151. package/cpp/skia/modules/svg/include/SkSVGTypes.h +21 -21
  152. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  153. package/cpp/skia/modules/svg/include/SkSVGValue.h +2 -2
  154. package/cpp/skia/{include/private → src/core}/SkChecksum.h +32 -17
  155. package/cpp/skia/src/core/SkTHash.h +1 -1
  156. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +3 -1
  157. package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +3 -1
  158. package/lib/commonjs/renderer/Canvas.js +24 -13
  159. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  160. package/lib/commonjs/skia/core/Data.d.ts +2 -2
  161. package/lib/commonjs/skia/core/Data.js.map +1 -1
  162. package/lib/commonjs/skia/core/RRect.js +5 -1
  163. package/lib/commonjs/skia/core/RRect.js.map +1 -1
  164. package/lib/commonjs/skia/core/Rect.js +32 -6
  165. package/lib/commonjs/skia/core/Rect.js.map +1 -1
  166. package/lib/commonjs/skia/types/Color.js.map +1 -1
  167. package/lib/commonjs/skia/types/JsiInstance.d.ts +2 -4
  168. package/lib/commonjs/skia/types/JsiInstance.js.map +1 -1
  169. package/lib/module/renderer/Canvas.js +25 -14
  170. package/lib/module/renderer/Canvas.js.map +1 -1
  171. package/lib/module/skia/core/Data.d.ts +2 -2
  172. package/lib/module/skia/core/Data.js.map +1 -1
  173. package/lib/module/skia/core/RRect.js +5 -1
  174. package/lib/module/skia/core/RRect.js.map +1 -1
  175. package/lib/module/skia/core/Rect.js +32 -6
  176. package/lib/module/skia/core/Rect.js.map +1 -1
  177. package/lib/module/skia/types/Color.js.map +1 -1
  178. package/lib/module/skia/types/JsiInstance.d.ts +2 -4
  179. package/lib/module/skia/types/JsiInstance.js.map +1 -1
  180. package/lib/typescript/src/skia/core/Data.d.ts +2 -2
  181. package/lib/typescript/src/skia/types/JsiInstance.d.ts +2 -4
  182. package/libs/android/arm64-v8a/libskia.a +0 -0
  183. package/libs/android/arm64-v8a/libskottie.a +0 -0
  184. package/libs/android/arm64-v8a/libsksg.a +0 -0
  185. package/libs/android/arm64-v8a/libsvg.a +0 -0
  186. package/libs/android/armeabi-v7a/libskia.a +0 -0
  187. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  188. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  189. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  190. package/libs/android/x86/libskia.a +0 -0
  191. package/libs/android/x86/libskottie.a +0 -0
  192. package/libs/android/x86/libsksg.a +0 -0
  193. package/libs/android/x86/libsvg.a +0 -0
  194. package/libs/android/x86_64/libskia.a +0 -0
  195. package/libs/android/x86_64/libskottie.a +0 -0
  196. package/libs/android/x86_64/libsksg.a +0 -0
  197. package/libs/android/x86_64/libsvg.a +0 -0
  198. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  199. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  200. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  201. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  202. package/libs/ios/libsksg.xcframework/Info.plist +5 -5
  203. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  204. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  205. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  206. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  207. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  208. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  209. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  210. package/package.json +3 -4
  211. package/src/renderer/Canvas.tsx +25 -19
  212. package/src/skia/core/Data.ts +3 -3
  213. package/src/skia/core/RRect.tsx +4 -2
  214. package/src/skia/core/Rect.ts +29 -12
  215. package/src/skia/types/Color.ts +1 -1
  216. package/src/skia/types/JsiInstance.ts +2 -5
  217. package/cpp/skia/include/effects/SkTableColorFilter.h +0 -29
  218. package/cpp/skia/include/private/SkOpts_spi.h +0 -23
  219. package/cpp/skia/include/private/SkSpinlock.h +0 -57
  220. package/cpp/skia/include/private/chromium/GrSlug.h +0 -16
  221. package/scripts/install-npm.js +0 -33
@@ -47,21 +47,21 @@ add_library(
47
47
  "${PROJECT_SOURCE_DIR}/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp"
48
48
  "${PROJECT_SOURCE_DIR}/cpp/rnskia-android/SkiaOpenGLRenderer.cpp"
49
49
 
50
- "${PROJECT_SOURCE_DIR}/cpp/jsi/JsiHostObject.cpp"
51
- "${PROJECT_SOURCE_DIR}/cpp/jsi/JsiValue.cpp"
52
- "${PROJECT_SOURCE_DIR}/cpp/jsi/RuntimeLifecycleMonitor.cpp"
53
- "${PROJECT_SOURCE_DIR}/cpp/jsi/RuntimeAwareCache.cpp"
54
- "${PROJECT_SOURCE_DIR}/cpp/jsi/JsiPromises.cpp"
50
+ "${PROJECT_SOURCE_DIR}/../cpp/jsi/JsiHostObject.cpp"
51
+ "${PROJECT_SOURCE_DIR}/../cpp/jsi/JsiValue.cpp"
52
+ "${PROJECT_SOURCE_DIR}/../cpp/jsi/RuntimeLifecycleMonitor.cpp"
53
+ "${PROJECT_SOURCE_DIR}/../cpp/jsi/RuntimeAwareCache.cpp"
54
+ "${PROJECT_SOURCE_DIR}/../cpp/jsi/JsiPromises.cpp"
55
55
 
56
- "${PROJECT_SOURCE_DIR}/cpp/rnskia/RNSkManager.cpp"
57
- "${PROJECT_SOURCE_DIR}/cpp/rnskia/RNSkJsView.cpp"
58
- "${PROJECT_SOURCE_DIR}/cpp/rnskia/RNSkDomView.cpp"
59
- "${PROJECT_SOURCE_DIR}/cpp/rnskia/RNSkDispatchQueue.cpp"
56
+ "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkManager.cpp"
57
+ "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkJsView.cpp"
58
+ "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkDomView.cpp"
59
+ "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkDispatchQueue.cpp"
60
60
 
61
- "${PROJECT_SOURCE_DIR}/cpp/rnskia/dom/base/DrawingContext.cpp"
62
- "${PROJECT_SOURCE_DIR}/cpp/rnskia/dom/base/ConcatablePaint.cpp"
61
+ "${PROJECT_SOURCE_DIR}/../cpp/rnskia/dom/base/DrawingContext.cpp"
62
+ "${PROJECT_SOURCE_DIR}/../cpp/rnskia/dom/base/ConcatablePaint.cpp"
63
63
 
64
- "${PROJECT_SOURCE_DIR}/cpp/api/third_party/CSSColorParser.cpp"
64
+ "${PROJECT_SOURCE_DIR}/../cpp/api/third_party/CSSColorParser.cpp"
65
65
 
66
66
  )
67
67
 
@@ -75,27 +75,28 @@ target_include_directories(
75
75
  "${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core"
76
76
  "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
77
77
 
78
- cpp/skia/include/config/
79
- cpp/skia/include/core/
80
- cpp/skia/include/effects/
81
- cpp/skia/include/utils/
82
- cpp/skia/include/pathops/
83
- cpp/skia/modules/
84
- #cpp/skia/modules/skparagraph/include/
85
- cpp/skia/include/
86
- cpp/skia
87
-
88
- cpp/api
89
- cpp/jsi
90
78
  cpp/jni/include
91
79
  cpp/rnskia-android
92
- cpp/rnskia
93
- cpp/rnskia/values
94
- cpp/rnskia/dom
95
- cpp/rnskia/dom/base
96
- cpp/rnskia/dom/nodes
97
- cpp/rnskia/dom/props
98
- cpp/utils
80
+
81
+ ../cpp/skia/include/config/
82
+ ../cpp/skia/include/core/
83
+ ../cpp/skia/include/effects/
84
+ ../cpp/skia/include/utils/
85
+ ../cpp/skia/include/pathops/
86
+ ../cpp/skia/modules/
87
+ #cpp/skia/modules/skparagraph/include/
88
+ ../cpp/skia/include/
89
+ ../cpp/skia
90
+
91
+ ../cpp/api
92
+ ../cpp/jsi
93
+ ../cpp/rnskia
94
+ ../cpp/rnskia/values
95
+ ../cpp/rnskia/dom
96
+ ../cpp/rnskia/dom/base
97
+ ../cpp/rnskia/dom/nodes
98
+ ../cpp/rnskia/dom/props
99
+ ../cpp/utils
99
100
 
100
101
  ${libfbjni_include_DIRS}
101
102
  )
@@ -4,6 +4,8 @@
4
4
  #include <android/native_window.h>
5
5
  #include <android/native_window_jni.h>
6
6
 
7
+ #pragma clang diagnostic push
8
+
7
9
  #define STENCIL_BUFFER_SIZE 8
8
10
 
9
11
  namespace RNSkia {
@@ -102,7 +104,7 @@ sk_sp<SkSurface> MakeOffscreenGLSurface(int width, int height) {
102
104
  };
103
105
  auto ctx = new OffscreenRenderContext({eglDisplay, eglSurface});
104
106
 
105
- auto surface = SkSurface::MakeFromBackendRenderTarget(
107
+ auto surface = SkSurfaces::WrapBackendRenderTarget(
106
108
  grContext.get(), renderTarget, kBottomLeft_GrSurfaceOrigin,
107
109
  kRGBA_8888_SkColorType, nullptr, nullptr,
108
110
  [](void *addr) {
@@ -170,7 +172,7 @@ bool SkiaOpenGLRenderer::run(const std::function<void(SkCanvas *)> &cb,
170
172
 
171
173
  SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
172
174
 
173
- sk_sp<SkSurface> renderTarget(SkSurface::MakeFromBackendRenderTarget(
175
+ sk_sp<SkSurface> renderTarget(SkSurfaces::WrapBackendRenderTarget(
174
176
  getThreadDrawingContext()->skContext.get(), backendRT,
175
177
  kBottomLeft_GrSurfaceOrigin, colorType, nullptr, &props));
176
178
 
@@ -20,7 +20,10 @@
20
20
  #include "SkColorSpace.h"
21
21
  #include "SkPicture.h"
22
22
  #include "SkSurface.h"
23
+
24
+ #include "include/gpu/GrBackendSurface.h"
23
25
  #include "include/gpu/GrDirectContext.h"
26
+ #include "include/gpu/ganesh/SkSurfaceGanesh.h"
24
27
  #include "include/gpu/gl/GrGLInterface.h"
25
28
 
26
29
  #pragma clang diagnostic pop
@@ -14,7 +14,7 @@
14
14
  #include "SkBase64.h"
15
15
  #include "SkImage.h"
16
16
  #include "SkStream.h"
17
- #include "codec/SkEncodedImageFormat.h"
17
+ #include "include/codec/SkEncodedImageFormat.h"
18
18
  #include "include/encode/SkJpegEncoder.h"
19
19
  #include "include/encode/SkPngEncoder.h"
20
20
 
@@ -169,8 +169,8 @@ public:
169
169
  auto tileW = arguments[4].asNumber();
170
170
  auto tileH = arguments[5].asNumber();
171
171
  SkISize size = SkISize::Make(tileW, tileH);
172
- sk_sp<SkShader> gradient = SkPerlinNoiseShader::MakeTurbulence(
173
- baseFreqX, baseFreqY, octaves, seed, &size);
172
+ sk_sp<SkShader> gradient =
173
+ SkShaders::MakeTurbulence(baseFreqX, baseFreqY, octaves, seed, &size);
174
174
  return jsi::Object::createFromHostObject(
175
175
  runtime,
176
176
  std::make_shared<JsiSkShader>(getContext(), std::move(gradient)));
@@ -184,8 +184,8 @@ public:
184
184
  auto tileW = arguments[4].asNumber();
185
185
  auto tileH = arguments[5].asNumber();
186
186
  SkISize size = SkISize::Make(tileW, tileH);
187
- sk_sp<SkShader> gradient = SkPerlinNoiseShader::MakeFractalNoise(
188
- baseFreqX, baseFreqY, octaves, seed, &size);
187
+ sk_sp<SkShader> gradient =
188
+ SkShaders::MakeFractalNoise(baseFreqX, baseFreqY, octaves, seed, &size);
189
189
  return jsi::Object::createFromHostObject(
190
190
  runtime,
191
191
  std::make_shared<JsiSkShader>(getContext(), std::move(gradient)));
@@ -9,7 +9,6 @@
9
9
 
10
10
  #include "JsiSkCanvas.h"
11
11
  #include "JsiSkImage.h"
12
- #include "JsiSkSurfaceFactory.h"
13
12
 
14
13
  #pragma clang diagnostic push
15
14
  #pragma clang diagnostic ignored "-Wdocumentation"
@@ -25,7 +25,8 @@ public:
25
25
  JSI_HOST_FUNCTION(Make) {
26
26
  auto width = static_cast<int>(arguments[0].asNumber());
27
27
  auto height = static_cast<int>(arguments[1].asNumber());
28
- auto surface = SkSurface::MakeRasterN32Premul(width, height);
28
+ auto imageInfo = SkImageInfo::MakeN32Premul(width, height);
29
+ auto surface = SkSurfaces::Raster(imageInfo);
29
30
  if (surface == nullptr) {
30
31
  return jsi::Value::null();
31
32
  }
@@ -343,46 +343,26 @@ private:
343
343
  }
344
344
  auto onSizeObj = onSize.asObject(*runtime);
345
345
 
346
- // Is this a host SkSize object?
347
- if (onSizeObj.isHostObject(*runtime)) {
348
- auto point = std::dynamic_pointer_cast<JsiSkPoint>(
349
- onSizeObj.asHostObject(*runtime));
350
- if (point == nullptr) {
351
- throw jsi::JSError(*runtime,
352
- "Expected onSize property to be a mutable "
353
- "Skia value of type SkSize.");
354
- return;
355
- }
356
-
357
- auto w = point->getObject()->x();
358
- auto h = point->getObject()->y();
359
- if (w != width || h != height) {
360
- auto nextSize =
361
- std::make_shared<SkPoint>(SkPoint::Make(width, height));
362
- point->setObject(nextSize);
363
- self->_onSize->set_current(*runtime, onSize);
364
- }
365
-
366
- } else {
367
- auto wVal = onSizeObj.getProperty(*runtime, "width");
368
- auto hVal = onSizeObj.getProperty(*runtime, "height");
369
-
370
- if (!wVal.isNumber() || !hVal.isNumber()) {
371
- throw jsi::JSError(*runtime,
372
- "Expected onSize property to be a mutable "
373
- "Skia value of type SkSize.");
374
- return;
375
- }
376
-
377
- auto w = wVal.asNumber();
378
- auto h = hVal.asNumber();
379
-
380
- if (w != width || h != height) {
381
- // Update
382
- onSizeObj.setProperty(*runtime, "width", width);
383
- onSizeObj.setProperty(*runtime, "height", height);
384
- self->_onSize->set_current(*runtime, onSize);
385
- }
346
+ auto wVal = onSizeObj.getProperty(*runtime, "width");
347
+ auto hVal = onSizeObj.getProperty(*runtime, "height");
348
+
349
+ if (!wVal.isNumber() || !hVal.isNumber()) {
350
+ throw jsi::JSError(*runtime,
351
+ "Expected onSize property to be a mutable "
352
+ "Skia value of type SkSize.");
353
+ return;
354
+ }
355
+
356
+ auto w = wVal.asNumber();
357
+ auto h = hVal.asNumber();
358
+
359
+ if (w != width || h != height) {
360
+ // Update
361
+ auto newValue = jsi::Object(*runtime);
362
+ newValue.setProperty(*runtime, "width", width);
363
+ newValue.setProperty(*runtime, "height", height);
364
+ self->_onSize->set_current(*runtime,
365
+ jsi::Value(*runtime, newValue));
386
366
  }
387
367
  }
388
368
  });
@@ -256,7 +256,7 @@ public:
256
256
  SkISize size = SkISize::Make(_tileWidthProp->value().getAsNumber(),
257
257
  _tileHeightProp->value().getAsNumber());
258
258
 
259
- context->getShaders()->push(SkPerlinNoiseShader::MakeTurbulence(
259
+ context->getShaders()->push(SkShaders::MakeTurbulence(
260
260
  _freqXProp->value().getAsNumber(), _freqYProp->value().getAsNumber(),
261
261
  _octavesProp->value().getAsNumber(), _seedProp->value().getAsNumber(),
262
262
  &size));
@@ -274,7 +274,7 @@ public:
274
274
  SkISize size = SkISize::Make(_tileWidthProp->value().getAsNumber(),
275
275
  _tileHeightProp->value().getAsNumber());
276
276
 
277
- context->getShaders()->push(SkPerlinNoiseShader::MakeFractalNoise(
277
+ context->getShaders()->push(SkShaders::MakeFractalNoise(
278
278
  _freqXProp->value().getAsNumber(), _freqYProp->value().getAsNumber(),
279
279
  _octavesProp->value().getAsNumber(), _seedProp->value().getAsNumber(),
280
280
  &size));
@@ -11,7 +11,7 @@
11
11
  #include <jsi/jsi.h>
12
12
 
13
13
  #include "JsiSkHostObjects.h"
14
- #include "JsiValueWrapper.h"
14
+ #include "JsiValue.h"
15
15
  #include "RNSkPlatformContext.h"
16
16
 
17
17
  namespace RNSkia {
@@ -29,8 +29,7 @@ public:
29
29
  explicit RNSkReadonlyValue(
30
30
  std::shared_ptr<RNSkPlatformContext> platformContext)
31
31
  : JsiSkHostObject(platformContext),
32
- _valueHolder(std::make_shared<RNJsi::JsiValueWrapper>(
33
- *platformContext->getJsRuntime())) {}
32
+ _valueHolder(std::make_shared<RNJsi::JsiValue>()) {}
34
33
 
35
34
  virtual ~RNSkReadonlyValue() { invalidate(); }
36
35
 
@@ -107,7 +106,7 @@ public:
107
106
  @param value Next value
108
107
  */
109
108
  virtual void update(jsi::Runtime &runtime, const jsi::Value &value) {
110
- auto equal = _valueHolder->equals(runtime, value);
109
+ auto equal = _valueHolder->operator==(RNJsi::JsiValue(runtime, value));
111
110
  if (!equal) {
112
111
  _valueHolder->setCurrent(runtime, value);
113
112
  notifyListeners(runtime);
@@ -127,14 +126,14 @@ public:
127
126
  Returns the current value as a jsi::Value
128
127
  */
129
128
  jsi::Value getCurrent(jsi::Runtime &runtime) {
130
- return _valueHolder->getCurrent(runtime);
129
+ return _valueHolder->getAsJsiValue(runtime);
131
130
  }
132
131
 
133
132
  /**
134
133
  Returns the underlying current value wrapper. This can be used to query the
135
134
  holder for data type and get pointers to elements in the holder.
136
135
  */
137
- std::shared_ptr<RNJsi::JsiValueWrapper> getCurrent() { return _valueHolder; }
136
+ std::shared_ptr<RNJsi::JsiValue> getCurrent() { return _valueHolder; }
138
137
 
139
138
  protected:
140
139
  /**
@@ -158,7 +157,7 @@ protected:
158
157
  }
159
158
 
160
159
  private:
161
- std::shared_ptr<RNJsi::JsiValueWrapper> _valueHolder;
160
+ std::shared_ptr<RNJsi::JsiValue> _valueHolder;
162
161
 
163
162
  long _listenerId = 0;
164
163
  std::unordered_map<long, std::function<void(jsi::Runtime &)>> _listeners;
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkCanvasAndroid_DEFINED
9
+ #define SkCanvasAndroid_DEFINED
10
+
11
+ class SkCanvas;
12
+ struct SkIRect;
13
+ class GrBackendRenderTarget;
14
+
15
+ namespace skgpu::ganesh {
16
+ SkIRect TopLayerBounds(const SkCanvas*);
17
+ GrBackendRenderTarget TopLayerBackendRenderTarget(const SkCanvas*);
18
+ }
19
+
20
+ #endif
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+ #ifndef SkHeifDecoder_DEFINED
8
+ #define SkHeifDecoder_DEFINED
9
+
10
+ #include "include/codec/SkCodec.h"
11
+ #include "include/core/SkRefCnt.h"
12
+
13
+ class SkData;
14
+ class SkStream;
15
+
16
+ #include <memory>
17
+
18
+ namespace SkHeifDecoder {
19
+
20
+ /** Returns true if this data claims to be a HEIF image. */
21
+ SK_API bool IsHeif(const void*, size_t);
22
+
23
+ /**
24
+ * Attempts to decode the given bytes as a HEIF.
25
+ *
26
+ * If the bytes are not a HEIF, returns nullptr.
27
+ *
28
+ * DecodeContext is treated as a SkCodec::SelectionPolicy*
29
+ */
30
+ SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
31
+ SkCodec::Result*,
32
+ SkCodecs::DecodeContext = nullptr);
33
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SkCodec::Result*,
35
+ SkCodecs::DecodeContext = nullptr);
36
+
37
+ inline SkCodecs::Decoder Decoder() {
38
+ return { "heif", IsHeif, Decode };
39
+ }
40
+
41
+ } // namespace SkHeifDecoder
42
+
43
+ #endif // SkHeifDecoder_DEFINED
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkSurfaceAndroid_DEFINED
9
+ #define SkSurfaceAndroid_DEFINED
10
+
11
+ #include "include/core/SkRefCnt.h"
12
+ #include "include/core/SkSurface.h"
13
+ #include "include/gpu/GrTypes.h"
14
+
15
+ class SkColorSpace;
16
+ class GrDirectContext;
17
+ class SkPixmap;
18
+ struct AHardwareBuffer;
19
+
20
+ namespace SkSurfaces {
21
+
22
+ /** Private; only to be used by Android Framework.
23
+ Creates SkSurface from Android hardware buffer.
24
+ Returned SkSurface takes a reference on the buffer. The ref on the buffer will be released
25
+ when the SkSurface is destroyed and there is no pending work on the GPU involving the
26
+ buffer.
27
+
28
+ Currently this is only supported for buffers that can be textured as well as rendered to.
29
+ In other words that must have both AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT and
30
+ AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE usage bits.
31
+
32
+ @param context GPU context
33
+ @param hardwareBuffer AHardwareBuffer Android hardware buffer
34
+ @param colorSpace range of colors; may be nullptr
35
+ @param surfaceProps LCD striping orientation and setting for device independent
36
+ fonts; may be nullptr
37
+ @param fromWindow Whether or not the AHardwareBuffer is part of an Android Window.
38
+ Currently only used with Vulkan backend.
39
+ @return created SkSurface, or nullptr
40
+ */
41
+ SK_API sk_sp<SkSurface> WrapAndroidHardwareBuffer(GrDirectContext* context,
42
+ AHardwareBuffer* hardwareBuffer,
43
+ GrSurfaceOrigin origin,
44
+ sk_sp<SkColorSpace> colorSpace,
45
+ const SkSurfaceProps* surfaceProps,
46
+ bool fromWindow = false);
47
+
48
+ } // namespace SkSurfaces
49
+
50
+ #endif
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+ #ifndef SkAvifDecoder_DEFINED
8
+ #define SkAvifDecoder_DEFINED
9
+
10
+ #include "include/codec/SkCodec.h"
11
+ #include "include/core/SkRefCnt.h"
12
+
13
+ class SkData;
14
+ class SkStream;
15
+
16
+ #include <memory>
17
+
18
+ namespace SkAvifDecoder {
19
+
20
+ /** Returns true if this data claims to be a AVIF image. */
21
+ SK_API bool IsAvif(const void*, size_t);
22
+
23
+ /**
24
+ * Attempts to decode the given bytes as a AVIF.
25
+ *
26
+ * If the bytes are not a AVIF, returns nullptr.
27
+ *
28
+ * DecodeContext is ignored
29
+ */
30
+ SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
31
+ SkCodec::Result*,
32
+ SkCodecs::DecodeContext = nullptr);
33
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SkCodec::Result*,
35
+ SkCodecs::DecodeContext = nullptr);
36
+
37
+ inline SkCodecs::Decoder Decoder() {
38
+ return { "avif", IsAvif, Decode };
39
+ }
40
+
41
+ } // namespace SkAvifDecoder
42
+
43
+ #endif // SkAvifDecoder_DEFINED
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+ #ifndef SkBmpDecoder_DEFINED
8
+ #define SkBmpDecoder_DEFINED
9
+
10
+ #include "include/codec/SkCodec.h"
11
+ #include "include/core/SkRefCnt.h"
12
+
13
+ class SkData;
14
+ class SkStream;
15
+
16
+ #include <memory>
17
+
18
+ namespace SkBmpDecoder {
19
+
20
+ /** Returns true if this data claims to be a BMP image. */
21
+ SK_API bool IsBmp(const void*, size_t);
22
+
23
+ /**
24
+ * Attempts to decode the given bytes as a BMP.
25
+ *
26
+ * If the bytes are not a BMP, returns nullptr.
27
+ *
28
+ * DecodeContext is ignored
29
+ */
30
+ SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
31
+ SkCodec::Result*,
32
+ SkCodecs::DecodeContext = nullptr);
33
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SkCodec::Result*,
35
+ SkCodecs::DecodeContext = nullptr);
36
+
37
+ inline SkCodecs::Decoder Decoder() {
38
+ return { "bmp", IsBmp, Decode };
39
+ }
40
+
41
+ } // namespace SkBmpDecoder
42
+
43
+ #endif // SkBmpDecoder_DEFINED
@@ -23,6 +23,7 @@
23
23
  #include <cstddef>
24
24
  #include <functional>
25
25
  #include <memory>
26
+ #include <string>
26
27
  #include <tuple>
27
28
  #include <vector>
28
29
 
@@ -41,7 +42,6 @@ enum class Blend;
41
42
  enum class DisposalMethod;
42
43
  }
43
44
 
44
-
45
45
  namespace DM {
46
46
  class CodecSrc;
47
47
  } // namespace DM
@@ -1012,4 +1012,28 @@ private:
1012
1012
  friend class SkIcoCodec;
1013
1013
  friend class SkAndroidCodec; // for fEncodedInfo
1014
1014
  };
1015
+
1016
+ namespace SkCodecs {
1017
+
1018
+ using DecodeContext = void*;
1019
+ using IsFormatCallback = bool (*)(const void* data, size_t len);
1020
+ using MakeFromStreamCallback = std::unique_ptr<SkCodec> (*)(std::unique_ptr<SkStream>,
1021
+ SkCodec::Result*,
1022
+ DecodeContext);
1023
+
1024
+ struct Decoder {
1025
+ // By convention, we use all lowercase letters and go with the primary filename extension.
1026
+ // For example "png", "jpg", "ico", "webp", etc
1027
+ std::string id;
1028
+ IsFormatCallback isFormat;
1029
+ MakeFromStreamCallback makeFromStream;
1030
+ };
1031
+
1032
+ // Add the decoder to the end of a linked list of decoders, which will be used to identify calls to
1033
+ // SkCodec::MakeFromStream. If a decoder with the same id already exists, this new decoder
1034
+ // will replace the existing one (in the same position). This is not thread-safe, so make sure all
1035
+ // initialization is done before the first call.
1036
+ void Register(Decoder d);
1037
+ }
1038
+
1015
1039
  #endif // SkCodec_DEFINED
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+ #ifndef SkGifDecoder_DEFINED
8
+ #define SkGifDecoder_DEFINED
9
+
10
+ #include "include/codec/SkCodec.h"
11
+ #include "include/core/SkRefCnt.h"
12
+
13
+ class SkData;
14
+ class SkStream;
15
+
16
+ #include <memory>
17
+
18
+ namespace SkGifDecoder {
19
+
20
+ /** Returns true if this data claims to be a GIF image. */
21
+ SK_API bool IsGif(const void*, size_t);
22
+
23
+ /**
24
+ * Attempts to decode the given bytes as a GIF.
25
+ *
26
+ * If the bytes are not a GIF, returns nullptr.
27
+ *
28
+ * DecodeContext is ignored
29
+ */
30
+ SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
31
+ SkCodec::Result*,
32
+ SkCodecs::DecodeContext = nullptr);
33
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SkCodec::Result*,
35
+ SkCodecs::DecodeContext = nullptr);
36
+
37
+ inline SkCodecs::Decoder Decoder() {
38
+ return { "gif", IsGif, Decode };
39
+ }
40
+
41
+ } // namespace SkGifDecoder
42
+
43
+ #endif // SkGifDecoder_DEFINED
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+ #ifndef SkIcoDecoder_DEFINED
8
+ #define SkIcoDecoder_DEFINED
9
+
10
+ #include "include/codec/SkCodec.h"
11
+ #include "include/core/SkRefCnt.h"
12
+
13
+ class SkData;
14
+ class SkStream;
15
+
16
+ #include <memory>
17
+
18
+ namespace SkIcoDecoder {
19
+
20
+ /** Returns true if this data claims to be a ICO image. */
21
+ SK_API bool IsIco(const void*, size_t);
22
+
23
+ /**
24
+ * Attempts to decode the given bytes as a ICO.
25
+ *
26
+ * If the bytes are not a ICO, returns nullptr.
27
+ *
28
+ * DecodeContext is ignored
29
+ */
30
+ SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
31
+ SkCodec::Result*,
32
+ SkCodecs::DecodeContext = nullptr);
33
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SkCodec::Result*,
35
+ SkCodecs::DecodeContext = nullptr);
36
+
37
+ inline SkCodecs::Decoder Decoder() {
38
+ return { "ico", IsIco, Decode };
39
+ }
40
+
41
+ } // namespace SkIcoDecoder
42
+
43
+ #endif // SkIcoDecoder_DEFINED