@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,21 +8,18 @@
8
8
  #ifndef SkTDArray_DEFINED
9
9
  #define SkTDArray_DEFINED
10
10
 
11
- #include "include/core/SkTypes.h"
12
- #include "include/private/SkMalloc.h"
13
- #include "include/private/SkTo.h"
11
+ #include "include/private/base/SkAPI.h"
12
+ #include "include/private/base/SkAssert.h"
13
+ #include "include/private/base/SkTo.h"
14
14
 
15
15
  #include <algorithm>
16
16
  #include <cstddef>
17
- #include <climits>
18
17
  #include <initializer_list>
19
- #include <tuple>
20
- #include <utility>
21
18
 
22
19
  class SK_SPI SkTDStorage {
23
20
  public:
24
21
  explicit SkTDStorage(int sizeOfT);
25
- SkTDStorage(const void* src, int count, int sizeOfT);
22
+ SkTDStorage(const void* src, int size, int sizeOfT);
26
23
 
27
24
  // Copy
28
25
  SkTDStorage(const SkTDStorage& that);
@@ -38,15 +35,15 @@ public:
38
35
  void swap(SkTDStorage& that);
39
36
 
40
37
  // Size routines
41
- bool empty() const { return fCount == 0; }
42
- void clear() { fCount = 0; }
43
- int size() const { return fCount; }
44
- void resize(int newCount);
45
- size_t size_bytes() const { return this->bytes(fCount); }
38
+ bool empty() const { return fSize == 0; }
39
+ void clear() { fSize = 0; }
40
+ int size() const { return fSize; }
41
+ void resize(int newSize);
42
+ size_t size_bytes() const { return this->bytes(fSize); }
46
43
 
47
44
  // Capacity routines
48
- int capacity() const { return fReserve; }
49
- void reserve(int newReserve);
45
+ int capacity() const { return fCapacity; }
46
+ void reserve(int newCapacity);
50
47
  void shrink_to_fit();
51
48
 
52
49
  void* data() { return fStorage; }
@@ -68,8 +65,8 @@ public:
68
65
  void* insert(int index, int count, const void* src);
69
66
 
70
67
  void pop_back() {
71
- SkASSERT(fCount > 0);
72
- fCount--;
68
+ SkASSERT(fSize > 0);
69
+ fSize--;
73
70
  }
74
71
 
75
72
  friend bool operator==(const SkTDStorage& a, const SkTDStorage& b);
@@ -81,7 +78,7 @@ private:
81
78
  size_t bytes(int n) const { return SkToSizeT(n * fSizeOfT); }
82
79
  void* address(int n) { return fStorage + this->bytes(n); }
83
80
 
84
- // Adds delta to fCount. Crash if outside [0, INT_MAX]
81
+ // Adds delta to fSize. Crash if outside [0, INT_MAX]
85
82
  int calculateSizeOrDie(int delta);
86
83
 
87
84
  // Move the tail of the array defined by the indexes tailStart and tailEnd to dstIndex. The
@@ -93,8 +90,8 @@ private:
93
90
 
94
91
  const int fSizeOfT;
95
92
  std::byte* fStorage{nullptr};
96
- int fReserve{0}; // size of the allocation in fArray (#elements)
97
- int fCount{0}; // logical number of elements (fCount <= fReserve)
93
+ int fCapacity{0}; // size of the allocation in fArray (#elements)
94
+ int fSize{0}; // logical number of elements (fSize <= fCapacity)
98
95
  };
99
96
 
100
97
  static inline void swap(SkTDStorage& a, SkTDStorage& b) {
@@ -188,7 +185,7 @@ public:
188
185
  fStorage.resize(count);
189
186
  }
190
187
 
191
- void reserve(size_t n) {
188
+ void reserve(int n) {
192
189
  fStorage.reserve(n);
193
190
  }
194
191
 
@@ -219,18 +216,6 @@ public:
219
216
  fStorage.removeShuffle(index);
220
217
  }
221
218
 
222
- int find(const T& elem) const {
223
- const T* iter = this->begin();
224
- const T* stop = this->end();
225
-
226
- for (; iter < stop; iter++) {
227
- if (*iter == elem) {
228
- return SkToInt(iter - this->begin());
229
- }
230
- }
231
- return -1;
232
- }
233
-
234
219
  // routines to treat the array like a stack
235
220
  void push_back(const T& v) {
236
221
  this->append();
@@ -238,28 +223,6 @@ public:
238
223
  }
239
224
  void pop_back() { fStorage.pop_back(); }
240
225
 
241
- void deleteAll() {
242
- for (T p : *this) {
243
- delete p;
244
- }
245
- this->reset();
246
- }
247
-
248
- void freeAll() {
249
- for (T p : *this) {
250
- sk_free(p);
251
- }
252
-
253
- this->reset();
254
- }
255
-
256
- void unrefAll() {
257
- for (T p : *this) {
258
- p->unref();
259
- }
260
- this->reset();
261
- }
262
-
263
226
  void shrink_to_fit() {
264
227
  fStorage.shrink_to_fit();
265
228
  }
@@ -8,8 +8,10 @@
8
8
  #ifndef SkTFitsIn_DEFINED
9
9
  #define SkTFitsIn_DEFINED
10
10
 
11
+ #include "include/private/base/SkDebug.h"
12
+
13
+ #include <cstdint>
11
14
  #include <limits>
12
- #include <stdint.h>
13
15
  #include <type_traits>
14
16
 
15
17
  /**
@@ -71,28 +73,32 @@ static constexpr inline
71
73
  typename std::enable_if<(std::is_integral<S>::value || std::is_enum<S>::value) &&
72
74
  (std::is_integral<D>::value || std::is_enum<D>::value), bool>::type
73
75
  /*bool*/ SkTFitsIn(S src) {
76
+ // Ensure that is_signed and is_unsigned are passed the arithmetic underlyng types of enums.
77
+ using Sa = typename sk_strip_enum<S>::type;
78
+ using Da = typename sk_strip_enum<D>::type;
79
+
74
80
  // SkTFitsIn() is used in public headers, so needs to be written targeting at most C++11.
75
81
  return
76
82
 
77
83
  // E.g. (int8_t)(uint8_t) int8_t(-1) == -1, but the uint8_t == 255, not -1.
78
- (std::is_signed<S>::value && std::is_unsigned<D>::value && sizeof(S) <= sizeof(D)) ?
84
+ (std::is_signed<Sa>::value && std::is_unsigned<Da>::value && sizeof(Sa) <= sizeof(Da)) ?
79
85
  (S)0 <= src :
80
86
 
81
87
  // E.g. (uint8_t)(int8_t) uint8_t(255) == 255, but the int8_t == -1.
82
- (std::is_signed<D>::value && std::is_unsigned<S>::value && sizeof(D) <= sizeof(S)) ?
83
- src <= (S)std::numeric_limits<typename sk_strip_enum<D>::type>::max() :
88
+ (std::is_signed<Da>::value && std::is_unsigned<Sa>::value && sizeof(Da) <= sizeof(Sa)) ?
89
+ src <= (S)std::numeric_limits<Da>::max() :
84
90
 
85
91
  #if !defined(SK_DEBUG) && !defined(__MSVC_RUNTIME_CHECKS )
86
92
  // Correct (simple) version. This trips up MSVC's /RTCc run-time checking.
87
93
  (S)(D)src == src;
88
94
  #else
89
95
  // More complex version that's safe with /RTCc. Used in all debug builds, for coverage.
90
- (std::is_signed<S>::value) ?
91
- (intmax_t)src >= (intmax_t)std::numeric_limits<typename sk_strip_enum<D>::type>::min() &&
92
- (intmax_t)src <= (intmax_t)std::numeric_limits<typename sk_strip_enum<D>::type>::max() :
96
+ (std::is_signed<Sa>::value) ?
97
+ (intmax_t)src >= (intmax_t)std::numeric_limits<Da>::min() &&
98
+ (intmax_t)src <= (intmax_t)std::numeric_limits<Da>::max() :
93
99
 
94
100
  // std::is_unsigned<S> ?
95
- (uintmax_t)src <= (uintmax_t)std::numeric_limits<typename sk_strip_enum<D>::type>::max();
101
+ (uintmax_t)src <= (uintmax_t)std::numeric_limits<Da>::max();
96
102
  #endif
97
103
  }
98
104
 
@@ -14,7 +14,7 @@
14
14
 
15
15
  #include <iterator>
16
16
  #include <type_traits>
17
- #include "include/private/SkTo.h"
17
+ #include "include/private/base/SkTo.h"
18
18
 
19
19
  // The sknonstd namespace contains things we would like to be proposed and feel std-ish.
20
20
  namespace sknonstd {
@@ -8,18 +8,21 @@
8
8
  #ifndef SkTemplates_DEFINED
9
9
  #define SkTemplates_DEFINED
10
10
 
11
- #include "include/core/SkTypes.h"
12
- #include "include/private/SkMalloc.h"
13
- #include "include/private/SkTLogic.h"
11
+ #include "include/private/base/SkAlign.h"
12
+ #include "include/private/base/SkAssert.h"
13
+ #include "include/private/base/SkDebug.h"
14
+ #include "include/private/base/SkMalloc.h"
15
+ #include "include/private/base/SkTLogic.h"
14
16
 
15
- #include <string.h>
16
17
  #include <array>
17
18
  #include <cstddef>
19
+ #include <cstdint>
20
+ #include <cstring>
18
21
  #include <memory>
19
- #include <new>
20
22
  #include <type_traits>
21
23
  #include <utility>
22
24
 
25
+
23
26
  /** \file SkTemplates.h
24
27
 
25
28
  This file contains light-weight template classes for type-safe and exception-safe
@@ -32,6 +35,17 @@
32
35
  */
33
36
  template<typename T> inline void sk_ignore_unused_variable(const T&) { }
34
37
 
38
+ /**
39
+ * This is a general purpose absolute-value function.
40
+ * See SkAbs32 in (SkSafe32.h) for a 32-bit int specific version that asserts.
41
+ */
42
+ template <typename T> static inline T SkTAbs(T value) {
43
+ if (value < 0) {
44
+ value = -value;
45
+ }
46
+ return value;
47
+ }
48
+
35
49
  /**
36
50
  * Returns a pointer to a D which comes immediately after S[count].
37
51
  */
@@ -48,14 +62,16 @@ template <typename D, typename S> inline D* SkTAddOffset(S* ptr, ptrdiff_t byteO
48
62
  return reinterpret_cast<D*>(reinterpret_cast<sknonstd::same_cv_t<char, D>*>(ptr) + byteOffset);
49
63
  }
50
64
 
51
- // TODO: when C++17 the language is available, use template <auto P>
52
- template <typename T, T* P> struct SkFunctionWrapper {
65
+ template <typename T, T* P> struct SkOverloadedFunctionObject {
53
66
  template <typename... Args>
54
67
  auto operator()(Args&&... args) const -> decltype(P(std::forward<Args>(args)...)) {
55
68
  return P(std::forward<Args>(args)...);
56
69
  }
57
70
  };
58
71
 
72
+ template <auto F> using SkFunctionObject =
73
+ SkOverloadedFunctionObject<std::remove_pointer_t<decltype(F)>, F>;
74
+
59
75
  /** \class SkAutoTCallVProc
60
76
 
61
77
  Call a function when this goes out of scope. The template uses two
@@ -65,8 +81,8 @@ template <typename T, T* P> struct SkFunctionWrapper {
65
81
  function.
66
82
  */
67
83
  template <typename T, void (*P)(T*)> class SkAutoTCallVProc
68
- : public std::unique_ptr<T, SkFunctionWrapper<std::remove_pointer_t<decltype(P)>, P>> {
69
- using inherited = std::unique_ptr<T, SkFunctionWrapper<std::remove_pointer_t<decltype(P)>, P>>;
84
+ : public std::unique_ptr<T, SkFunctionObject<P>> {
85
+ using inherited = std::unique_ptr<T, SkFunctionObject<P>>;
70
86
  public:
71
87
  using inherited::inherited;
72
88
  SkAutoTCallVProc(const SkAutoTCallVProc&) = delete;
@@ -75,14 +91,16 @@ public:
75
91
  operator T*() const { return this->get(); }
76
92
  };
77
93
 
94
+
95
+ namespace skia_private {
78
96
  /** Allocate an array of T elements, and free the array in the destructor
79
97
  */
80
- template <typename T> class SkAutoTArray {
98
+ template <typename T> class AutoTArray {
81
99
  public:
82
- SkAutoTArray() {}
100
+ AutoTArray() {}
83
101
  /** Allocate count number of T elements
84
102
  */
85
- explicit SkAutoTArray(int count) {
103
+ explicit AutoTArray(int count) {
86
104
  SkASSERT(count >= 0);
87
105
  if (count) {
88
106
  fArray.reset(new T[count]);
@@ -90,10 +108,10 @@ public:
90
108
  SkDEBUGCODE(fCount = count;)
91
109
  }
92
110
 
93
- SkAutoTArray(SkAutoTArray&& other) : fArray(std::move(other.fArray)) {
111
+ AutoTArray(AutoTArray&& other) : fArray(std::move(other.fArray)) {
94
112
  SkDEBUGCODE(fCount = other.fCount; other.fCount = 0;)
95
113
  }
96
- SkAutoTArray& operator=(SkAutoTArray&& other) {
114
+ AutoTArray& operator=(AutoTArray&& other) {
97
115
  if (this != &other) {
98
116
  fArray = std::move(other.fArray);
99
117
  SkDEBUGCODE(fCount = other.fCount; other.fCount = 0;)
@@ -103,7 +121,7 @@ public:
103
121
 
104
122
  /** Reallocates given a new count. Reallocation occurs even if new count equals old count.
105
123
  */
106
- void reset(int count = 0) { *this = SkAutoTArray(count); }
124
+ void reset(int count = 0) { *this = AutoTArray(count); }
107
125
 
108
126
  /** Return the array of T elements. Will be NULL if count == 0
109
127
  */
@@ -125,30 +143,30 @@ private:
125
143
  SkDEBUGCODE(int fCount = 0;)
126
144
  };
127
145
 
128
- /** Wraps SkAutoTArray, with room for kCountRequested elements preallocated.
146
+ /** Wraps AutoTArray, with room for kCountRequested elements preallocated.
129
147
  */
130
- template <int kCountRequested, typename T> class SkAutoSTArray {
148
+ template <int kCountRequested, typename T> class AutoSTArray {
131
149
  public:
132
- SkAutoSTArray(SkAutoSTArray&&) = delete;
133
- SkAutoSTArray(const SkAutoSTArray&) = delete;
134
- SkAutoSTArray& operator=(SkAutoSTArray&&) = delete;
135
- SkAutoSTArray& operator=(const SkAutoSTArray&) = delete;
150
+ AutoSTArray(AutoSTArray&&) = delete;
151
+ AutoSTArray(const AutoSTArray&) = delete;
152
+ AutoSTArray& operator=(AutoSTArray&&) = delete;
153
+ AutoSTArray& operator=(const AutoSTArray&) = delete;
136
154
 
137
155
  /** Initialize with no objects */
138
- SkAutoSTArray() {
156
+ AutoSTArray() {
139
157
  fArray = nullptr;
140
158
  fCount = 0;
141
159
  }
142
160
 
143
161
  /** Allocate count number of T elements
144
162
  */
145
- SkAutoSTArray(int count) {
163
+ AutoSTArray(int count) {
146
164
  fArray = nullptr;
147
165
  fCount = 0;
148
166
  this->reset(count);
149
167
  }
150
168
 
151
- ~SkAutoSTArray() {
169
+ ~AutoSTArray() {
152
170
  this->reset(0);
153
171
  }
154
172
 
@@ -216,8 +234,8 @@ public:
216
234
 
217
235
  private:
218
236
  #if defined(SK_BUILD_FOR_GOOGLE3)
219
- // Stack frame size is limited for SK_BUILD_FOR_GOOGLE3. 4k is less than the actual max, but some functions
220
- // have multiple large stack allocations.
237
+ // Stack frame size is limited for SK_BUILD_FOR_GOOGLE3. 4k is less than the actual max,
238
+ // but some functions have multiple large stack allocations.
221
239
  static const int kMaxBytes = 4 * 1024;
222
240
  static const int kCount = kCountRequested * sizeof(T) > kMaxBytes
223
241
  ? kMaxBytes / sizeof(T)
@@ -226,10 +244,9 @@ private:
226
244
  static const int kCount = kCountRequested;
227
245
  #endif
228
246
 
229
- int fCount;
230
- T* fArray;
231
- // since we come right after fArray, fStorage should be properly aligned
232
- char fStorage[kCount * sizeof(T)];
247
+ int fCount;
248
+ T* fArray;
249
+ alignas(T) char fStorage[kCount * sizeof(T)];
233
250
  };
234
251
 
235
252
  /** Manages an array of T elements, freeing the array in the destructor.
@@ -238,17 +255,17 @@ private:
238
255
  template <typename T,
239
256
  typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value &&
240
257
  std::is_trivially_destructible<T>::value>>
241
- class SkAutoTMalloc {
258
+ class AutoTMalloc {
242
259
  public:
243
260
  /** Takes ownership of the ptr. The ptr must be a value which can be passed to sk_free. */
244
- explicit SkAutoTMalloc(T* ptr = nullptr) : fPtr(ptr) {}
261
+ explicit AutoTMalloc(T* ptr = nullptr) : fPtr(ptr) {}
245
262
 
246
263
  /** Allocates space for 'count' Ts. */
247
- explicit SkAutoTMalloc(size_t count)
264
+ explicit AutoTMalloc(size_t count)
248
265
  : fPtr(count ? (T*)sk_malloc_throw(count, sizeof(T)) : nullptr) {}
249
266
 
250
- SkAutoTMalloc(SkAutoTMalloc&&) = default;
251
- SkAutoTMalloc& operator=(SkAutoTMalloc&&) = default;
267
+ AutoTMalloc(AutoTMalloc&&) = default;
268
+ AutoTMalloc& operator=(AutoTMalloc&&) = default;
252
269
 
253
270
  /** Resize the memory area pointed to by the current ptr preserving contents. */
254
271
  void realloc(size_t count) {
@@ -283,18 +300,18 @@ public:
283
300
  T* release() { return fPtr.release(); }
284
301
 
285
302
  private:
286
- std::unique_ptr<T, SkFunctionWrapper<void(void*), sk_free>> fPtr;
303
+ std::unique_ptr<T, SkOverloadedFunctionObject<void(void*), sk_free>> fPtr;
287
304
  };
288
305
 
289
306
  template <size_t kCountRequested,
290
307
  typename T,
291
308
  typename = std::enable_if_t<std::is_trivially_default_constructible<T>::value &&
292
309
  std::is_trivially_destructible<T>::value>>
293
- class SkAutoSTMalloc {
310
+ class AutoSTMalloc {
294
311
  public:
295
- SkAutoSTMalloc() : fPtr(fTStorage) {}
312
+ AutoSTMalloc() : fPtr(fTStorage) {}
296
313
 
297
- SkAutoSTMalloc(size_t count) {
314
+ AutoSTMalloc(size_t count) {
298
315
  if (count > kCount) {
299
316
  fPtr = (T*)sk_malloc_throw(count, sizeof(T));
300
317
  } else if (count) {
@@ -304,12 +321,12 @@ public:
304
321
  }
305
322
  }
306
323
 
307
- SkAutoSTMalloc(SkAutoSTMalloc&&) = delete;
308
- SkAutoSTMalloc(const SkAutoSTMalloc&) = delete;
309
- SkAutoSTMalloc& operator=(SkAutoSTMalloc&&) = delete;
310
- SkAutoSTMalloc& operator=(const SkAutoSTMalloc&) = delete;
324
+ AutoSTMalloc(AutoSTMalloc&&) = delete;
325
+ AutoSTMalloc(const AutoSTMalloc&) = delete;
326
+ AutoSTMalloc& operator=(AutoSTMalloc&&) = delete;
327
+ AutoSTMalloc& operator=(const AutoSTMalloc&) = delete;
311
328
 
312
- ~SkAutoSTMalloc() {
329
+ ~AutoSTMalloc() {
313
330
  if (fPtr != fTStorage) {
314
331
  sk_free(fPtr);
315
332
  }
@@ -391,27 +408,9 @@ private:
391
408
  };
392
409
  };
393
410
 
394
- //////////////////////////////////////////////////////////////////////////////////////////////////
411
+ using UniqueVoidPtr = std::unique_ptr<void, SkOverloadedFunctionObject<void(void*), sk_free>>;
395
412
 
396
- template <int N, typename T> class SkAlignedSTStorage {
397
- public:
398
- SkAlignedSTStorage() {}
399
- SkAlignedSTStorage(SkAlignedSTStorage&&) = delete;
400
- SkAlignedSTStorage(const SkAlignedSTStorage&) = delete;
401
- SkAlignedSTStorage& operator=(SkAlignedSTStorage&&) = delete;
402
- SkAlignedSTStorage& operator=(const SkAlignedSTStorage&) = delete;
403
-
404
- /**
405
- * Returns void* because this object does not initialize the
406
- * memory. Use placement new for types that require a constructor.
407
- */
408
- void* get() { return fStorage; }
409
- const void* get() const { return fStorage; }
410
- private:
411
- alignas(T) char fStorage[sizeof(T)*N];
412
- };
413
-
414
- using SkAutoFree = std::unique_ptr<void, SkFunctionWrapper<void(void*), sk_free>>;
413
+ } // namespace skia_private
415
414
 
416
415
  template<typename C, std::size_t... Is>
417
416
  constexpr auto SkMakeArrayFromIndexSequence(C c, std::index_sequence<Is...> is)
@@ -424,28 +423,4 @@ template<size_t N, typename C> constexpr auto SkMakeArray(C c)
424
423
  return SkMakeArrayFromIndexSequence(c, std::make_index_sequence<N>{});
425
424
  }
426
425
 
427
- /**
428
- * Trait for identifying types which are relocatable via memcpy, for container optimizations.
429
- *
430
- */
431
- template<typename, typename = void>
432
- struct sk_has_trivially_relocatable_member : std::false_type {};
433
-
434
- // Types can declare themselves trivially relocatable with a public
435
- // using sk_is_trivially_relocatable = std::true_type;
436
- template<typename T>
437
- struct sk_has_trivially_relocatable_member<T, std::void_t<typename T::sk_is_trivially_relocatable>>
438
- : T::sk_is_trivially_relocatable {};
439
-
440
- // By default, all trivially copyable types are trivially relocatable.
441
- template <typename T>
442
- struct sk_is_trivially_relocatable
443
- : std::disjunction<std::is_trivially_copyable<T>, sk_has_trivially_relocatable_member<T>
444
- >{};
445
-
446
- // Here be some dragons: while technically not guaranteed, we count on all sane unique_ptr
447
- // implementations to be trivially relocatable.
448
- template <typename T>
449
- struct sk_is_trivially_relocatable<std::unique_ptr<T>> : std::true_type {};
450
-
451
426
  #endif
@@ -8,11 +8,14 @@
8
8
  #ifndef SkThreadID_DEFINED
9
9
  #define SkThreadID_DEFINED
10
10
 
11
- #include "include/core/SkTypes.h"
11
+ #include "include/private/base/SkAPI.h"
12
+ #include "include/private/base/SkDebug.h"
13
+
14
+ #include <cstdint>
12
15
 
13
16
  typedef int64_t SkThreadID;
14
17
 
15
- // SkMutex.h uses SkGetThredID in debug only code.
18
+ // SkMutex.h uses SkGetThreadID in debug only code.
16
19
  SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID();
17
20
 
18
21
  const SkThreadID kIllegalThreadID = 0;
@@ -7,8 +7,11 @@
7
7
  #ifndef SkTo_DEFINED
8
8
  #define SkTo_DEFINED
9
9
 
10
- #include "include/core/SkTypes.h"
11
- #include "include/private/SkTFitsIn.h"
10
+ #include "include/private/base/SkAssert.h"
11
+ #include "include/private/base/SkTFitsIn.h"
12
+
13
+ #include <cstddef>
14
+ #include <cstdint>
12
15
 
13
16
  template <typename D, typename S> constexpr D SkTo(S s) {
14
17
  return SkASSERT(SkTFitsIn<D>(s)),
@@ -21,8 +24,16 @@ template <typename S> constexpr int16_t SkToS16(S x) { return SkTo<int16_t>(x
21
24
  template <typename S> constexpr uint16_t SkToU16(S x) { return SkTo<uint16_t>(x); }
22
25
  template <typename S> constexpr int32_t SkToS32(S x) { return SkTo<int32_t>(x); }
23
26
  template <typename S> constexpr uint32_t SkToU32(S x) { return SkTo<uint32_t>(x); }
27
+ template <typename S> constexpr int64_t SkToS64(S x) { return SkTo<int64_t>(x); }
28
+ template <typename S> constexpr uint64_t SkToU64(S x) { return SkTo<uint64_t>(x); }
24
29
  template <typename S> constexpr int SkToInt(S x) { return SkTo<int>(x); }
25
30
  template <typename S> constexpr unsigned SkToUInt(S x) { return SkTo<unsigned>(x); }
26
31
  template <typename S> constexpr size_t SkToSizeT(S x) { return SkTo<size_t>(x); }
27
32
 
33
+ /** @return false or true based on the condition
34
+ */
35
+ template <typename T> static constexpr bool SkToBool(const T& x) {
36
+ return (bool)x;
37
+ }
38
+
28
39
  #endif // SkTo_DEFINED
@@ -0,0 +1,33 @@
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 SkTypeTraits_DEFINED
5
+ #define SkTypeTraits_DEFINED
6
+
7
+ #include <memory>
8
+ #include <type_traits>
9
+
10
+ // Trait for identifying types which are relocatable via memcpy, for container optimizations.
11
+ template<typename, typename = void>
12
+ struct sk_has_trivially_relocatable_member : std::false_type {};
13
+
14
+ // Types can declare themselves trivially relocatable with a public
15
+ // using sk_is_trivially_relocatable = std::true_type;
16
+ template<typename T>
17
+ struct sk_has_trivially_relocatable_member<T, std::void_t<typename T::sk_is_trivially_relocatable>>
18
+ : T::sk_is_trivially_relocatable {};
19
+
20
+ // By default, all trivially copyable types are trivially relocatable.
21
+ template <typename T>
22
+ struct sk_is_trivially_relocatable
23
+ : std::disjunction<std::is_trivially_copyable<T>, sk_has_trivially_relocatable_member<T>>{};
24
+
25
+ // Here be some dragons: while technically not guaranteed, we count on all sane unique_ptr
26
+ // implementations to be trivially relocatable.
27
+ template <typename T>
28
+ struct sk_is_trivially_relocatable<std::unique_ptr<T>> : std::true_type {};
29
+
30
+ template <typename T>
31
+ inline constexpr bool sk_is_trivially_relocatable_v = sk_is_trivially_relocatable<T>::value;
32
+
33
+ #endif // SkTypeTraits_DEFINED