@shopify/react-native-skia 0.1.192 → 0.1.193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/android/CMakeLists.txt +1 -1
  2. package/android/build.gradle +1 -0
  3. package/android/cpp/jni/JniPlatformContext.cpp +1 -1
  4. package/cpp/api/JsiSkImage.h +25 -4
  5. package/cpp/api/JsiSkImageFactory.h +2 -2
  6. package/cpp/api/JsiSkPath.h +8 -6
  7. package/cpp/rnskia/dom/base/Declaration.h +5 -7
  8. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +1 -0
  9. package/cpp/rnskia/dom/nodes/JsiPathNode.h +2 -2
  10. package/cpp/rnskia/dom/props/BoxShadowProps.h +2 -0
  11. package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +2 -8
  12. package/cpp/skia/include/android/SkImageAndroid.h +101 -0
  13. package/cpp/skia/include/codec/SkAndroidCodec.h +26 -8
  14. package/cpp/skia/include/codec/SkCodec.h +31 -17
  15. package/cpp/skia/include/codec/SkEncodedImageFormat.h +36 -0
  16. package/cpp/skia/include/codec/SkPixmapUtils.h +31 -0
  17. package/cpp/skia/include/config/SkUserConfig.h +61 -29
  18. package/cpp/skia/include/core/SkBitmap.h +25 -25
  19. package/cpp/skia/include/core/SkBlurTypes.h +0 -2
  20. package/cpp/skia/include/core/SkCanvas.h +32 -15
  21. package/cpp/skia/include/core/SkCapabilities.h +2 -2
  22. package/cpp/skia/include/core/SkColor.h +2 -0
  23. package/cpp/skia/include/core/SkColorPriv.h +19 -4
  24. package/cpp/skia/include/core/SkColorSpace.h +14 -17
  25. package/cpp/skia/include/core/SkColorType.h +1 -0
  26. package/cpp/skia/include/core/SkContourMeasure.h +1 -1
  27. package/cpp/skia/include/core/SkCoverageMode.h +0 -2
  28. package/cpp/skia/include/core/SkCubicMap.h +2 -0
  29. package/cpp/skia/include/core/SkData.h +5 -2
  30. package/cpp/skia/include/core/SkDataTable.h +6 -2
  31. package/cpp/skia/include/core/SkDeferredDisplayList.h +11 -10
  32. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +9 -8
  33. package/cpp/skia/include/core/SkDrawable.h +10 -2
  34. package/cpp/skia/include/core/SkEncodedImageFormat.h +3 -30
  35. package/cpp/skia/include/core/SkFlattenable.h +4 -2
  36. package/cpp/skia/include/core/SkFont.h +1 -0
  37. package/cpp/skia/include/core/SkFontMetrics.h +1 -0
  38. package/cpp/skia/include/core/SkFontMgr.h +20 -29
  39. package/cpp/skia/include/core/SkFontStyle.h +4 -1
  40. package/cpp/skia/include/core/SkGraphics.h +21 -18
  41. package/cpp/skia/include/core/SkICC.h +3 -13
  42. package/cpp/skia/include/core/SkImage.h +395 -717
  43. package/cpp/skia/include/core/SkImageGenerator.h +19 -74
  44. package/cpp/skia/include/core/SkImageInfo.h +7 -5
  45. package/cpp/skia/include/core/SkM44.h +11 -0
  46. package/cpp/skia/include/core/SkMaskFilter.h +6 -3
  47. package/cpp/skia/include/core/SkMatrix.h +14 -4
  48. package/cpp/skia/include/core/SkMesh.h +52 -18
  49. package/cpp/skia/include/core/SkMilestone.h +1 -1
  50. package/cpp/skia/include/core/SkPaint.h +11 -34
  51. package/cpp/skia/include/core/SkPath.h +23 -4
  52. package/cpp/skia/include/core/SkPathBuilder.h +13 -5
  53. package/cpp/skia/include/core/SkPathMeasure.h +1 -1
  54. package/cpp/skia/include/core/SkPathTypes.h +0 -2
  55. package/cpp/skia/include/core/SkPathUtils.h +42 -0
  56. package/cpp/skia/include/core/SkPicture.h +3 -2
  57. package/cpp/skia/include/core/SkPictureRecorder.h +2 -0
  58. package/cpp/skia/include/core/SkPixelRef.h +4 -8
  59. package/cpp/skia/include/core/SkPixmap.h +12 -20
  60. package/cpp/skia/include/core/SkPoint.h +4 -2
  61. package/cpp/skia/include/core/SkPromiseImageTexture.h +2 -2
  62. package/cpp/skia/include/core/SkRRect.h +5 -1
  63. package/cpp/skia/include/core/SkRect.h +6 -3
  64. package/cpp/skia/include/core/SkRefCnt.h +9 -14
  65. package/cpp/skia/include/core/SkRegion.h +1 -1
  66. package/cpp/skia/include/core/SkScalar.h +2 -4
  67. package/cpp/skia/include/core/SkSerialProcs.h +18 -10
  68. package/cpp/skia/include/core/SkShader.h +1 -64
  69. package/cpp/skia/include/core/SkSize.h +2 -0
  70. package/cpp/skia/include/core/SkSpan.h +4 -112
  71. package/cpp/skia/include/core/SkStream.h +11 -12
  72. package/cpp/skia/include/core/SkString.h +9 -25
  73. package/cpp/skia/include/core/SkStrokeRec.h +1 -1
  74. package/cpp/skia/include/core/SkSurface.h +83 -61
  75. package/cpp/skia/include/core/SkSurfaceCharacterization.h +3 -3
  76. package/cpp/skia/include/core/SkSurfaceProps.h +9 -1
  77. package/cpp/skia/include/core/SkTextBlob.h +2 -2
  78. package/cpp/skia/include/core/SkTextureCompressionType.h +30 -0
  79. package/cpp/skia/include/core/SkTime.h +1 -1
  80. package/cpp/skia/include/core/SkTypeface.h +9 -2
  81. package/cpp/skia/include/core/SkTypes.h +37 -466
  82. package/cpp/skia/include/core/SkVertices.h +2 -0
  83. package/cpp/skia/include/core/SkYUVAInfo.h +4 -0
  84. package/cpp/skia/include/core/SkYUVAPixmaps.h +7 -1
  85. package/cpp/skia/include/docs/SkPDFDocument.h +12 -1
  86. package/cpp/skia/include/effects/SkColorMatrix.h +2 -1
  87. package/cpp/skia/include/effects/SkGradientShader.h +65 -14
  88. package/cpp/skia/include/effects/SkImageFilters.h +0 -11
  89. package/cpp/skia/include/effects/SkRuntimeEffect.h +41 -11
  90. package/cpp/skia/include/encode/SkEncoder.h +7 -3
  91. package/cpp/skia/include/encode/SkICC.h +36 -0
  92. package/cpp/skia/include/encode/SkJpegEncoder.h +102 -71
  93. package/cpp/skia/include/encode/SkPngEncoder.h +89 -71
  94. package/cpp/skia/include/encode/SkWebpEncoder.h +65 -38
  95. package/cpp/skia/include/gpu/GpuTypes.h +23 -1
  96. package/cpp/skia/include/gpu/GrBackendSurface.h +9 -7
  97. package/cpp/skia/include/gpu/GrContextOptions.h +28 -9
  98. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +6 -4
  99. package/cpp/skia/include/gpu/GrDirectContext.h +84 -63
  100. package/cpp/skia/include/gpu/GrDriverBugWorkarounds.h +2 -1
  101. package/cpp/skia/include/gpu/GrRecordingContext.h +9 -5
  102. package/cpp/skia/include/gpu/GrTypes.h +18 -18
  103. package/cpp/skia/include/gpu/d3d/GrD3DTypes.h +4 -4
  104. package/cpp/skia/include/gpu/dawn/GrDawnTypes.h +3 -3
  105. package/cpp/skia/include/gpu/ganesh/GrTextureGenerator.h +77 -0
  106. package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +385 -0
  107. package/cpp/skia/include/gpu/gl/GrGLExtensions.h +3 -3
  108. package/cpp/skia/include/gpu/gl/GrGLFunctions.h +1 -1
  109. package/cpp/skia/include/gpu/gl/GrGLInterface.h +0 -3
  110. package/cpp/skia/include/gpu/gl/GrGLTypes.h +2 -1
  111. package/cpp/skia/include/gpu/graphite/BackendTexture.h +72 -3
  112. package/cpp/skia/include/gpu/graphite/Context.h +85 -32
  113. package/cpp/skia/include/gpu/graphite/ContextOptions.h +15 -11
  114. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +55 -5
  115. package/cpp/skia/include/gpu/graphite/ImageProvider.h +6 -4
  116. package/cpp/skia/include/gpu/graphite/Recorder.h +41 -11
  117. package/cpp/skia/include/gpu/graphite/Recording.h +50 -3
  118. package/cpp/skia/include/gpu/graphite/TextureInfo.h +47 -8
  119. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +139 -0
  120. package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +40 -0
  121. package/cpp/skia/include/gpu/graphite/dawn/DawnUtils.h +28 -0
  122. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +1 -1
  123. package/cpp/skia/include/gpu/graphite/mtl/{MtlTypes.h → MtlGraphiteTypes.h} +7 -6
  124. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +27 -0
  125. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +4 -9
  126. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteUtils.h +28 -0
  127. package/cpp/skia/include/gpu/mock/GrMockTypes.h +17 -13
  128. package/cpp/skia/include/gpu/mtl/GrMtlTypes.h +2 -2
  129. package/cpp/skia/include/gpu/vk/GrVkBackendContext.h +1 -1
  130. package/cpp/skia/include/gpu/vk/GrVkTypes.h +3 -3
  131. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +3 -3
  132. package/cpp/skia/include/gpu/vk/VulkanMemoryAllocator.h +5 -7
  133. package/cpp/skia/include/pathops/SkPathOps.h +3 -3
  134. package/cpp/skia/include/ports/SkFontMgr_data.h +22 -0
  135. package/cpp/skia/include/ports/SkFontMgr_indirect.h +14 -14
  136. package/cpp/skia/include/ports/SkRemotableFontMgr.h +2 -2
  137. package/cpp/skia/include/ports/SkTypeface_win.h +2 -1
  138. package/cpp/skia/include/private/SkChecksum.h +32 -7
  139. package/cpp/skia/include/private/SkColorData.h +1 -26
  140. package/cpp/skia/include/private/SkGainmapInfo.h +97 -0
  141. package/cpp/skia/include/private/SkGainmapShader.h +53 -0
  142. package/cpp/skia/include/private/SkIDChangeListener.h +4 -3
  143. package/cpp/skia/include/private/SkJpegGainmapEncoder.h +71 -0
  144. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +61 -0
  145. package/cpp/skia/include/private/SkOpts_spi.h +3 -1
  146. package/cpp/skia/include/private/SkPathRef.h +64 -47
  147. package/cpp/skia/include/private/SkSLDefines.h +5 -5
  148. package/cpp/skia/include/private/SkSLSampleUsage.h +0 -4
  149. package/cpp/skia/include/private/SkSpinlock.h +1 -1
  150. package/cpp/skia/include/private/SkWeakRefCnt.h +3 -0
  151. package/cpp/skia/include/private/{SingleOwner.h → base/SingleOwner.h} +8 -5
  152. package/cpp/skia/include/private/base/SkAPI.h +52 -0
  153. package/cpp/skia/include/private/base/SkAlign.h +39 -0
  154. package/cpp/skia/include/private/base/SkAlignedStorage.h +32 -0
  155. package/cpp/skia/include/private/base/SkAssert.h +92 -0
  156. package/cpp/skia/include/private/base/SkAttributes.h +102 -0
  157. package/cpp/skia/include/private/base/SkCPUTypes.h +25 -0
  158. package/cpp/skia/include/private/base/SkContainers.h +46 -0
  159. package/cpp/skia/include/private/base/SkDebug.h +27 -0
  160. package/cpp/skia/include/private/{SkDeque.h → base/SkDeque.h} +3 -1
  161. package/cpp/skia/include/private/base/SkFeatures.h +151 -0
  162. package/cpp/skia/include/private/{SkFixed.h → base/SkFixed.h} +9 -7
  163. package/cpp/skia/include/private/{SkFloatBits.h → base/SkFloatBits.h} +2 -3
  164. package/cpp/skia/include/private/{SkFloatingPoint.h → base/SkFloatingPoint.h} +18 -9
  165. package/cpp/skia/include/private/base/SkLoadUserConfig.h +63 -0
  166. package/cpp/skia/include/private/{SkMacros.h → base/SkMacros.h} +17 -2
  167. package/cpp/skia/include/private/{SkMalloc.h → base/SkMalloc.h} +4 -7
  168. package/cpp/skia/include/{core → private/base}/SkMath.h +25 -2
  169. package/cpp/skia/include/private/{SkMutex.h → base/SkMutex.h} +5 -5
  170. package/cpp/skia/include/private/{SkNoncopyable.h → base/SkNoncopyable.h} +2 -2
  171. package/cpp/skia/include/private/{SkOnce.h → base/SkOnce.h} +3 -1
  172. package/cpp/skia/include/private/base/SkPathEnums.h +25 -0
  173. package/cpp/skia/include/private/{SkSafe32.h → base/SkSafe32.h} +16 -1
  174. package/cpp/skia/include/private/{SkSemaphore.h → base/SkSemaphore.h} +4 -3
  175. package/cpp/skia/include/private/base/SkSpan_impl.h +129 -0
  176. package/cpp/skia/include/private/base/SkTArray.h +694 -0
  177. package/cpp/skia/include/private/{SkTDArray.h → base/SkTDArray.h} +17 -54
  178. package/cpp/skia/include/private/{SkTFitsIn.h → base/SkTFitsIn.h} +14 -8
  179. package/cpp/skia/include/private/{SkTLogic.h → base/SkTLogic.h} +1 -1
  180. package/cpp/skia/include/private/{SkTemplates.h → base/SkTemplates.h} +63 -88
  181. package/cpp/skia/include/private/{SkThreadID.h → base/SkThreadID.h} +5 -2
  182. package/cpp/skia/include/private/{SkTo.h → base/SkTo.h} +13 -2
  183. package/cpp/skia/include/private/base/SkTypeTraits.h +33 -0
  184. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +130 -0
  185. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +5 -9
  186. package/cpp/skia/include/private/chromium/SkDiscardableMemory.h +70 -0
  187. package/cpp/skia/include/private/chromium/Slug.h +0 -9
  188. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +2 -1
  189. package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +1 -1
  190. package/cpp/skia/include/private/gpu/ganesh/GrDawnTypesPriv.h +1 -1
  191. package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +1 -1
  192. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
  193. package/cpp/skia/include/private/gpu/ganesh/GrMockTypesPriv.h +3 -2
  194. package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +1 -1
  195. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +17 -23
  196. package/cpp/skia/include/private/gpu/ganesh/GrVkTypesPriv.h +2 -2
  197. package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +38 -0
  198. package/cpp/skia/include/private/gpu/graphite/{MtlTypesPriv.h → MtlGraphiteTypesPriv.h} +5 -5
  199. package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +1 -9
  200. package/cpp/skia/include/private/gpu/vk/SkiaVulkan.h +4 -0
  201. package/cpp/skia/include/utils/SkCamera.h +1 -1
  202. package/cpp/skia/include/utils/SkCustomTypeface.h +7 -1
  203. package/cpp/skia/include/utils/SkNWayCanvas.h +6 -6
  204. package/cpp/skia/include/utils/SkOrderedFontMgr.h +7 -6
  205. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +2 -2
  206. package/cpp/skia/include/utils/SkParsePath.h +1 -1
  207. package/cpp/skia/modules/skcms/skcms.h +14 -0
  208. package/cpp/skia/modules/skcms/src/Transform_inl.h +19 -0
  209. package/cpp/skia/modules/skparagraph/include/FontCollection.h +2 -2
  210. package/cpp/skia/modules/skparagraph/include/Paragraph.h +72 -2
  211. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +1 -11
  212. package/cpp/skia/modules/skparagraph/include/ParagraphPainter.h +63 -0
  213. package/cpp/skia/modules/skparagraph/include/TextStyle.h +27 -4
  214. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +13 -13
  215. package/cpp/skia/modules/skresources/include/SkResources.h +18 -4
  216. package/cpp/skia/modules/svg/include/SkSVGAttribute.h +1 -1
  217. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +2 -2
  218. package/cpp/skia/modules/svg/include/SkSVGContainer.h +2 -2
  219. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -1
  220. package/cpp/skia/modules/svg/include/SkSVGFilterContext.h +2 -2
  221. package/cpp/skia/modules/svg/include/SkSVGGradient.h +2 -2
  222. package/cpp/skia/modules/svg/include/SkSVGIDMapper.h +2 -2
  223. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
  224. package/cpp/skia/modules/svg/include/SkSVGSVG.h +1 -1
  225. package/cpp/skia/modules/svg/include/SkSVGTypes.h +22 -21
  226. package/cpp/skia/modules/svg/include/SkSVGValue.h +1 -1
  227. package/cpp/skia/{include/private → src/core}/SkTHash.h +41 -37
  228. package/ios/RNSkia-iOS/ViewScreenshotService.mm +1 -1
  229. package/libs/android/arm64-v8a/libskia.a +0 -0
  230. package/libs/android/arm64-v8a/libskottie.a +0 -0
  231. package/libs/android/arm64-v8a/libsksg.a +0 -0
  232. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  233. package/libs/android/arm64-v8a/libsvg.a +0 -0
  234. package/libs/android/armeabi-v7a/libskia.a +0 -0
  235. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  236. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  237. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  238. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  239. package/libs/android/x86/libskia.a +0 -0
  240. package/libs/android/x86/libskottie.a +0 -0
  241. package/libs/android/x86/libsksg.a +0 -0
  242. package/libs/android/x86/libskshaper.a +0 -0
  243. package/libs/android/x86/libsvg.a +0 -0
  244. package/libs/android/x86_64/libskia.a +0 -0
  245. package/libs/android/x86_64/libskottie.a +0 -0
  246. package/libs/android/x86_64/libsksg.a +0 -0
  247. package/libs/android/x86_64/libskshaper.a +0 -0
  248. package/libs/android/x86_64/libsvg.a +0 -0
  249. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  250. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  251. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  252. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  253. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  254. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  255. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  256. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  257. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  258. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  259. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  260. package/package.json +1 -1
  261. package/react-native-skia.podspec +1 -1
  262. package/scripts/install-npm.js +11 -1
  263. package/cpp/skia/include/core/SkImageEncoder.h +0 -71
  264. package/cpp/skia/include/gpu/GrConfig.h +0 -53
  265. package/cpp/skia/include/gpu/graphite/CombinationBuilder.h +0 -195
  266. package/cpp/skia/include/private/SkHalf.h +0 -38
  267. package/cpp/skia/include/private/SkImageInfoPriv.h +0 -199
  268. package/cpp/skia/include/private/SkSLIRNode.h +0 -64
  269. package/cpp/skia/include/private/SkSLLayout.h +0 -144
  270. package/cpp/skia/include/private/SkSLModifiers.h +0 -178
  271. package/cpp/skia/include/private/SkSLProgramElement.h +0 -77
  272. package/cpp/skia/include/private/SkSLProgramKind.h +0 -35
  273. package/cpp/skia/include/private/SkSLStatement.h +0 -86
  274. package/cpp/skia/include/private/SkSLString.h +0 -41
  275. package/cpp/skia/include/private/SkSLSymbol.h +0 -94
  276. package/cpp/skia/include/private/SkSafe_math.h +0 -52
  277. package/cpp/skia/include/private/SkStringView.h +0 -51
  278. package/cpp/skia/include/private/SkTArray.h +0 -655
  279. package/cpp/skia/include/private/SkUniquePaintParamsID.h +0 -35
  280. package/cpp/skia/include/private/SkVx.h +0 -1026
  281. package/cpp/skia/include/sksl/DSL.h +0 -37
  282. package/cpp/skia/include/sksl/DSLBlock.h +0 -58
  283. package/cpp/skia/include/sksl/DSLCase.h +0 -62
  284. package/cpp/skia/include/sksl/DSLCore.h +0 -492
  285. package/cpp/skia/include/sksl/DSLExpression.h +0 -241
  286. package/cpp/skia/include/sksl/DSLFunction.h +0 -113
  287. package/cpp/skia/include/sksl/DSLLayout.h +0 -92
  288. package/cpp/skia/include/sksl/DSLModifiers.h +0 -69
  289. package/cpp/skia/include/sksl/DSLStatement.h +0 -82
  290. package/cpp/skia/include/sksl/DSLSymbols.h +0 -61
  291. package/cpp/skia/include/sksl/DSLType.h +0 -271
  292. package/cpp/skia/include/sksl/DSLVar.h +0 -231
  293. package/cpp/skia/include/sksl/SkSLErrorReporter.h +0 -65
  294. package/cpp/skia/include/sksl/SkSLOperator.h +0 -154
  295. package/cpp/skia/include/sksl/SkSLPosition.h +0 -104
  296. package/cpp/skia/include/utils/SkRandom.h +0 -169
  297. package/cpp/skia/src/core/SkLRUCache.h +0 -126
  298. package/cpp/skia/src/core/SkTInternalLList.h +0 -302
  299. /package/cpp/skia/include/{core → codec}/SkPngChunkReader.h +0 -0
  300. /package/cpp/skia/include/private/{SkTPin.h → base/SkTPin.h} +0 -0
  301. /package/cpp/skia/include/private/{SkThreadAnnotations.h → base/SkThreadAnnotations.h} +0 -0
@@ -8,36 +8,25 @@
8
8
  #ifndef SkPathRef_DEFINED
9
9
  #define SkPathRef_DEFINED
10
10
 
11
- #include "include/core/SkMatrix.h"
12
11
  #include "include/core/SkPoint.h"
13
12
  #include "include/core/SkRect.h"
14
13
  #include "include/core/SkRefCnt.h"
14
+ #include "include/core/SkScalar.h"
15
+ #include "include/core/SkTypes.h"
15
16
  #include "include/private/SkIDChangeListener.h"
16
- #include "include/private/SkMutex.h"
17
- #include "include/private/SkTDArray.h"
18
- #include "include/private/SkTemplates.h"
19
- #include "include/private/SkTo.h"
17
+ #include "include/private/base/SkDebug.h"
18
+ #include "include/private/base/SkTArray.h"
19
+ #include "include/private/base/SkTo.h"
20
20
 
21
21
  #include <atomic>
22
- #include <limits>
22
+ #include <cstddef>
23
+ #include <cstdint>
23
24
  #include <tuple>
25
+ #include <utility>
24
26
 
25
- class SkRBuffer;
26
- class SkWBuffer;
27
+ class SkMatrix;
27
28
  class SkRRect;
28
29
 
29
- enum class SkPathConvexity {
30
- kConvex,
31
- kConcave,
32
- kUnknown,
33
- };
34
-
35
- enum class SkPathFirstDirection {
36
- kCW, // == SkPathDirection::kCW
37
- kCCW, // == SkPathDirection::kCCW
38
- kUnknown,
39
- };
40
-
41
30
  // These are computed from a stream of verbs
42
31
  struct SkPathVerbAnalysis {
43
32
  bool valid;
@@ -64,7 +53,13 @@ SkPathVerbAnalysis sk_path_analyze_verbs(const uint8_t verbs[], int count);
64
53
 
65
54
  class SK_API SkPathRef final : public SkNVRefCnt<SkPathRef> {
66
55
  public:
67
- SkPathRef(SkTDArray<SkPoint> points, SkTDArray<uint8_t> verbs, SkTDArray<SkScalar> weights,
56
+ // See https://bugs.chromium.org/p/skia/issues/detail?id=13817 for how these sizes were
57
+ // determined.
58
+ using PointsArray = skia_private::STArray<4, SkPoint>;
59
+ using VerbsArray = skia_private::STArray<4, uint8_t>;
60
+ using ConicWeightsArray = skia_private::STArray<2, SkScalar>;
61
+
62
+ SkPathRef(PointsArray points, VerbsArray verbs, ConicWeightsArray weights,
68
63
  unsigned segmentMask)
69
64
  : fPoints(std::move(points))
70
65
  , fVerbs(std::move(verbs))
@@ -320,24 +315,15 @@ public:
320
315
 
321
316
  bool operator== (const SkPathRef& ref) const;
322
317
 
323
- /**
324
- * Writes the path points and verbs to a buffer.
325
- */
326
- void writeToBuffer(SkWBuffer* buffer) const;
327
-
328
- /**
329
- * Gets the number of bytes that would be written in writeBuffer()
330
- */
331
- uint32_t writeSize() const;
332
-
333
318
  void interpolate(const SkPathRef& ending, SkScalar weight, SkPathRef* out) const;
334
319
 
335
320
  /**
336
321
  * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the
337
322
  * same ID then they have the same verbs and points. However, two path refs may have the same
338
323
  * contents but different genIDs.
324
+ * skbug.com/1762 for background on why fillType is necessary (for now).
339
325
  */
340
- uint32_t genID() const;
326
+ uint32_t genID(uint8_t fillType) const;
341
327
 
342
328
  void addGenIDChangeListener(sk_sp<SkIDChangeListener>); // Threadsafe.
343
329
  int genIDChangeListenerCount(); // Threadsafe
@@ -346,6 +332,15 @@ public:
346
332
  bool isValid() const;
347
333
  SkDEBUGCODE(void validate() const { SkASSERT(this->isValid()); } )
348
334
 
335
+ /**
336
+ * Resets this SkPathRef to a clean state.
337
+ */
338
+ void reset();
339
+
340
+ bool isInitialEmptyPathRef() const {
341
+ return fGenerationID == kEmptyGenID;
342
+ }
343
+
349
344
  private:
350
345
  enum SerializationOffsets {
351
346
  kLegacyRRectOrOvalStartIdx_SerializationShift = 28, // requires 3 bits, ignored.
@@ -356,7 +351,7 @@ private:
356
351
  kSegmentMask_SerializationShift = 0 // requires 4 bits (deprecated)
357
352
  };
358
353
 
359
- SkPathRef() {
354
+ SkPathRef(int numVerbs = 0, int numPoints = 0) {
360
355
  fBoundsIsDirty = true; // this also invalidates fIsFinite
361
356
  fGenerationID = kEmptyGenID;
362
357
  fSegmentMask = 0;
@@ -365,6 +360,10 @@ private:
365
360
  // The next two values don't matter unless fIsOval or fIsRRect are true.
366
361
  fRRectOrOvalIsCCW = false;
367
362
  fRRectOrOvalStartIdx = 0xAC;
363
+ if (numPoints > 0)
364
+ fPoints.reserve_back(numPoints);
365
+ if (numVerbs > 0)
366
+ fVerbs.reserve_back(numVerbs);
368
367
  SkDEBUGCODE(fEditorsAttached.store(0);)
369
368
  SkDEBUGCODE(this->validate();)
370
369
  }
@@ -397,15 +396,20 @@ private:
397
396
  /** Makes additional room but does not change the counts or change the genID */
398
397
  void incReserve(int additionalVerbs, int additionalPoints) {
399
398
  SkDEBUGCODE(this->validate();)
400
- fPoints.reserve(fPoints.size() + additionalPoints);
401
- fVerbs.reserve(fVerbs.size() + additionalVerbs);
399
+ // Use reserve() so that if there is not enough space, the array will grow with some
400
+ // additional space. This ensures repeated calls to grow won't always allocate.
401
+ if (additionalPoints > 0)
402
+ fPoints.reserve(fPoints.size() + additionalPoints);
403
+ if (additionalVerbs > 0)
404
+ fVerbs.reserve(fVerbs.size() + additionalVerbs);
402
405
  SkDEBUGCODE(this->validate();)
403
406
  }
404
407
 
405
- /** Resets the path ref with verbCount verbs and pointCount points, all uninitialized. Also
406
- * allocates space for reserveVerb additional verbs and reservePoints additional points.*/
407
- void resetToSize(int verbCount, int pointCount, int conicCount,
408
- int reserveVerbs = 0, int reservePoints = 0) {
408
+ /**
409
+ * Resets all state except that of the verbs, points, and conic-weights.
410
+ * Intended to be called from other functions that reset state.
411
+ */
412
+ void commonReset() {
409
413
  SkDEBUGCODE(this->validate();)
410
414
  this->callGenIDChangeListeners();
411
415
  fBoundsIsDirty = true; // this also invalidates fIsFinite
@@ -414,12 +418,25 @@ private:
414
418
  fSegmentMask = 0;
415
419
  fIsOval = false;
416
420
  fIsRRect = false;
421
+ }
417
422
 
418
- fPoints.reserve(pointCount + reservePoints);
419
- fPoints.resize(pointCount);
420
- fVerbs.reserve(verbCount + reserveVerbs);
421
- fVerbs.resize(verbCount);
422
- fConicWeights.resize(conicCount);
423
+ /** Resets the path ref with verbCount verbs and pointCount points, all uninitialized. Also
424
+ * allocates space for reserveVerb additional verbs and reservePoints additional points.*/
425
+ void resetToSize(int verbCount, int pointCount, int conicCount,
426
+ int reserveVerbs = 0, int reservePoints = 0) {
427
+ commonReset();
428
+ // Use reserve_back() so the arrays are sized to exactly fit the data.
429
+ const int pointDelta = pointCount + reservePoints - fPoints.size();
430
+ if (pointDelta > 0) {
431
+ fPoints.reserve_back(pointDelta);
432
+ }
433
+ fPoints.resize_back(pointCount);
434
+ const int verbDelta = verbCount + reserveVerbs - fVerbs.size();
435
+ if (verbDelta > 0) {
436
+ fVerbs.reserve_back(verbDelta);
437
+ }
438
+ fVerbs.resize_back(verbCount);
439
+ fConicWeights.resize_back(conicCount);
423
440
  SkDEBUGCODE(this->validate();)
424
441
  }
425
442
 
@@ -489,9 +506,9 @@ private:
489
506
 
490
507
  mutable SkRect fBounds;
491
508
 
492
- SkTDArray<SkPoint> fPoints;
493
- SkTDArray<uint8_t> fVerbs;
494
- SkTDArray<SkScalar> fConicWeights;
509
+ PointsArray fPoints;
510
+ VerbsArray fVerbs;
511
+ ConicWeightsArray fConicWeights;
495
512
 
496
513
  enum {
497
514
  kEmptyGenID = 1, // GenID reserved for path ref with zero points and zero verbs.
@@ -11,7 +11,7 @@
11
11
  #include <cstdint>
12
12
 
13
13
  #include "include/core/SkTypes.h"
14
- #include "include/private/SkTArray.h"
14
+ #include "include/private/base/SkTArray.h"
15
15
 
16
16
  using SKSL_INT = int64_t;
17
17
  using SKSL_FLOAT = float;
@@ -21,17 +21,17 @@ namespace SkSL {
21
21
  class Expression;
22
22
  class Statement;
23
23
 
24
- using ComponentArray = SkSTArray<4, int8_t>; // for Swizzles
24
+ using ComponentArray = skia_private::STArray<4, int8_t>; // for Swizzles
25
25
 
26
- class ExpressionArray : public SkSTArray<2, std::unique_ptr<Expression>> {
26
+ class ExpressionArray : public skia_private::STArray<2, std::unique_ptr<Expression>> {
27
27
  public:
28
- using SkSTArray::SkSTArray;
28
+ using STArray::STArray;
29
29
 
30
30
  /** Returns a new ExpressionArray containing a clone of every element. */
31
31
  ExpressionArray clone() const;
32
32
  };
33
33
 
34
- using StatementArray = SkSTArray<2, std::unique_ptr<Statement>>;
34
+ using StatementArray = skia_private::STArray<2, std::unique_ptr<Statement>>;
35
35
 
36
36
  // Functions larger than this (measured in IR nodes) will not be inlined. This growth factor
37
37
  // accounts for the number of calls being inlined--i.e., a function called five times (that is, with
@@ -10,8 +10,6 @@
10
10
 
11
11
  #include "include/core/SkTypes.h"
12
12
 
13
- #include <string>
14
-
15
13
  namespace SkSL {
16
14
 
17
15
  /**
@@ -77,8 +75,6 @@ public:
77
75
  bool isUniformMatrix() const { return fKind == Kind::kUniformMatrix; }
78
76
  bool isFragCoord() const { return fKind == Kind::kFragCoord; }
79
77
 
80
- std::string constructor() const;
81
-
82
78
  private:
83
79
  Kind fKind = Kind::kNone;
84
80
  bool fHasPerspective = false; // Only valid if fKind is kUniformMatrix
@@ -9,7 +9,7 @@
9
9
  #define SkSpinlock_DEFINED
10
10
 
11
11
  #include "include/core/SkTypes.h"
12
- #include "include/private/SkThreadAnnotations.h"
12
+ #include "include/private/base/SkThreadAnnotations.h"
13
13
  #include <atomic>
14
14
 
15
15
  class SK_CAPABILITY("mutex") SkSpinlock {
@@ -9,7 +9,10 @@
9
9
  #define SkWeakRefCnt_DEFINED
10
10
 
11
11
  #include "include/core/SkRefCnt.h"
12
+ #include "include/core/SkTypes.h"
13
+
12
14
  #include <atomic>
15
+ #include <cstdint>
13
16
 
14
17
  /** \class SkWeakRefCnt
15
18
 
@@ -8,16 +8,19 @@
8
8
  #ifndef skgpu_SingleOwner_DEFINED
9
9
  #define skgpu_SingleOwner_DEFINED
10
10
 
11
- #include "include/core/SkTypes.h"
11
+ #include "include/private/base/SkDebug.h" // IWYU pragma: keep
12
+
13
+ #if defined(SK_DEBUG)
14
+ #include "include/private/base/SkAssert.h"
15
+ #include "include/private/base/SkMutex.h"
16
+ #include "include/private/base/SkThreadAnnotations.h"
17
+ #include "include/private/base/SkThreadID.h"
12
18
 
13
- #ifdef SK_DEBUG
14
- #include "include/private/SkMutex.h"
15
- #include "include/private/SkThreadID.h"
16
19
  #endif
17
20
 
18
21
  namespace skgpu {
19
22
 
20
- #ifdef SK_DEBUG
23
+ #if defined(SK_DEBUG)
21
24
 
22
25
  #define SKGPU_ASSERT_SINGLE_OWNER(obj) \
23
26
  skgpu::SingleOwner::AutoEnforce debug_SingleOwner(obj, __FILE__, __LINE__);
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Copyright 2022 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkAPI_DEFINED
9
+ #define SkAPI_DEFINED
10
+
11
+ #include "include/private/base/SkLoadUserConfig.h" // IWYU pragma: keep
12
+
13
+ // If SKIA_IMPLEMENTATION is defined as 1, that signals we are building Skia and should
14
+ // export our symbols. If it is not set (or set to 0), then Skia is being used by a client
15
+ // and we should not export our symbols.
16
+ #if !defined(SKIA_IMPLEMENTATION)
17
+ #define SKIA_IMPLEMENTATION 0
18
+ #endif
19
+
20
+ // If we are compiling Skia is being as a DLL, we need to be sure to export all of our public
21
+ // APIs to that DLL. If a client is using Skia which was compiled as a DLL, we need to instruct
22
+ // the linker to use the symbols from that DLL. This is the goal of the SK_API define.
23
+ #if !defined(SK_API)
24
+ #if defined(SKIA_DLL)
25
+ #if defined(_MSC_VER)
26
+ #if SKIA_IMPLEMENTATION
27
+ #define SK_API __declspec(dllexport)
28
+ #else
29
+ #define SK_API __declspec(dllimport)
30
+ #endif
31
+ #else
32
+ #define SK_API __attribute__((visibility("default")))
33
+ #endif
34
+ #else
35
+ #define SK_API
36
+ #endif
37
+ #endif
38
+
39
+ // SK_SPI is functionally identical to SK_API, but used within src to clarify that it's less stable
40
+ #if !defined(SK_SPI)
41
+ #define SK_SPI SK_API
42
+ #endif
43
+
44
+ // See https://clang.llvm.org/docs/AttributeReference.html#availability
45
+ // The API_AVAILABLE macro comes from <os/availability.h> on MacOS
46
+ #if defined(SK_ENABLE_API_AVAILABLE)
47
+ # define SK_API_AVAILABLE API_AVAILABLE
48
+ #else
49
+ # define SK_API_AVAILABLE(...)
50
+ #endif
51
+
52
+ #endif
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright 2022 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkAlign_DEFINED
9
+ #define SkAlign_DEFINED
10
+
11
+ #include "include/private/base/SkAssert.h"
12
+
13
+ #include <cstddef>
14
+
15
+ template <typename T> static constexpr T SkAlign2(T x) { return (x + 1) >> 1 << 1; }
16
+ template <typename T> static constexpr T SkAlign4(T x) { return (x + 3) >> 2 << 2; }
17
+ template <typename T> static constexpr T SkAlign8(T x) { return (x + 7) >> 3 << 3; }
18
+
19
+ template <typename T> static constexpr bool SkIsAlign2(T x) { return 0 == (x & 1); }
20
+ template <typename T> static constexpr bool SkIsAlign4(T x) { return 0 == (x & 3); }
21
+ template <typename T> static constexpr bool SkIsAlign8(T x) { return 0 == (x & 7); }
22
+
23
+ template <typename T> static constexpr T SkAlignPtr(T x) {
24
+ return sizeof(void*) == 8 ? SkAlign8(x) : SkAlign4(x);
25
+ }
26
+ template <typename T> static constexpr bool SkIsAlignPtr(T x) {
27
+ return sizeof(void*) == 8 ? SkIsAlign8(x) : SkIsAlign4(x);
28
+ }
29
+
30
+ /**
31
+ * align up to a power of 2
32
+ */
33
+ static inline constexpr size_t SkAlignTo(size_t x, size_t alignment) {
34
+ // The same as alignment && SkIsPow2(value), w/o a dependency cycle.
35
+ SkASSERT(alignment && (alignment & (alignment - 1)) == 0);
36
+ return (x + alignment - 1) & ~(alignment - 1);
37
+ }
38
+
39
+ #endif
@@ -0,0 +1,32 @@
1
+ // Copyright 2022 Google LLC
2
+ // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3
+
4
+ #ifndef SkAlignedStorage_DEFINED
5
+ #define SkAlignedStorage_DEFINED
6
+
7
+ #include <cstddef>
8
+ #include <iterator>
9
+
10
+ template <int N, typename T> class SkAlignedSTStorage {
11
+ public:
12
+ SkAlignedSTStorage() {}
13
+ SkAlignedSTStorage(SkAlignedSTStorage&&) = delete;
14
+ SkAlignedSTStorage(const SkAlignedSTStorage&) = delete;
15
+ SkAlignedSTStorage& operator=(SkAlignedSTStorage&&) = delete;
16
+ SkAlignedSTStorage& operator=(const SkAlignedSTStorage&) = delete;
17
+
18
+ // Returns void* because this object does not initialize the
19
+ // memory. Use placement new for types that require a constructor.
20
+ void* get() { return fStorage; }
21
+ const void* get() const { return fStorage; }
22
+
23
+ // Act as a container of bytes because the storage is uninitialized.
24
+ std::byte* data() { return fStorage; }
25
+ const std::byte* data() const { return fStorage; }
26
+ size_t size() const { return std::size(fStorage); }
27
+
28
+ private:
29
+ alignas(T) std::byte fStorage[sizeof(T) * N];
30
+ };
31
+
32
+ #endif // SkAlignedStorage_DEFINED
@@ -0,0 +1,92 @@
1
+ /*
2
+ * Copyright 2022 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkAssert_DEFINED
9
+ #define SkAssert_DEFINED
10
+
11
+ #include "include/private/base/SkAPI.h"
12
+ #include "include/private/base/SkDebug.h" // IWYU pragma: keep
13
+
14
+ /** Called internally if we hit an unrecoverable error.
15
+ The platform implementation must not return, but should either throw
16
+ an exception or otherwise exit.
17
+ */
18
+ [[noreturn]] SK_API extern void sk_abort_no_print(void);
19
+
20
+ #if defined(SK_BUILD_FOR_GOOGLE3)
21
+ void SkDebugfForDumpStackTrace(const char* data, void* unused);
22
+ namespace base {
23
+ void DumpStackTrace(int skip_count, void w(const char*, void*), void* arg);
24
+ }
25
+ # define SK_DUMP_GOOGLE3_STACK() ::base::DumpStackTrace(0, SkDebugfForDumpStackTrace, nullptr)
26
+ #else
27
+ # define SK_DUMP_GOOGLE3_STACK()
28
+ #endif
29
+
30
+ #if !defined(SK_ABORT)
31
+ # if defined(SK_BUILD_FOR_WIN)
32
+ // This style lets Visual Studio follow errors back to the source file.
33
+ # define SK_DUMP_LINE_FORMAT "%s(%d)"
34
+ # else
35
+ # define SK_DUMP_LINE_FORMAT "%s:%d"
36
+ # endif
37
+ # define SK_ABORT(message, ...) \
38
+ do { \
39
+ SkDebugf(SK_DUMP_LINE_FORMAT ": fatal error: \"" message "\"\n", \
40
+ __FILE__, __LINE__, ##__VA_ARGS__); \
41
+ SK_DUMP_GOOGLE3_STACK(); \
42
+ sk_abort_no_print(); \
43
+ } while (false)
44
+ #endif
45
+
46
+ // SkASSERT, SkASSERTF and SkASSERT_RELEASE can be used as stand alone assertion expressions, e.g.
47
+ // uint32_t foo(int x) {
48
+ // SkASSERT(x > 4);
49
+ // return x - 4;
50
+ // }
51
+ // and are also written to be compatible with constexpr functions:
52
+ // constexpr uint32_t foo(int x) {
53
+ // return SkASSERT(x > 4),
54
+ // x - 4;
55
+ // }
56
+ #define SkASSERT_RELEASE(cond) \
57
+ static_cast<void>( (cond) ? (void)0 : []{ SK_ABORT("assert(%s)", #cond); }() )
58
+
59
+ #if defined(SK_DEBUG)
60
+ #define SkASSERT(cond) SkASSERT_RELEASE(cond)
61
+ #define SkASSERTF(cond, fmt, ...) static_cast<void>( (cond) ? (void)0 : [&]{ \
62
+ SkDebugf(fmt"\n", ##__VA_ARGS__); \
63
+ SK_ABORT("assert(%s)", #cond); \
64
+ }() )
65
+ #define SkDEBUGFAIL(message) SK_ABORT("%s", message)
66
+ #define SkDEBUGFAILF(fmt, ...) SK_ABORT(fmt, ##__VA_ARGS__)
67
+ #define SkAssertResult(cond) SkASSERT(cond)
68
+ #else
69
+ #define SkASSERT(cond) static_cast<void>(0)
70
+ #define SkASSERTF(cond, fmt, ...) static_cast<void>(0)
71
+ #define SkDEBUGFAIL(message)
72
+ #define SkDEBUGFAILF(fmt, ...)
73
+
74
+ // unlike SkASSERT, this macro executes its condition in the non-debug build.
75
+ // The if is present so that this can be used with functions marked SK_WARN_UNUSED_RESULT.
76
+ #define SkAssertResult(cond) if (cond) {} do {} while(false)
77
+ #endif
78
+
79
+ #if !defined(SkUNREACHABLE)
80
+ # if defined(_MSC_VER) && !defined(__clang__)
81
+ # include <intrin.h>
82
+ # define FAST_FAIL_INVALID_ARG 5
83
+ // See https://developercommunity.visualstudio.com/content/problem/1128631/code-flow-doesnt-see-noreturn-with-extern-c.html
84
+ // for why this is wrapped. Hopefully removable after msvc++ 19.27 is no longer supported.
85
+ [[noreturn]] static inline void sk_fast_fail() { __fastfail(FAST_FAIL_INVALID_ARG); }
86
+ # define SkUNREACHABLE sk_fast_fail()
87
+ # else
88
+ # define SkUNREACHABLE __builtin_trap()
89
+ # endif
90
+ #endif
91
+
92
+ #endif
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Copyright 2022 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkAttributes_DEFINED
9
+ #define SkAttributes_DEFINED
10
+
11
+ #include "include/private/base/SkFeatures.h" // IWYU pragma: keep
12
+ #include "include/private/base/SkLoadUserConfig.h" // IWYU pragma: keep
13
+
14
+ #if defined(__clang__) || defined(__GNUC__)
15
+ # define SK_ATTRIBUTE(attr) __attribute__((attr))
16
+ #else
17
+ # define SK_ATTRIBUTE(attr)
18
+ #endif
19
+
20
+ #if !defined(SK_UNUSED)
21
+ # if !defined(__clang__) && defined(_MSC_VER)
22
+ # define SK_UNUSED __pragma(warning(suppress:4189))
23
+ # else
24
+ # define SK_UNUSED SK_ATTRIBUTE(unused)
25
+ # endif
26
+ #endif
27
+
28
+ #if !defined(SK_WARN_UNUSED_RESULT)
29
+ #define SK_WARN_UNUSED_RESULT SK_ATTRIBUTE(warn_unused_result)
30
+ #endif
31
+
32
+ /**
33
+ * If your judgment is better than the compiler's (i.e. you've profiled it),
34
+ * you can use SK_ALWAYS_INLINE to force inlining. E.g.
35
+ * inline void someMethod() { ... } // may not be inlined
36
+ * SK_ALWAYS_INLINE void someMethod() { ... } // should always be inlined
37
+ */
38
+ #if !defined(SK_ALWAYS_INLINE)
39
+ # if defined(SK_BUILD_FOR_WIN)
40
+ # define SK_ALWAYS_INLINE __forceinline
41
+ # else
42
+ # define SK_ALWAYS_INLINE SK_ATTRIBUTE(always_inline) inline
43
+ # endif
44
+ #endif
45
+
46
+ /**
47
+ * If your judgment is better than the compiler's (i.e. you've profiled it),
48
+ * you can use SK_NEVER_INLINE to prevent inlining.
49
+ */
50
+ #if !defined(SK_NEVER_INLINE)
51
+ # if defined(SK_BUILD_FOR_WIN)
52
+ # define SK_NEVER_INLINE __declspec(noinline)
53
+ # else
54
+ # define SK_NEVER_INLINE SK_ATTRIBUTE(noinline)
55
+ # endif
56
+ #endif
57
+
58
+ /**
59
+ * Used to annotate a function as taking printf style arguments.
60
+ * `A` is the (1 based) index of the format string argument.
61
+ * `B` is the (1 based) index of the first argument used by the format string.
62
+ */
63
+ #if !defined(SK_PRINTF_LIKE)
64
+ # define SK_PRINTF_LIKE(A, B) SK_ATTRIBUTE(format(printf, (A), (B)))
65
+ #endif
66
+
67
+ /**
68
+ * Used to ignore sanitizer warnings.
69
+ */
70
+ #if !defined(SK_NO_SANITIZE)
71
+ # define SK_NO_SANITIZE(A) SK_ATTRIBUTE(no_sanitize(A))
72
+ #endif
73
+
74
+ /**
75
+ * Helper macro to define no_sanitize attributes only with clang.
76
+ */
77
+ #if defined(__clang__) && defined(__has_attribute)
78
+ #if __has_attribute(no_sanitize)
79
+ #define SK_CLANG_NO_SANITIZE(A) SK_NO_SANITIZE(A)
80
+ #endif
81
+ #endif
82
+
83
+ #if !defined(SK_CLANG_NO_SANITIZE)
84
+ #define SK_CLANG_NO_SANITIZE(A)
85
+ #endif
86
+
87
+ /**
88
+ * Annotates a class' non-trivial special functions as trivial for the purposes of calls.
89
+ * Allows a class with a non-trivial destructor to be __is_trivially_relocatable.
90
+ * Use of this attribute on a public API breaks platform ABI.
91
+ * Annotated classes may not hold pointers derived from `this`.
92
+ * Annotated classes must implement move+delete as equivalent to memcpy+free.
93
+ * Use may require more complete types, as callee destroys.
94
+ *
95
+ * https://clang.llvm.org/docs/AttributeReference.html#trivial-abi
96
+ * https://libcxx.llvm.org/DesignDocs/UniquePtrTrivialAbi.html
97
+ */
98
+ #if !defined(SK_TRIVIAL_ABI)
99
+ # define SK_TRIVIAL_ABI
100
+ #endif
101
+
102
+ #endif
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+ #ifndef SkCPUTypes_DEFINED
8
+ #define SkCPUTypes_DEFINED
9
+
10
+ // TODO(bungeman,kjlubick) There are a lot of assumptions throughout the codebase that
11
+ // these types are 32 bits, when they could be more or less. Public APIs should stop
12
+ // using these. Internally, we could use uint_fast8_t and uint_fast16_t, but not in
13
+ // public APIs due to ABI incompatibilities.
14
+
15
+ /** Fast type for unsigned 8 bits. Use for parameter passing and local
16
+ variables, not for storage
17
+ */
18
+ typedef unsigned U8CPU;
19
+
20
+ /** Fast type for unsigned 16 bits. Use for parameter passing and local
21
+ variables, not for storage
22
+ */
23
+ typedef unsigned U16CPU;
24
+
25
+ #endif
@@ -0,0 +1,46 @@
1
+ // Copyright 2022 Google LLC.
2
+ // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3
+
4
+ #ifndef SkContainers_DEFINED
5
+ #define SkContainers_DEFINED
6
+
7
+ #include "include/private/base/SkAPI.h"
8
+ #include "include/private/base/SkSpan_impl.h"
9
+
10
+ #include <cstddef>
11
+ #include <cstdint>
12
+
13
+ class SK_SPI SkContainerAllocator {
14
+ public:
15
+ SkContainerAllocator(size_t sizeOfT, int maxCapacity)
16
+ : fSizeOfT{sizeOfT}
17
+ , fMaxCapacity{maxCapacity} {}
18
+
19
+ // allocate will abort on failure. Given a capacity of 0, it will return the empty span.
20
+ // The bytes allocated are freed using sk_free().
21
+ SkSpan<std::byte> allocate(int capacity, double growthFactor = 1.0);
22
+
23
+ private:
24
+ friend struct SkContainerAllocatorTestingPeer;
25
+ // All capacity counts will be rounded up to kCapacityMultiple.
26
+ // TODO: this is a constant from the original SkTArray code. This should be checked some how.
27
+ static constexpr int64_t kCapacityMultiple = 8;
28
+
29
+ // Rounds up capacity to next multiple of kCapacityMultiple and pin to fMaxCapacity.
30
+ size_t roundUpCapacity(int64_t capacity) const;
31
+
32
+ // Grows the capacity by growthFactor being sure to stay with in kMinBytes and fMaxCapacity.
33
+ size_t growthFactorCapacity(int capacity, double growthFactor) const;
34
+
35
+ const size_t fSizeOfT;
36
+ const int64_t fMaxCapacity;
37
+ };
38
+
39
+ // sk_allocate_canfail returns the empty span on failure. Parameter size must be > 0.
40
+ SkSpan<std::byte> sk_allocate_canfail(size_t size);
41
+
42
+ // Returns the empty span if size is 0. sk_allocate_throw aborts on failure.
43
+ SkSpan<std::byte> sk_allocate_throw(size_t size);
44
+
45
+ SK_SPI void sk_report_container_overflow_and_die();
46
+ #endif // SkContainers_DEFINED