@shopify/react-native-skia 0.1.158 → 0.1.159

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 (403) hide show
  1. package/android/CMakeLists.txt +35 -11
  2. package/android/build.gradle +21 -25
  3. package/android/cpp/jni/JniLoad.cpp +2 -0
  4. package/android/cpp/jni/include/JniSkiaDomView.h +89 -0
  5. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +4 -3
  6. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +4 -3
  7. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +2 -1
  8. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomView.java +45 -0
  9. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomViewManager.java +64 -0
  10. package/cpp/api/JsiSkHostObjects.h +6 -0
  11. package/cpp/api/JsiSkImageFilterFactory.h +1 -1
  12. package/cpp/api/JsiSkPaint.h +9 -2
  13. package/cpp/api/JsiSkPath.h +1 -0
  14. package/cpp/api/JsiSkRuntimeEffect.h +36 -36
  15. package/cpp/jsi/JsiHostObject.cpp +16 -28
  16. package/cpp/jsi/JsiHostObject.h +127 -7
  17. package/cpp/jsi/JsiValue.cpp +346 -0
  18. package/cpp/jsi/JsiValue.h +222 -0
  19. package/cpp/jsi/JsiValueWrapper.h +33 -5
  20. package/cpp/rnskia/RNSkDomView.cpp +220 -0
  21. package/cpp/rnskia/RNSkDomView.h +140 -0
  22. package/cpp/rnskia/RNSkJsView.cpp +0 -4
  23. package/cpp/rnskia/RNSkJsView.h +6 -4
  24. package/cpp/rnskia/RNSkManager.cpp +7 -0
  25. package/cpp/rnskia/RNSkPictureView.h +5 -8
  26. package/cpp/rnskia/RNSkView.h +113 -5
  27. package/cpp/rnskia/dom/JsiDomApi.h +167 -0
  28. package/cpp/rnskia/dom/base/BaseNodeProp.h +72 -0
  29. package/cpp/rnskia/dom/base/DerivedNodeProp.h +187 -0
  30. package/cpp/rnskia/dom/base/DrawingContext.cpp +227 -0
  31. package/cpp/rnskia/dom/base/DrawingContext.h +136 -0
  32. package/cpp/rnskia/dom/base/JsiDependencyManager.h +294 -0
  33. package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +176 -0
  34. package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +50 -0
  35. package/cpp/rnskia/dom/base/JsiDomNode.h +361 -0
  36. package/cpp/rnskia/dom/base/JsiDomRenderNode.h +267 -0
  37. package/cpp/rnskia/dom/base/NodeProp.h +130 -0
  38. package/cpp/rnskia/dom/base/NodePropsContainer.h +119 -0
  39. package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +38 -0
  40. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +112 -0
  41. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +78 -0
  42. package/cpp/rnskia/dom/nodes/JsiBoxNode.h +104 -0
  43. package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +33 -0
  44. package/cpp/rnskia/dom/nodes/JsiCircleNode.h +38 -0
  45. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +192 -0
  46. package/cpp/rnskia/dom/nodes/JsiCustomDrawingNode.h +123 -0
  47. package/cpp/rnskia/dom/nodes/JsiDiffRectNode.h +42 -0
  48. package/cpp/rnskia/dom/nodes/JsiFillNode.h +22 -0
  49. package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +56 -0
  50. package/cpp/rnskia/dom/nodes/JsiGroupNode.h +26 -0
  51. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +415 -0
  52. package/cpp/rnskia/dom/nodes/JsiImageNode.h +34 -0
  53. package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +44 -0
  54. package/cpp/rnskia/dom/nodes/JsiLayerNode.h +64 -0
  55. package/cpp/rnskia/dom/nodes/JsiLineNode.h +43 -0
  56. package/cpp/rnskia/dom/nodes/JsiOvalNode.h +34 -0
  57. package/cpp/rnskia/dom/nodes/JsiPaintNode.h +77 -0
  58. package/cpp/rnskia/dom/nodes/JsiPatchNode.h +54 -0
  59. package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +315 -0
  60. package/cpp/rnskia/dom/nodes/JsiPathNode.h +181 -0
  61. package/cpp/rnskia/dom/nodes/JsiPictureNode.h +32 -0
  62. package/cpp/rnskia/dom/nodes/JsiPointsNode.h +51 -0
  63. package/cpp/rnskia/dom/nodes/JsiRRectNode.h +34 -0
  64. package/cpp/rnskia/dom/nodes/JsiRectNode.h +34 -0
  65. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +517 -0
  66. package/cpp/rnskia/dom/nodes/JsiTextBlobNode.h +47 -0
  67. package/cpp/rnskia/dom/nodes/JsiTextNode.h +54 -0
  68. package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +32 -0
  69. package/cpp/rnskia/dom/nodes/JsiVerticesNode.h +43 -0
  70. package/cpp/rnskia/dom/props/BezierProps.h +63 -0
  71. package/cpp/rnskia/dom/props/BlendModeProp.h +101 -0
  72. package/cpp/rnskia/dom/props/BoxShadowProps.h +61 -0
  73. package/cpp/rnskia/dom/props/CircleProp.h +46 -0
  74. package/cpp/rnskia/dom/props/ClipProp.h +62 -0
  75. package/cpp/rnskia/dom/props/ColorProp.h +80 -0
  76. package/cpp/rnskia/dom/props/DrawingProp.h +33 -0
  77. package/cpp/rnskia/dom/props/FontProp.h +34 -0
  78. package/cpp/rnskia/dom/props/GlyphsProp.h +53 -0
  79. package/cpp/rnskia/dom/props/ImageProps.h +173 -0
  80. package/cpp/rnskia/dom/props/LayerProp.h +50 -0
  81. package/cpp/rnskia/dom/props/MatrixProp.h +33 -0
  82. package/cpp/rnskia/dom/props/NumbersProp.h +63 -0
  83. package/cpp/rnskia/dom/props/PaintProps.h +172 -0
  84. package/cpp/rnskia/dom/props/PathProp.h +55 -0
  85. package/cpp/rnskia/dom/props/PictureProp.h +38 -0
  86. package/cpp/rnskia/dom/props/PointProp.h +72 -0
  87. package/cpp/rnskia/dom/props/PointsProp.h +83 -0
  88. package/cpp/rnskia/dom/props/RRectProp.h +134 -0
  89. package/cpp/rnskia/dom/props/RadiusProp.h +43 -0
  90. package/cpp/rnskia/dom/props/RectProp.h +118 -0
  91. package/cpp/rnskia/dom/props/StrokeProps.h +75 -0
  92. package/cpp/rnskia/dom/props/SvgProp.h +37 -0
  93. package/cpp/rnskia/dom/props/TextBlobProp.h +128 -0
  94. package/cpp/rnskia/dom/props/TileModeProp.h +50 -0
  95. package/cpp/rnskia/dom/props/TransformProp.h +80 -0
  96. package/cpp/rnskia/dom/props/TransformsProps.h +68 -0
  97. package/cpp/rnskia/dom/props/UniformsProp.h +194 -0
  98. package/cpp/rnskia/dom/props/VertexModeProp.h +47 -0
  99. package/cpp/rnskia/dom/props/VerticesProps.h +67 -0
  100. package/cpp/rnskia/values/RNSkReadonlyValue.h +13 -4
  101. package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +35 -1
  102. package/cpp/skia/include/codec/SkAndroidCodec.h +17 -1
  103. package/cpp/skia/include/codec/SkCodec.h +8 -5
  104. package/cpp/skia/include/core/SkAnnotation.h +2 -0
  105. package/cpp/skia/include/core/SkBitmap.h +52 -1
  106. package/cpp/skia/include/core/SkBlendMode.h +2 -0
  107. package/cpp/skia/include/core/SkCanvas.h +52 -31
  108. package/cpp/skia/include/core/SkCapabilities.h +44 -0
  109. package/cpp/skia/include/core/SkColor.h +7 -0
  110. package/cpp/skia/include/core/SkColorFilter.h +37 -0
  111. package/cpp/skia/include/core/SkColorSpace.h +1 -1
  112. package/cpp/skia/include/core/SkFont.h +4 -0
  113. package/cpp/skia/include/core/SkFontMgr.h +3 -0
  114. package/cpp/skia/include/core/SkGraphics.h +9 -0
  115. package/cpp/skia/include/core/SkImage.h +77 -17
  116. package/cpp/skia/include/core/SkImageEncoder.h +5 -3
  117. package/cpp/skia/include/core/SkImageGenerator.h +27 -17
  118. package/cpp/skia/include/core/SkM44.h +1 -0
  119. package/cpp/skia/include/core/SkMesh.h +120 -34
  120. package/cpp/skia/include/core/SkMilestone.h +1 -1
  121. package/cpp/skia/include/core/SkOverdrawCanvas.h +2 -1
  122. package/cpp/skia/include/core/SkPaint.h +15 -2
  123. package/cpp/skia/include/core/SkPath.h +4 -0
  124. package/cpp/skia/include/core/SkPathBuilder.h +1 -1
  125. package/cpp/skia/include/core/SkPicture.h +0 -3
  126. package/cpp/skia/include/core/SkPictureRecorder.h +0 -2
  127. package/cpp/skia/include/core/SkPixmap.h +19 -0
  128. package/cpp/skia/include/core/SkRasterHandleAllocator.h +3 -1
  129. package/cpp/skia/include/core/SkRect.h +11 -4
  130. package/cpp/skia/include/core/SkRefCnt.h +13 -1
  131. package/cpp/skia/include/core/SkRegion.h +6 -0
  132. package/cpp/skia/include/core/SkSamplingOptions.h +8 -6
  133. package/cpp/skia/include/core/SkScalar.h +6 -25
  134. package/cpp/skia/include/core/SkShader.h +20 -12
  135. package/cpp/skia/include/core/SkSpan.h +51 -19
  136. package/cpp/skia/include/core/SkStream.h +2 -2
  137. package/cpp/skia/include/core/SkString.h +11 -3
  138. package/cpp/skia/include/core/SkSurface.h +85 -8
  139. package/cpp/skia/include/core/SkTextBlob.h +5 -2
  140. package/cpp/skia/include/core/SkTypes.h +11 -10
  141. package/cpp/skia/include/docs/SkPDFDocument.h +0 -5
  142. package/cpp/skia/include/effects/Sk1DPathEffect.h +6 -1
  143. package/cpp/skia/include/effects/Sk2DPathEffect.h +4 -1
  144. package/cpp/skia/include/effects/SkColorMatrix.h +1 -0
  145. package/cpp/skia/include/effects/SkColorMatrixFilter.h +5 -8
  146. package/cpp/skia/include/effects/SkCornerPathEffect.h +5 -1
  147. package/cpp/skia/include/effects/SkDashPathEffect.h +5 -1
  148. package/cpp/skia/include/effects/SkGradientShader.h +68 -38
  149. package/cpp/skia/include/effects/SkHighContrastFilter.h +5 -1
  150. package/cpp/skia/include/effects/SkImageFilters.h +5 -4
  151. package/cpp/skia/include/effects/SkLumaColorFilter.h +4 -1
  152. package/cpp/skia/include/effects/SkOpPathEffect.h +6 -2
  153. package/cpp/skia/include/effects/SkOverdrawColorFilter.h +5 -2
  154. package/cpp/skia/include/effects/SkRuntimeEffect.h +54 -62
  155. package/cpp/skia/include/effects/SkShaderMaskFilter.h +3 -1
  156. package/cpp/skia/include/effects/SkTableColorFilter.h +8 -21
  157. package/cpp/skia/include/effects/SkTableMaskFilter.h +5 -1
  158. package/cpp/skia/include/effects/SkTrimPathEffect.h +5 -1
  159. package/cpp/skia/include/encode/SkEncoder.h +17 -0
  160. package/cpp/skia/include/encode/SkWebpEncoder.h +17 -0
  161. package/cpp/skia/include/gpu/GpuTypes.h +18 -0
  162. package/cpp/skia/include/gpu/GrBackendSurface.h +38 -17
  163. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +6 -71
  164. package/cpp/skia/include/gpu/GrContextOptions.h +1 -1
  165. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +10 -9
  166. package/cpp/skia/include/gpu/GrDirectContext.h +42 -22
  167. package/cpp/skia/include/gpu/GrRecordingContext.h +6 -3
  168. package/cpp/skia/include/gpu/GrTypes.h +11 -11
  169. package/cpp/skia/include/gpu/MutableTextureState.h +122 -0
  170. package/cpp/skia/include/gpu/gl/GrGLFunctions.h +1 -0
  171. package/cpp/skia/include/gpu/gl/GrGLInterface.h +1 -0
  172. package/cpp/skia/include/gpu/graphite/BackendTexture.h +7 -0
  173. package/cpp/skia/include/gpu/graphite/CombinationBuilder.h +195 -0
  174. package/cpp/skia/include/gpu/graphite/Context.h +47 -55
  175. package/cpp/skia/include/gpu/graphite/ContextOptions.h +85 -0
  176. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +1 -17
  177. package/cpp/skia/include/gpu/graphite/ImageProvider.h +61 -0
  178. package/cpp/skia/include/gpu/graphite/Recorder.h +87 -8
  179. package/cpp/skia/include/gpu/graphite/Recording.h +19 -9
  180. package/cpp/skia/include/gpu/graphite/TextureInfo.h +40 -8
  181. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +25 -0
  182. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +3 -2
  183. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +69 -0
  184. package/cpp/skia/include/gpu/mtl/MtlMemoryAllocator.h +39 -0
  185. package/cpp/skia/include/gpu/vk/GrVkBackendContext.h +21 -19
  186. package/cpp/skia/include/gpu/vk/GrVkExtensions.h +2 -50
  187. package/cpp/skia/include/gpu/vk/GrVkMemoryAllocator.h +2 -127
  188. package/cpp/skia/include/gpu/vk/GrVkTypes.h +5 -43
  189. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +46 -0
  190. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +67 -0
  191. package/cpp/skia/include/gpu/vk/VulkanMemoryAllocator.h +116 -0
  192. package/cpp/skia/include/gpu/vk/VulkanTypes.h +59 -0
  193. package/cpp/skia/include/pathops/SkPathOps.h +1 -1
  194. package/cpp/skia/include/private/SkColorData.h +10 -40
  195. package/cpp/skia/include/private/SkEncodedInfo.h +9 -3
  196. package/cpp/skia/include/private/SkFloatingPoint.h +9 -6
  197. package/cpp/skia/include/private/SkHalf.h +5 -52
  198. package/cpp/skia/include/private/SkMacros.h +1 -1
  199. package/cpp/skia/include/private/SkMalloc.h +4 -0
  200. package/cpp/skia/include/private/SkPathRef.h +10 -10
  201. package/cpp/skia/include/private/SkSLModifiers.h +59 -23
  202. package/cpp/skia/include/private/SkSLProgramKind.h +1 -0
  203. package/cpp/skia/include/private/SkSLSymbol.h +7 -3
  204. package/cpp/skia/include/private/SkStringView.h +4 -0
  205. package/cpp/skia/include/private/SkTArray.h +21 -7
  206. package/cpp/skia/include/private/SkTDArray.h +173 -285
  207. package/cpp/skia/include/private/SkTHash.h +33 -32
  208. package/cpp/skia/include/private/SkTemplates.h +24 -26
  209. package/cpp/skia/include/private/SkVx.h +218 -135
  210. package/cpp/skia/include/private/chromium/GrSlug.h +3 -65
  211. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +6 -3
  212. package/cpp/skia/include/private/chromium/Slug.h +76 -0
  213. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +6 -1
  214. package/cpp/skia/include/private/gpu/ganesh/GrVkTypesPriv.h +5 -39
  215. package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +63 -0
  216. package/cpp/skia/include/{gpu/vk/GrVkVulkan.h → private/gpu/vk/SkiaVulkan.h} +2 -2
  217. package/cpp/skia/include/private/gpu/vk/VulkanTypesPriv.h +57 -0
  218. package/cpp/skia/include/sksl/DSL.h +0 -1
  219. package/cpp/skia/include/sksl/DSLBlock.h +4 -18
  220. package/cpp/skia/include/sksl/DSLCase.h +2 -8
  221. package/cpp/skia/include/sksl/DSLCore.h +8 -15
  222. package/cpp/skia/include/sksl/DSLExpression.h +51 -142
  223. package/cpp/skia/include/sksl/DSLFunction.h +7 -15
  224. package/cpp/skia/include/sksl/DSLModifiers.h +5 -2
  225. package/cpp/skia/include/sksl/DSLStatement.h +4 -39
  226. package/cpp/skia/include/sksl/DSLSymbols.h +1 -11
  227. package/cpp/skia/include/sksl/DSLType.h +20 -12
  228. package/cpp/skia/include/sksl/DSLVar.h +56 -146
  229. package/cpp/skia/include/sksl/SkSLErrorReporter.h +2 -15
  230. package/cpp/skia/include/sksl/SkSLOperator.h +62 -59
  231. package/cpp/skia/include/sksl/SkSLPosition.h +2 -0
  232. package/cpp/skia/include/sksl/SkSLVersion.h +27 -0
  233. package/cpp/skia/include/svg/SkSVGCanvas.h +1 -0
  234. package/cpp/skia/include/utils/SkAnimCodecPlayer.h +1 -1
  235. package/cpp/skia/include/utils/SkBase64.h +2 -0
  236. package/cpp/skia/include/utils/SkCustomTypeface.h +24 -11
  237. package/cpp/skia/include/utils/SkEventTracer.h +12 -1
  238. package/cpp/skia/include/utils/SkNWayCanvas.h +11 -4
  239. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +9 -4
  240. package/cpp/skia/include/utils/SkParse.h +3 -0
  241. package/cpp/skia/include/utils/SkShadowUtils.h +2 -0
  242. package/cpp/skia/include/utils/SkTextUtils.h +2 -1
  243. package/cpp/skia/{include/third_party → modules}/skcms/skcms.h +10 -0
  244. package/cpp/skia/modules/skcms/skcms_internal.h +56 -0
  245. package/cpp/skia/modules/skcms/src/Transform_inl.h +1609 -0
  246. package/cpp/skia/modules/skparagraph/include/DartTypes.h +153 -0
  247. package/cpp/skia/modules/skparagraph/include/FontArguments.h +46 -0
  248. package/cpp/skia/modules/skparagraph/include/FontCollection.h +84 -0
  249. package/cpp/skia/modules/skparagraph/include/Metrics.h +98 -0
  250. package/cpp/skia/modules/skparagraph/include/Paragraph.h +111 -0
  251. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +69 -0
  252. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +77 -0
  253. package/cpp/skia/modules/skparagraph/include/ParagraphStyle.h +143 -0
  254. package/cpp/skia/modules/skparagraph/include/TextShadow.h +30 -0
  255. package/cpp/skia/modules/skparagraph/include/TextStyle.h +352 -0
  256. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +81 -0
  257. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +1 -1
  258. package/cpp/skia/modules/svg/include/SkSVGTypes.h +3 -3
  259. package/cpp/skia/src/core/SkLRUCache.h +126 -0
  260. package/cpp/skia/src/core/SkTInternalLList.h +302 -0
  261. package/cpp/utils/RNSkTimingInfo.h +1 -0
  262. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +15 -4
  263. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +40 -54
  264. package/ios/RNSkia-iOS/SkiaDomViewManager.h +8 -0
  265. package/ios/RNSkia-iOS/SkiaDomViewManager.mm +51 -0
  266. package/lib/commonjs/dom/nodes/JsiSkDOM.js +56 -56
  267. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  268. package/lib/commonjs/dom/nodes/RenderNode.js +1 -1
  269. package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
  270. package/lib/commonjs/renderer/Canvas.js +19 -63
  271. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  272. package/lib/commonjs/renderer/DependencyManager.js +0 -5
  273. package/lib/commonjs/renderer/DependencyManager.js.map +1 -1
  274. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  275. package/lib/commonjs/renderer/useCanvas.js +4 -18
  276. package/lib/commonjs/renderer/useCanvas.js.map +1 -1
  277. package/lib/commonjs/views/SkiaBaseWebView.js +7 -0
  278. package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
  279. package/lib/commonjs/views/SkiaDomView.js +152 -0
  280. package/lib/commonjs/views/SkiaDomView.js.map +1 -0
  281. package/lib/commonjs/views/SkiaDomView.web.js +55 -0
  282. package/lib/commonjs/views/SkiaDomView.web.js.map +1 -0
  283. package/lib/commonjs/views/SkiaPictureView.js +16 -2
  284. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  285. package/lib/commonjs/views/SkiaView.js +17 -2
  286. package/lib/commonjs/views/SkiaView.js.map +1 -1
  287. package/lib/commonjs/views/index.js +13 -0
  288. package/lib/commonjs/views/index.js.map +1 -1
  289. package/lib/commonjs/views/types.js.map +1 -1
  290. package/lib/module/dom/nodes/JsiSkDOM.js +56 -56
  291. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  292. package/lib/module/dom/nodes/RenderNode.js +1 -1
  293. package/lib/module/dom/nodes/RenderNode.js.map +1 -1
  294. package/lib/module/renderer/Canvas.js +20 -64
  295. package/lib/module/renderer/Canvas.js.map +1 -1
  296. package/lib/module/renderer/DependencyManager.js +0 -5
  297. package/lib/module/renderer/DependencyManager.js.map +1 -1
  298. package/lib/module/renderer/HostComponents.js.map +1 -1
  299. package/lib/module/renderer/useCanvas.js +2 -13
  300. package/lib/module/renderer/useCanvas.js.map +1 -1
  301. package/lib/module/views/SkiaBaseWebView.js +7 -0
  302. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  303. package/lib/module/views/SkiaDomView.js +128 -0
  304. package/lib/module/views/SkiaDomView.js.map +1 -0
  305. package/lib/module/views/SkiaDomView.web.js +41 -0
  306. package/lib/module/views/SkiaDomView.web.js.map +1 -0
  307. package/lib/module/views/SkiaPictureView.js +14 -2
  308. package/lib/module/views/SkiaPictureView.js.map +1 -1
  309. package/lib/module/views/SkiaView.js +15 -2
  310. package/lib/module/views/SkiaView.js.map +1 -1
  311. package/lib/module/views/index.js +1 -0
  312. package/lib/module/views/index.js.map +1 -1
  313. package/lib/module/views/types.js.map +1 -1
  314. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +57 -64
  315. package/lib/typescript/src/renderer/Canvas.d.ts +5 -8
  316. package/lib/typescript/src/renderer/DependencyManager.d.ts +0 -2
  317. package/lib/typescript/src/renderer/HostComponents.d.ts +66 -3
  318. package/lib/typescript/src/renderer/useCanvas.d.ts +0 -6
  319. package/lib/typescript/src/views/SkiaBaseWebView.d.ts +4 -0
  320. package/lib/typescript/src/views/SkiaDomView.d.ts +31 -0
  321. package/lib/typescript/src/views/SkiaDomView.web.d.ts +7 -0
  322. package/lib/typescript/src/views/index.d.ts +1 -0
  323. package/lib/typescript/src/views/types.d.ts +12 -2
  324. package/libs/android/arm64-v8a/libskia.a +0 -0
  325. package/libs/android/arm64-v8a/libskottie.a +0 -0
  326. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  327. package/libs/android/arm64-v8a/libsksg.a +0 -0
  328. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  329. package/libs/android/arm64-v8a/libskunicode.a +0 -0
  330. package/libs/android/arm64-v8a/libsvg.a +0 -0
  331. package/libs/android/armeabi-v7a/libskia.a +0 -0
  332. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  333. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  334. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  335. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  336. package/libs/android/armeabi-v7a/libskunicode.a +0 -0
  337. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  338. package/libs/android/x86/libskia.a +0 -0
  339. package/libs/android/x86/libskottie.a +0 -0
  340. package/libs/android/x86/libskparagraph.a +0 -0
  341. package/libs/android/x86/libsksg.a +0 -0
  342. package/libs/android/x86/libskshaper.a +0 -0
  343. package/libs/android/x86/libskunicode.a +0 -0
  344. package/libs/android/x86/libsvg.a +0 -0
  345. package/libs/android/x86_64/libskia.a +0 -0
  346. package/libs/android/x86_64/libskottie.a +0 -0
  347. package/libs/android/x86_64/libskparagraph.a +0 -0
  348. package/libs/android/x86_64/libsksg.a +0 -0
  349. package/libs/android/x86_64/libskshaper.a +0 -0
  350. package/libs/android/x86_64/libskunicode.a +0 -0
  351. package/libs/android/x86_64/libsvg.a +0 -0
  352. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  353. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  354. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  355. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  356. package/libs/ios/libskparagraph.xcframework/Info.plist +42 -0
  357. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  358. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  359. package/libs/ios/libsksg.xcframework/Info.plist +5 -5
  360. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  361. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  362. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  363. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  364. package/libs/ios/libskunicode.xcframework/Info.plist +42 -0
  365. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
  366. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
  367. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  368. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  369. package/package.json +5 -3
  370. package/react-native-skia.podspec +3 -1
  371. package/src/dom/nodes/JsiSkDOM.ts +170 -56
  372. package/src/dom/nodes/RenderNode.ts +1 -1
  373. package/src/renderer/Canvas.tsx +32 -56
  374. package/src/renderer/DependencyManager.tsx +0 -5
  375. package/src/renderer/HostComponents.ts +152 -1
  376. package/src/renderer/useCanvas.ts +1 -15
  377. package/src/views/SkiaBaseWebView.tsx +4 -0
  378. package/src/views/SkiaDomView.tsx +120 -0
  379. package/src/views/SkiaDomView.web.tsx +37 -0
  380. package/src/views/SkiaPictureView.tsx +10 -2
  381. package/src/views/SkiaView.tsx +11 -3
  382. package/src/views/index.ts +1 -0
  383. package/src/views/types.ts +19 -2
  384. package/cpp/jsi/JsiSimpleValueWrapper.h +0 -99
  385. package/cpp/skia/include/c/sk_canvas.h +0 -159
  386. package/cpp/skia/include/c/sk_colorspace.h +0 -25
  387. package/cpp/skia/include/c/sk_data.h +0 -65
  388. package/cpp/skia/include/c/sk_image.h +0 -71
  389. package/cpp/skia/include/c/sk_imageinfo.h +0 -62
  390. package/cpp/skia/include/c/sk_maskfilter.h +0 -47
  391. package/cpp/skia/include/c/sk_matrix.h +0 -49
  392. package/cpp/skia/include/c/sk_paint.h +0 -145
  393. package/cpp/skia/include/c/sk_path.h +0 -102
  394. package/cpp/skia/include/c/sk_picture.h +0 -70
  395. package/cpp/skia/include/c/sk_shader.h +0 -143
  396. package/cpp/skia/include/c/sk_surface.h +0 -73
  397. package/cpp/skia/include/c/sk_types.h +0 -278
  398. package/cpp/skia/include/gpu/graphite/SkStuff.h +0 -47
  399. package/cpp/skia/include/private/SkNx.h +0 -430
  400. package/cpp/skia/include/private/SkNx_neon.h +0 -713
  401. package/cpp/skia/include/private/SkNx_sse.h +0 -823
  402. package/cpp/skia/include/sksl/DSLRuntimeEffects.h +0 -32
  403. package/cpp/skia/include/sksl/DSLWrapper.h +0 -77
@@ -149,6 +149,8 @@ struct alignas(N*sizeof(T)) Vec : public VecStorage<N,T> {
149
149
 
150
150
  using VecStorage<N,T>::VecStorage;
151
151
 
152
+ // NOTE: Vec{x} produces x000..., whereas Vec(x) produces xxxx.... since this constructor fills
153
+ // unspecified lanes with 0s, whereas the single T constructor fills all lanes with the value.
152
154
  SKVX_ALWAYS_INLINE Vec(std::initializer_list<T> xs) {
153
155
  T vals[N] = {0};
154
156
  memcpy(vals, xs.begin(), std::min(xs.size(), (size_t)N)*sizeof(T));
@@ -193,21 +195,14 @@ struct Vec<1,T> {
193
195
  }
194
196
  };
195
197
 
196
- // Ideally we'd only use bit_pun(), but until this file is always built as C++17 with constexpr if,
197
- // we'll sometimes find need to use unchecked_bit_pun(). Please do check the call sites yourself!
198
198
  template <typename D, typename S>
199
- SI D unchecked_bit_pun(const S& s) {
199
+ SI D bit_pun(const S& s) {
200
+ static_assert(sizeof(D) == sizeof(S));
200
201
  D d;
201
202
  memcpy(&d, &s, sizeof(D));
202
203
  return d;
203
204
  }
204
205
 
205
- template <typename D, typename S>
206
- SI D bit_pun(const S& s) {
207
- static_assert(sizeof(D) == sizeof(S), "");
208
- return unchecked_bit_pun<D>(s);
209
- }
210
-
211
206
  // Translate from a value type T to its corresponding Mask, the result of a comparison.
212
207
  template <typename T> struct Mask { using type = T; };
213
208
  template <> struct Mask<float > { using type = int32_t; };
@@ -459,30 +454,29 @@ SIT Vec<1,T> if_then_else(const Vec<1,M<T>>& cond, const Vec<1,T>& t, const Vec<
459
454
  }
460
455
  SINT Vec<N,T> if_then_else(const Vec<N,M<T>>& cond, const Vec<N,T>& t, const Vec<N,T>& e) {
461
456
  // Specializations inline here so they can generalize what types the apply to.
462
- // (This header is used in C++14 contexts, so we have to kind of fake constexpr if.)
463
457
  #if SKVX_USE_SIMD && defined(__AVX2__)
464
- if /*constexpr*/ (N*sizeof(T) == 32) {
465
- return unchecked_bit_pun<Vec<N,T>>(_mm256_blendv_epi8(unchecked_bit_pun<__m256i>(e),
466
- unchecked_bit_pun<__m256i>(t),
467
- unchecked_bit_pun<__m256i>(cond)));
458
+ if constexpr (N*sizeof(T) == 32) {
459
+ return bit_pun<Vec<N,T>>(_mm256_blendv_epi8(bit_pun<__m256i>(e),
460
+ bit_pun<__m256i>(t),
461
+ bit_pun<__m256i>(cond)));
468
462
  }
469
463
  #endif
470
464
  #if SKVX_USE_SIMD && defined(__SSE4_1__)
471
- if /*constexpr*/ (N*sizeof(T) == 16) {
472
- return unchecked_bit_pun<Vec<N,T>>(_mm_blendv_epi8(unchecked_bit_pun<__m128i>(e),
473
- unchecked_bit_pun<__m128i>(t),
474
- unchecked_bit_pun<__m128i>(cond)));
465
+ if constexpr (N*sizeof(T) == 16) {
466
+ return bit_pun<Vec<N,T>>(_mm_blendv_epi8(bit_pun<__m128i>(e),
467
+ bit_pun<__m128i>(t),
468
+ bit_pun<__m128i>(cond)));
475
469
  }
476
470
  #endif
477
471
  #if SKVX_USE_SIMD && defined(__ARM_NEON)
478
- if /*constexpr*/ (N*sizeof(T) == 16) {
479
- return unchecked_bit_pun<Vec<N,T>>(vbslq_u8(unchecked_bit_pun<uint8x16_t>(cond),
480
- unchecked_bit_pun<uint8x16_t>(t),
481
- unchecked_bit_pun<uint8x16_t>(e)));
472
+ if constexpr (N*sizeof(T) == 16) {
473
+ return bit_pun<Vec<N,T>>(vbslq_u8(bit_pun<uint8x16_t>(cond),
474
+ bit_pun<uint8x16_t>(t),
475
+ bit_pun<uint8x16_t>(e)));
482
476
  }
483
477
  #endif
484
478
  // Recurse for large vectors to try to hit the specializations above.
485
- if /*constexpr*/ (N*sizeof(T) > 16) {
479
+ if constexpr (N*sizeof(T) > 16) {
486
480
  return join(if_then_else(cond.lo, t.lo, e.lo),
487
481
  if_then_else(cond.hi, t.hi, e.hi));
488
482
  }
@@ -492,9 +486,36 @@ SINT Vec<N,T> if_then_else(const Vec<N,M<T>>& cond, const Vec<N,T>& t, const Vec
492
486
 
493
487
  SIT bool any(const Vec<1,T>& x) { return x.val != 0; }
494
488
  SINT bool any(const Vec<N,T>& x) {
489
+ // For any(), the _mm_testz intrinsics are correct and don't require comparing 'x' to 0, so it's
490
+ // lower latency compared to _mm_movemask + _mm_compneq on plain SSE.
491
+ #if SKVX_USE_SIMD && defined(__AVX2__)
492
+ if constexpr (N*sizeof(T) == 32) {
493
+ return !_mm256_testz_si256(bit_pun<__m256i>(x), _mm256_set1_epi32(-1));
494
+ }
495
+ #endif
496
+ #if SKVX_USE_SIMD && defined(__SSE_4_1__)
497
+ if constexpr (N*sizeof(T) == 16) {
498
+ return !_mm_testz_si128(bit_pun<__m128i>(x), _mm_set1_epi32(-1));
499
+ }
500
+ #endif
501
+ #if SKVX_USE_SIMD && defined(__SSE__)
502
+ if constexpr (N*sizeof(T) == 16) {
503
+ // On SSE, movemask checks only the MSB in each lane, which is fine if the lanes were set
504
+ // directly from a comparison op (which sets all bits to 1 when true), but skvx::Vec<>
505
+ // treats any non-zero value as true, so we have to compare 'x' to 0 before calling movemask
506
+ return _mm_movemask_ps(_mm_cmpneq_ps(bit_pun<__m128>(x), _mm_set1_ps(0))) != 0b0000;
507
+ }
508
+ #endif
509
+ #if SKVX_USE_SIMD && defined(__aarch64__)
510
+ // On 64-bit NEON, take the max across lanes, which will be non-zero if any lane was true.
511
+ // The specific lane-size doesn't really matter in this case since it's really any set bit
512
+ // that we're looking for.
513
+ if constexpr (N*sizeof(T) == 8 ) { return vmaxv_u8 (bit_pun<uint8x8_t> (x)) > 0; }
514
+ if constexpr (N*sizeof(T) == 16) { return vmaxvq_u8(bit_pun<uint8x16_t>(x)) > 0; }
515
+ #endif
495
516
  #if SKVX_USE_SIMD && defined(__wasm_simd128__)
496
517
  if constexpr (N == 4 && sizeof(T) == 4) {
497
- return wasm_i32x4_any_true(unchecked_bit_pun<VExt<4,int>>(x));
518
+ return wasm_i32x4_any_true(bit_pun<VExt<4,int>>(x));
498
519
  }
499
520
  #endif
500
521
  return any(x.lo)
@@ -503,21 +524,27 @@ SINT bool any(const Vec<N,T>& x) {
503
524
 
504
525
  SIT bool all(const Vec<1,T>& x) { return x.val != 0; }
505
526
  SINT bool all(const Vec<N,T>& x) {
506
- #if SKVX_USE_SIMD && defined(__AVX2__)
507
- if /*constexpr*/ (N*sizeof(T) == 32) {
508
- return _mm256_testc_si256(unchecked_bit_pun<__m256i>(x),
509
- _mm256_set1_epi32(-1));
527
+ // Unlike any(), we have to respect the lane layout, or we'll miss cases where a
528
+ // true lane has a mix of 0 and 1 bits.
529
+ #if SKVX_USE_SIMD && defined(__SSE__)
530
+ // Unfortunately, the _mm_testc intrinsics don't let us avoid the comparison to 0 for all()'s
531
+ // correctness, so always just use the plain SSE version.
532
+ if constexpr (N == 4 && sizeof(T) == 4) {
533
+ return _mm_movemask_ps(_mm_cmpneq_ps(bit_pun<__m128>(x), _mm_set1_ps(0))) == 0b1111;
510
534
  }
511
535
  #endif
512
- #if SKVX_USE_SIMD && defined(__SSE4_1__)
513
- if /*constexpr*/ (N*sizeof(T) == 16) {
514
- return _mm_testc_si128(unchecked_bit_pun<__m128i>(x),
515
- _mm_set1_epi32(-1));
516
- }
536
+ #if SKVX_USE_SIMD && defined(__aarch64__)
537
+ // On 64-bit NEON, take the min across the lanes, which will be non-zero if all lanes are != 0.
538
+ if constexpr (sizeof(T)==1 && N==8) {return vminv_u8 (bit_pun<uint8x8_t> (x)) > 0;}
539
+ if constexpr (sizeof(T)==1 && N==16) {return vminvq_u8 (bit_pun<uint8x16_t>(x)) > 0;}
540
+ if constexpr (sizeof(T)==2 && N==4) {return vminv_u16 (bit_pun<uint16x4_t>(x)) > 0;}
541
+ if constexpr (sizeof(T)==2 && N==8) {return vminvq_u16(bit_pun<uint16x8_t>(x)) > 0;}
542
+ if constexpr (sizeof(T)==4 && N==2) {return vminv_u32 (bit_pun<uint32x2_t>(x)) > 0;}
543
+ if constexpr (sizeof(T)==4 && N==4) {return vminvq_u32(bit_pun<uint32x4_t>(x)) > 0;}
517
544
  #endif
518
545
  #if SKVX_USE_SIMD && defined(__wasm_simd128__)
519
- if /*constexpr*/ (N == 4 && sizeof(T) == 4) {
520
- return wasm_i32x4_all_true(unchecked_bit_pun<VExt<4,int>>(x));
546
+ if constexpr (N == 4 && sizeof(T) == 4) {
547
+ return wasm_i32x4_all_true(bit_pun<VExt<4,int>>(x));
521
548
  }
522
549
  #endif
523
550
  return all(x.lo)
@@ -620,13 +647,13 @@ SI Vec<1,int> lrint(const Vec<1,float>& x) {
620
647
  }
621
648
  SIN Vec<N,int> lrint(const Vec<N,float>& x) {
622
649
  #if SKVX_USE_SIMD && defined(__AVX__)
623
- if /*constexpr*/ (N == 8) {
624
- return unchecked_bit_pun<Vec<N,int>>(_mm256_cvtps_epi32(unchecked_bit_pun<__m256>(x)));
650
+ if constexpr (N == 8) {
651
+ return bit_pun<Vec<N,int>>(_mm256_cvtps_epi32(bit_pun<__m256>(x)));
625
652
  }
626
653
  #endif
627
654
  #if SKVX_USE_SIMD && defined(__SSE__)
628
- if /*constexpr*/ (N == 4) {
629
- return unchecked_bit_pun<Vec<N,int>>(_mm_cvtps_epi32(unchecked_bit_pun<__m128>(x)));
655
+ if constexpr (N == 4) {
656
+ return bit_pun<Vec<N,int>>(_mm_cvtps_epi32(bit_pun<__m128>(x)));
630
657
  }
631
658
  #endif
632
659
  return join(lrint(x.lo),
@@ -635,8 +662,7 @@ SIN Vec<N,int> lrint(const Vec<N,float>& x) {
635
662
 
636
663
  SIN Vec<N,float> fract(const Vec<N,float>& x) { return x - floor(x); }
637
664
 
638
- // The default logic for to_half/from_half is borrowed from skcms,
639
- // and assumes inputs are finite and treat/flush denorm half floats as/to zero.
665
+ // Assumes inputs are finite and treat/flush denorm half floats as/to zero.
640
666
  // Key constants to watch for:
641
667
  // - a float is 32-bit, 1-8-23 sign-exponent-mantissa, with 127 exponent bias;
642
668
  // - a half is 16-bit, 1-5-10 sign-exponent-mantissa, with 15 exponent bias.
@@ -644,17 +670,17 @@ SIN Vec<N,uint16_t> to_half_finite_ftz(const Vec<N,float>& x) {
644
670
  Vec<N,uint32_t> sem = bit_pun<Vec<N,uint32_t>>(x),
645
671
  s = sem & 0x8000'0000,
646
672
  em = sem ^ s,
647
- is_denorm = em < 0x3880'0000;
648
- return cast<uint16_t>(if_then_else(is_denorm, Vec<N,uint32_t>(0)
649
- , (s>>16) + (em>>13) - ((127-15)<<10)));
673
+ is_norm = em > 0x387f'd000, // halfway between largest f16 denorm and smallest norm
674
+ norm = (em>>13) - ((127-15)<<10);
675
+ return cast<uint16_t>((s>>16) | (is_norm & norm));
650
676
  }
651
677
  SIN Vec<N,float> from_half_finite_ftz(const Vec<N,uint16_t>& x) {
652
678
  Vec<N,uint32_t> wide = cast<uint32_t>(x),
653
679
  s = wide & 0x8000,
654
- em = wide ^ s;
655
- auto is_denorm = bit_pun<Vec<N,int32_t>>(em < 0x0400);
656
- return if_then_else(is_denorm, Vec<N,float>(0)
657
- , bit_pun<Vec<N,float>>( (s<<16) + (em<<13) + ((127-15)<<23) ));
680
+ em = wide ^ s,
681
+ is_norm = em > 0x3ff,
682
+ norm = (em<<13) + ((127-15)<<23);
683
+ return bit_pun<Vec<N,float>>((s<<16) | (is_norm & norm));
658
684
  }
659
685
 
660
686
  // Like if_then_else(), these N=1 base cases won't actually be used unless explicitly called.
@@ -663,18 +689,18 @@ SI Vec<1,float> from_half(const Vec<1,uint16_t>& x) { return from_half_finite_f
663
689
 
664
690
  SIN Vec<N,uint16_t> to_half(const Vec<N,float>& x) {
665
691
  #if SKVX_USE_SIMD && defined(__F16C__)
666
- if /*constexpr*/ (N == 8) {
667
- return unchecked_bit_pun<Vec<N,uint16_t>>(_mm256_cvtps_ph(unchecked_bit_pun<__m256>(x),
668
- _MM_FROUND_CUR_DIRECTION));
692
+ if constexpr (N == 8) {
693
+ return bit_pun<Vec<N,uint16_t>>(_mm256_cvtps_ph(bit_pun<__m256>(x),
694
+ _MM_FROUND_TO_NEAREST_INT));
669
695
  }
670
696
  #endif
671
697
  #if SKVX_USE_SIMD && defined(__aarch64__)
672
- if /*constexpr*/ (N == 4) {
673
- return unchecked_bit_pun<Vec<N,uint16_t>>(vcvt_f16_f32(unchecked_bit_pun<float32x4_t>(x)));
698
+ if constexpr (N == 4) {
699
+ return bit_pun<Vec<N,uint16_t>>(vcvt_f16_f32(bit_pun<float32x4_t>(x)));
674
700
 
675
701
  }
676
702
  #endif
677
- if /*constexpr*/ (N > 4) {
703
+ if constexpr (N > 4) {
678
704
  return join(to_half(x.lo),
679
705
  to_half(x.hi));
680
706
  }
@@ -683,16 +709,16 @@ SIN Vec<N,uint16_t> to_half(const Vec<N,float>& x) {
683
709
 
684
710
  SIN Vec<N,float> from_half(const Vec<N,uint16_t>& x) {
685
711
  #if SKVX_USE_SIMD && defined(__F16C__)
686
- if /*constexpr*/ (N == 8) {
687
- return unchecked_bit_pun<Vec<N,float>>(_mm256_cvtph_ps(unchecked_bit_pun<__m128i>(x)));
712
+ if constexpr (N == 8) {
713
+ return bit_pun<Vec<N,float>>(_mm256_cvtph_ps(bit_pun<__m128i>(x)));
688
714
  }
689
715
  #endif
690
716
  #if SKVX_USE_SIMD && defined(__aarch64__)
691
- if /*constexpr*/ (N == 4) {
692
- return unchecked_bit_pun<Vec<N,float>>(vcvt_f32_f16(unchecked_bit_pun<float16x4_t>(x)));
717
+ if constexpr (N == 4) {
718
+ return bit_pun<Vec<N,float>>(vcvt_f32_f16(bit_pun<float16x4_t>(x)));
693
719
  }
694
720
  #endif
695
- if /*constexpr*/ (N > 4) {
721
+ if constexpr (N > 4) {
696
722
  return join(from_half(x.lo),
697
723
  from_half(x.hi));
698
724
  }
@@ -714,6 +740,29 @@ SIN Vec<N,uint8_t> approx_scale(const Vec<N,uint8_t>& x, const Vec<N,uint8_t>& y
714
740
  return cast<uint8_t>( (X*Y+X)/256 );
715
741
  }
716
742
 
743
+ // saturated_add(x,y) sums values and clamps to the maximum value instead of overflowing.
744
+ SINT std::enable_if_t<std::is_unsigned_v<T>, Vec<N,T>> saturated_add(const Vec<N,T>& x,
745
+ const Vec<N,T>& y) {
746
+ #if SKVX_USE_SIMD && (defined(__SSE__) || defined(__ARM_NEON))
747
+ // Both SSE and ARM have 16-lane saturated adds, so use intrinsics for those and recurse down
748
+ // or join up to take advantage.
749
+ if constexpr (N == 16 && sizeof(T) == 1) {
750
+ #if defined(__SSE__)
751
+ return bit_pun<Vec<N,T>>(_mm_adds_epu8(bit_pun<__m128i>(x), bit_pun<__m128i>(y)));
752
+ #else // __ARM_NEON
753
+ return bit_pun<Vec<N,T>>(vqaddq_u8(bit_pun<uint8x16_t>(x), bit_pun<uint8x16_t>(y)));
754
+ #endif
755
+ } else if constexpr (N < 16 && sizeof(T) == 1) {
756
+ return saturated_add(join(x,x), join(y,y)).lo;
757
+ } else if constexpr (sizeof(T) == 1) {
758
+ return join(saturated_add(x.lo, y.lo), saturated_add(x.hi, y.hi));
759
+ }
760
+ #endif
761
+ // Otherwise saturate manually
762
+ auto sum = x + y;
763
+ return if_then_else(sum < x, Vec<N,T>(std::numeric_limits<T>::max()), sum);
764
+ }
765
+
717
766
  // The ScaledDividerU32 takes a divisor > 1, and creates a function divide(numerator) that
718
767
  // calculates a numerator / denominator. For this to be rounded properly, numerator should have
719
768
  // half added in:
@@ -758,105 +807,109 @@ private:
758
807
  const uint32_t fHalf;
759
808
  };
760
809
 
761
- #if SKVX_USE_SIMD && defined(__ARM_NEON)
762
- // With NEON we can do eight u8*u8 -> u16 in one instruction, vmull_u8 (read, mul-long).
763
- SI Vec<8,uint16_t> mull(const Vec<8,uint8_t>& x,
764
- const Vec<8,uint8_t>& y) {
765
- return to_vec<8,uint16_t>(vmull_u8(to_vext(x),
766
- to_vext(y)));
767
- }
768
810
 
769
- SIN std::enable_if_t<(N < 8), Vec<N,uint16_t>> mull(const Vec<N,uint8_t>& x,
770
- const Vec<N,uint8_t>& y) {
771
- // N < 8 --> double up data until N == 8, returning the part we need.
772
- return mull(join(x,x),
773
- join(y,y)).lo;
774
- }
775
-
776
- SIN std::enable_if_t<(N > 8), Vec<N,uint16_t>> mull(const Vec<N,uint8_t>& x,
777
- const Vec<N,uint8_t>& y) {
778
- // N > 8 --> usual join(lo,hi) strategy to recurse down to N == 8.
779
- return join(mull(x.lo, y.lo),
780
- mull(x.hi, y.hi));
811
+ SIN Vec<N,uint16_t> mull(const Vec<N,uint8_t>& x,
812
+ const Vec<N,uint8_t>& y) {
813
+ #if SKVX_USE_SIMD && defined(__ARM_NEON)
814
+ // With NEON we can do eight u8*u8 -> u16 in one instruction, vmull_u8 (read, mul-long).
815
+ if constexpr (N == 8) {
816
+ return to_vec<8,uint16_t>(vmull_u8(to_vext(x), to_vext(y)));
817
+ } else if constexpr (N < 8) {
818
+ return mull(join(x,x), join(y,y)).lo;
819
+ } else { // N > 8
820
+ return join(mull(x.lo, y.lo), mull(x.hi, y.hi));
821
+ }
822
+ #else
823
+ return cast<uint16_t>(x) * cast<uint16_t>(y);
824
+ #endif
781
825
  }
782
826
 
827
+ SIN Vec<N,uint32_t> mull(const Vec<N,uint16_t>& x,
828
+ const Vec<N,uint16_t>& y) {
829
+ #if SKVX_USE_SIMD && defined(__ARM_NEON)
830
+ // NEON can do four u16*u16 -> u32 in one instruction, vmull_u16
831
+ if constexpr (N == 4) {
832
+ return to_vec<4,uint32_t>(vmull_u16(to_vext(x), to_vext(y)));
833
+ } else if constexpr (N < 4) {
834
+ return mull(join(x,x), join(y,y)).lo;
835
+ } else { // N > 4
836
+ return join(mull(x.lo, y.lo), mull(x.hi, y.hi));
837
+ }
783
838
  #else
784
-
785
- // Nothing special when we don't have NEON... just cast up to 16-bit and multiply.
786
- SIN Vec<N,uint16_t> mull(const Vec<N,uint8_t>& x,
787
- const Vec<N,uint8_t>& y) {
788
- return cast<uint16_t>(x)
789
- * cast<uint16_t>(y);
790
- }
839
+ return cast<uint32_t>(x) * cast<uint32_t>(y);
791
840
  #endif
841
+ }
792
842
 
793
- // Allow floating point contraction. e.g., allow a*x + y to be compiled to a single FMA even though
794
- // it introduces LSB differences on platforms that don't have an FMA instruction.
795
- #if defined(__clang__)
796
- #pragma STDC FP_CONTRACT ON
843
+ SIN Vec<N,uint16_t> mulhi(const Vec<N,uint16_t>& x,
844
+ const Vec<N,uint16_t>& y) {
845
+ #if SKVX_USE_SIMD && defined(__SSE__)
846
+ // Use _mm_mulhi_epu16 for 8xuint16_t and join or split to get there.
847
+ if constexpr (N == 8) {
848
+ return bit_pun<Vec<8,uint16_t>>(_mm_mulhi_epu16(bit_pun<__m128i>(x), bit_pun<__m128i>(y)));
849
+ } else if constexpr (N < 8) {
850
+ return mulhi(join(x,x), join(y,y)).lo;
851
+ } else { // N > 8
852
+ return join(mulhi(x.lo, y.lo), mulhi(x.hi, y.hi));
853
+ }
854
+ #else
855
+ return skvx::cast<uint16_t>(mull(x, y) >> 16);
797
856
  #endif
857
+ }
798
858
 
799
- // Approximates the inverse cosine of x within 0.96 degrees using the rational polynomial:
800
- //
801
- // acos(x) ~= (bx^3 + ax) / (dx^4 + cx^2 + 1) + pi/2
802
- //
803
- // See: https://stackoverflow.com/a/36387954
804
- //
805
- // For a proof of max error, see the "SkVx_approx_acos" unit test.
806
- //
807
- // NOTE: This function deviates immediately from pi and 0 outside -1 and 1. (The derivatives are
808
- // infinite at -1 and 1). So the input must still be clamped between -1 and 1.
809
- #define SKVX_APPROX_ACOS_MAX_ERROR SkDegreesToRadians(.96f)
810
- SIN Vec<N,float> approx_acos(Vec<N,float> x) {
811
- constexpr static float a = -0.939115566365855f;
812
- constexpr static float b = 0.9217841528914573f;
813
- constexpr static float c = -1.2845906244690837f;
814
- constexpr static float d = 0.295624144969963174f;
815
- constexpr static float pi_over_2 = 1.5707963267948966f;
816
- auto xx = x*x;
817
- auto numer = b*xx + a;
818
- auto denom = xx*(d*xx + c) + 1;
819
- return x * (numer/denom) + pi_over_2;
859
+ SINT T dot(const Vec<N, T>& a, const Vec<N, T>& b) {
860
+ auto ab = a*b;
861
+ if constexpr (N == 2) {
862
+ return ab[0] + ab[1];
863
+ } else if constexpr (N == 4) {
864
+ return ab[0] + ab[1] + ab[2] + ab[3];
865
+ } else {
866
+ T sum = ab[0];
867
+ for (int i = 1; i < N; ++i) {
868
+ sum += ab[i];
869
+ }
870
+ return sum;
871
+ }
820
872
  }
821
873
 
822
- #if defined(__clang__)
823
- #pragma STDC FP_CONTRACT DEFAULT
824
- #endif
874
+ SI float cross(const Vec<2, float>& a, const Vec<2, float>& b) {
875
+ auto x = a * shuffle<1,0>(b);
876
+ return x[0] - x[1];
877
+ }
825
878
 
826
879
  // De-interleaving load of 4 vectors.
827
880
  //
828
881
  // WARNING: These are really only supported well on NEON. Consider restructuring your data before
829
882
  // resorting to these methods.
830
883
  SIT void strided_load4(const T* v,
831
- skvx::Vec<1,T>& a,
832
- skvx::Vec<1,T>& b,
833
- skvx::Vec<1,T>& c,
834
- skvx::Vec<1,T>& d) {
884
+ Vec<1,T>& a,
885
+ Vec<1,T>& b,
886
+ Vec<1,T>& c,
887
+ Vec<1,T>& d) {
835
888
  a.val = v[0];
836
889
  b.val = v[1];
837
890
  c.val = v[2];
838
891
  d.val = v[3];
839
892
  }
840
893
  SINT void strided_load4(const T* v,
841
- skvx::Vec<N,T>& a,
842
- skvx::Vec<N,T>& b,
843
- skvx::Vec<N,T>& c,
844
- skvx::Vec<N,T>& d) {
894
+ Vec<N,T>& a,
895
+ Vec<N,T>& b,
896
+ Vec<N,T>& c,
897
+ Vec<N,T>& d) {
845
898
  strided_load4(v, a.lo, b.lo, c.lo, d.lo);
846
899
  strided_load4(v + 4*(N/2), a.hi, b.hi, c.hi, d.hi);
847
900
  }
848
901
  #if SKVX_USE_SIMD && defined(__ARM_NEON)
849
902
  #define IMPL_LOAD4_TRANSPOSED(N, T, VLD) \
850
903
  SI void strided_load4(const T* v, \
851
- skvx::Vec<N,T>& a, \
852
- skvx::Vec<N,T>& b, \
853
- skvx::Vec<N,T>& c, \
854
- skvx::Vec<N,T>& d) { \
904
+ Vec<N,T>& a, \
905
+ Vec<N,T>& b, \
906
+ Vec<N,T>& c, \
907
+ Vec<N,T>& d) { \
855
908
  auto mat = VLD(v); \
856
- a = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[0]); \
857
- b = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[1]); \
858
- c = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[2]); \
859
- d = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[3]); \
909
+ a = bit_pun<Vec<N,T>>(mat.val[0]); \
910
+ b = bit_pun<Vec<N,T>>(mat.val[1]); \
911
+ c = bit_pun<Vec<N,T>>(mat.val[2]); \
912
+ d = bit_pun<Vec<N,T>>(mat.val[3]); \
860
913
  }
861
914
  IMPL_LOAD4_TRANSPOSED(2, uint32_t, vld4_u32)
862
915
  IMPL_LOAD4_TRANSPOSED(4, uint16_t, vld4_u16)
@@ -881,7 +934,6 @@ SI void strided_load4(const float* v,
881
934
  Vec<4,float>& b,
882
935
  Vec<4,float>& c,
883
936
  Vec<4,float>& d) {
884
- using skvx::bit_pun;
885
937
  __m128 a_ = _mm_loadu_ps(v);
886
938
  __m128 b_ = _mm_loadu_ps(v+4);
887
939
  __m128 c_ = _mm_loadu_ps(v+8);
@@ -898,20 +950,20 @@ SI void strided_load4(const float* v,
898
950
  //
899
951
  // WARNING: These are really only supported well on NEON. Consider restructuring your data before
900
952
  // resorting to these methods.
901
- SIT void strided_load2(const T* v, skvx::Vec<1,T>& a, skvx::Vec<1,T>& b) {
953
+ SIT void strided_load2(const T* v, Vec<1,T>& a, Vec<1,T>& b) {
902
954
  a.val = v[0];
903
955
  b.val = v[1];
904
956
  }
905
- SINT void strided_load2(const T* v, skvx::Vec<N,T>& a, skvx::Vec<N,T>& b) {
957
+ SINT void strided_load2(const T* v, Vec<N,T>& a, Vec<N,T>& b) {
906
958
  strided_load2(v, a.lo, b.lo);
907
959
  strided_load2(v + 2*(N/2), a.hi, b.hi);
908
960
  }
909
961
  #if SKVX_USE_SIMD && defined(__ARM_NEON)
910
962
  #define IMPL_LOAD2_TRANSPOSED(N, T, VLD) \
911
- SI void strided_load2(const T* v, skvx::Vec<N,T>& a, skvx::Vec<N,T>& b) { \
963
+ SI void strided_load2(const T* v, Vec<N,T>& a, Vec<N,T>& b) { \
912
964
  auto mat = VLD(v); \
913
- a = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[0]); \
914
- b = skvx::bit_pun<skvx::Vec<N,T>>(mat.val[1]); \
965
+ a = bit_pun<Vec<N,T>>(mat.val[0]); \
966
+ b = bit_pun<Vec<N,T>>(mat.val[1]); \
915
967
  }
916
968
  IMPL_LOAD2_TRANSPOSED(2, uint32_t, vld2_u32)
917
969
  IMPL_LOAD2_TRANSPOSED(4, uint16_t, vld2_u16)
@@ -930,6 +982,37 @@ IMPL_LOAD2_TRANSPOSED(4, float, vld2q_f32)
930
982
  #undef IMPL_LOAD2_TRANSPOSED
931
983
  #endif
932
984
 
985
+ // Define commonly used aliases
986
+ using float2 = Vec< 2, float>;
987
+ using float4 = Vec< 4, float>;
988
+ using float8 = Vec< 8, float>;
989
+
990
+ using double2 = Vec< 2, double>;
991
+ using double4 = Vec< 4, double>;
992
+ using double8 = Vec< 8, double>;
993
+
994
+ using byte2 = Vec< 2, uint8_t>;
995
+ using byte4 = Vec< 4, uint8_t>;
996
+ using byte8 = Vec< 8, uint8_t>;
997
+ using byte16 = Vec<16, uint8_t>;
998
+
999
+ using int2 = Vec< 2, int32_t>;
1000
+ using int4 = Vec< 4, int32_t>;
1001
+ using int8 = Vec< 8, int32_t>;
1002
+
1003
+ using uint2 = Vec< 2, uint32_t>;
1004
+ using uint4 = Vec< 4, uint32_t>;
1005
+ using uint8 = Vec< 8, uint32_t>;
1006
+
1007
+ using long2 = Vec< 2, int64_t>;
1008
+ using long4 = Vec< 4, int64_t>;
1009
+ using long8 = Vec< 8, int64_t>;
1010
+
1011
+ // Use with from_half and to_half to convert between floatX, and use these for storage.
1012
+ using half2 = Vec< 2, uint16_t>;
1013
+ using half4 = Vec< 4, uint16_t>;
1014
+ using half8 = Vec< 8, uint16_t>;
1015
+
933
1016
  } // namespace skvx
934
1017
 
935
1018
  #undef SINTU
@@ -8,71 +8,9 @@
8
8
  #ifndef GrSlug_DEFINED
9
9
  #define GrSlug_DEFINED
10
10
 
11
- #include "include/core/SkData.h"
12
- #include "include/core/SkRect.h"
13
- #include "include/core/SkRefCnt.h"
11
+ #include "include/private/chromium/Slug.h"
14
12
 
15
- class SkCanvas;
16
- class SkMatrix;
17
- class SkPaint;
18
- class SkTextBlob;
19
- class SkReadBuffer;
20
- class SkStrikeClient;
21
- class SkWriteBuffer;
13
+ // TODO: Update Chrome to use sktext::gpu classes and remove these
14
+ using GrSlug = sktext::gpu::Slug;
22
15
 
23
- // You can use GrSlug to simulate drawTextBlob by defining the following at compile time.
24
- // SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG
25
- // You can use GrSlug serialization to simulate drawTextBlob by defining the following:
26
- // SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE
27
- // For Skia, add this to your args.gn file.
28
- // extra_cflags = ["-D", "SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG"]
29
-
30
- // Internal infrastructure for using SubRuns.
31
- class SK_API GrTextReferenceFrame : public SkRefCnt {
32
- public:
33
- ~GrTextReferenceFrame() override;
34
- virtual const SkMatrix& initialPositionMatrix() const = 0;
35
- };
36
-
37
- // GrSlug encapsulates an SkTextBlob at a specific origin, using a specific paint. It can be
38
- // manipulated using matrix and clip changes to the canvas. If the canvas is transformed, then
39
- // the GrSlug will also transform with smaller glyphs using bi-linear interpolation to render. You
40
- // can think of a GrSlug as making a rubber stamp out of a SkTextBlob.
41
- class SK_API GrSlug : public GrTextReferenceFrame {
42
- public:
43
- ~GrSlug() override;
44
- // Return nullptr if the blob would not draw. This is not because of clipping, but because of
45
- // some paint optimization. The GrSlug is captured as if drawn using drawTextBlob.
46
- static sk_sp<GrSlug> ConvertBlob(
47
- SkCanvas* canvas, const SkTextBlob& blob, SkPoint origin, const SkPaint& paint);
48
-
49
- // Serialize the slug.
50
- sk_sp<SkData> serialize() const;
51
- size_t serialize(void* buffer, size_t size) const;
52
-
53
- // Set the client parameter to the appropriate SkStrikeClient when typeface ID translation
54
- // is needed.
55
- static sk_sp<GrSlug> Deserialize(
56
- const void* data, size_t size, const SkStrikeClient* client = nullptr);
57
- static sk_sp<GrSlug> MakeFromBuffer(SkReadBuffer& buffer);
58
-
59
-
60
- // Draw the GrSlug obeying the canvas's mapping and clipping.
61
- void draw(SkCanvas* canvas) const;
62
-
63
- virtual SkRect sourceBounds() const = 0;
64
-
65
- // The paint passed into ConvertBlob; this paint is used instead of the paint resulting from
66
- // the call to aboutToDraw because when we call draw(), the initial paint is needed to call
67
- // aboutToDraw again to get the layer right.
68
- virtual const SkPaint& initialPaint() const = 0;
69
-
70
- virtual void doFlatten(SkWriteBuffer&) const = 0;
71
-
72
- uint32_t uniqueID() const { return fUniqueID; }
73
-
74
- private:
75
- static uint32_t NextUniqueID();
76
- const uint32_t fUniqueID{NextUniqueID()};
77
- };
78
16
  #endif // GrSlug_DEFINED
@@ -15,7 +15,6 @@
15
15
  #include "include/core/SkRefCnt.h"
16
16
  #include "include/utils/SkNoDrawCanvas.h"
17
17
 
18
- class GrSlug;
19
18
  struct SkPackedGlyphID;
20
19
  class SkAutoDescriptor;
21
20
  class SkStrikeCache;
@@ -23,6 +22,7 @@ class SkStrikeClientImpl;
23
22
  class SkStrikeServer;
24
23
  class SkStrikeServerImpl;
25
24
  class SkTypeface;
25
+ namespace sktext::gpu { class Slug; }
26
26
 
27
27
  using SkDiscardableHandleId = uint32_t;
28
28
  // This class is not thread-safe.
@@ -59,7 +59,8 @@ public:
59
59
  SK_API std::unique_ptr<SkCanvas> makeAnalysisCanvas(int width, int height,
60
60
  const SkSurfaceProps& props,
61
61
  sk_sp<SkColorSpace> colorSpace,
62
- bool DFTSupport);
62
+ bool DFTSupport,
63
+ bool DFTPerspSupport = true);
63
64
 
64
65
  // Serializes the typeface to be transmitted using this server.
65
66
  SK_SPI sk_sp<SkData> serializeTypeface(SkTypeface*);
@@ -107,6 +108,8 @@ public:
107
108
  // successful, subsequent attempts to delete the same handle are invalid.
108
109
  virtual bool deleteHandle(SkDiscardableHandleId) = 0;
109
110
 
111
+ virtual void assertHandleValid(SkDiscardableHandleId) {}
112
+
110
113
  virtual void notifyCacheMiss(CacheMissType type, int fontSize) = 0;
111
114
 
112
115
  struct ReadFailureData {
@@ -141,7 +144,7 @@ public:
141
144
 
142
145
  // Given a buffer, unflatten into a slug making sure to do the typefaceID translation from
143
146
  // renderer to GPU. Returns nullptr if there was a problem.
144
- sk_sp<GrSlug> deserializeSlug(const void* data, size_t size) const;
147
+ sk_sp<sktext::gpu::Slug> deserializeSlug(const void* data, size_t size) const;
145
148
 
146
149
  private:
147
150
  std::unique_ptr<SkStrikeClientImpl> fImpl;