@shopify/react-native-skia 0.1.157 → 0.1.159

Sign up to get free protection for your applications and to get access to all the features.
Files changed (482) hide show
  1. package/android/CMakeLists.txt +35 -11
  2. package/android/build.gradle +31 -30
  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/JsiSkContourMeasure.h +7 -5
  11. package/cpp/api/JsiSkHostObjects.h +6 -0
  12. package/cpp/api/JsiSkImageFilterFactory.h +1 -1
  13. package/cpp/api/JsiSkPaint.h +9 -2
  14. package/cpp/api/JsiSkPath.h +1 -0
  15. package/cpp/api/JsiSkRuntimeEffect.h +36 -36
  16. package/cpp/jsi/JsiHostObject.cpp +16 -28
  17. package/cpp/jsi/JsiHostObject.h +127 -7
  18. package/cpp/jsi/JsiValue.cpp +346 -0
  19. package/cpp/jsi/JsiValue.h +222 -0
  20. package/cpp/jsi/JsiValueWrapper.h +33 -5
  21. package/cpp/rnskia/RNSkDomView.cpp +220 -0
  22. package/cpp/rnskia/RNSkDomView.h +140 -0
  23. package/cpp/rnskia/RNSkJsView.cpp +0 -4
  24. package/cpp/rnskia/RNSkJsView.h +6 -4
  25. package/cpp/rnskia/RNSkManager.cpp +7 -0
  26. package/cpp/rnskia/RNSkPictureView.h +5 -8
  27. package/cpp/rnskia/RNSkView.h +113 -5
  28. package/cpp/rnskia/dom/JsiDomApi.h +167 -0
  29. package/cpp/rnskia/dom/base/BaseNodeProp.h +72 -0
  30. package/cpp/rnskia/dom/base/DerivedNodeProp.h +187 -0
  31. package/cpp/rnskia/dom/base/DrawingContext.cpp +227 -0
  32. package/cpp/rnskia/dom/base/DrawingContext.h +136 -0
  33. package/cpp/rnskia/dom/base/JsiDependencyManager.h +294 -0
  34. package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +176 -0
  35. package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +50 -0
  36. package/cpp/rnskia/dom/base/JsiDomNode.h +361 -0
  37. package/cpp/rnskia/dom/base/JsiDomRenderNode.h +267 -0
  38. package/cpp/rnskia/dom/base/NodeProp.h +130 -0
  39. package/cpp/rnskia/dom/base/NodePropsContainer.h +119 -0
  40. package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +38 -0
  41. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +112 -0
  42. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +78 -0
  43. package/cpp/rnskia/dom/nodes/JsiBoxNode.h +104 -0
  44. package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +33 -0
  45. package/cpp/rnskia/dom/nodes/JsiCircleNode.h +38 -0
  46. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +192 -0
  47. package/cpp/rnskia/dom/nodes/JsiCustomDrawingNode.h +123 -0
  48. package/cpp/rnskia/dom/nodes/JsiDiffRectNode.h +42 -0
  49. package/cpp/rnskia/dom/nodes/JsiFillNode.h +22 -0
  50. package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +56 -0
  51. package/cpp/rnskia/dom/nodes/JsiGroupNode.h +26 -0
  52. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +415 -0
  53. package/cpp/rnskia/dom/nodes/JsiImageNode.h +34 -0
  54. package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +44 -0
  55. package/cpp/rnskia/dom/nodes/JsiLayerNode.h +64 -0
  56. package/cpp/rnskia/dom/nodes/JsiLineNode.h +43 -0
  57. package/cpp/rnskia/dom/nodes/JsiOvalNode.h +34 -0
  58. package/cpp/rnskia/dom/nodes/JsiPaintNode.h +77 -0
  59. package/cpp/rnskia/dom/nodes/JsiPatchNode.h +54 -0
  60. package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +315 -0
  61. package/cpp/rnskia/dom/nodes/JsiPathNode.h +181 -0
  62. package/cpp/rnskia/dom/nodes/JsiPictureNode.h +32 -0
  63. package/cpp/rnskia/dom/nodes/JsiPointsNode.h +51 -0
  64. package/cpp/rnskia/dom/nodes/JsiRRectNode.h +34 -0
  65. package/cpp/rnskia/dom/nodes/JsiRectNode.h +34 -0
  66. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +517 -0
  67. package/cpp/rnskia/dom/nodes/JsiTextBlobNode.h +47 -0
  68. package/cpp/rnskia/dom/nodes/JsiTextNode.h +54 -0
  69. package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +32 -0
  70. package/cpp/rnskia/dom/nodes/JsiVerticesNode.h +43 -0
  71. package/cpp/rnskia/dom/props/BezierProps.h +63 -0
  72. package/cpp/rnskia/dom/props/BlendModeProp.h +101 -0
  73. package/cpp/rnskia/dom/props/BoxShadowProps.h +61 -0
  74. package/cpp/rnskia/dom/props/CircleProp.h +46 -0
  75. package/cpp/rnskia/dom/props/ClipProp.h +62 -0
  76. package/cpp/rnskia/dom/props/ColorProp.h +80 -0
  77. package/cpp/rnskia/dom/props/DrawingProp.h +33 -0
  78. package/cpp/rnskia/dom/props/FontProp.h +34 -0
  79. package/cpp/rnskia/dom/props/GlyphsProp.h +53 -0
  80. package/cpp/rnskia/dom/props/ImageProps.h +173 -0
  81. package/cpp/rnskia/dom/props/LayerProp.h +50 -0
  82. package/cpp/rnskia/dom/props/MatrixProp.h +33 -0
  83. package/cpp/rnskia/dom/props/NumbersProp.h +63 -0
  84. package/cpp/rnskia/dom/props/PaintProps.h +172 -0
  85. package/cpp/rnskia/dom/props/PathProp.h +55 -0
  86. package/cpp/rnskia/dom/props/PictureProp.h +38 -0
  87. package/cpp/rnskia/dom/props/PointProp.h +72 -0
  88. package/cpp/rnskia/dom/props/PointsProp.h +83 -0
  89. package/cpp/rnskia/dom/props/RRectProp.h +134 -0
  90. package/cpp/rnskia/dom/props/RadiusProp.h +43 -0
  91. package/cpp/rnskia/dom/props/RectProp.h +118 -0
  92. package/cpp/rnskia/dom/props/StrokeProps.h +75 -0
  93. package/cpp/rnskia/dom/props/SvgProp.h +37 -0
  94. package/cpp/rnskia/dom/props/TextBlobProp.h +128 -0
  95. package/cpp/rnskia/dom/props/TileModeProp.h +50 -0
  96. package/cpp/rnskia/dom/props/TransformProp.h +80 -0
  97. package/cpp/rnskia/dom/props/TransformsProps.h +68 -0
  98. package/cpp/rnskia/dom/props/UniformsProp.h +194 -0
  99. package/cpp/rnskia/dom/props/VertexModeProp.h +47 -0
  100. package/cpp/rnskia/dom/props/VerticesProps.h +67 -0
  101. package/cpp/rnskia/values/RNSkReadonlyValue.h +13 -4
  102. package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +35 -1
  103. package/cpp/skia/include/codec/SkAndroidCodec.h +17 -1
  104. package/cpp/skia/include/codec/SkCodec.h +8 -5
  105. package/cpp/skia/include/core/SkAnnotation.h +2 -0
  106. package/cpp/skia/include/core/SkBitmap.h +52 -1
  107. package/cpp/skia/include/core/SkBlendMode.h +2 -0
  108. package/cpp/skia/include/core/SkCanvas.h +52 -31
  109. package/cpp/skia/include/core/SkCapabilities.h +44 -0
  110. package/cpp/skia/include/core/SkColor.h +7 -0
  111. package/cpp/skia/include/core/SkColorFilter.h +37 -0
  112. package/cpp/skia/include/core/SkColorSpace.h +1 -1
  113. package/cpp/skia/include/core/SkFont.h +4 -0
  114. package/cpp/skia/include/core/SkFontMgr.h +3 -0
  115. package/cpp/skia/include/core/SkGraphics.h +9 -0
  116. package/cpp/skia/include/core/SkImage.h +77 -17
  117. package/cpp/skia/include/core/SkImageEncoder.h +5 -3
  118. package/cpp/skia/include/core/SkImageGenerator.h +27 -17
  119. package/cpp/skia/include/core/SkM44.h +1 -0
  120. package/cpp/skia/include/core/SkMesh.h +120 -34
  121. package/cpp/skia/include/core/SkMilestone.h +1 -1
  122. package/cpp/skia/include/core/SkOverdrawCanvas.h +2 -1
  123. package/cpp/skia/include/core/SkPaint.h +15 -2
  124. package/cpp/skia/include/core/SkPath.h +4 -0
  125. package/cpp/skia/include/core/SkPathBuilder.h +1 -1
  126. package/cpp/skia/include/core/SkPicture.h +0 -3
  127. package/cpp/skia/include/core/SkPictureRecorder.h +0 -2
  128. package/cpp/skia/include/core/SkPixmap.h +19 -0
  129. package/cpp/skia/include/core/SkRasterHandleAllocator.h +3 -1
  130. package/cpp/skia/include/core/SkRect.h +11 -4
  131. package/cpp/skia/include/core/SkRefCnt.h +13 -1
  132. package/cpp/skia/include/core/SkRegion.h +6 -0
  133. package/cpp/skia/include/core/SkSamplingOptions.h +8 -6
  134. package/cpp/skia/include/core/SkScalar.h +6 -25
  135. package/cpp/skia/include/core/SkShader.h +20 -12
  136. package/cpp/skia/include/core/SkSpan.h +51 -19
  137. package/cpp/skia/include/core/SkStream.h +2 -2
  138. package/cpp/skia/include/core/SkString.h +11 -3
  139. package/cpp/skia/include/core/SkSurface.h +85 -8
  140. package/cpp/skia/include/core/SkTextBlob.h +5 -2
  141. package/cpp/skia/include/core/SkTypes.h +11 -10
  142. package/cpp/skia/include/docs/SkPDFDocument.h +0 -5
  143. package/cpp/skia/include/effects/Sk1DPathEffect.h +6 -1
  144. package/cpp/skia/include/effects/Sk2DPathEffect.h +4 -1
  145. package/cpp/skia/include/effects/SkColorMatrix.h +1 -0
  146. package/cpp/skia/include/effects/SkColorMatrixFilter.h +5 -8
  147. package/cpp/skia/include/effects/SkCornerPathEffect.h +5 -1
  148. package/cpp/skia/include/effects/SkDashPathEffect.h +5 -1
  149. package/cpp/skia/include/effects/SkGradientShader.h +68 -38
  150. package/cpp/skia/include/effects/SkHighContrastFilter.h +5 -1
  151. package/cpp/skia/include/effects/SkImageFilters.h +5 -4
  152. package/cpp/skia/include/effects/SkLumaColorFilter.h +4 -1
  153. package/cpp/skia/include/effects/SkOpPathEffect.h +6 -2
  154. package/cpp/skia/include/effects/SkOverdrawColorFilter.h +5 -2
  155. package/cpp/skia/include/effects/SkRuntimeEffect.h +54 -62
  156. package/cpp/skia/include/effects/SkShaderMaskFilter.h +3 -1
  157. package/cpp/skia/include/effects/SkTableColorFilter.h +8 -21
  158. package/cpp/skia/include/effects/SkTableMaskFilter.h +5 -1
  159. package/cpp/skia/include/effects/SkTrimPathEffect.h +5 -1
  160. package/cpp/skia/include/encode/SkEncoder.h +17 -0
  161. package/cpp/skia/include/encode/SkWebpEncoder.h +17 -0
  162. package/cpp/skia/include/gpu/GpuTypes.h +18 -0
  163. package/cpp/skia/include/gpu/GrBackendSurface.h +38 -17
  164. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +6 -71
  165. package/cpp/skia/include/gpu/GrContextOptions.h +1 -1
  166. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +10 -9
  167. package/cpp/skia/include/gpu/GrDirectContext.h +42 -22
  168. package/cpp/skia/include/gpu/GrRecordingContext.h +6 -3
  169. package/cpp/skia/include/gpu/GrTypes.h +11 -11
  170. package/cpp/skia/include/gpu/MutableTextureState.h +122 -0
  171. package/cpp/skia/include/gpu/gl/GrGLFunctions.h +1 -0
  172. package/cpp/skia/include/gpu/gl/GrGLInterface.h +1 -0
  173. package/cpp/skia/include/gpu/graphite/BackendTexture.h +7 -0
  174. package/cpp/skia/include/gpu/graphite/CombinationBuilder.h +195 -0
  175. package/cpp/skia/include/gpu/graphite/Context.h +47 -55
  176. package/cpp/skia/include/gpu/graphite/ContextOptions.h +85 -0
  177. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +1 -17
  178. package/cpp/skia/include/gpu/graphite/ImageProvider.h +61 -0
  179. package/cpp/skia/include/gpu/graphite/Recorder.h +87 -8
  180. package/cpp/skia/include/gpu/graphite/Recording.h +19 -9
  181. package/cpp/skia/include/gpu/graphite/TextureInfo.h +40 -8
  182. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +25 -0
  183. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +3 -2
  184. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +69 -0
  185. package/cpp/skia/include/gpu/mtl/MtlMemoryAllocator.h +39 -0
  186. package/cpp/skia/include/gpu/vk/GrVkBackendContext.h +21 -19
  187. package/cpp/skia/include/gpu/vk/GrVkExtensions.h +2 -50
  188. package/cpp/skia/include/gpu/vk/GrVkMemoryAllocator.h +2 -127
  189. package/cpp/skia/include/gpu/vk/GrVkTypes.h +5 -43
  190. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +46 -0
  191. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +67 -0
  192. package/cpp/skia/include/gpu/vk/VulkanMemoryAllocator.h +116 -0
  193. package/cpp/skia/include/gpu/vk/VulkanTypes.h +59 -0
  194. package/cpp/skia/include/pathops/SkPathOps.h +1 -1
  195. package/cpp/skia/include/private/SkColorData.h +10 -40
  196. package/cpp/skia/include/private/SkEncodedInfo.h +9 -3
  197. package/cpp/skia/include/private/SkFloatingPoint.h +9 -6
  198. package/cpp/skia/include/private/SkHalf.h +5 -52
  199. package/cpp/skia/include/private/SkMacros.h +1 -1
  200. package/cpp/skia/include/private/SkMalloc.h +4 -0
  201. package/cpp/skia/include/private/SkPathRef.h +10 -10
  202. package/cpp/skia/include/private/SkSLModifiers.h +59 -23
  203. package/cpp/skia/include/private/SkSLProgramKind.h +1 -0
  204. package/cpp/skia/include/private/SkSLSymbol.h +7 -3
  205. package/cpp/skia/include/private/SkStringView.h +4 -0
  206. package/cpp/skia/include/private/SkTArray.h +21 -7
  207. package/cpp/skia/include/private/SkTDArray.h +173 -285
  208. package/cpp/skia/include/private/SkTHash.h +33 -32
  209. package/cpp/skia/include/private/SkTemplates.h +24 -26
  210. package/cpp/skia/include/private/SkVx.h +218 -135
  211. package/cpp/skia/include/private/chromium/GrSlug.h +3 -65
  212. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +6 -3
  213. package/cpp/skia/include/private/chromium/Slug.h +76 -0
  214. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +6 -1
  215. package/cpp/skia/include/private/gpu/ganesh/GrVkTypesPriv.h +5 -39
  216. package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +63 -0
  217. package/cpp/skia/include/{gpu/vk/GrVkVulkan.h → private/gpu/vk/SkiaVulkan.h} +2 -2
  218. package/cpp/skia/include/private/gpu/vk/VulkanTypesPriv.h +57 -0
  219. package/cpp/skia/include/sksl/DSL.h +0 -1
  220. package/cpp/skia/include/sksl/DSLBlock.h +4 -18
  221. package/cpp/skia/include/sksl/DSLCase.h +2 -8
  222. package/cpp/skia/include/sksl/DSLCore.h +8 -15
  223. package/cpp/skia/include/sksl/DSLExpression.h +51 -142
  224. package/cpp/skia/include/sksl/DSLFunction.h +7 -15
  225. package/cpp/skia/include/sksl/DSLModifiers.h +5 -2
  226. package/cpp/skia/include/sksl/DSLStatement.h +4 -39
  227. package/cpp/skia/include/sksl/DSLSymbols.h +1 -11
  228. package/cpp/skia/include/sksl/DSLType.h +20 -12
  229. package/cpp/skia/include/sksl/DSLVar.h +56 -146
  230. package/cpp/skia/include/sksl/SkSLErrorReporter.h +2 -15
  231. package/cpp/skia/include/sksl/SkSLOperator.h +62 -59
  232. package/cpp/skia/include/sksl/SkSLPosition.h +2 -0
  233. package/cpp/skia/include/sksl/SkSLVersion.h +27 -0
  234. package/cpp/skia/include/svg/SkSVGCanvas.h +1 -0
  235. package/cpp/skia/include/utils/SkAnimCodecPlayer.h +1 -1
  236. package/cpp/skia/include/utils/SkBase64.h +2 -0
  237. package/cpp/skia/include/utils/SkCustomTypeface.h +24 -11
  238. package/cpp/skia/include/utils/SkEventTracer.h +12 -1
  239. package/cpp/skia/include/utils/SkNWayCanvas.h +11 -4
  240. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +9 -4
  241. package/cpp/skia/include/utils/SkParse.h +3 -0
  242. package/cpp/skia/include/utils/SkShadowUtils.h +2 -0
  243. package/cpp/skia/include/utils/SkTextUtils.h +2 -1
  244. package/cpp/skia/{include/third_party → modules}/skcms/skcms.h +10 -0
  245. package/cpp/skia/modules/skcms/skcms_internal.h +56 -0
  246. package/cpp/skia/modules/skcms/src/Transform_inl.h +1609 -0
  247. package/cpp/skia/modules/skparagraph/include/DartTypes.h +153 -0
  248. package/cpp/skia/modules/skparagraph/include/FontArguments.h +46 -0
  249. package/cpp/skia/modules/skparagraph/include/FontCollection.h +84 -0
  250. package/cpp/skia/modules/skparagraph/include/Metrics.h +98 -0
  251. package/cpp/skia/modules/skparagraph/include/Paragraph.h +111 -0
  252. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +69 -0
  253. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +77 -0
  254. package/cpp/skia/modules/skparagraph/include/ParagraphStyle.h +143 -0
  255. package/cpp/skia/modules/skparagraph/include/TextShadow.h +30 -0
  256. package/cpp/skia/modules/skparagraph/include/TextStyle.h +352 -0
  257. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +81 -0
  258. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +1 -1
  259. package/cpp/skia/modules/svg/include/SkSVGTypes.h +3 -3
  260. package/cpp/skia/src/core/SkLRUCache.h +126 -0
  261. package/cpp/skia/src/core/SkTInternalLList.h +302 -0
  262. package/cpp/utils/RNSkTimingInfo.h +1 -0
  263. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +15 -4
  264. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +40 -54
  265. package/ios/RNSkia-iOS/SkiaDomViewManager.h +8 -0
  266. package/ios/RNSkia-iOS/SkiaDomViewManager.mm +51 -0
  267. package/lib/commonjs/dom/nodes/DrawingNode.js +1 -5
  268. package/lib/commonjs/dom/nodes/DrawingNode.js.map +1 -1
  269. package/lib/commonjs/dom/nodes/JsiSkDOM.js +56 -56
  270. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  271. package/lib/commonjs/dom/nodes/RenderNode.js +3 -9
  272. package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
  273. package/lib/commonjs/dom/nodes/drawings/Text.js +4 -9
  274. package/lib/commonjs/dom/nodes/drawings/Text.js.map +1 -1
  275. package/lib/commonjs/dom/types/Common.js.map +1 -1
  276. package/lib/commonjs/dom/types/Drawings.js.map +1 -1
  277. package/lib/commonjs/mock/index.js +0 -1
  278. package/lib/commonjs/mock/index.js.map +1 -1
  279. package/lib/commonjs/renderer/Canvas.js +21 -57
  280. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  281. package/lib/commonjs/renderer/DependencyManager.js +0 -5
  282. package/lib/commonjs/renderer/DependencyManager.js.map +1 -1
  283. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  284. package/lib/commonjs/renderer/components/Mask.js +1 -3
  285. package/lib/commonjs/renderer/components/Mask.js.map +1 -1
  286. package/lib/commonjs/renderer/components/Paint.js +5 -18
  287. package/lib/commonjs/renderer/components/Paint.js.map +1 -1
  288. package/lib/commonjs/renderer/useCanvas.js +8 -6
  289. package/lib/commonjs/renderer/useCanvas.js.map +1 -1
  290. package/lib/commonjs/skia/core/Picture.js +1 -24
  291. package/lib/commonjs/skia/core/Picture.js.map +1 -1
  292. package/lib/commonjs/skia/core/Rect.js +1 -1
  293. package/lib/commonjs/skia/core/Rect.js.map +1 -1
  294. package/lib/commonjs/skia/types/ContourMeasure.js.map +1 -1
  295. package/lib/commonjs/skia/types/Size.js +2 -0
  296. package/lib/commonjs/skia/types/Size.js.map +1 -0
  297. package/lib/commonjs/skia/types/index.js +13 -0
  298. package/lib/commonjs/skia/types/index.js.map +1 -1
  299. package/lib/commonjs/skia/web/JsiSkColor.js +8 -0
  300. package/lib/commonjs/skia/web/JsiSkColor.js.map +1 -1
  301. package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -7
  302. package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
  303. package/lib/commonjs/values/web/RNSkReadonlyValue.js +4 -2
  304. package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -1
  305. package/lib/commonjs/views/SkiaBaseWebView.js +9 -2
  306. package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
  307. package/lib/commonjs/views/SkiaDomView.js +152 -0
  308. package/lib/commonjs/views/SkiaDomView.js.map +1 -0
  309. package/lib/commonjs/views/SkiaDomView.web.js +55 -0
  310. package/lib/commonjs/views/SkiaDomView.web.js.map +1 -0
  311. package/lib/commonjs/views/SkiaPictureView.js +16 -2
  312. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  313. package/lib/commonjs/views/SkiaView.js +17 -2
  314. package/lib/commonjs/views/SkiaView.js.map +1 -1
  315. package/lib/commonjs/views/index.js +13 -0
  316. package/lib/commonjs/views/index.js.map +1 -1
  317. package/lib/commonjs/views/types.js.map +1 -1
  318. package/lib/module/dom/nodes/DrawingNode.js +2 -6
  319. package/lib/module/dom/nodes/DrawingNode.js.map +1 -1
  320. package/lib/module/dom/nodes/JsiSkDOM.js +56 -56
  321. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  322. package/lib/module/dom/nodes/RenderNode.js +2 -5
  323. package/lib/module/dom/nodes/RenderNode.js.map +1 -1
  324. package/lib/module/dom/nodes/drawings/Text.js +4 -9
  325. package/lib/module/dom/nodes/drawings/Text.js.map +1 -1
  326. package/lib/module/dom/types/Common.js.map +1 -1
  327. package/lib/module/dom/types/Drawings.js.map +1 -1
  328. package/lib/module/mock/index.js +0 -1
  329. package/lib/module/mock/index.js.map +1 -1
  330. package/lib/module/renderer/Canvas.js +22 -58
  331. package/lib/module/renderer/Canvas.js.map +1 -1
  332. package/lib/module/renderer/DependencyManager.js +0 -5
  333. package/lib/module/renderer/DependencyManager.js.map +1 -1
  334. package/lib/module/renderer/HostComponents.js.map +1 -1
  335. package/lib/module/renderer/components/Mask.js +2 -4
  336. package/lib/module/renderer/components/Mask.js.map +1 -1
  337. package/lib/module/renderer/components/Paint.js +3 -14
  338. package/lib/module/renderer/components/Paint.js.map +1 -1
  339. package/lib/module/renderer/useCanvas.js +6 -4
  340. package/lib/module/renderer/useCanvas.js.map +1 -1
  341. package/lib/module/skia/core/Picture.js +0 -18
  342. package/lib/module/skia/core/Picture.js.map +1 -1
  343. package/lib/module/skia/core/Rect.js +1 -1
  344. package/lib/module/skia/core/Rect.js.map +1 -1
  345. package/lib/module/skia/types/ContourMeasure.js.map +1 -1
  346. package/lib/module/skia/types/Size.js +2 -0
  347. package/lib/module/skia/types/Size.js.map +1 -0
  348. package/lib/module/skia/types/index.js +1 -0
  349. package/lib/module/skia/types/index.js.map +1 -1
  350. package/lib/module/skia/web/JsiSkColor.js +8 -0
  351. package/lib/module/skia/web/JsiSkColor.js.map +1 -1
  352. package/lib/module/skia/web/JsiSkContourMeasure.js +3 -7
  353. package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
  354. package/lib/module/values/web/RNSkReadonlyValue.js +4 -2
  355. package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -1
  356. package/lib/module/views/SkiaBaseWebView.js +9 -2
  357. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  358. package/lib/module/views/SkiaDomView.js +128 -0
  359. package/lib/module/views/SkiaDomView.js.map +1 -0
  360. package/lib/module/views/SkiaDomView.web.js +41 -0
  361. package/lib/module/views/SkiaDomView.web.js.map +1 -0
  362. package/lib/module/views/SkiaPictureView.js +14 -2
  363. package/lib/module/views/SkiaPictureView.js.map +1 -1
  364. package/lib/module/views/SkiaView.js +15 -2
  365. package/lib/module/views/SkiaView.js.map +1 -1
  366. package/lib/module/views/index.js +1 -0
  367. package/lib/module/views/index.js.map +1 -1
  368. package/lib/module/views/types.js.map +1 -1
  369. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +57 -64
  370. package/lib/typescript/src/dom/nodes/RenderNode.d.ts +1 -3
  371. package/lib/typescript/src/dom/types/Common.d.ts +2 -3
  372. package/lib/typescript/src/dom/types/Drawings.d.ts +1 -3
  373. package/lib/typescript/src/renderer/Canvas.d.ts +5 -5
  374. package/lib/typescript/src/renderer/DependencyManager.d.ts +0 -2
  375. package/lib/typescript/src/renderer/HostComponents.d.ts +67 -8
  376. package/lib/typescript/src/renderer/components/Paint.d.ts +3 -4
  377. package/lib/typescript/src/renderer/useCanvas.d.ts +1 -6
  378. package/lib/typescript/src/skia/core/Picture.d.ts +0 -8
  379. package/lib/typescript/src/skia/types/ContourMeasure.d.ts +3 -2
  380. package/lib/typescript/src/skia/types/Size.d.ts +4 -0
  381. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  382. package/lib/typescript/src/skia/web/JsiSkContourMeasure.d.ts +2 -6
  383. package/lib/typescript/src/views/SkiaBaseWebView.d.ts +4 -0
  384. package/lib/typescript/src/views/SkiaDomView.d.ts +31 -0
  385. package/lib/typescript/src/views/SkiaDomView.web.d.ts +7 -0
  386. package/lib/typescript/src/views/index.d.ts +1 -0
  387. package/lib/typescript/src/views/types.d.ts +12 -2
  388. package/libs/android/arm64-v8a/libskia.a +0 -0
  389. package/libs/android/arm64-v8a/libskottie.a +0 -0
  390. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  391. package/libs/android/arm64-v8a/libsksg.a +0 -0
  392. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  393. package/libs/android/arm64-v8a/libskunicode.a +0 -0
  394. package/libs/android/arm64-v8a/libsvg.a +0 -0
  395. package/libs/android/armeabi-v7a/libskia.a +0 -0
  396. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  397. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  398. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  399. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  400. package/libs/android/armeabi-v7a/libskunicode.a +0 -0
  401. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  402. package/libs/android/x86/libskia.a +0 -0
  403. package/libs/android/x86/libskottie.a +0 -0
  404. package/libs/android/x86/libskparagraph.a +0 -0
  405. package/libs/android/x86/libsksg.a +0 -0
  406. package/libs/android/x86/libskshaper.a +0 -0
  407. package/libs/android/x86/libskunicode.a +0 -0
  408. package/libs/android/x86/libsvg.a +0 -0
  409. package/libs/android/x86_64/libskia.a +0 -0
  410. package/libs/android/x86_64/libskottie.a +0 -0
  411. package/libs/android/x86_64/libskparagraph.a +0 -0
  412. package/libs/android/x86_64/libsksg.a +0 -0
  413. package/libs/android/x86_64/libskshaper.a +0 -0
  414. package/libs/android/x86_64/libskunicode.a +0 -0
  415. package/libs/android/x86_64/libsvg.a +0 -0
  416. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  417. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  418. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  419. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  420. package/libs/ios/libskparagraph.xcframework/Info.plist +42 -0
  421. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  422. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  423. package/libs/ios/libsksg.xcframework/Info.plist +5 -5
  424. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  425. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  426. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  427. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  428. package/libs/ios/libskunicode.xcframework/Info.plist +42 -0
  429. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
  430. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
  431. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  432. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  433. package/package.json +6 -4
  434. package/react-native-skia.podspec +3 -1
  435. package/src/dom/nodes/DrawingNode.ts +2 -4
  436. package/src/dom/nodes/JsiSkDOM.ts +170 -56
  437. package/src/dom/nodes/RenderNode.ts +2 -14
  438. package/src/dom/nodes/drawings/Text.ts +4 -4
  439. package/src/dom/types/Common.ts +2 -4
  440. package/src/dom/types/Drawings.ts +1 -4
  441. package/src/mock/index.ts +0 -1
  442. package/src/renderer/Canvas.tsx +32 -51
  443. package/src/renderer/DependencyManager.tsx +0 -5
  444. package/src/renderer/HostComponents.ts +153 -5
  445. package/src/renderer/components/Mask.tsx +2 -2
  446. package/src/renderer/components/Paint.tsx +3 -14
  447. package/src/renderer/useCanvas.ts +5 -5
  448. package/src/skia/core/Picture.ts +0 -24
  449. package/src/skia/core/Rect.ts +1 -1
  450. package/src/skia/types/ContourMeasure.tsx +3 -2
  451. package/src/skia/types/Size.ts +4 -0
  452. package/src/skia/types/index.ts +1 -0
  453. package/src/skia/web/JsiSkColor.ts +11 -0
  454. package/src/skia/web/JsiSkContourMeasure.ts +7 -3
  455. package/src/values/web/RNSkReadonlyValue.ts +4 -2
  456. package/src/views/SkiaBaseWebView.tsx +6 -2
  457. package/src/views/SkiaDomView.tsx +120 -0
  458. package/src/views/SkiaDomView.web.tsx +37 -0
  459. package/src/views/SkiaPictureView.tsx +10 -2
  460. package/src/views/SkiaView.tsx +11 -3
  461. package/src/views/index.ts +1 -0
  462. package/src/views/types.ts +19 -2
  463. package/cpp/jsi/JsiSimpleValueWrapper.h +0 -99
  464. package/cpp/skia/include/c/sk_canvas.h +0 -159
  465. package/cpp/skia/include/c/sk_colorspace.h +0 -25
  466. package/cpp/skia/include/c/sk_data.h +0 -65
  467. package/cpp/skia/include/c/sk_image.h +0 -71
  468. package/cpp/skia/include/c/sk_imageinfo.h +0 -62
  469. package/cpp/skia/include/c/sk_maskfilter.h +0 -47
  470. package/cpp/skia/include/c/sk_matrix.h +0 -49
  471. package/cpp/skia/include/c/sk_paint.h +0 -145
  472. package/cpp/skia/include/c/sk_path.h +0 -102
  473. package/cpp/skia/include/c/sk_picture.h +0 -70
  474. package/cpp/skia/include/c/sk_shader.h +0 -143
  475. package/cpp/skia/include/c/sk_surface.h +0 -73
  476. package/cpp/skia/include/c/sk_types.h +0 -278
  477. package/cpp/skia/include/gpu/graphite/SkStuff.h +0 -47
  478. package/cpp/skia/include/private/SkNx.h +0 -430
  479. package/cpp/skia/include/private/SkNx_neon.h +0 -713
  480. package/cpp/skia/include/private/SkNx_sse.h +0 -823
  481. package/cpp/skia/include/sksl/DSLRuntimeEffects.h +0 -32
  482. package/cpp/skia/include/sksl/DSLWrapper.h +0 -77
@@ -19,6 +19,7 @@ enum class SkFilterMode {
19
19
 
20
20
  kLast = kLinear,
21
21
  };
22
+ static constexpr int kSkFilterModeCount = static_cast<int>(SkFilterMode::kLast) + 1;
22
23
 
23
24
  enum class SkMipmapMode {
24
25
  kNone, // ignore mipmap levels, sample from the "base"
@@ -27,6 +28,7 @@ enum class SkMipmapMode {
27
28
 
28
29
  kLast = kLinear,
29
30
  };
31
+ static constexpr int kSkMipmapModeCount = static_cast<int>(SkMipmapMode::kLast) + 1;
30
32
 
31
33
  /*
32
34
  * Specify B and C (each between 0...1) to create a shader that applies the corresponding
@@ -60,7 +62,7 @@ struct SK_API SkSamplingOptions {
60
62
  const SkFilterMode filter = SkFilterMode::kNearest;
61
63
  const SkMipmapMode mipmap = SkMipmapMode::kNone;
62
64
 
63
- SkSamplingOptions() = default;
65
+ constexpr SkSamplingOptions() = default;
64
66
  SkSamplingOptions(const SkSamplingOptions&) = default;
65
67
  SkSamplingOptions& operator=(const SkSamplingOptions& that) {
66
68
  this->~SkSamplingOptions(); // A pedantic no-op.
@@ -68,19 +70,19 @@ struct SK_API SkSamplingOptions {
68
70
  return *this;
69
71
  }
70
72
 
71
- SkSamplingOptions(SkFilterMode fm, SkMipmapMode mm)
73
+ constexpr SkSamplingOptions(SkFilterMode fm, SkMipmapMode mm)
72
74
  : filter(fm)
73
75
  , mipmap(mm) {}
74
76
 
75
- explicit SkSamplingOptions(SkFilterMode fm)
77
+ explicit constexpr SkSamplingOptions(SkFilterMode fm)
76
78
  : filter(fm)
77
79
  , mipmap(SkMipmapMode::kNone) {}
78
80
 
79
- explicit SkSamplingOptions(const SkCubicResampler& c)
81
+ explicit constexpr SkSamplingOptions(const SkCubicResampler& c)
80
82
  : useCubic(true)
81
83
  , cubic(c) {}
82
84
 
83
- static SkSamplingOptions Aniso(int maxAniso) {
85
+ static constexpr SkSamplingOptions Aniso(int maxAniso) {
84
86
  return SkSamplingOptions{std::max(maxAniso, 1)};
85
87
  }
86
88
 
@@ -97,7 +99,7 @@ struct SK_API SkSamplingOptions {
97
99
  bool isAniso() const { return maxAniso != 0; }
98
100
 
99
101
  private:
100
- SkSamplingOptions(int maxAniso) : maxAniso(maxAniso) {}
102
+ constexpr SkSamplingOptions(int maxAniso) : maxAniso(maxAniso) {}
101
103
  };
102
104
 
103
105
  #endif
@@ -22,13 +22,14 @@ typedef float SkScalar;
22
22
  #define SK_ScalarTanPIOver8 0.414213562f
23
23
  #define SK_ScalarRoot2Over2 0.707106781f
24
24
  #define SK_ScalarMax 3.402823466e+38f
25
+ #define SK_ScalarMin (-SK_ScalarMax)
25
26
  #define SK_ScalarInfinity SK_FloatInfinity
26
27
  #define SK_ScalarNegativeInfinity SK_FloatNegativeInfinity
27
28
  #define SK_ScalarNaN SK_FloatNaN
28
29
 
29
30
  #define SkScalarFloorToScalar(x) sk_float_floor(x)
30
31
  #define SkScalarCeilToScalar(x) sk_float_ceil(x)
31
- #define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f)
32
+ #define SkScalarRoundToScalar(x) sk_float_round(x)
32
33
  #define SkScalarTruncToScalar(x) sk_float_trunc(x)
33
34
 
34
35
  #define SkScalarFloorToInt(x) sk_float_floor2int(x)
@@ -62,8 +63,6 @@ typedef float SkScalar;
62
63
  #define SkScalarToDouble(x) static_cast<double>(x)
63
64
  #define SkDoubleToScalar(x) sk_double_to_float(x)
64
65
 
65
- #define SK_ScalarMin (-SK_ScalarMax)
66
-
67
66
  static inline bool SkScalarIsNaN(SkScalar x) { return x != x; }
68
67
 
69
68
  /** Returns true if x is not NaN and not infinite
@@ -78,26 +77,6 @@ static inline bool SkScalarsAreFinite(const SkScalar array[], int count) {
78
77
  return sk_floats_are_finite(array, count);
79
78
  }
80
79
 
81
- /**
82
- * Variant of SkScalarRoundToInt, that performs the rounding step (adding 0.5) explicitly using
83
- * double, to avoid possibly losing the low bit(s) of the answer before calling floor().
84
- *
85
- * This routine will likely be slower than SkScalarRoundToInt(), and should only be used when the
86
- * extra precision is known to be valuable.
87
- *
88
- * In particular, this catches the following case:
89
- * SkScalar x = 0.49999997;
90
- * int ix = SkScalarRoundToInt(x);
91
- * SkASSERT(0 == ix); // <--- fails
92
- * ix = SkDScalarRoundToInt(x);
93
- * SkASSERT(0 == ix); // <--- succeeds
94
- */
95
- static inline int SkDScalarRoundToInt(SkScalar x) {
96
- double xx = x;
97
- xx += 0.5;
98
- return (int)floor(xx);
99
- }
100
-
101
80
  /** Returns the fractional part of the scalar. */
102
81
  static inline SkScalar SkScalarFraction(SkScalar x) {
103
82
  return x - SkScalarTruncToScalar(x);
@@ -145,14 +124,16 @@ static inline bool SkScalarNearlyEqual(SkScalar x, SkScalar y,
145
124
  return SkScalarAbs(x-y) <= tolerance;
146
125
  }
147
126
 
127
+ #define SK_ScalarSinCosNearlyZero (SK_Scalar1 / (1 << 16))
128
+
148
129
  static inline float SkScalarSinSnapToZero(SkScalar radians) {
149
130
  float v = SkScalarSin(radians);
150
- return SkScalarNearlyZero(v) ? 0.0f : v;
131
+ return SkScalarNearlyZero(v, SK_ScalarSinCosNearlyZero) ? 0.0f : v;
151
132
  }
152
133
 
153
134
  static inline float SkScalarCosSnapToZero(SkScalar radians) {
154
135
  float v = SkScalarCos(radians);
155
- return SkScalarNearlyZero(v) ? 0.0f : v;
136
+ return SkScalarNearlyZero(v, SK_ScalarSinCosNearlyZero) ? 0.0f : v;
156
137
  }
157
138
 
158
139
  /** Linearly interpolate between A and B, based on t.
@@ -56,6 +56,12 @@ public:
56
56
  return this->isAImage(nullptr, (SkTileMode*)nullptr) != nullptr;
57
57
  }
58
58
 
59
+ // TODO(skbug.com/8941): Have Android use SkAndroidFrameworkUtils, move types to SkShaderBase,
60
+ // and delete asAGradient().
61
+ #ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
62
+ private:
63
+ #endif
64
+
59
65
  /**
60
66
  * If the shader subclass can be represented as a gradient, asAGradient
61
67
  * returns the matching GradientType enum (or kNone_GradientType if it
@@ -92,24 +98,26 @@ public:
92
98
  kRadial_GradientType,
93
99
  kSweep_GradientType,
94
100
  kConical_GradientType,
95
- kLast_GradientType = kConical_GradientType,
96
101
  };
97
102
 
98
103
  struct GradientInfo {
99
- int fColorCount; //!< In-out parameter, specifies passed size
100
- // of fColors/fColorOffsets on input, and
101
- // actual number of colors/offsets on
102
- // output.
103
- SkColor* fColors; //!< The colors in the gradient.
104
- SkScalar* fColorOffsets; //!< The unit offset for color transitions.
105
- SkPoint fPoint[2]; //!< Type specific, see above.
106
- SkScalar fRadius[2]; //!< Type specific, see above.
104
+ int fColorCount = 0; //!< In-out parameter, specifies passed size
105
+ // of fColors/fColorOffsets on input, and
106
+ // actual number of colors/offsets on
107
+ // output.
108
+ SkColor* fColors = nullptr; //!< The colors in the gradient.
109
+ SkScalar* fColorOffsets = nullptr; //!< The unit offset for color transitions.
110
+ SkPoint fPoint[2]; //!< Type specific, see above.
111
+ SkScalar fRadius[2]; //!< Type specific, see above.
107
112
  SkTileMode fTileMode;
108
- uint32_t fGradientFlags; //!< see SkGradientShader::Flags
113
+ uint32_t fGradientFlags = 0; //!< see SkGradientShader::Flags
109
114
  };
110
115
 
111
- // DEPRECATED. skbug.com/8941
112
- virtual GradientType asAGradient(GradientInfo* info) const;
116
+ GradientType asAGradient(GradientInfo* info) const;
117
+
118
+ #ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
119
+ public:
120
+ #endif
113
121
 
114
122
  //////////////////////////////////////////////////////////////////////////
115
123
  // Methods to create combinations or variants of shaders
@@ -9,29 +9,67 @@
9
9
  #define SkSpan_DEFINED
10
10
 
11
11
  #include <cstddef>
12
+ #include <initializer_list>
12
13
  #include <iterator>
13
14
  #include <type_traits>
14
15
  #include <utility>
15
16
  #include "include/private/SkTLogic.h"
16
17
 
18
+ // Add macro to check the lifetime of initializer_list arguments. initializer_list has a very
19
+ // short life span, and can only be used as a parameter, and not as a variable.
20
+ #if defined(__clang__) && defined(__has_cpp_attribute) && __has_cpp_attribute(clang::lifetimebound)
21
+ #define SK_CHECK_IL_LIFETIME [[clang::lifetimebound]]
22
+ #else
23
+ #define SK_CHECK_IL_LIFETIME
24
+ #endif
25
+
17
26
  /**
18
- * An SkSpan is a view of a contiguous collection of elements of type T. It can be directly
19
- * constructed from a pointer and size. SkMakeSpan can be used to construct one from an array,
20
- * or a container (like std::vector).
27
+ * SkSpan holds a reference to contiguous data of type T along with a count. SkSpan does not own
28
+ * the data itself but is merely a reference, therefore you must take care with the lifetime of
29
+ * the underlying data.
30
+ *
31
+ * SkSpan is a count and a pointer into existing array or data type that stores its data in
32
+ * contiguous memory like std::vector. Any container that works with std::size() and std::data()
33
+ * can be used.
34
+ *
35
+ * SkSpan makes a convenient parameter for a routine to accept array like things. This allows you to
36
+ * write the routine without overloads for all different container types.
37
+ *
38
+ * Example:
39
+ * void routine(SkSpan<const int> a) { ... }
40
+ *
41
+ * std::vector v = {1, 2, 3, 4, 5};
42
+ *
43
+ * routine(a);
44
+ *
45
+ * A word of caution when working with initializer_list, initializer_lists have a lifetime that is
46
+ * limited to the current statement. The following is correct and safe:
21
47
  *
22
- * With C++17, we could add template deduction guides that eliminate the need for SkMakeSpan:
23
- * https://skia-review.googlesource.com/c/skia/+/320264
48
+ * Example:
49
+ * routine({1,2,3,4,5});
50
+ *
51
+ * The following is undefined, and will result in erratic execution:
52
+ *
53
+ * Bad Example:
54
+ * initializer_list l = {1, 2, 3, 4, 5}; // The data behind l dies at the ;.
55
+ * routine(l);
24
56
  */
25
57
  template <typename T>
26
58
  class SkSpan {
27
59
  public:
28
60
  constexpr SkSpan() : fPtr{nullptr}, fSize{0} {}
29
61
  constexpr SkSpan(T* ptr, size_t size) : fPtr{ptr}, fSize{size} {
62
+ SkASSERT(ptr || size == 0); // disallow nullptr + a nonzero size
30
63
  SkASSERT(size < kMaxSize);
31
64
  }
32
65
  template <typename U, typename = typename std::enable_if<std::is_same<const U, T>::value>::type>
33
- constexpr SkSpan(const SkSpan<U>& that) : fPtr(that.data()), fSize{that.size()} {}
66
+ constexpr SkSpan(const SkSpan<U>& that) : fPtr(std::data(that)), fSize{std::size(that)} {}
34
67
  constexpr SkSpan(const SkSpan& o) = default;
68
+ template<size_t N> constexpr SkSpan(T(&a)[N]) : SkSpan(a, N) { }
69
+ template<typename Container>
70
+ constexpr SkSpan(Container& c) : SkSpan{std::data(c), std::size(c)} { }
71
+ SkSpan(std::initializer_list<T> il SK_CHECK_IL_LIFETIME)
72
+ : SkSpan(std::data(il), std::size(il)) {}
35
73
 
36
74
  constexpr SkSpan& operator=(const SkSpan& that) = default;
37
75
 
@@ -67,23 +105,17 @@ public:
67
105
  }
68
106
 
69
107
  private:
70
- static constexpr size_t kMaxSize = std::numeric_limits<size_t>::max() / sizeof(T);
108
+ static const constexpr size_t kMaxSize = std::numeric_limits<size_t>::max() / sizeof(T);
71
109
  T* fPtr;
72
110
  size_t fSize;
73
111
  };
74
112
 
75
- template <typename T, typename S> inline constexpr SkSpan<T> SkMakeSpan(T* p, S s) {
76
- return SkSpan<T>{p, SkTo<size_t>(s)};
77
- }
78
-
79
- template <size_t N, typename T> inline constexpr SkSpan<T> SkMakeSpan(T (&a)[N]) {
80
- return SkSpan<T>{a, N};
81
- }
82
-
83
113
  template <typename Container>
84
- inline auto SkMakeSpan(Container& c)
85
- -> SkSpan<typename std::remove_reference<decltype(*(c.data()))>::type> {
86
- return {c.data(), c.size()};
87
- }
114
+ SkSpan(Container&) ->
115
+ SkSpan<std::remove_pointer_t<decltype(std::data(std::declval<Container&>()))>>;
116
+
117
+ template <typename T>
118
+ SkSpan(std::initializer_list<T>) ->
119
+ SkSpan<std::remove_pointer_t<decltype(std::data(std::declval<std::initializer_list<T>>()))>>;
88
120
 
89
121
  #endif // SkSpan_DEFINED
@@ -122,7 +122,7 @@ public:
122
122
  }
123
123
 
124
124
  //SkStreamSeekable
125
- /** Returns true if this stream can report it's current position. */
125
+ /** Returns true if this stream can report its current position. */
126
126
  virtual bool hasPosition() const { return false; }
127
127
  /** Returns the current position in the stream. If this cannot be done, returns 0. */
128
128
  virtual size_t getPosition() const { return 0; }
@@ -140,7 +140,7 @@ public:
140
140
  virtual bool move(long /*offset*/) { return false; }
141
141
 
142
142
  //SkStreamAsset
143
- /** Returns true if this stream can report it's total length. */
143
+ /** Returns true if this stream can report its total length. */
144
144
  virtual bool hasLength() const { return false; }
145
145
  /** Returns the total length of the stream. If this cannot be done, returns 0. */
146
146
  virtual size_t getLength() const { return 0; }
@@ -184,10 +184,12 @@ public:
184
184
  void set(const SkString& src) { *this = src; }
185
185
  void set(const char text[]);
186
186
  void set(const char text[], size_t len);
187
+ void set(std::string_view str) { this->set(str.data(), str.size()); }
187
188
 
188
- void insert(size_t offset, const SkString& src) { this->insert(offset, src.c_str(), src.size()); }
189
189
  void insert(size_t offset, const char text[]);
190
190
  void insert(size_t offset, const char text[], size_t len);
191
+ void insert(size_t offset, const SkString& str) { this->insert(offset, str.c_str(), str.size()); }
192
+ void insert(size_t offset, std::string_view str) { this->insert(offset, str.data(), str.size()); }
191
193
  void insertUnichar(size_t offset, SkUnichar);
192
194
  void insertS32(size_t offset, int32_t value);
193
195
  void insertS64(size_t offset, int64_t value, int minDigits = 0);
@@ -196,9 +198,10 @@ public:
196
198
  void insertHex(size_t offset, uint32_t value, int minDigits = 0);
197
199
  void insertScalar(size_t offset, SkScalar);
198
200
 
199
- void append(const SkString& str) { this->insert((size_t)-1, str); }
200
201
  void append(const char text[]) { this->insert((size_t)-1, text); }
201
202
  void append(const char text[], size_t len) { this->insert((size_t)-1, text, len); }
203
+ void append(const SkString& str) { this->insert((size_t)-1, str.c_str(), str.size()); }
204
+ void append(std::string_view str) { this->insert((size_t)-1, str.data(), str.size()); }
202
205
  void appendUnichar(SkUnichar uni) { this->insertUnichar((size_t)-1, uni); }
203
206
  void appendS32(int32_t value) { this->insertS32((size_t)-1, value); }
204
207
  void appendS64(int64_t value, int minDigits = 0) { this->insertS64((size_t)-1, value, minDigits); }
@@ -207,9 +210,10 @@ public:
207
210
  void appendHex(uint32_t value, int minDigits = 0) { this->insertHex((size_t)-1, value, minDigits); }
208
211
  void appendScalar(SkScalar value) { this->insertScalar((size_t)-1, value); }
209
212
 
210
- void prepend(const SkString& str) { this->insert(0, str); }
211
213
  void prepend(const char text[]) { this->insert(0, text); }
212
214
  void prepend(const char text[], size_t len) { this->insert(0, text, len); }
215
+ void prepend(const SkString& str) { this->insert(0, str.c_str(), str.size()); }
216
+ void prepend(std::string_view str) { this->insert(0, str.data(), str.size()); }
213
217
  void prependUnichar(SkUnichar uni) { this->insertUnichar(0, uni); }
214
218
  void prependS32(int32_t value) { this->insertS32(0, value); }
215
219
  void prependS64(int32_t value, int minDigits = 0) { this->insertS64(0, value, minDigits); }
@@ -235,6 +239,8 @@ public:
235
239
  */
236
240
  void swap(SkString& other);
237
241
 
242
+ using sk_is_trivially_relocatable = std::true_type;
243
+
238
244
  private:
239
245
  struct Rec {
240
246
  public:
@@ -259,6 +265,8 @@ private:
259
265
  };
260
266
  sk_sp<Rec> fRec;
261
267
 
268
+ static_assert(::sk_is_trivially_relocatable<decltype(fRec)>::value);
269
+
262
270
  #ifdef SK_DEBUG
263
271
  const SkString& validate() const;
264
272
  #else
@@ -21,24 +21,31 @@
21
21
  #include <android/hardware_buffer.h>
22
22
  #endif
23
23
 
24
- #ifdef SK_METAL
24
+ #if SK_SUPPORT_GPU && defined(SK_METAL)
25
25
  #include "include/gpu/mtl/GrMtlTypes.h"
26
26
  #endif
27
27
 
28
28
  class SkCanvas;
29
+ class SkCapabilities;
29
30
  class SkDeferredDisplayList;
30
31
  class SkPaint;
31
32
  class SkSurfaceCharacterization;
32
33
  class GrBackendRenderTarget;
33
34
  class GrBackendSemaphore;
34
- class GrBackendSurfaceMutableState;
35
35
  class GrBackendTexture;
36
36
  class GrDirectContext;
37
37
  class GrRecordingContext;
38
38
  class GrRenderTarget;
39
39
  enum GrSurfaceOrigin: int;
40
40
 
41
- namespace skgpu::graphite { class Recorder; }
41
+ namespace skgpu {
42
+ class MutableTextureState;
43
+ }
44
+
45
+ namespace skgpu::graphite {
46
+ class BackendTexture;
47
+ class Recorder;
48
+ }
42
49
 
43
50
  /** \class SkSurface
44
51
  SkSurface is responsible for managing the pixels that a canvas draws into. The pixels can be
@@ -391,7 +398,41 @@ public:
391
398
  );
392
399
  #endif
393
400
 
394
- #ifdef SK_METAL
401
+ #ifdef SK_GRAPHITE_ENABLED
402
+ /**
403
+ * In Graphite, while clients hold a ref on an SkSurface, the backing gpu object does _not_
404
+ * count against the budget. Once an SkSurface is freed, the backing gpu object may or may
405
+ * not become a scratch (i.e., reusable) resource but, if it does, it will be counted against
406
+ * the budget.
407
+ */
408
+ static sk_sp<SkSurface> MakeGraphite(
409
+ skgpu::graphite::Recorder*,
410
+ const SkImageInfo& imageInfo,
411
+ skgpu::graphite::Mipmapped = skgpu::graphite::Mipmapped::kNo,
412
+ const SkSurfaceProps* surfaceProps = nullptr);
413
+
414
+ /**
415
+ * Wraps a GPU-backed texture in an SkSurface. Depending on the backend gpu API, the caller may
416
+ * be required to ensure the texture is valid for the lifetime of the returned SkSurface. The
417
+ * required lifetimes for the specific apis are:
418
+ * Metal: Skia will call retain on the underlying MTLTexture so the caller can drop it once
419
+ * this call returns.
420
+ *
421
+ * SkSurface is returned if all the parameters are valid. The backendTexture is valid if its
422
+ * format agrees with colorSpace and recorder; for instance, if backendTexture has an sRGB
423
+ * configuration, then the recorder must support sRGB, and colorSpace must be present. Further,
424
+ * backendTexture's width and height must not exceed the recorder's capabilities, and the
425
+ * recorder must be able to support the back-end texture.
426
+ */
427
+ static sk_sp<SkSurface> MakeGraphiteFromBackendTexture(skgpu::graphite::Recorder*,
428
+ const skgpu::graphite::BackendTexture&,
429
+ SkColorType colorType,
430
+ sk_sp<SkColorSpace> colorSpace,
431
+ const SkSurfaceProps* props);
432
+
433
+ #endif // SK_GRAPHITE_ENABLED
434
+
435
+ #if SK_SUPPORT_GPU && defined(SK_METAL)
395
436
  /** Creates SkSurface from CAMetalLayer.
396
437
  Returned SkSurface takes a reference on the CAMetalLayer. The ref on the layer will be
397
438
  released when the SkSurface is destroyed.
@@ -600,6 +641,12 @@ public:
600
641
  */
601
642
  SkCanvas* getCanvas();
602
643
 
644
+ /** Returns SkCapabilities that describes the capabilities of the SkSurface's device.
645
+
646
+ @return SkCapabilities of SkSurface's device.
647
+ */
648
+ sk_sp<const SkCapabilities> capabilities();
649
+
603
650
  /** Returns a compatible SkSurface, or nullptr. Returned SkSurface contains
604
651
  the same raster, GPU, or null properties as the original. Returned SkSurface
605
652
  does not share the same pixels.
@@ -787,6 +834,36 @@ public:
787
834
  using RescaleGamma = SkImage::RescaleGamma;
788
835
  using RescaleMode = SkImage::RescaleMode;
789
836
 
837
+ /** Makes surface pixel data available to caller, possibly asynchronously.
838
+
839
+ Currently asynchronous reads are only supported on the GPU backend and only when the
840
+ underlying 3D API supports transfer buffers and CPU/GPU synchronization primitives. In all
841
+ other cases this operates synchronously.
842
+
843
+ Data is read from the source sub-rectangle, then converted to the color space, color type,
844
+ and alpha type of 'info'. A 'srcRect' that is not contained by the bounds of the surface
845
+ causes failure.
846
+
847
+ When the pixel data is ready the caller's ReadPixelsCallback is called with a
848
+ AsyncReadResult containing pixel data in the requested color type, alpha type, and color
849
+ space. The AsyncReadResult will have count() == 1. Upon failure the callback is called
850
+ with nullptr for AsyncReadResult. For a GPU surface this flushes work but a submit must
851
+ occur to guarantee a finite time before the callback is called.
852
+
853
+ The data is valid for the lifetime of AsyncReadResult with the exception that if the
854
+ SkSurface is GPU-backed the data is immediately invalidated if the context is abandoned
855
+ or destroyed.
856
+
857
+ @param info info of the requested pixels
858
+ @param srcRect subrectangle of surface to read
859
+ @param callback function to call with result of the read
860
+ @param context passed to callback
861
+ */
862
+ void asyncReadPixels(const SkImageInfo& info,
863
+ const SkIRect& srcRect,
864
+ ReadPixelsCallback callback,
865
+ ReadPixelsContext context);
866
+
790
867
  /** Makes surface pixel data available to caller, possibly asynchronously. It can also rescale
791
868
  the surface pixels.
792
869
 
@@ -990,15 +1067,15 @@ public:
990
1067
  The GrFlushInfo describes additional options to flush. Please see documentation at
991
1068
  GrFlushInfo for more info.
992
1069
 
993
- If a GrBackendSurfaceMutableState is passed in, at the end of the flush we will transition
994
- the surface to be in the state requested by the GrBackendSurfaceMutableState. If the surface
1070
+ If a skgpu::MutableTextureState is passed in, at the end of the flush we will transition
1071
+ the surface to be in the state requested by the skgpu::MutableTextureState. If the surface
995
1072
  (or SkImage or GrBackendSurface wrapping the same backend object) is used again after this
996
1073
  flush the state may be changed and no longer match what is requested here. This is often
997
1074
  used if the surface will be used for presenting or external use and the client wants backend
998
1075
  object to be prepped for that use. A finishedProc or semaphore on the GrFlushInfo will also
999
1076
  include the work for any requested state change.
1000
1077
 
1001
- If the backend API is Vulkan, the caller can set the GrBackendSurfaceMutableState's
1078
+ If the backend API is Vulkan, the caller can set the skgpu::MutableTextureState's
1002
1079
  VkImageLayout to VK_IMAGE_LAYOUT_UNDEFINED or queueFamilyIndex to VK_QUEUE_FAMILY_IGNORED to
1003
1080
  tell Skia to not change those respective states.
1004
1081
 
@@ -1022,7 +1099,7 @@ public:
1022
1099
  @param access optional state change request after flush
1023
1100
  */
1024
1101
  GrSemaphoresSubmitted flush(const GrFlushInfo& info,
1025
- const GrBackendSurfaceMutableState* newState = nullptr);
1102
+ const skgpu::MutableTextureState* newState = nullptr);
1026
1103
  #endif // SK_SUPPORT_GPU
1027
1104
 
1028
1105
  void flush();
@@ -20,6 +20,10 @@ struct SkRSXform;
20
20
  struct SkSerialProcs;
21
21
  struct SkDeserialProcs;
22
22
 
23
+ namespace sktext {
24
+ class GlyphRunList;
25
+ }
26
+
23
27
  /** \class SkTextBlob
24
28
  SkTextBlob combines multiple text runs into an immutable container. Each text
25
29
  run consists of glyphs, SkPaint, and position. Only parts of SkPaint related to
@@ -250,8 +254,7 @@ private:
250
254
  fCacheID.store(cacheID);
251
255
  }
252
256
 
253
- friend class SkGlyphRunList;
254
- friend class GrTextBlobCache;
257
+ friend class sktext::GlyphRunList;
255
258
  friend class SkTextBlobBuilder;
256
259
  friend class SkTextBlobPriv;
257
260
  friend class SkTextBlobRunIterator;
@@ -193,9 +193,9 @@
193
193
  #else
194
194
  #include "include/config/SkUserConfig.h"
195
195
  #endif
196
+ // IWYU pragma: end_exports
196
197
  #include <stddef.h>
197
198
  #include <stdint.h>
198
- // IWYU pragma: end_exports
199
199
 
200
200
  // Post SkUserConfig.h checks and such.
201
201
  #if !defined(SK_DEBUG) && !defined(SK_RELEASE)
@@ -236,7 +236,7 @@
236
236
  # define SK_SUPPORT_GPU 1
237
237
  #endif
238
238
 
239
- #if SK_SUPPORT_GPU || SK_GRAPHITE_ENABLED
239
+ #if SK_SUPPORT_GPU || defined(SK_GRAPHITE_ENABLED)
240
240
  # if !defined(SK_ENABLE_SKSL)
241
241
  # define SK_ENABLE_SKSL
242
242
  # endif
@@ -340,14 +340,6 @@
340
340
  # endif
341
341
  #endif
342
342
 
343
- #if !defined(SK_MAYBE_UNUSED)
344
- # if defined(__clang__) || defined(__GNUC__)
345
- # define SK_MAYBE_UNUSED [[maybe_unused]]
346
- # else
347
- # define SK_MAYBE_UNUSED
348
- # endif
349
- #endif
350
-
351
343
  /**
352
344
  * If your judgment is better than the compiler's (i.e. you've profiled it),
353
345
  * you can use SK_ALWAYS_INLINE to force inlining. E.g.
@@ -529,6 +521,15 @@ static inline constexpr int64_t SkLeftShift(int64_t value, int32_t shift) {
529
521
 
530
522
  /** @return the number of entries in an array (not a pointer)
531
523
  */
524
+ // The SkArrayCountHelper template returns a type 'char (&)[N]', a reference to an array of
525
+ // char with N elements, where N is deduced using function parameter type deduction. This is then
526
+ // used in the sizeof operator in SK_ARRAY_COUNT. The sizeof operator ignores the reference, and
527
+ // just evaluates the size of the array type.
528
+ //
529
+ // DEPRECATED: use std::size() instead.
530
+ // Note: Rarely, std::size(z) can't deduce the type of z during compile time for static_assert
531
+ // while SK_ARRAY_COUNT can. It can't be deduced because z is part of class, and the class' this
532
+ // pointer is not a valid constexpr expression. Use SkASSERT instead.
532
533
  template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N];
533
534
  #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array)))
534
535
 
@@ -35,14 +35,9 @@ public:
35
35
  void appendInt(const char* owner, const char* name, int value);
36
36
  void appendFloat(const char* owner, const char* name, float value);
37
37
  void appendName(const char* owner, const char* attrName, const char* value);
38
- void appendString(const char* owner, const char* attrName, const char* value);
39
38
  void appendFloatArray(const char* owner,
40
39
  const char* name,
41
40
  const std::vector<float>& value);
42
- // Deprecated.
43
- void appendStringArray(const char* owner,
44
- const char* attrName,
45
- const std::vector<SkString>& values);
46
41
  void appendNodeIdArray(const char* owner,
47
42
  const char* attrName,
48
43
  const std::vector<int>& nodeIds);
@@ -8,7 +8,12 @@
8
8
  #ifndef Sk1DPathEffect_DEFINED
9
9
  #define Sk1DPathEffect_DEFINED
10
10
 
11
- #include "include/core/SkPathEffect.h"
11
+ #include "include/core/SkRefCnt.h"
12
+ #include "include/core/SkScalar.h"
13
+ #include "include/core/SkTypes.h"
14
+
15
+ class SkPath;
16
+ class SkPathEffect;
12
17
 
13
18
  class SK_API SkPath1DPathEffect {
14
19
  public:
@@ -8,10 +8,13 @@
8
8
  #ifndef Sk2DPathEffect_DEFINED
9
9
  #define Sk2DPathEffect_DEFINED
10
10
 
11
- #include "include/core/SkPathEffect.h"
11
+ #include "include/core/SkRefCnt.h"
12
+ #include "include/core/SkScalar.h"
13
+ #include "include/core/SkTypes.h"
12
14
 
13
15
  class SkMatrix;
14
16
  class SkPath;
17
+ class SkPathEffect;
15
18
 
16
19
  class SK_API SkLine2DPathEffect {
17
20
  public:
@@ -9,6 +9,7 @@
9
9
  #define SkColorMatrix_DEFINED
10
10
 
11
11
  #include "include/core/SkImageInfo.h"
12
+ #include "include/core/SkTypes.h"
12
13
 
13
14
  #include <algorithm>
14
15
  #include <array>
@@ -9,17 +9,14 @@
9
9
  #define SkColorMatrixFilter_DEFINED
10
10
 
11
11
  #include "include/core/SkColorFilter.h"
12
- #include "include/effects/SkColorMatrix.h"
13
12
 
13
+ // (DEPRECATED) This factory function is deprecated. Please use the one in
14
+ // SkColorFilters (i.e., Lighting).
14
15
  class SK_API SkColorMatrixFilter : public SkColorFilter {
15
16
  public:
16
- /**
17
- * Create a colorfilter that multiplies the RGB channels by one color, and
18
- * then adds a second color, pinning the result for each component to
19
- * [0..255]. The alpha components of the mul and add arguments
20
- * are ignored.
21
- */
22
- static sk_sp<SkColorFilter> MakeLightingFilter(SkColor mul, SkColor add);
17
+ static sk_sp<SkColorFilter> MakeLightingFilter(SkColor mul, SkColor add) {
18
+ return SkColorFilters::Lighting(mul, add);
19
+ }
23
20
  };
24
21
 
25
22
  #endif