@shopify/react-native-skia 0.1.196 → 0.1.199

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. package/android/CMakeLists.txt +32 -31
  2. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +4 -2
  3. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -0
  4. package/cpp/api/JsiSkImage.h +1 -1
  5. package/cpp/api/JsiSkShaderFactory.h +4 -4
  6. package/cpp/api/JsiSkSurface.h +0 -1
  7. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  8. package/cpp/rnskia/RNSkView.h +20 -40
  9. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +2 -2
  10. package/cpp/rnskia/values/RNSkReadonlyValue.h +6 -7
  11. package/cpp/skia/include/android/SkCanvasAndroid.h +20 -0
  12. package/cpp/skia/include/android/SkHeifDecoder.h +43 -0
  13. package/cpp/skia/include/android/SkSurfaceAndroid.h +50 -0
  14. package/cpp/skia/include/codec/SkAvifDecoder.h +43 -0
  15. package/cpp/skia/include/codec/SkBmpDecoder.h +43 -0
  16. package/cpp/skia/include/codec/SkCodec.h +25 -1
  17. package/cpp/skia/include/codec/SkGifDecoder.h +43 -0
  18. package/cpp/skia/include/codec/SkIcoDecoder.h +43 -0
  19. package/cpp/skia/include/codec/SkJpegDecoder.h +43 -0
  20. package/cpp/skia/include/codec/SkJpegxlDecoder.h +43 -0
  21. package/cpp/skia/include/codec/SkPngDecoder.h +43 -0
  22. package/cpp/skia/include/codec/SkRawDecoder.h +49 -0
  23. package/cpp/skia/include/codec/SkWbmpDecoder.h +43 -0
  24. package/cpp/skia/include/codec/SkWebpDecoder.h +43 -0
  25. package/cpp/skia/include/core/SkBBHFactory.h +5 -1
  26. package/cpp/skia/include/core/SkBlender.h +0 -2
  27. package/cpp/skia/include/core/SkCanvas.h +4 -23
  28. package/cpp/skia/include/core/SkColorFilter.h +14 -1
  29. package/cpp/skia/include/core/SkColorTable.h +59 -0
  30. package/cpp/skia/include/core/SkContourMeasure.h +3 -0
  31. package/cpp/skia/include/core/SkDeferredDisplayList.h +8 -104
  32. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +8 -91
  33. package/cpp/skia/include/core/SkDrawable.h +5 -2
  34. package/cpp/skia/include/core/SkGraphics.h +7 -19
  35. package/cpp/skia/include/core/SkImage.h +157 -249
  36. package/cpp/skia/include/core/SkImageGenerator.h +0 -31
  37. package/cpp/skia/include/core/SkMilestone.h +1 -1
  38. package/cpp/skia/include/core/SkPathMeasure.h +3 -3
  39. package/cpp/skia/include/core/SkPictureRecorder.h +1 -1
  40. package/cpp/skia/include/core/SkPoint.h +5 -563
  41. package/cpp/skia/include/core/SkPoint3.h +1 -0
  42. package/cpp/skia/include/core/SkPromiseImageTexture.h +4 -30
  43. package/cpp/skia/include/core/SkRect.h +8 -8
  44. package/cpp/skia/include/core/SkSamplingOptions.h +4 -2
  45. package/cpp/skia/include/core/SkScalar.h +1 -1
  46. package/cpp/skia/include/core/SkSerialProcs.h +5 -1
  47. package/cpp/skia/include/core/SkShader.h +14 -21
  48. package/cpp/skia/include/core/SkString.h +2 -0
  49. package/cpp/skia/include/core/SkSurface.h +169 -701
  50. package/cpp/skia/include/core/SkSurfaceCharacterization.h +8 -256
  51. package/cpp/skia/include/core/SkTiledImageUtils.h +97 -0
  52. package/cpp/skia/include/core/SkTypes.h +4 -2
  53. package/cpp/skia/include/core/SkYUVAPixmaps.h +0 -5
  54. package/cpp/skia/include/effects/SkGradientShader.h +10 -1
  55. package/cpp/skia/include/effects/SkImageFilters.h +62 -37
  56. package/cpp/skia/include/effects/SkPerlinNoiseShader.h +28 -29
  57. package/cpp/skia/include/effects/SkRuntimeEffect.h +17 -12
  58. package/cpp/skia/include/gpu/GrBackendSurface.h +12 -39
  59. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +6 -0
  60. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +3 -3
  61. package/cpp/skia/include/gpu/GrDirectContext.h +103 -3
  62. package/cpp/skia/include/gpu/GrRecordingContext.h +10 -19
  63. package/cpp/skia/include/gpu/MutableTextureState.h +4 -0
  64. package/cpp/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +54 -0
  65. package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +20 -76
  66. package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +217 -0
  67. package/cpp/skia/include/gpu/ganesh/mtl/SkSurfaceMetal.h +73 -0
  68. package/cpp/skia/include/gpu/gl/GrGLTypes.h +13 -2
  69. package/cpp/skia/include/gpu/graphite/BackendSemaphore.h +78 -0
  70. package/cpp/skia/include/gpu/graphite/BackendTexture.h +1 -0
  71. package/cpp/skia/include/gpu/graphite/Image.h +277 -0
  72. package/cpp/skia/include/gpu/graphite/ImageProvider.h +1 -1
  73. package/cpp/skia/include/gpu/graphite/Recording.h +1 -4
  74. package/cpp/skia/include/gpu/graphite/Surface.h +81 -0
  75. package/cpp/skia/include/gpu/graphite/TextureInfo.h +5 -7
  76. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +2 -2
  77. package/cpp/skia/include/gpu/mock/GrMockTypes.h +23 -8
  78. package/cpp/skia/include/ports/SkTypeface_fontations.h +21 -0
  79. package/cpp/skia/include/private/SkGainmapInfo.h +2 -0
  80. package/cpp/skia/include/private/SkGainmapShader.h +1 -0
  81. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +19 -1
  82. package/cpp/skia/include/private/SkPathRef.h +13 -15
  83. package/cpp/skia/include/private/SkXmp.h +53 -0
  84. package/cpp/skia/include/private/base/SkFeatures.h +0 -4
  85. package/cpp/skia/include/private/base/SkFloatingPoint.h +11 -5
  86. package/cpp/skia/include/private/base/SkPoint_impl.h +569 -0
  87. package/cpp/skia/include/private/base/SkSpan_impl.h +3 -7
  88. package/cpp/skia/include/private/base/SkTArray.h +11 -11
  89. package/cpp/skia/include/private/chromium/GrDeferredDisplayList.h +120 -0
  90. package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +98 -0
  91. package/cpp/skia/include/private/chromium/GrPromiseImageTexture.h +43 -0
  92. package/cpp/skia/include/private/chromium/GrSurfaceCharacterization.h +215 -0
  93. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +6 -6
  94. package/cpp/skia/include/private/chromium/SkImageChromium.h +104 -0
  95. package/cpp/skia/include/private/chromium/Slug.h +7 -3
  96. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +7 -3
  97. package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +2 -0
  98. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +3 -2
  99. package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +10 -2
  100. package/cpp/skia/include/{gpu → private/gpu}/ganesh/GrTextureGenerator.h +2 -13
  101. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  102. package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +7 -0
  103. package/cpp/skia/include/private/gpu/graphite/MtlGraphiteTypesPriv.h +19 -6
  104. package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +13 -0
  105. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +0 -1
  106. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +14 -1
  107. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +999 -79
  108. package/cpp/skia/modules/skcms/src/Transform_inl.h +36 -236
  109. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -0
  110. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +16 -0
  111. package/cpp/skia/modules/skparagraph/include/TextStyle.h +6 -2
  112. package/cpp/skia/modules/skresources/include/SkResources.h +1 -1
  113. package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
  114. package/cpp/skia/modules/svg/include/SkSVGClipPath.h +1 -1
  115. package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
  116. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -1
  117. package/cpp/skia/modules/svg/include/SkSVGDefs.h +1 -1
  118. package/cpp/skia/modules/svg/include/SkSVGEllipse.h +1 -1
  119. package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
  120. package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
  121. package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
  122. package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
  123. package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
  124. package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
  125. package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
  126. package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
  127. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  128. package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
  129. package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
  130. package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
  131. package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
  132. package/cpp/skia/modules/svg/include/SkSVGG.h +1 -1
  133. package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
  134. package/cpp/skia/modules/svg/include/SkSVGHiddenContainer.h +1 -1
  135. package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
  136. package/cpp/skia/modules/svg/include/SkSVGLine.h +1 -1
  137. package/cpp/skia/modules/svg/include/SkSVGLinearGradient.h +1 -1
  138. package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
  139. package/cpp/skia/modules/svg/include/SkSVGNode.h +1 -1
  140. package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
  141. package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
  142. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  143. package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
  144. package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
  145. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
  146. package/cpp/skia/modules/svg/include/SkSVGSVG.h +1 -1
  147. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -1
  148. package/cpp/skia/modules/svg/include/SkSVGStop.h +1 -1
  149. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  150. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +1 -1
  151. package/cpp/skia/modules/svg/include/SkSVGTypes.h +21 -21
  152. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  153. package/cpp/skia/modules/svg/include/SkSVGValue.h +2 -2
  154. package/cpp/skia/{include/private → src/core}/SkChecksum.h +32 -17
  155. package/cpp/skia/src/core/SkTHash.h +1 -1
  156. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +3 -1
  157. package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +3 -1
  158. package/lib/commonjs/renderer/Canvas.js +24 -13
  159. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  160. package/lib/commonjs/skia/core/Data.d.ts +2 -2
  161. package/lib/commonjs/skia/core/Data.js.map +1 -1
  162. package/lib/commonjs/skia/core/RRect.js +5 -1
  163. package/lib/commonjs/skia/core/RRect.js.map +1 -1
  164. package/lib/commonjs/skia/core/Rect.js +32 -6
  165. package/lib/commonjs/skia/core/Rect.js.map +1 -1
  166. package/lib/commonjs/skia/types/Color.js.map +1 -1
  167. package/lib/commonjs/skia/types/JsiInstance.d.ts +2 -4
  168. package/lib/commonjs/skia/types/JsiInstance.js.map +1 -1
  169. package/lib/module/renderer/Canvas.js +25 -14
  170. package/lib/module/renderer/Canvas.js.map +1 -1
  171. package/lib/module/skia/core/Data.d.ts +2 -2
  172. package/lib/module/skia/core/Data.js.map +1 -1
  173. package/lib/module/skia/core/RRect.js +5 -1
  174. package/lib/module/skia/core/RRect.js.map +1 -1
  175. package/lib/module/skia/core/Rect.js +32 -6
  176. package/lib/module/skia/core/Rect.js.map +1 -1
  177. package/lib/module/skia/types/Color.js.map +1 -1
  178. package/lib/module/skia/types/JsiInstance.d.ts +2 -4
  179. package/lib/module/skia/types/JsiInstance.js.map +1 -1
  180. package/lib/typescript/src/skia/core/Data.d.ts +2 -2
  181. package/lib/typescript/src/skia/types/JsiInstance.d.ts +2 -4
  182. package/libs/android/arm64-v8a/libskia.a +0 -0
  183. package/libs/android/arm64-v8a/libskottie.a +0 -0
  184. package/libs/android/arm64-v8a/libsksg.a +0 -0
  185. package/libs/android/arm64-v8a/libsvg.a +0 -0
  186. package/libs/android/armeabi-v7a/libskia.a +0 -0
  187. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  188. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  189. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  190. package/libs/android/x86/libskia.a +0 -0
  191. package/libs/android/x86/libskottie.a +0 -0
  192. package/libs/android/x86/libsksg.a +0 -0
  193. package/libs/android/x86/libsvg.a +0 -0
  194. package/libs/android/x86_64/libskia.a +0 -0
  195. package/libs/android/x86_64/libskottie.a +0 -0
  196. package/libs/android/x86_64/libsksg.a +0 -0
  197. package/libs/android/x86_64/libsvg.a +0 -0
  198. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  199. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  200. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  201. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  202. package/libs/ios/libsksg.xcframework/Info.plist +5 -5
  203. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  204. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  205. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  206. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  207. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  208. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  209. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  210. package/package.json +3 -4
  211. package/src/renderer/Canvas.tsx +25 -19
  212. package/src/skia/core/Data.ts +3 -3
  213. package/src/skia/core/RRect.tsx +4 -2
  214. package/src/skia/core/Rect.ts +29 -12
  215. package/src/skia/types/Color.ts +1 -1
  216. package/src/skia/types/JsiInstance.ts +2 -5
  217. package/cpp/skia/include/effects/SkTableColorFilter.h +0 -29
  218. package/cpp/skia/include/private/SkOpts_spi.h +0 -23
  219. package/cpp/skia/include/private/SkSpinlock.h +0 -57
  220. package/cpp/skia/include/private/chromium/GrSlug.h +0 -16
  221. package/scripts/install-npm.js +0 -33
@@ -15,11 +15,6 @@
15
15
  #include "include/core/SkSize.h"
16
16
  #include "include/private/base/SkAPI.h"
17
17
 
18
- #if defined(SK_GRAPHITE)
19
- #include "include/gpu/graphite/GraphiteTypes.h"
20
- class SkYUVAPixmaps;
21
- #endif
22
-
23
18
  #include <cstddef>
24
19
  #include <cstdint>
25
20
  #include <memory>
@@ -47,7 +42,12 @@ enum class SkTileMode;
47
42
  struct SkIPoint;
48
43
  struct SkSamplingOptions;
49
44
 
50
- #if defined(SK_GRAPHITE)
45
+ namespace skgpu::graphite { class Recorder; }
46
+
47
+ #if !defined(SK_DISABLE_LEGACY_GRAPHITE_IMAGE_FACTORIES) && defined(SK_GRAPHITE)
48
+ #include "include/gpu/graphite/GraphiteTypes.h"
49
+
50
+ namespace skgpu { enum class Mipmapped : bool; }
51
51
  namespace skgpu::graphite {
52
52
  class BackendTexture;
53
53
  class Recorder;
@@ -680,263 +680,64 @@ public:
680
680
  Returns nullptr if any of the following are true:
681
681
  - Subset is empty
682
682
  - Subset is not contained inside the image's bounds
683
- - Pixels in the image could not be read or copied
683
+ - Pixels in the source image could not be read or copied
684
+ - This image is texture-backed and the provided context is null or does not match
685
+ the source image's context.
684
686
 
685
- If this image is texture-backed, the context parameter is required and must match the
686
- context of the source image. If the context parameter is provided, and the image is
687
- raster-backed, the subset will be converted to texture-backed.
687
+ If the source image was texture-backed, the resulting image will be texture-backed also.
688
+ Otherwise, the returned image will be raster-backed.
688
689
 
690
+ @param direct the GrDirectContext of the source image (nullptr is ok if the source image
691
+ is not texture-backed).
689
692
  @param subset bounds of returned SkImage
690
- @param context the GrDirectContext in play, if it exists
691
693
  @return the subsetted image, or nullptr
692
694
 
693
695
  example: https://fiddle.skia.org/c/@Image_makeSubset
694
696
  */
695
- sk_sp<SkImage> makeSubset(const SkIRect& subset, GrDirectContext* direct = nullptr) const;
696
-
697
- /**
698
- * Returns true if the image has mipmap levels.
699
- */
700
- bool hasMipmaps() const;
697
+ virtual sk_sp<SkImage> makeSubset(GrDirectContext* direct, const SkIRect& subset) const = 0;
701
698
 
702
- /**
703
- * Returns an image with the same "base" pixels as the this image, but with mipmap levels
704
- * automatically generated and attached.
705
- */
706
- sk_sp<SkImage> withDefaultMipmaps() const;
707
-
708
- #if defined(SK_GANESH) || defined(SK_GRAPHITE)
709
- using ReleaseContext = SkImages::ReleaseContext;
710
- using TextureReleaseProc = void (*)(ReleaseContext);
699
+ #if !defined(SK_DISABLE_LEGACY_IMAGE_SUBSET_METHODS)
700
+ sk_sp<SkImage> makeSubset(const SkIRect& subset, GrDirectContext* direct = nullptr) const {
701
+ return this->makeSubset(direct, subset);
702
+ }
711
703
  #endif
712
704
 
713
- #if defined(SK_GRAPHITE)
714
- // Passed to both fulfill and imageRelease
715
- using GraphitePromiseImageContext = void*;
716
- // Returned from fulfill and passed into textureRelease
717
- using GraphitePromiseTextureReleaseContext = void*;
718
-
719
- using GraphitePromiseImageFulfillProc =
720
- std::tuple<skgpu::graphite::BackendTexture, GraphitePromiseTextureReleaseContext>
721
- (*)(GraphitePromiseImageContext);
722
- using GraphitePromiseImageReleaseProc = void (*)(GraphitePromiseImageContext);
723
- using GraphitePromiseTextureReleaseProc = void (*)(GraphitePromiseTextureReleaseContext);
724
-
725
- /** Create a new SkImage that is very similar to an SkImage created by
726
- MakeGraphiteFromBackendTexture. The difference is that the caller need not have created the
727
- backend texture nor populated it with data when creating the image. Instead of passing a
728
- BackendTexture to the factory the client supplies a description of the texture consisting
729
- of dimensions, TextureInfo, SkColorInfo and Volatility.
730
-
731
- In general, 'fulfill' must return a BackendTexture that matches the properties
732
- provided at SkImage creation time. The BackendTexture must refer to a valid existing
733
- texture in the backend API context/device, and already be populated with data.
734
- The texture cannot be deleted until 'textureRelease' is called. 'textureRelease' will
735
- be called with the textureReleaseContext returned by 'fulfill'.
736
-
737
- Wrt when and how often the fulfill, imageRelease, and textureRelease callbacks will
738
- be called:
739
-
740
- For non-volatile promise images, 'fulfill' will be called at Context::insertRecording
741
- time. Regardless of whether 'fulfill' succeeded or failed, 'imageRelease' will always be
742
- called only once - when Skia will no longer try calling 'fulfill' to get a backend
743
- texture. If 'fulfill' failed (i.e., it didn't return a valid backend texture) then
744
- 'textureRelease' will never be called. If 'fulfill' was successful then
745
- 'textureRelease' will be called only once when the GPU is done with the contents of the
746
- promise image. This will usually occur during a Context::submit call but it could occur
747
- earlier due to error conditions. 'fulfill' can be called multiple times if the promise
748
- image is used in multiple recordings. If 'fulfill' fails, the insertRecording itself will
749
- fail. Subsequent insertRecording calls (with Recordings that use the promise image) will
750
- keep calling 'fulfill' until it succeeds.
751
-
752
- For volatile promise images, 'fulfill' will be called each time the Recording is inserted
753
- into a Context. Regardless of whether 'fulfill' succeeded or failed, 'imageRelease'
754
- will always be called only once just like the non-volatile case. If 'fulfill' fails at
755
- insertRecording-time, 'textureRelease' will never be called. If 'fulfill' was successful
756
- then a 'textureRelease' matching that 'fulfill' will be called when the GPU is done with
757
- the contents of the promise image. This will usually occur during a Context::submit call
758
- but it could occur earlier due to error conditions.
759
-
760
- @param recorder the recorder that will capture the commands creating the image
761
- @param dimensions width & height of promised gpu texture
762
- @param textureInfo structural information for the promised gpu texture
763
- @param colorInfo color type, alpha type and colorSpace information for the image
764
- @param isVolatile volatility of the promise image
765
- @param fulfill function called to get the actual backend texture
766
- @param imageRelease function called when any image-centric data can be deleted
767
- @param textureRelease function called when the backend texture can be deleted
768
- @param imageContext state passed to fulfill and imageRelease
769
- @return created SkImage, or nullptr
770
- */
771
- static sk_sp<SkImage> MakeGraphitePromiseTexture(skgpu::graphite::Recorder*,
772
- SkISize dimensions,
773
- const skgpu::graphite::TextureInfo&,
774
- const SkColorInfo&,
775
- skgpu::graphite::Volatile,
776
- GraphitePromiseImageFulfillProc,
777
- GraphitePromiseImageReleaseProc,
778
- GraphitePromiseTextureReleaseProc,
779
- GraphitePromiseImageContext);
780
-
781
- /** Creates an SkImage from a GPU texture associated with the recorder.
782
-
783
- SkImage is returned if the format of backendTexture is recognized and supported.
784
- Recognized formats vary by GPU back-end.
785
-
786
- @param recorder The recorder
787
- @param backendTexture texture residing on GPU
788
- @param colorSpace This describes the color space of this image's contents, as
789
- seen after sampling. In general, if the format of the backend
790
- texture is SRGB, some linear colorSpace should be supplied
791
- (e.g., SkColorSpace::MakeSRGBLinear()). If the format of the
792
- backend texture is linear, then the colorSpace should include
793
- a description of the transfer function as
794
- well (e.g., SkColorSpace::MakeSRGB()).
795
- @return created SkImage, or nullptr
796
- */
797
- static sk_sp<SkImage> MakeGraphiteFromBackendTexture(skgpu::graphite::Recorder*,
798
- const skgpu::graphite::BackendTexture&,
799
- SkColorType colorType,
800
- SkAlphaType alphaType,
801
- sk_sp<SkColorSpace> colorSpace,
802
- TextureReleaseProc = nullptr,
803
- ReleaseContext = nullptr);
804
-
805
- /** Creates an SkImage from YUV[A] planar textures associated with the recorder.
806
- @param recorder The recorder.
807
- @param yuvaBackendTextures A set of textures containing YUVA data and a description of the
808
- data and transformation to RGBA.
809
- @param imageColorSpace range of colors of the resulting image after conversion to RGB;
810
- may be nullptr
811
- @param TextureReleaseProc called when the backend textures can be released
812
- @param ReleaseContext state passed to TextureReleaseProc
813
- @return created SkImage, or nullptr
814
- */
815
- static sk_sp<SkImage> MakeGraphiteFromYUVABackendTextures(
816
- skgpu::graphite::Recorder* recorder,
817
- const skgpu::graphite::YUVABackendTextures& yuvaBackendTextures,
818
- sk_sp<SkColorSpace> imageColorSpace,
819
- TextureReleaseProc = nullptr,
820
- ReleaseContext = nullptr);
821
-
822
- struct RequiredImageProperties {
823
- skgpu::Mipmapped fMipmapped;
705
+ struct RequiredProperties {
706
+ bool fMipmapped;
824
707
  };
825
708
 
826
- /** Creates SkImage from SkYUVAPixmaps.
827
-
828
- The image will remain planar with each plane converted to a texture using the passed
829
- Recorder.
830
-
831
- SkYUVAPixmaps has a SkYUVAInfo which specifies the transformation from YUV to RGB.
832
- The SkColorSpace of the resulting RGB values is specified by imgColorSpace. This will
833
- be the SkColorSpace reported by the image and when drawn the RGB values will be converted
834
- from this space into the destination space (if the destination is tagged).
835
-
836
- This is only supported using the GPU backend and will fail if recorder is nullptr.
837
-
838
- SkYUVAPixmaps does not need to remain valid after this returns.
839
-
840
- @param Recorder The Recorder to use for storing commands
841
- @param pixmaps The planes as pixmaps with supported SkYUVAInfo that
842
- specifies conversion to RGB.
843
- @param RequiredImageProperties Properties the returned SkImage must possess (e.g.,
844
- mipmaps)
845
- @param limitToMaxTextureSize Downscale image to GPU maximum texture size, if necessary
846
- @param imgColorSpace Range of colors of the resulting image; may be nullptr
847
- @return Created SkImage, or nullptr
848
- */
849
- static sk_sp<SkImage> MakeGraphiteFromYUVAPixmaps(skgpu::graphite::Recorder*,
850
- const SkYUVAPixmaps& pixmaps,
851
- RequiredImageProperties = {},
852
- bool limitToMaxTextureSize = false,
853
- sk_sp<SkColorSpace> imgColorSpace = nullptr);
854
-
855
- /** Graphite version of makeTextureImage.
856
-
857
- Returns an SkImage backed by a Graphite texture, using the provided Recorder for creation
858
- and uploads if necessary. The returned SkImage respects the required image properties'
859
- mipmap setting for non-Graphite SkImages; i.e., if mipmapping is required, the backing
860
- Graphite texture will have allocated mip map levels.
861
-
862
- It is assumed that MIP maps are always supported by the GPU.
863
-
864
- Returns original SkImage if the image is already Graphite-backed and the required mipmapping
865
- is compatible with the backing Graphite texture. If the required mipmapping is not
866
- compatible, nullptr will be returned.
867
-
868
- Returns nullptr if no Recorder is provided, or if SkImage was created with another
869
- Recorder and work on that Recorder has not been submitted.
870
-
871
- @param Recorder the Recorder to use for storing commands
872
- @param RequiredImageProperties properties the returned SkImage must possess (e.g.,
873
- mipmaps)
874
- @return created SkImage, or nullptr
875
- */
876
- virtual sk_sp<SkImage> makeTextureImage(skgpu::graphite::Recorder*,
877
- RequiredImageProperties = {}) const = 0;
878
-
879
709
  /** Returns subset of this image.
880
710
 
881
711
  Returns nullptr if any of the following are true:
882
712
  - Subset is empty
883
713
  - Subset is not contained inside the image's bounds
884
714
  - Pixels in the image could not be read or copied
715
+ - This image is texture-backed and the provided context is null or does not match
716
+ the source image's context.
885
717
 
886
- If this image is texture-backed, the recorder parameter is required.
887
- If the recorder parameter is provided, and the image is raster-backed, the subset will
888
- be converted to texture-backed.
718
+ If the source image was texture-backed, the resulting image will be texture-backed also.
719
+ Otherwise, the returned image will be raster-backed.
889
720
 
890
- @param subset bounds of returned SkImage
891
- @param recorder the recorder in which to create the new image
892
- @param RequiredImageProperties properties the returned SkImage must possess (e.g.,
893
- mipmaps)
894
- @return the subsetted image, or nullptr
721
+ @param recorder the recorder of the source image (nullptr is ok if the
722
+ source image was texture-backed).
723
+ @param subset bounds of returned SkImage
724
+ @param RequiredProperties properties the returned SkImage must possess (e.g. mipmaps)
725
+ @return the subsetted image, or nullptr
895
726
  */
896
- sk_sp<SkImage> makeSubset(const SkIRect& subset,
897
- skgpu::graphite::Recorder*,
898
- RequiredImageProperties = {}) const;
899
-
900
- /** Creates SkImage in target SkColorSpace.
901
- Returns nullptr if SkImage could not be created.
902
-
903
- Returns original SkImage if it is in target SkColorSpace.
904
- Otherwise, converts pixels from SkImage SkColorSpace to target SkColorSpace.
905
- If SkImage colorSpace() returns nullptr, SkImage SkColorSpace is assumed to be sRGB.
906
-
907
- If this image is graphite-backed, the recorder parameter is required.
908
-
909
- @param targetColorSpace SkColorSpace describing color range of returned SkImage
910
- @param recorder The Recorder in which to create the new image
911
- @param RequiredImageProperties properties the returned SkImage must possess (e.g.,
912
- mipmaps)
913
- @return created SkImage in target SkColorSpace
914
- */
915
- sk_sp<SkImage> makeColorSpace(sk_sp<SkColorSpace> targetColorSpace,
916
- skgpu::graphite::Recorder*,
917
- RequiredImageProperties = {}) const;
918
-
919
- /** Experimental.
920
- Creates SkImage in target SkColorType and SkColorSpace.
921
- Returns nullptr if SkImage could not be created.
922
-
923
- Returns original SkImage if it is in target SkColorType and SkColorSpace.
924
-
925
- If this image is graphite-backed, the recorder parameter is required.
727
+ virtual sk_sp<SkImage> makeSubset(skgpu::graphite::Recorder*,
728
+ const SkIRect& subset,
729
+ RequiredProperties) const = 0;
926
730
 
927
- @param targetColorType SkColorType of returned SkImage
928
- @param targetColorSpace SkColorSpace of returned SkImage
929
- @param recorder The Recorder in which to create the new image
930
- @param RequiredImageProperties properties the returned SkImage must possess (e.g.,
931
- mipmaps)
932
- @return created SkImage in target SkColorType and SkColorSpace
933
- */
934
- sk_sp<SkImage> makeColorTypeAndColorSpace(SkColorType targetColorType,
935
- sk_sp<SkColorSpace> targetColorSpace,
936
- skgpu::graphite::Recorder*,
937
- RequiredImageProperties = {}) const;
731
+ /**
732
+ * Returns true if the image has mipmap levels.
733
+ */
734
+ bool hasMipmaps() const;
938
735
 
939
- #endif // SK_GRAPHITE
736
+ /**
737
+ * Returns an image with the same "base" pixels as the this image, but with mipmap levels
738
+ * automatically generated and attached.
739
+ */
740
+ sk_sp<SkImage> withDefaultMipmaps() const;
940
741
 
941
742
  /** Returns raster image or lazy image. Copies SkImage backed by GPU texture into
942
743
  CPU memory if needed. Returns original SkImage if decoded in raster bitmap,
@@ -948,7 +749,7 @@ public:
948
749
 
949
750
  example: https://fiddle.skia.org/c/@Image_makeNonTextureImage
950
751
  */
951
- sk_sp<SkImage> makeNonTextureImage() const;
752
+ sk_sp<SkImage> makeNonTextureImage(GrDirectContext* = nullptr) const;
952
753
 
953
754
  /** Returns raster image. Copies SkImage backed by GPU texture into CPU memory,
954
755
  or decodes SkImage from lazy image. Returns original SkImage if decoded in
@@ -963,7 +764,14 @@ public:
963
764
 
964
765
  example: https://fiddle.skia.org/c/@Image_makeRasterImage
965
766
  */
966
- sk_sp<SkImage> makeRasterImage(CachingHint cachingHint = kDisallow_CachingHint) const;
767
+ sk_sp<SkImage> makeRasterImage(GrDirectContext*,
768
+ CachingHint cachingHint = kDisallow_CachingHint) const;
769
+
770
+ #if !defined(SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API)
771
+ sk_sp<SkImage> makeRasterImage(CachingHint cachingHint = kDisallow_CachingHint) const {
772
+ return this->makeRasterImage(nullptr, cachingHint);
773
+ }
774
+ #endif
967
775
 
968
776
  /** Creates filtered SkImage. filter processes original SkImage, potentially changing
969
777
  color, position, and size. subset is the bounds of original SkImage processed
@@ -989,10 +797,12 @@ public:
989
797
  @param offset storage for returned SkImage translation
990
798
  @return filtered SkImage, or nullptr
991
799
  */
992
- sk_sp<SkImage> makeWithFilter(GrRecordingContext* context,
993
- const SkImageFilter* filter, const SkIRect& subset,
994
- const SkIRect& clipBounds, SkIRect* outSubset,
995
- SkIPoint* offset) const;
800
+ virtual sk_sp<SkImage> makeWithFilter(GrRecordingContext* context,
801
+ const SkImageFilter* filter,
802
+ const SkIRect& subset,
803
+ const SkIRect& clipBounds,
804
+ SkIRect* outSubset,
805
+ SkIPoint* offset) const = 0;
996
806
 
997
807
  /** Deprecated.
998
808
  */
@@ -1021,7 +831,7 @@ public:
1021
831
  example: https://fiddle.skia.org/c/@Image_isLazyGenerated_a
1022
832
  example: https://fiddle.skia.org/c/@Image_isLazyGenerated_b
1023
833
  */
1024
- bool isLazyGenerated() const;
834
+ virtual bool isLazyGenerated() const = 0;
1025
835
 
1026
836
  /** Creates SkImage in target SkColorSpace.
1027
837
  Returns nullptr if SkImage could not be created.
@@ -1033,14 +843,37 @@ public:
1033
843
  If this image is texture-backed, the context parameter is required and must match the
1034
844
  context of the source image.
1035
845
 
1036
- @param target SkColorSpace describing color range of returned SkImage
1037
846
  @param direct The GrDirectContext in play, if it exists
847
+ @param target SkColorSpace describing color range of returned SkImage
1038
848
  @return created SkImage in target SkColorSpace
1039
849
 
1040
850
  example: https://fiddle.skia.org/c/@Image_makeColorSpace
1041
851
  */
852
+ virtual sk_sp<SkImage> makeColorSpace(GrDirectContext* direct,
853
+ sk_sp<SkColorSpace> target) const = 0;
854
+
855
+ #if !defined(SK_DISABLE_LEGACY_IMAGE_COLORSPACE_METHODS)
1042
856
  sk_sp<SkImage> makeColorSpace(sk_sp<SkColorSpace> target,
1043
857
  GrDirectContext* direct = nullptr) const;
858
+ #endif
859
+
860
+ /** Creates SkImage in target SkColorSpace.
861
+ Returns nullptr if SkImage could not be created.
862
+
863
+ Returns original SkImage if it is in target SkColorSpace.
864
+ Otherwise, converts pixels from SkImage SkColorSpace to target SkColorSpace.
865
+ If SkImage colorSpace() returns nullptr, SkImage SkColorSpace is assumed to be sRGB.
866
+
867
+ If this image is graphite-backed, the recorder parameter is required.
868
+
869
+ @param targetColorSpace SkColorSpace describing color range of returned SkImage
870
+ @param recorder The Recorder in which to create the new image
871
+ @param RequiredProperties properties the returned SkImage must possess (e.g. mipmaps)
872
+ @return created SkImage in target SkColorSpace
873
+ */
874
+ virtual sk_sp<SkImage> makeColorSpace(skgpu::graphite::Recorder*,
875
+ sk_sp<SkColorSpace> targetColorSpace,
876
+ RequiredProperties) const = 0;
1044
877
 
1045
878
  /** Experimental.
1046
879
  Creates SkImage in target SkColorType and SkColorSpace.
@@ -1051,14 +884,39 @@ public:
1051
884
  If this image is texture-backed, the context parameter is required and must match the
1052
885
  context of the source image.
1053
886
 
887
+ @param direct The GrDirectContext in play, if it exists
1054
888
  @param targetColorType SkColorType of returned SkImage
1055
889
  @param targetColorSpace SkColorSpace of returned SkImage
1056
- @param direct The GrDirectContext in play, if it exists
1057
890
  @return created SkImage in target SkColorType and SkColorSpace
1058
891
  */
892
+ virtual sk_sp<SkImage> makeColorTypeAndColorSpace(GrDirectContext* direct,
893
+ SkColorType targetColorType,
894
+ sk_sp<SkColorSpace> targetCS) const = 0;
895
+
896
+ #if !defined(SK_DISABLE_LEGACY_IMAGE_COLORSPACE_METHODS)
1059
897
  sk_sp<SkImage> makeColorTypeAndColorSpace(SkColorType targetColorType,
1060
898
  sk_sp<SkColorSpace> targetColorSpace,
1061
899
  GrDirectContext* direct = nullptr) const;
900
+ #endif
901
+
902
+ /** Experimental.
903
+ Creates SkImage in target SkColorType and SkColorSpace.
904
+ Returns nullptr if SkImage could not be created.
905
+
906
+ Returns original SkImage if it is in target SkColorType and SkColorSpace.
907
+
908
+ If this image is graphite-backed, the recorder parameter is required.
909
+
910
+ @param targetColorType SkColorType of returned SkImage
911
+ @param targetColorSpace SkColorSpace of returned SkImage
912
+ @param recorder The Recorder in which to create the new image
913
+ @param RequiredProperties properties the returned SkImage must possess (e.g. mipmaps)
914
+ @return created SkImage in target SkColorType and SkColorSpace
915
+ */
916
+ virtual sk_sp<SkImage> makeColorTypeAndColorSpace(skgpu::graphite::Recorder*,
917
+ SkColorType targetColorType,
918
+ sk_sp<SkColorSpace> targetColorSpace,
919
+ RequiredProperties) const = 0;
1062
920
 
1063
921
  /** Creates a new SkImage identical to this one, but with a different SkColorSpace.
1064
922
  This does not convert the underlying pixel data, so the resulting image will draw
@@ -1080,6 +938,56 @@ private:
1080
938
  sk_sp<SkImage> withMipmaps(sk_sp<SkMipmap>) const;
1081
939
 
1082
940
  using INHERITED = SkRefCnt;
941
+
942
+ public:
943
+ #if !defined(SK_DISABLE_LEGACY_IMAGE_RELEASE_PROCS)
944
+ using ReleaseContext = SkImages::ReleaseContext;
945
+ using TextureReleaseProc = void (*)(ReleaseContext);
946
+ #endif
947
+ #if !defined(SK_DISABLE_LEGACY_GRAPHITE_IMAGE_METHODS) && defined(SK_GRAPHITE)
948
+ struct RequiredImageProperties {
949
+ skgpu::Mipmapped fMipmapped;
950
+ };
951
+
952
+ sk_sp<SkImage> makeTextureImage(skgpu::graphite::Recorder*, RequiredImageProperties) const;
953
+ #endif
954
+ #if !defined(SK_DISABLE_LEGACY_GRAPHITE_IMAGE_FACTORIES) && defined(SK_GRAPHITE)
955
+ // Passed to both fulfill and imageRelease
956
+ using GraphitePromiseImageContext = void*;
957
+ // Returned from fulfill and passed into textureRelease
958
+ using GraphitePromiseTextureReleaseContext = void*;
959
+
960
+ using GraphitePromiseImageFulfillProc =
961
+ std::tuple<skgpu::graphite::BackendTexture, GraphitePromiseTextureReleaseContext>
962
+ (*)(GraphitePromiseImageContext);
963
+ using GraphitePromiseImageReleaseProc = void (*)(GraphitePromiseImageContext);
964
+ using GraphitePromiseTextureReleaseProc = void (*)(GraphitePromiseTextureReleaseContext);
965
+
966
+ static sk_sp<SkImage> MakeGraphitePromiseTexture(skgpu::graphite::Recorder*,
967
+ SkISize,
968
+ const skgpu::graphite::TextureInfo&,
969
+ const SkColorInfo&,
970
+ skgpu::graphite::Volatile,
971
+ GraphitePromiseImageFulfillProc,
972
+ GraphitePromiseImageReleaseProc,
973
+ GraphitePromiseTextureReleaseProc,
974
+ GraphitePromiseImageContext);
975
+
976
+ static sk_sp<SkImage> MakeGraphiteFromBackendTexture(skgpu::graphite::Recorder*,
977
+ const skgpu::graphite::BackendTexture&,
978
+ SkColorType,
979
+ SkAlphaType,
980
+ sk_sp<SkColorSpace>,
981
+ TextureReleaseProc = nullptr,
982
+ ReleaseContext = nullptr);
983
+
984
+ static sk_sp<SkImage> MakeGraphiteFromYUVABackendTextures(
985
+ skgpu::graphite::Recorder*,
986
+ const skgpu::graphite::YUVABackendTextures&,
987
+ sk_sp<SkColorSpace>,
988
+ TextureReleaseProc = nullptr,
989
+ ReleaseContext = nullptr);
990
+ #endif
1083
991
  };
1084
992
 
1085
993
  #endif
@@ -22,11 +22,8 @@
22
22
 
23
23
  #include <cstddef>
24
24
  #include <cstdint>
25
- #include <memory>
26
- #include <optional>
27
25
 
28
26
  class GrRecordingContext;
29
- enum SkAlphaType : int;
30
27
 
31
28
  class SK_API SkImageGenerator {
32
29
  public:
@@ -116,23 +113,6 @@ public:
116
113
 
117
114
  virtual bool isTextureGenerator() const { return false; }
118
115
 
119
- #if defined(SK_GRAPHITE)
120
- sk_sp<SkImage> makeTextureImage(skgpu::graphite::Recorder*,
121
- const SkImageInfo&,
122
- skgpu::Mipmapped);
123
- #endif
124
-
125
- /**
126
- * If the default image decoder system can interpret the specified (encoded) data, then
127
- * this returns a new ImageGenerator for it. Otherwise this returns NULL. Either way
128
- * the caller is still responsible for managing their ownership of the data.
129
- * By default, images will be converted to premultiplied pixels. The alpha type can be
130
- * overridden by specifying kPremul_SkAlphaType or kUnpremul_SkAlphaType. Specifying
131
- * kOpaque_SkAlphaType is not supported, and will return NULL.
132
- */
133
- static std::unique_ptr<SkImageGenerator> MakeFromEncoded(
134
- sk_sp<SkData>, std::optional<SkAlphaType> = std::nullopt);
135
-
136
116
  protected:
137
117
  static constexpr int kNeedNewImageUniqueID = 0;
138
118
 
@@ -146,22 +126,11 @@ protected:
146
126
  SkYUVAPixmapInfo*) const { return false; }
147
127
  virtual bool onGetYUVAPlanes(const SkYUVAPixmaps&) { return false; }
148
128
 
149
- #if defined(SK_GRAPHITE)
150
- virtual sk_sp<SkImage> onMakeTextureImage(skgpu::graphite::Recorder*,
151
- const SkImageInfo&,
152
- skgpu::Mipmapped);
153
- #endif
154
129
  const SkImageInfo fInfo;
155
130
 
156
131
  private:
157
132
  const uint32_t fUniqueID;
158
133
 
159
- // This is our default impl, which may be different on different platforms.
160
- // It is called from NewFromEncoded() after it has checked for any runtime factory.
161
- // The SkData will never be NULL, as that will have been checked by NewFromEncoded.
162
- static std::unique_ptr<SkImageGenerator> MakeFromEncodedImpl(sk_sp<SkData>,
163
- std::optional<SkAlphaType>);
164
-
165
134
  SkImageGenerator(SkImageGenerator&&) = delete;
166
135
  SkImageGenerator(const SkImageGenerator&) = delete;
167
136
  SkImageGenerator& operator=(SkImageGenerator&&) = delete;
@@ -5,5 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
  #ifndef SK_MILESTONE
8
- #define SK_MILESTONE 114
8
+ #define SK_MILESTONE 116
9
9
  #endif
@@ -24,6 +24,9 @@ public:
24
24
  SkPathMeasure(const SkPath& path, bool forceClosed, SkScalar resScale = 1);
25
25
  ~SkPathMeasure();
26
26
 
27
+ SkPathMeasure(SkPathMeasure&&) = default;
28
+ SkPathMeasure& operator=(SkPathMeasure&&) = default;
29
+
27
30
  /** Reset the pathmeasure with the specified path. The parts of the path that are needed
28
31
  * are copied, so the client is free to modify/delete the path after this call..
29
32
  */
@@ -80,9 +83,6 @@ public:
80
83
  private:
81
84
  SkContourMeasureIter fIter;
82
85
  sk_sp<SkContourMeasure> fContour;
83
-
84
- SkPathMeasure(const SkPathMeasure&) = delete;
85
- SkPathMeasure& operator=(const SkPathMeasure&) = delete;
86
86
  };
87
87
 
88
88
  #endif
@@ -86,7 +86,7 @@ public:
86
86
  * Unlike finishRecordingAsPicture(), which returns an immutable picture, the returned drawable
87
87
  * may contain live references to other drawables (if they were added to the recording canvas)
88
88
  * and therefore this drawable will reflect the current state of those nested drawables anytime
89
- * it is drawn or a new picture is snapped from it (by calling drawable->newPictureSnapshot()).
89
+ * it is drawn or a new picture is snapped from it (by calling drawable->makePictureSnapshot()).
90
90
  */
91
91
  sk_sp<SkDrawable> finishRecordingAsDrawable();
92
92