@shopify/react-native-skia 0.1.158 → 0.1.160

Sign up to get free protection for your applications and to get access to all the features.
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 +222 -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 +293 -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 +384 -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 +79 -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 +62 -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 +171 -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 +41 -55
  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 +24 -66
  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 +15 -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 +25 -66
  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 +15 -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 +5 -2
  371. package/src/dom/nodes/JsiSkDOM.ts +170 -56
  372. package/src/dom/nodes/RenderNode.ts +1 -1
  373. package/src/renderer/Canvas.tsx +37 -57
  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 +9 -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
@@ -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