@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
@@ -12,6 +12,7 @@
12
12
  #include "include/core/SkColor.h"
13
13
  #include "include/core/SkImage.h"
14
14
  #include "include/core/SkImageInfo.h"
15
+ #include "include/core/SkSurfaceProps.h"
15
16
  #include "include/core/SkYUVAPixmaps.h"
16
17
 
17
18
  #include <optional>
@@ -27,6 +28,13 @@ class SkPicture;
27
28
 
28
29
  enum class GrImageTexGenPolicy : int;
29
30
 
31
+ #if SK_GRAPHITE_ENABLED
32
+ namespace skgpu::graphite {
33
+ enum class Mipmapped : bool;
34
+ class Recorder;
35
+ }
36
+ #endif
37
+
30
38
  class SK_API SkImageGenerator {
31
39
  public:
32
40
  /**
@@ -118,25 +126,13 @@ public:
118
126
  * If the generator can natively/efficiently return its pixels as a GPU image (backed by a
119
127
  * texture) this will return that image. If not, this will return NULL.
120
128
  *
121
- * This routine also supports retrieving only a subset of the pixels. That subset is specified
122
- * by the following rectangle:
123
- *
124
- * subset = SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height())
125
- *
126
- * If subset is not contained inside the generator's bounds, this returns false.
127
- *
128
- * whole = SkIRect::MakeWH(getInfo().width(), getInfo().height())
129
- * if (!whole.contains(subset)) {
130
- * return false;
131
- * }
132
- *
133
129
  * Regarding the GrRecordingContext parameter:
134
130
  *
135
131
  * It must be non-NULL. The generator should only succeed if:
136
132
  * - its internal context is the same
137
133
  * - it can somehow convert its texture into one that is valid for the provided context.
138
134
  *
139
- * If the willNeedMipMaps flag is true, the generator should try to create a TextureProxy that
135
+ * If the mipmapped parameter is kYes, the generator should try to create a TextureProxy that
140
136
  * at least has the mip levels allocated and the base layer filled in. If this is not possible,
141
137
  * the generator is allowed to return a non mipped proxy, but this will have some additional
142
138
  * overhead in later allocating mips and copying of the base layer.
@@ -145,9 +141,16 @@ public:
145
141
  * status) or whether this may (but is not required to) return a pre-existing texture that is
146
142
  * retained by the generator (kDraw).
147
143
  */
148
- GrSurfaceProxyView generateTexture(GrRecordingContext*, const SkImageInfo& info,
149
- const SkIPoint& origin, GrMipmapped, GrImageTexGenPolicy);
144
+ GrSurfaceProxyView generateTexture(GrRecordingContext*,
145
+ const SkImageInfo& info,
146
+ GrMipmapped mipmapped,
147
+ GrImageTexGenPolicy);
148
+ #endif
150
149
 
150
+ #if SK_GRAPHITE_ENABLED
151
+ sk_sp<SkImage> makeTextureImage(skgpu::graphite::Recorder*,
152
+ const SkImageInfo&,
153
+ skgpu::graphite::Mipmapped);
151
154
  #endif
152
155
 
153
156
  /**
@@ -169,7 +172,8 @@ public:
169
172
  static std::unique_ptr<SkImageGenerator> MakeFromPicture(const SkISize&, sk_sp<SkPicture>,
170
173
  const SkMatrix*, const SkPaint*,
171
174
  SkImage::BitDepth,
172
- sk_sp<SkColorSpace>);
175
+ sk_sp<SkColorSpace>,
176
+ SkSurfaceProps props = {});
173
177
 
174
178
  protected:
175
179
  static constexpr int kNeedNewImageUniqueID = 0;
@@ -186,7 +190,7 @@ protected:
186
190
  #if SK_SUPPORT_GPU
187
191
  // returns nullptr
188
192
  virtual GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
189
- const SkIPoint&, GrMipmapped, GrImageTexGenPolicy);
193
+ GrMipmapped, GrImageTexGenPolicy);
190
194
 
191
195
  // Most internal SkImageGenerators produce textures and views that use kTopLeft_GrSurfaceOrigin.
192
196
  // If the generator may produce textures with different origins (e.g.
@@ -195,6 +199,12 @@ protected:
195
199
  virtual GrSurfaceOrigin origin() const { return kTopLeft_GrSurfaceOrigin; }
196
200
  #endif
197
201
 
202
+ #if SK_GRAPHITE_ENABLED
203
+ virtual sk_sp<SkImage> onMakeTextureImage(skgpu::graphite::Recorder*,
204
+ const SkImageInfo&,
205
+ skgpu::graphite::Mipmapped);
206
+ #endif
207
+
198
208
  private:
199
209
  const SkImageInfo fInfo;
200
210
  const uint32_t fUniqueID;
@@ -30,6 +30,7 @@ struct SK_API SkV2 {
30
30
  friend SkV2 operator*(SkV2 v, SkScalar s) { return {v.x*s, v.y*s}; }
31
31
  friend SkV2 operator*(SkScalar s, SkV2 v) { return {v.x*s, v.y*s}; }
32
32
  friend SkV2 operator/(SkV2 v, SkScalar s) { return {v.x/s, v.y/s}; }
33
+ friend SkV2 operator/(SkScalar s, SkV2 v) { return {s/v.x, s/v.y}; }
33
34
 
34
35
  void operator+=(SkV2 v) { *this = *this + v; }
35
36
  void operator-=(SkV2 v) { *this = *this - v; }
@@ -16,6 +16,7 @@
16
16
  #include "include/core/SkRefCnt.h"
17
17
  #include "include/core/SkSpan.h"
18
18
  #include "include/core/SkString.h"
19
+ #include "include/effects/SkRuntimeEffect.h"
19
20
 
20
21
  #include <memory>
21
22
  #include <vector>
@@ -44,6 +45,10 @@ namespace SkSL { struct Program; }
44
45
  * return type is void then the interpolated position from vertex shader return is used as the local
45
46
  * coordinate. If the color variant is used it will be blended with SkShader (or SkPaint color in
46
47
  * absence of a shader) using the SkBlender provided to the SkCanvas draw call.
48
+ *
49
+ * The vertex and fragment programs may both contain uniforms. Uniforms with the same name are
50
+ * assumed to be shared between stages. It is an error to specify uniforms in the vertex and
51
+ * fragment program with the same name but different types, dimensionality, or layouts.
47
52
  */
48
53
  class SkMeshSpecification : public SkNVRefCnt<SkMeshSpecification> {
49
54
  public:
@@ -86,6 +91,8 @@ public:
86
91
  SkString name;
87
92
  };
88
93
 
94
+ using Uniform = SkRuntimeEffect::Uniform;
95
+
89
96
  ~SkMeshSpecification();
90
97
 
91
98
  struct Result {
@@ -134,7 +141,29 @@ public:
134
141
  sk_sp<SkColorSpace> cs,
135
142
  SkAlphaType at);
136
143
 
137
- SkSpan<const Attribute> attributes() const { return SkMakeSpan(fAttributes); }
144
+ SkSpan<const Attribute> attributes() const { return SkSpan(fAttributes); }
145
+
146
+ /**
147
+ * Combined size of all 'uniform' variables. When creating a SkMesh with this specification
148
+ * provide an SkData of this size, containing values for all of those variables. Use uniforms()
149
+ * to get the offset of each uniform within the SkData.
150
+ */
151
+ size_t uniformSize() const;
152
+
153
+ /**
154
+ * Provides info about individual uniforms including the offset into an SkData where each
155
+ * uniform value should be placed.
156
+ */
157
+ SkSpan<const Uniform> uniforms() const { return SkSpan(fUniforms); }
158
+
159
+ /** Returns pointer to the named uniform variable's description, or nullptr if not found. */
160
+ const Uniform* findUniform(std::string_view name) const;
161
+
162
+ /** Returns pointer to the named attribute, or nullptr if not found. */
163
+ const Attribute* findAttribute(std::string_view name) const;
164
+
165
+ /** Returns pointer to the named varying, or nullptr if not found. */
166
+ const Varying* findVarying(std::string_view name) const;
138
167
 
139
168
  size_t stride() const { return fStride; }
140
169
 
@@ -158,8 +187,9 @@ private:
158
187
  SkMeshSpecification(SkSpan<const Attribute>,
159
188
  size_t,
160
189
  SkSpan<const Varying>,
161
- std::unique_ptr<SkSL::Program>,
162
- std::unique_ptr<SkSL::Program>,
190
+ std::vector<Uniform> uniforms,
191
+ std::unique_ptr<const SkSL::Program>,
192
+ std::unique_ptr<const SkSL::Program>,
163
193
  ColorType,
164
194
  bool hasLocalCoords,
165
195
  sk_sp<SkColorSpace>,
@@ -171,16 +201,17 @@ private:
171
201
  SkMeshSpecification& operator=(const SkMeshSpecification&) = delete;
172
202
  SkMeshSpecification& operator=(SkMeshSpecification&&) = delete;
173
203
 
174
- const std::vector<Attribute> fAttributes;
175
- const std::vector<Varying> fVaryings;
176
- std::unique_ptr<SkSL::Program> fVS;
177
- std::unique_ptr<SkSL::Program> fFS;
178
- size_t fStride;
179
- uint32_t fHash;
180
- ColorType fColorType;
181
- bool fHasLocalCoords;
182
- sk_sp<SkColorSpace> fColorSpace;
183
- SkAlphaType fAlphaType;
204
+ const std::vector<Attribute> fAttributes;
205
+ const std::vector<Varying> fVaryings;
206
+ const std::vector<Uniform> fUniforms;
207
+ const std::unique_ptr<const SkSL::Program> fVS;
208
+ const std::unique_ptr<const SkSL::Program> fFS;
209
+ const size_t fStride;
210
+ uint32_t fHash;
211
+ const ColorType fColorType;
212
+ const bool fHasLocalCoords;
213
+ const sk_sp<SkColorSpace> fColorSpace;
214
+ const SkAlphaType fAlphaType;
184
215
  };
185
216
 
186
217
  /**
@@ -199,11 +230,46 @@ private:
199
230
  *
200
231
  * If Make() is used the implicit index sequence is 0, 1, 2, 3, ... and vertexCount must be at least
201
232
  * 3.
233
+ *
234
+ * Both Make() and MakeIndexed() take a SkData with the uniform values. See
235
+ * SkMeshSpecification::uniformSize() and SkMeshSpecification::uniforms() for sizing and packing
236
+ * uniforms into the SkData.
202
237
  */
203
238
  class SkMesh {
204
239
  public:
205
- class IndexBuffer : public SkRefCnt {};
206
- class VertexBuffer : public SkRefCnt {};
240
+ class IndexBuffer : public SkRefCnt {
241
+ public:
242
+ virtual size_t size() const = 0;
243
+
244
+ /**
245
+ * Modifies the data in the IndexBuffer by copying size bytes from data into the buffer
246
+ * at offset. Fails if offset + size > this->size() or if either offset or size is not
247
+ * aligned to 4 bytes. The GrDirectContext* must match that used to create the buffer. We
248
+ * take it as a parameter to emphasize that the context must be used to update the data and
249
+ * thus the context must be valid for the current thread.
250
+ */
251
+ bool update(GrDirectContext*, const void* data, size_t offset, size_t size);
252
+
253
+ private:
254
+ virtual bool onUpdate(GrDirectContext*, const void* data, size_t offset, size_t size) = 0;
255
+ };
256
+
257
+ class VertexBuffer : public SkRefCnt {
258
+ public:
259
+ virtual size_t size() const = 0;
260
+
261
+ /**
262
+ * Modifies the data in the IndexBuffer by copying size bytes from data into the buffer
263
+ * at offset. Fails if offset + size > this->size() or if either offset or size is not
264
+ * aligned to 4 bytes. The GrDirectContext* must match that used to create the buffer. We
265
+ * take it as a parameter to emphasize that the context must be used to update the data and
266
+ * thus the context must be valid for the current thread.
267
+ */
268
+ bool update(GrDirectContext*, const void* data, size_t offset, size_t size);
269
+
270
+ private:
271
+ virtual bool onUpdate(GrDirectContext*, const void* data, size_t offset, size_t size) = 0;
272
+ };
207
273
 
208
274
  SkMesh();
209
275
  ~SkMesh();
@@ -215,29 +281,39 @@ public:
215
281
  SkMesh& operator=(SkMesh&&);
216
282
 
217
283
  /**
218
- * Makes an index buffer to be used with SkMeshes. The SkData is used to determine the
219
- * size and contents of the buffer. The buffer may be CPU- or GPU-backed depending on whether
220
- * GrDirectContext* is nullptr.
284
+ * Makes an index buffer to be used with SkMeshes. The buffer may be CPU- or GPU-backed
285
+ * depending on whether GrDirectContext* is nullptr.
221
286
  *
222
- * @param GrDirectContext* If nullptr a CPU-backed object is returned that owns the SkData.
223
- * Otherwise, the data is uploaded to the GPU and a GPU-backed buffer
224
- * is returned. It may only be used to draw into SkSurfaces that
225
- * are backed by the passed GrDirectContext.
226
- * @param sk_sp<SkData> required. The data used to populate the buffer.
287
+ * @param GrDirectContext* If nullptr a CPU-backed object is returned. Otherwise, the data is
288
+ * uploaded to the GPU and a GPU-backed buffer is returned. It may
289
+ * only be used to draw into SkSurfaces that are backed by the passed
290
+ * GrDirectContext.
291
+ * @param data The data used to populate the buffer, or nullptr to create a zero-
292
+ * initialized buffer.
293
+ * @param size Both the size of the data in 'data' and the size of the resulting
294
+ * buffer.
227
295
  */
296
+ static sk_sp<IndexBuffer> MakeIndexBuffer(GrDirectContext*, const void* data, size_t size);
297
+
298
+ /** Deprecated in favor of const void* and size_t version above. */
228
299
  static sk_sp<IndexBuffer> MakeIndexBuffer(GrDirectContext*, sk_sp<const SkData>);
229
300
 
230
301
  /**
231
- * Makes a vertex buffer to be used with SkMeshes. The SkData is used to determine the
232
- * size and contents of the buffer.The buffer may be CPU- or GPU-backed depending on whether
233
- * GrDirectContext* is nullptr.
302
+ * Makes a vertex buffer to be used with SkMeshes. The buffer may be CPU- or GPU-backed
303
+ * depending on whether GrDirectContext* is nullptr.
234
304
  *
235
- * @param GrDirectContext* If nullptr a CPU-backed object is returned that owns the SkData.
236
- * Otherwise, the data is uploaded to the GPU and a GPU-backed buffer
237
- * is returned. It may only be used to draw into SkSurfaces that
238
- * are backed by the passed GrDirectContext.
239
- * @param sk_sp<SkData> required. The data used to populate the buffer.
305
+ * @param GrDirectContext* If nullptr a CPU-backed object is returned. Otherwise, the data is
306
+ * uploaded to the GPU and a GPU-backed buffer is returned. It may
307
+ * only be used to draw into SkSurfaces that are backed by the passed
308
+ * GrDirectContext.
309
+ * @param data The data used to populate the buffer, or nullptr to create a zero-
310
+ * initialized buffer.
311
+ * @param size Both the size of the data in 'data' and the size of the resulting
312
+ * buffer.
240
313
  */
314
+ static sk_sp<VertexBuffer> MakeVertexBuffer(GrDirectContext*, const void*, size_t size);
315
+
316
+ /** Deprecated in favor of const void* and size_t version above. */
241
317
  static sk_sp<VertexBuffer> MakeVertexBuffer(GrDirectContext*, sk_sp<const SkData>);
242
318
 
243
319
  enum class Mode { kTriangles, kTriangleStrip };
@@ -247,6 +323,7 @@ public:
247
323
  sk_sp<VertexBuffer>,
248
324
  size_t vertexCount,
249
325
  size_t vertexOffset,
326
+ sk_sp<const SkData> uniforms,
250
327
  const SkRect& bounds);
251
328
 
252
329
  static SkMesh MakeIndexed(sk_sp<SkMeshSpecification>,
@@ -257,22 +334,29 @@ public:
257
334
  sk_sp<IndexBuffer>,
258
335
  size_t indexCount,
259
336
  size_t indexOffset,
337
+ sk_sp<const SkData> uniforms,
260
338
  const SkRect& bounds);
261
339
 
262
- sk_sp<SkMeshSpecification> spec() const { return fSpec; }
340
+ sk_sp<SkMeshSpecification> refSpec() const { return fSpec; }
341
+ SkMeshSpecification* spec() const { return fSpec.get(); }
263
342
 
264
343
  Mode mode() const { return fMode; }
265
344
 
266
- sk_sp<VertexBuffer> vertexBuffer() const { return fVB; }
345
+ sk_sp<VertexBuffer> refVertexBuffer() const { return fVB; }
346
+ VertexBuffer* vertexBuffer() const { return fVB.get(); }
267
347
 
268
348
  size_t vertexOffset() const { return fVOffset; }
269
349
  size_t vertexCount() const { return fVCount; }
270
350
 
271
- sk_sp<IndexBuffer> indexBuffer() const { return fIB; }
351
+ sk_sp<IndexBuffer> refIndexBuffer() const { return fIB; }
352
+ IndexBuffer* indexBuffer() const { return fIB.get(); }
272
353
 
273
354
  size_t indexOffset() const { return fIOffset; }
274
355
  size_t indexCount() const { return fICount; }
275
356
 
357
+ sk_sp<const SkData> refUniforms() const { return fUniforms; }
358
+ const SkData* uniforms() const { return fUniforms.get(); }
359
+
276
360
  SkRect bounds() const { return fBounds; }
277
361
 
278
362
  bool isValid() const;
@@ -287,6 +371,8 @@ private:
287
371
  sk_sp<VertexBuffer> fVB;
288
372
  sk_sp<IndexBuffer> fIB;
289
373
 
374
+ sk_sp<const SkData> fUniforms;
375
+
290
376
  size_t fVOffset = 0; // Must be a multiple of spec->stride()
291
377
  size_t fVCount = 0;
292
378
 
@@ -5,5 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
  #ifndef SK_MILESTONE
8
- #define SK_MILESTONE 103
8
+ #define SK_MILESTONE 108
9
9
  #endif
@@ -22,7 +22,8 @@ public:
22
22
  SkOverdrawCanvas(SkCanvas*);
23
23
 
24
24
  void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override;
25
- void onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
25
+ void onDrawGlyphRunList(
26
+ const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override;
26
27
  void onDrawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], SkBlendMode,
27
28
  const SkPaint&) override;
28
29
  void onDrawPaint(const SkPaint&) override;
@@ -251,12 +251,14 @@ public:
251
251
 
252
252
  /** Retrieves alpha from the color used when stroking and filling.
253
253
 
254
- @return alpha ranging from zero, fully transparent, to 255, fully opaque
254
+ @return alpha ranging from zero, fully transparent, to one, fully opaque
255
255
  */
256
256
  float getAlphaf() const { return fColor4f.fA; }
257
257
 
258
258
  // Helper that scales the alpha by 255.
259
- uint8_t getAlpha() const { return sk_float_round2int(this->getAlphaf() * 255); }
259
+ uint8_t getAlpha() const {
260
+ return static_cast<uint8_t>(sk_float_round2int(this->getAlphaf() * 255));
261
+ }
260
262
 
261
263
  /** Replaces alpha, leaving RGB
262
264
  unchanged. An out of range value triggers an assert in the debug
@@ -676,6 +678,8 @@ public:
676
678
  const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
677
679
  Style style) const;
678
680
 
681
+ using sk_is_trivially_relocatable = std::true_type;
682
+
679
683
  private:
680
684
  sk_sp<SkPathEffect> fPathEffect;
681
685
  sk_sp<SkShader> fShader;
@@ -699,6 +703,15 @@ private:
699
703
  uint32_t fBitfieldsUInt;
700
704
  };
701
705
 
706
+ static_assert(::sk_is_trivially_relocatable<decltype(fPathEffect)>::value);
707
+ static_assert(::sk_is_trivially_relocatable<decltype(fShader)>::value);
708
+ static_assert(::sk_is_trivially_relocatable<decltype(fMaskFilter)>::value);
709
+ static_assert(::sk_is_trivially_relocatable<decltype(fColorFilter)>::value);
710
+ static_assert(::sk_is_trivially_relocatable<decltype(fImageFilter)>::value);
711
+ static_assert(::sk_is_trivially_relocatable<decltype(fBlender)>::value);
712
+ static_assert(::sk_is_trivially_relocatable<decltype(fColor4f)>::value);
713
+ static_assert(::sk_is_trivially_relocatable<decltype(fBitfields)>::value);
714
+
702
715
  friend class SkPaintPriv;
703
716
  };
704
717
 
@@ -1756,6 +1756,8 @@ public:
1756
1756
  */
1757
1757
  bool isValid() const;
1758
1758
 
1759
+ using sk_is_trivially_relocatable = std::true_type;
1760
+
1759
1761
  private:
1760
1762
  SkPath(sk_sp<SkPathRef>, SkPathFillType, bool isVolatile, SkPathConvexity,
1761
1763
  SkPathFirstDirection firstDirection);
@@ -1767,6 +1769,8 @@ private:
1767
1769
  uint8_t fFillType : 2;
1768
1770
  uint8_t fIsVolatile : 1;
1769
1771
 
1772
+ static_assert(::sk_is_trivially_relocatable<decltype(fPathRef)>::value);
1773
+
1770
1774
  /** Resets all fields other than fPathRef to their initial 'empty' values.
1771
1775
  * Assumes the caller has already emptied fPathRef.
1772
1776
  * On Android increments fGenerationID without reseting it.
@@ -242,7 +242,7 @@ private:
242
242
  int fIsAStart = -1; // tracks direction iff fIsA is not unknown
243
243
  bool fIsACCW = false; // tracks direction iff fIsA is not unknown
244
244
 
245
- int countVerbs() const { return fVerbs.count(); }
245
+ int countVerbs() const { return fVerbs.size(); }
246
246
 
247
247
  // called right before we add a (non-move) verb
248
248
  void ensureMove() {
@@ -240,7 +240,6 @@ private:
240
240
  friend class SkBigPicture;
241
241
  friend class SkEmptyPicture;
242
242
  friend class SkPicturePriv;
243
- template <typename> friend class SkMiniPicture;
244
243
 
245
244
  void serialize(SkWStream*, const SkSerialProcs*, class SkRefCntSet* typefaces,
246
245
  bool textBlobsOnly=false) const;
@@ -263,8 +262,6 @@ private:
263
262
  // Returns NULL if this is not an SkBigPicture.
264
263
  virtual const class SkBigPicture* asSkBigPicture() const { return nullptr; }
265
264
 
266
- friend struct SkPathCounter;
267
-
268
265
  static bool IsValidPictInfo(const struct SkPictInfo& info);
269
266
  static sk_sp<SkPicture> Forwardport(const struct SkPictInfo&,
270
267
  const class SkPictureData*,
@@ -20,7 +20,6 @@ namespace android {
20
20
 
21
21
  class SkCanvas;
22
22
  class SkDrawable;
23
- class SkMiniRecorder;
24
23
  class SkPictureRecord;
25
24
  class SkRecord;
26
25
  class SkRecorder;
@@ -106,7 +105,6 @@ private:
106
105
  sk_sp<SkBBoxHierarchy> fBBH;
107
106
  std::unique_ptr<SkRecorder> fRecorder;
108
107
  sk_sp<SkRecord> fRecord;
109
- std::unique_ptr<SkMiniRecorder> fMiniRecorder;
110
108
 
111
109
  SkPictureRecorder(SkPictureRecorder&&) = delete;
112
110
  SkPictureRecorder& operator=(SkPictureRecorder&&) = delete;
@@ -261,6 +261,25 @@ public:
261
261
  */
262
262
  SkColor getColor(int x, int y) const;
263
263
 
264
+ /** Returns pixel at (x, y) as unpremultiplied color as an SkColor4f.
265
+ Returns black with alpha if SkColorType is kAlpha_8_SkColorType.
266
+
267
+ Input is not validated: out of bounds values of x or y trigger an assert() if
268
+ built with SK_DEBUG defined; and returns undefined values or may crash if
269
+ SK_RELEASE is defined. Fails if SkColorType is kUnknown_SkColorType or
270
+ pixel address is nullptr.
271
+
272
+ SkColorSpace in SkImageInfo is ignored. Some color precision may be lost in the
273
+ conversion to unpremultiplied color; original pixel data may have additional
274
+ precision, though this is less likely than for getColor(). Rounding errors may
275
+ occur if the underlying type has lower precision.
276
+
277
+ @param x column index, zero or greater, and less than width()
278
+ @param y row index, zero or greater, and less than height()
279
+ @return pixel converted to unpremultiplied float color
280
+ */
281
+ SkColor4f getColor4f(int x, int y) const;
282
+
264
283
  /** Look up the pixel at (x,y) and return its alpha component, normalized to [0..1].
265
284
  This is roughly equivalent to SkGetColorA(getColor()), but can be more efficent
266
285
  (and more precise if the pixels store more than 8 bits per component).
@@ -13,6 +13,7 @@
13
13
  class SkBitmap;
14
14
  class SkCanvas;
15
15
  class SkMatrix;
16
+ class SkSurfaceProps;
16
17
 
17
18
  /**
18
19
  * If a client wants to control the allocation of raster layers in a canvas, it should subclass
@@ -76,7 +77,8 @@ public:
76
77
  * If rec is null, then the allocator will be called for the base-layer as well.
77
78
  */
78
79
  static std::unique_ptr<SkCanvas> MakeCanvas(std::unique_ptr<SkRasterHandleAllocator>,
79
- const SkImageInfo&, const Rec* rec = nullptr);
80
+ const SkImageInfo&, const Rec* rec = nullptr,
81
+ const SkSurfaceProps* props = nullptr);
80
82
 
81
83
  protected:
82
84
  SkRasterHandleAllocator() = default;
@@ -215,7 +215,8 @@ struct SK_API SkIRect {
215
215
  @return true if members are equal
216
216
  */
217
217
  friend bool operator==(const SkIRect& a, const SkIRect& b) {
218
- return !memcmp(&a, &b, sizeof(a));
218
+ return a.fLeft == b.fLeft && a.fTop == b.fTop &&
219
+ a.fRight == b.fRight && a.fBottom == b.fBottom;
219
220
  }
220
221
 
221
222
  /** Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not
@@ -226,7 +227,8 @@ struct SK_API SkIRect {
226
227
  @return true if members are not equal
227
228
  */
228
229
  friend bool operator!=(const SkIRect& a, const SkIRect& b) {
229
- return !(a == b);
230
+ return a.fLeft != b.fLeft || a.fTop != b.fTop ||
231
+ a.fRight != b.fRight || a.fBottom != b.fBottom;
230
232
  }
231
233
 
232
234
  /** Sets SkIRect to (0, 0, 0, 0).
@@ -783,7 +785,7 @@ struct SK_API SkRect {
783
785
 
784
786
  @return midpoint on x-axis
785
787
  */
786
- SkScalar centerX() const {
788
+ constexpr SkScalar centerX() const {
787
789
  // don't use SkScalarHalf(fLeft + fBottom) as that might overflow before the 0.5
788
790
  return SkScalarHalf(fLeft) + SkScalarHalf(fRight);
789
791
  }
@@ -793,11 +795,16 @@ struct SK_API SkRect {
793
795
 
794
796
  @return midpoint on y-axis
795
797
  */
796
- SkScalar centerY() const {
798
+ constexpr SkScalar centerY() const {
797
799
  // don't use SkScalarHalf(fTop + fBottom) as that might overflow before the 0.5
798
800
  return SkScalarHalf(fTop) + SkScalarHalf(fBottom);
799
801
  }
800
802
 
803
+ /** Returns the point this->centerX(), this->centerY().
804
+ @return rectangle center
805
+ */
806
+ constexpr SkPoint center() const { return {this->centerX(), this->centerY()}; }
807
+
801
808
  /** Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are
802
809
  equal to the corresponding members in b.
803
810
 
@@ -9,6 +9,7 @@
9
9
  #define SkRefCnt_DEFINED
10
10
 
11
11
  #include "include/core/SkTypes.h"
12
+ #include "include/private/SkTemplates.h"
12
13
 
13
14
  #include <atomic> // std::atomic, std::memory_order_*
14
15
  #include <cstddef> // std::nullptr_t
@@ -211,8 +212,17 @@ private:
211
212
  * This can be used for classes inheriting from SkRefCnt, but it also works for other
212
213
  * classes that match the interface, but have different internal choices: e.g. the hosted class
213
214
  * may have its ref/unref be thread-safe, but that is not assumed/imposed by sk_sp.
215
+ *
216
+ * Declared with the trivial_abi attribute where supported so that sk_sp and types containing it
217
+ * may be considered as trivially relocatable by the compiler so that destroying-move operations
218
+ * i.e. move constructor followed by destructor can be optimized to memcpy.
214
219
  */
215
- template <typename T> class sk_sp {
220
+ #if defined(__clang__) && defined(__has_cpp_attribute) && __has_cpp_attribute(clang::trivial_abi)
221
+ #define SK_SP_TRIVIAL_ABI [[clang::trivial_abi]]
222
+ #else
223
+ #define SK_SP_TRIVIAL_ABI
224
+ #endif
225
+ template <typename T> class SK_SP_TRIVIAL_ABI sk_sp {
216
226
  public:
217
227
  using element_type = T;
218
228
 
@@ -327,6 +337,8 @@ public:
327
337
  swap(fPtr, that.fPtr);
328
338
  }
329
339
 
340
+ using sk_is_trivially_relocatable = std::true_type;
341
+
330
342
  private:
331
343
  T* fPtr;
332
344
  };
@@ -9,6 +9,7 @@
9
9
  #define SkRegion_DEFINED
10
10
 
11
11
  #include "include/core/SkRect.h"
12
+ #include "include/private/SkTemplates.h"
12
13
 
13
14
  class SkPath;
14
15
  class SkRgnBuilder;
@@ -606,6 +607,8 @@ public:
606
607
  */
607
608
  size_t readFromMemory(const void* buffer, size_t length);
608
609
 
610
+ using sk_is_trivially_relocatable = std::true_type;
611
+
609
612
  private:
610
613
  static constexpr int kOpCount = kReplace_Op + 1;
611
614
 
@@ -629,6 +632,9 @@ private:
629
632
  SkIRect fBounds;
630
633
  RunHead* fRunHead;
631
634
 
635
+ static_assert(::sk_is_trivially_relocatable<decltype(fBounds)>::value);
636
+ static_assert(::sk_is_trivially_relocatable<decltype(fRunHead)>::value);
637
+
632
638
  void freeRuns();
633
639
 
634
640
  /**