@shopify/react-native-skia 0.1.197 → 0.1.200

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) 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/JsiSkShaderFactory.h +4 -4
  5. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  6. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +2 -2
  7. package/cpp/skia/include/android/SkCanvasAndroid.h +20 -0
  8. package/cpp/skia/include/android/SkHeifDecoder.h +43 -0
  9. package/cpp/skia/include/android/SkSurfaceAndroid.h +50 -0
  10. package/cpp/skia/include/codec/SkAvifDecoder.h +43 -0
  11. package/cpp/skia/include/codec/SkBmpDecoder.h +43 -0
  12. package/cpp/skia/include/codec/SkCodec.h +25 -1
  13. package/cpp/skia/include/codec/SkGifDecoder.h +43 -0
  14. package/cpp/skia/include/codec/SkIcoDecoder.h +43 -0
  15. package/cpp/skia/include/codec/SkJpegDecoder.h +43 -0
  16. package/cpp/skia/include/codec/SkJpegxlDecoder.h +43 -0
  17. package/cpp/skia/include/codec/SkPngDecoder.h +43 -0
  18. package/cpp/skia/include/codec/SkRawDecoder.h +49 -0
  19. package/cpp/skia/include/codec/SkWbmpDecoder.h +43 -0
  20. package/cpp/skia/include/codec/SkWebpDecoder.h +43 -0
  21. package/cpp/skia/include/core/SkBBHFactory.h +5 -1
  22. package/cpp/skia/include/core/SkBlender.h +0 -2
  23. package/cpp/skia/include/core/SkCanvas.h +4 -23
  24. package/cpp/skia/include/core/SkColorFilter.h +14 -1
  25. package/cpp/skia/include/core/SkColorTable.h +59 -0
  26. package/cpp/skia/include/core/SkContourMeasure.h +3 -0
  27. package/cpp/skia/include/core/SkDeferredDisplayList.h +8 -104
  28. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +8 -91
  29. package/cpp/skia/include/core/SkDrawable.h +5 -2
  30. package/cpp/skia/include/core/SkGraphics.h +7 -19
  31. package/cpp/skia/include/core/SkImage.h +157 -249
  32. package/cpp/skia/include/core/SkImageGenerator.h +0 -31
  33. package/cpp/skia/include/core/SkMilestone.h +1 -1
  34. package/cpp/skia/include/core/SkPathMeasure.h +3 -3
  35. package/cpp/skia/include/core/SkPictureRecorder.h +1 -1
  36. package/cpp/skia/include/core/SkPoint.h +5 -563
  37. package/cpp/skia/include/core/SkPoint3.h +1 -0
  38. package/cpp/skia/include/core/SkPromiseImageTexture.h +4 -30
  39. package/cpp/skia/include/core/SkRect.h +8 -8
  40. package/cpp/skia/include/core/SkSamplingOptions.h +4 -2
  41. package/cpp/skia/include/core/SkScalar.h +1 -1
  42. package/cpp/skia/include/core/SkSerialProcs.h +5 -1
  43. package/cpp/skia/include/core/SkShader.h +14 -21
  44. package/cpp/skia/include/core/SkString.h +2 -0
  45. package/cpp/skia/include/core/SkSurface.h +169 -701
  46. package/cpp/skia/include/core/SkSurfaceCharacterization.h +8 -256
  47. package/cpp/skia/include/core/SkTiledImageUtils.h +97 -0
  48. package/cpp/skia/include/core/SkTypes.h +4 -2
  49. package/cpp/skia/include/core/SkYUVAPixmaps.h +0 -5
  50. package/cpp/skia/include/effects/SkGradientShader.h +10 -1
  51. package/cpp/skia/include/effects/SkImageFilters.h +62 -37
  52. package/cpp/skia/include/effects/SkPerlinNoiseShader.h +28 -29
  53. package/cpp/skia/include/effects/SkRuntimeEffect.h +17 -12
  54. package/cpp/skia/include/gpu/GrBackendSurface.h +12 -39
  55. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +6 -0
  56. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +3 -3
  57. package/cpp/skia/include/gpu/GrDirectContext.h +103 -3
  58. package/cpp/skia/include/gpu/GrRecordingContext.h +10 -19
  59. package/cpp/skia/include/gpu/MutableTextureState.h +4 -0
  60. package/cpp/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +54 -0
  61. package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +20 -76
  62. package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +217 -0
  63. package/cpp/skia/include/gpu/ganesh/mtl/SkSurfaceMetal.h +73 -0
  64. package/cpp/skia/include/gpu/gl/GrGLTypes.h +13 -2
  65. package/cpp/skia/include/gpu/graphite/BackendSemaphore.h +78 -0
  66. package/cpp/skia/include/gpu/graphite/BackendTexture.h +1 -0
  67. package/cpp/skia/include/gpu/graphite/Image.h +277 -0
  68. package/cpp/skia/include/gpu/graphite/ImageProvider.h +1 -1
  69. package/cpp/skia/include/gpu/graphite/Recording.h +1 -4
  70. package/cpp/skia/include/gpu/graphite/Surface.h +81 -0
  71. package/cpp/skia/include/gpu/graphite/TextureInfo.h +5 -7
  72. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +2 -2
  73. package/cpp/skia/include/gpu/mock/GrMockTypes.h +23 -8
  74. package/cpp/skia/include/ports/SkTypeface_fontations.h +21 -0
  75. package/cpp/skia/include/private/SkGainmapInfo.h +2 -0
  76. package/cpp/skia/include/private/SkGainmapShader.h +1 -0
  77. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +19 -1
  78. package/cpp/skia/include/private/SkPathRef.h +13 -15
  79. package/cpp/skia/include/private/SkXmp.h +53 -0
  80. package/cpp/skia/include/private/base/SkFeatures.h +0 -4
  81. package/cpp/skia/include/private/base/SkFloatingPoint.h +11 -5
  82. package/cpp/skia/include/private/base/SkPoint_impl.h +569 -0
  83. package/cpp/skia/include/private/base/SkSpan_impl.h +3 -7
  84. package/cpp/skia/include/private/base/SkTArray.h +11 -11
  85. package/cpp/skia/include/private/chromium/GrDeferredDisplayList.h +120 -0
  86. package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +98 -0
  87. package/cpp/skia/include/private/chromium/GrPromiseImageTexture.h +43 -0
  88. package/cpp/skia/include/private/chromium/GrSurfaceCharacterization.h +215 -0
  89. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +6 -6
  90. package/cpp/skia/include/private/chromium/SkImageChromium.h +104 -0
  91. package/cpp/skia/include/private/chromium/Slug.h +7 -3
  92. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +7 -3
  93. package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +2 -0
  94. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +3 -2
  95. package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +10 -2
  96. package/cpp/skia/include/{gpu → private/gpu}/ganesh/GrTextureGenerator.h +2 -13
  97. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  98. package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +7 -0
  99. package/cpp/skia/include/private/gpu/graphite/MtlGraphiteTypesPriv.h +19 -6
  100. package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +13 -0
  101. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +0 -1
  102. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +14 -1
  103. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +999 -79
  104. package/cpp/skia/modules/skcms/src/Transform_inl.h +36 -236
  105. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -0
  106. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +16 -0
  107. package/cpp/skia/modules/skparagraph/include/TextStyle.h +6 -2
  108. package/cpp/skia/modules/skresources/include/SkResources.h +1 -1
  109. package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
  110. package/cpp/skia/modules/svg/include/SkSVGClipPath.h +1 -1
  111. package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
  112. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -1
  113. package/cpp/skia/modules/svg/include/SkSVGDefs.h +1 -1
  114. package/cpp/skia/modules/svg/include/SkSVGEllipse.h +1 -1
  115. package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
  116. package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
  117. package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
  118. package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
  119. package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
  120. package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
  121. package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
  122. package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
  123. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  124. package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
  125. package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
  126. package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
  127. package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
  128. package/cpp/skia/modules/svg/include/SkSVGG.h +1 -1
  129. package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
  130. package/cpp/skia/modules/svg/include/SkSVGHiddenContainer.h +1 -1
  131. package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
  132. package/cpp/skia/modules/svg/include/SkSVGLine.h +1 -1
  133. package/cpp/skia/modules/svg/include/SkSVGLinearGradient.h +1 -1
  134. package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
  135. package/cpp/skia/modules/svg/include/SkSVGNode.h +1 -1
  136. package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
  137. package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
  138. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  139. package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
  140. package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
  141. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
  142. package/cpp/skia/modules/svg/include/SkSVGSVG.h +1 -1
  143. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -1
  144. package/cpp/skia/modules/svg/include/SkSVGStop.h +1 -1
  145. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  146. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +1 -1
  147. package/cpp/skia/modules/svg/include/SkSVGTypes.h +21 -21
  148. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  149. package/cpp/skia/modules/svg/include/SkSVGValue.h +2 -2
  150. package/cpp/skia/{include/private → src/core}/SkChecksum.h +32 -17
  151. package/cpp/skia/src/core/SkTHash.h +1 -1
  152. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +3 -1
  153. package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +3 -1
  154. package/libs/android/arm64-v8a/libskia.a +0 -0
  155. package/libs/android/arm64-v8a/libskottie.a +0 -0
  156. package/libs/android/arm64-v8a/libsksg.a +0 -0
  157. package/libs/android/arm64-v8a/libsvg.a +0 -0
  158. package/libs/android/armeabi-v7a/libskia.a +0 -0
  159. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  160. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  161. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  162. package/libs/android/x86/libskia.a +0 -0
  163. package/libs/android/x86/libskottie.a +0 -0
  164. package/libs/android/x86/libsksg.a +0 -0
  165. package/libs/android/x86/libsvg.a +0 -0
  166. package/libs/android/x86_64/libskia.a +0 -0
  167. package/libs/android/x86_64/libskottie.a +0 -0
  168. package/libs/android/x86_64/libsksg.a +0 -0
  169. package/libs/android/x86_64/libsvg.a +0 -0
  170. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  171. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  172. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  173. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  174. package/libs/ios/libsksg.xcframework/Info.plist +5 -5
  175. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  176. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  177. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  178. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  179. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  180. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  181. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  182. package/package.json +1 -3
  183. package/cpp/skia/include/effects/SkTableColorFilter.h +0 -29
  184. package/cpp/skia/include/private/SkOpts_spi.h +0 -23
  185. package/cpp/skia/include/private/SkSpinlock.h +0 -57
  186. package/cpp/skia/include/private/chromium/GrSlug.h +0 -16
  187. package/scripts/install-npm.js +0 -33
@@ -0,0 +1,277 @@
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
+
8
+ #ifndef skgpu_graphite_Image_DEFINED
9
+ #define skgpu_graphite_Image_DEFINED
10
+
11
+ #include "include/core/SkImage.h"
12
+ #include "include/core/SkRefCnt.h"
13
+ #include "include/core/SkSpan.h"
14
+
15
+ class SkYUVAInfo;
16
+ class SkYUVAPixmaps;
17
+ struct SkIRect;
18
+
19
+ namespace skgpu::graphite {
20
+ class BackendTexture;
21
+ class Recorder;
22
+ class TextureInfo;
23
+ class YUVABackendTextureInfo;
24
+ class YUVABackendTextures;
25
+ enum class Volatile : bool;
26
+ }
27
+
28
+ namespace SkImages {
29
+ using TextureReleaseProc = void (*)(ReleaseContext);
30
+
31
+ // Passed to both non-YUVA fulfill and imageRelease
32
+ using GraphitePromiseImageContext = void*;
33
+ // Passed to YUVA fulfill
34
+ using GraphitePromiseTextureContext = void*;
35
+ // Returned from fulfill and passed into textureRelease
36
+ using GraphitePromiseTextureReleaseContext = void*;
37
+
38
+ using GraphitePromiseImageFulfillProc =
39
+ std::tuple<skgpu::graphite::BackendTexture, GraphitePromiseTextureReleaseContext> (*)(
40
+ GraphitePromiseImageContext);
41
+ using GraphitePromiseImageYUVAFulfillProc =
42
+ std::tuple<skgpu::graphite::BackendTexture, GraphitePromiseTextureReleaseContext> (*)(
43
+ GraphitePromiseTextureContext);
44
+ using GraphitePromiseImageReleaseProc = void (*)(GraphitePromiseImageContext);
45
+ using GraphitePromiseTextureReleaseProc = void (*)(GraphitePromiseTextureReleaseContext);
46
+
47
+ /** Creates an SkImage from a GPU texture associated with the recorder.
48
+
49
+ SkImage is returned if the format of backendTexture is recognized and supported.
50
+ Recognized formats vary by GPU back-end.
51
+
52
+ @param recorder The recorder
53
+ @param backendTexture texture residing on GPU
54
+ @param colorSpace This describes the color space of this image's contents, as
55
+ seen after sampling. In general, if the format of the backend
56
+ texture is SRGB, some linear colorSpace should be supplied
57
+ (e.g., SkColorSpace::MakeSRGBLinear()). If the format of the
58
+ backend texture is linear, then the colorSpace should include
59
+ a description of the transfer function as
60
+ well (e.g., SkColorSpace::MakeSRGB()).
61
+ @return created SkImage, or nullptr
62
+ */
63
+ SK_API sk_sp<SkImage> AdoptTextureFrom(skgpu::graphite::Recorder*,
64
+ const skgpu::graphite::BackendTexture&,
65
+ SkColorType colorType,
66
+ SkAlphaType alphaType,
67
+ sk_sp<SkColorSpace> colorSpace,
68
+ TextureReleaseProc = nullptr,
69
+ ReleaseContext = nullptr);
70
+
71
+ /** Create a new SkImage that is very similar to an SkImage created by
72
+ AdoptTextureFrom. The difference is that the caller need not have created the
73
+ backend texture nor populated it with data when creating the image. Instead of passing a
74
+ BackendTexture to the factory the client supplies a description of the texture consisting
75
+ of dimensions, TextureInfo, SkColorInfo and Volatility.
76
+
77
+ In general, 'fulfill' must return a BackendTexture that matches the properties
78
+ provided at SkImage creation time. The BackendTexture must refer to a valid existing
79
+ texture in the backend API context/device, and already be populated with data.
80
+ The texture cannot be deleted until 'textureRelease' is called. 'textureRelease' will
81
+ be called with the textureReleaseContext returned by 'fulfill'.
82
+
83
+ Wrt when and how often the fulfill, imageRelease, and textureRelease callbacks will
84
+ be called:
85
+
86
+ For non-volatile promise images, 'fulfill' will be called at Context::insertRecording
87
+ time. Regardless of whether 'fulfill' succeeded or failed, 'imageRelease' will always be
88
+ called only once - when Skia will no longer try calling 'fulfill' to get a backend
89
+ texture. If 'fulfill' failed (i.e., it didn't return a valid backend texture) then
90
+ 'textureRelease' will never be called. If 'fulfill' was successful then
91
+ 'textureRelease' will be called only once when the GPU is done with the contents of the
92
+ promise image. This will usually occur during a Context::submit call but it could occur
93
+ earlier due to error conditions. 'fulfill' can be called multiple times if the promise
94
+ image is used in multiple recordings. If 'fulfill' fails, the insertRecording itself will
95
+ fail. Subsequent insertRecording calls (with Recordings that use the promise image) will
96
+ keep calling 'fulfill' until it succeeds.
97
+
98
+ For volatile promise images, 'fulfill' will be called each time the Recording is inserted
99
+ into a Context. Regardless of whether 'fulfill' succeeded or failed, 'imageRelease'
100
+ will always be called only once just like the non-volatile case. If 'fulfill' fails at
101
+ insertRecording-time, 'textureRelease' will never be called. If 'fulfill' was successful
102
+ then a 'textureRelease' matching that 'fulfill' will be called when the GPU is done with
103
+ the contents of the promise image. This will usually occur during a Context::submit call
104
+ but it could occur earlier due to error conditions.
105
+
106
+ @param recorder the recorder that will capture the commands creating the image
107
+ @param dimensions width & height of promised gpu texture
108
+ @param textureInfo structural information for the promised gpu texture
109
+ @param colorInfo color type, alpha type and colorSpace information for the image
110
+ @param isVolatile volatility of the promise image
111
+ @param fulfill function called to get the actual backend texture,
112
+ and the instance for the GraphitePromiseTextureReleaseProc
113
+ @param imageRelease function called when any image-centric data can be deleted
114
+ @param textureRelease function called when the backend texture can be deleted
115
+ @param imageContext state passed to fulfill and imageRelease
116
+ @return created SkImage, or nullptr
117
+ */
118
+ SK_API sk_sp<SkImage> PromiseTextureFrom(skgpu::graphite::Recorder*,
119
+ SkISize dimensions,
120
+ const skgpu::graphite::TextureInfo&,
121
+ const SkColorInfo&,
122
+ skgpu::graphite::Volatile,
123
+ GraphitePromiseImageFulfillProc,
124
+ GraphitePromiseImageReleaseProc,
125
+ GraphitePromiseTextureReleaseProc,
126
+ GraphitePromiseImageContext);
127
+
128
+ /** This is similar to 'PromiseTextureFrom' but it creates a GPU-backed SkImage from YUV[A] data.
129
+ The source data may be planar (i.e. spread across multiple textures). In
130
+ the extreme Y, U, V, and A are all in different planes and thus the image is specified by
131
+ four textures. 'backendTextureInfo' describes the planar arrangement, texture formats,
132
+ and conversion to RGB. Separate 'fulfill' and 'textureRelease' calls are made for each texture.
133
+ Each texture has its own GraphitePromiseTextureContext. The GraphitePromiseImageReleaseProc
134
+ will be made even on failure. 'textureContexts' has one entry for each of the up to four
135
+ textures, as indicated by 'backendTextureInfo'. Currently the mipmapped property of
136
+ 'backendTextureInfo' is ignored. However, in the near future it will be required that if it is
137
+ kYes then the fulfillProc must return a mip mapped texture for each plane in order to
138
+ successfully draw the image.
139
+ @param recorder the recorder that will capture the commands creating the image
140
+ @param backendTextureInfo info about the promised yuva gpu texture(s)
141
+ @param imageColorSpace range of colors; may be nullptr
142
+ @param isVolatile volatility of the promise image
143
+ @param fulfill function called to get the actual backend texture for
144
+ a given GraphitePromiseTextureContext, and the instance
145
+ for the GraphitePromiseTextureReleaseProc
146
+ @param imageRelease function called when any image-centric data can be deleted
147
+ @param textureRelease function called when the backend texture can be deleted
148
+ @param imageContext state passed to imageRelease
149
+ @param textureContexts states passed to fulfill and textureRelease
150
+ @return created SkImage, or nullptr
151
+ */
152
+ SK_API sk_sp<SkImage> PromiseTextureFromYUVA(skgpu::graphite::Recorder*,
153
+ const skgpu::graphite::YUVABackendTextureInfo&,
154
+ sk_sp<SkColorSpace> imageColorSpace,
155
+ skgpu::graphite::Volatile,
156
+ GraphitePromiseImageYUVAFulfillProc,
157
+ GraphitePromiseImageReleaseProc,
158
+ GraphitePromiseTextureReleaseProc,
159
+ GraphitePromiseImageContext imageContext,
160
+ GraphitePromiseTextureContext textureContexts[]);
161
+
162
+
163
+ /** Returns an SkImage backed by a Graphite texture, using the provided Recorder for creation
164
+ and uploads if necessary. The returned SkImage respects the required image properties'
165
+ mipmap setting for non-Graphite SkImages; i.e., if mipmapping is required, the backing
166
+ Graphite texture will have allocated mip map levels.
167
+
168
+ It is assumed that MIP maps are always supported by the GPU.
169
+
170
+ Returns original SkImage if the image is already Graphite-backed and the required mipmapping
171
+ is compatible with the backing Graphite texture. If the required mipmapping is not
172
+ compatible, nullptr will be returned.
173
+
174
+ Returns nullptr if no Recorder is provided, or if SkImage was created with another
175
+ Recorder and work on that Recorder has not been submitted.
176
+
177
+ @param Recorder the Recorder to use for storing commands
178
+ @param RequiredProperties properties the returned SkImage must possess (e.g. mipmaps)
179
+ @return created SkImage, or nullptr
180
+ */
181
+ SK_API sk_sp<SkImage> TextureFromImage(skgpu::graphite::Recorder*,
182
+ const SkImage*,
183
+ SkImage::RequiredProperties = {});
184
+
185
+ inline sk_sp<SkImage> TextureFromImage(skgpu::graphite::Recorder* r,
186
+ sk_sp<const SkImage> img,
187
+ SkImage::RequiredProperties props = {}) {
188
+ return TextureFromImage(r, img.get(), props);
189
+ }
190
+
191
+ /** Creates SkImage from SkYUVAPixmaps.
192
+
193
+ The image will remain planar with each plane converted to a texture using the passed
194
+ Recorder.
195
+
196
+ SkYUVAPixmaps has a SkYUVAInfo which specifies the transformation from YUV to RGB.
197
+ The SkColorSpace of the resulting RGB values is specified by imgColorSpace. This will
198
+ be the SkColorSpace reported by the image and when drawn the RGB values will be converted
199
+ from this space into the destination space (if the destination is tagged).
200
+
201
+ This is only supported using the GPU backend and will fail if recorder is nullptr.
202
+
203
+ SkYUVAPixmaps does not need to remain valid after this returns.
204
+
205
+ @param Recorder The Recorder to use for storing commands
206
+ @param pixmaps The planes as pixmaps with supported SkYUVAInfo that
207
+ specifies conversion to RGB.
208
+ @param RequiredProperties Properties the returned SkImage must possess (e.g. mipmaps)
209
+ @param limitToMaxTextureSize Downscale image to GPU maximum texture size, if necessary
210
+ @param imgColorSpace Range of colors of the resulting image; may be nullptr
211
+ @return Created SkImage, or nullptr
212
+ */
213
+ SK_API sk_sp<SkImage> TextureFromYUVAPixmaps(skgpu::graphite::Recorder*,
214
+ const SkYUVAPixmaps& pixmaps,
215
+ SkImage::RequiredProperties = {},
216
+ bool limitToMaxTextureSize = false,
217
+ sk_sp<SkColorSpace> imgColorSpace = nullptr);
218
+
219
+ /** Creates an SkImage from YUV[A] planar textures associated with the recorder.
220
+ @param recorder The recorder.
221
+ @param yuvaBackendTextures A set of textures containing YUVA data and a description of the
222
+ data and transformation to RGBA.
223
+ @param imageColorSpace range of colors of the resulting image after conversion to RGB;
224
+ may be nullptr
225
+ @param TextureReleaseProc called when the backend textures can be released
226
+ @param ReleaseContext state passed to TextureReleaseProc
227
+ @return created SkImage, or nullptr
228
+ */
229
+ SK_API sk_sp<SkImage> TextureFromYUVATextures(
230
+ skgpu::graphite::Recorder* recorder,
231
+ const skgpu::graphite::YUVABackendTextures& yuvaBackendTextures,
232
+ sk_sp<SkColorSpace> imageColorSpace,
233
+ TextureReleaseProc = nullptr,
234
+ ReleaseContext = nullptr);
235
+
236
+ /** Creates an SkImage from YUV[A] planar SkImages associated with the recorder.
237
+
238
+ The images should have kGraphite type, and the result will be nullptr if any are not.
239
+ The resulting SkImage will not take a ref on the given SkImages but will take a ref on
240
+ the underlying TextureProxies. The releaseProcs, if any, for those Textures will be the
241
+ ones set when the given SkImages were created.
242
+
243
+ @param recorder The recorder.
244
+ @param yuvaInfo Structure describing the YUVA format
245
+ @param images A set of SkImages containing YUVA data
246
+ @param imageColorSpace Range of colors of the resulting image after conversion to RGB;
247
+ may be nullptr
248
+ @return created SkImage, or nullptr
249
+ */
250
+ SK_API sk_sp<SkImage> TextureFromYUVAImages(
251
+ skgpu::graphite::Recorder* recorder,
252
+ const SkYUVAInfo& yuvaInfo,
253
+ SkSpan<const sk_sp<SkImage>> images,
254
+ sk_sp<SkColorSpace> imageColorSpace);
255
+
256
+ /** Returns subset of this image as a texture-backed image.
257
+
258
+ Returns nullptr if any of the following are true:
259
+ - Subset is empty
260
+ - Subset is not contained inside the image's bounds
261
+ - Pixels in the source image could not be read or copied
262
+ - The source image is texture-backed and context does not match the source image's context.
263
+
264
+ @param recorder the non-null recorder in which to create the new image.
265
+ @param img Source image
266
+ @param subset bounds of returned SkImage
267
+ @param props properties the returned SkImage must possess (e.g. mipmaps)
268
+ @return the subsetted image, uploaded as a texture, or nullptr
269
+ */
270
+ SK_API sk_sp<SkImage> SubsetTextureFrom(skgpu::graphite::Recorder* recorder,
271
+ const SkImage* img,
272
+ const SkIRect& subset,
273
+ SkImage::RequiredProperties props = {});
274
+ } // namespace SkImages
275
+
276
+
277
+ #endif // skgpu_graphite_Image_DEFINED
@@ -55,7 +55,7 @@ public:
55
55
  // which could then be cached.
56
56
  virtual sk_sp<SkImage> findOrCreate(Recorder* recorder,
57
57
  const SkImage* image,
58
- SkImage::RequiredImageProperties) = 0;
58
+ SkImage::RequiredProperties) = 0;
59
59
  };
60
60
 
61
61
  } // namespace skgpu::graphite
@@ -9,7 +9,6 @@
9
9
  #define skgpu_graphite_Recording_DEFINED
10
10
 
11
11
  #include "include/core/SkRefCnt.h"
12
- #include "include/private/SkChecksum.h"
13
12
  #include "include/private/base/SkTArray.h"
14
13
 
15
14
  #include <memory>
@@ -62,9 +61,7 @@ private:
62
61
  };
63
62
 
64
63
  struct ProxyHash {
65
- std::size_t operator()(const sk_sp<TextureProxy>& proxy) const {
66
- return SkGoodHash()(proxy.get());
67
- }
64
+ std::size_t operator()(const sk_sp<TextureProxy>& proxy) const;
68
65
  };
69
66
 
70
67
  Recording(std::unique_ptr<TaskGraph>,
@@ -0,0 +1,81 @@
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
+
8
+ #ifndef skgpu_graphite_Surface_DEFINED
9
+ #define skgpu_graphite_Surface_DEFINED
10
+
11
+ #include "include/core/SkRefCnt.h"
12
+ #include "include/core/SkSurface.h"
13
+ #include "include/gpu/GpuTypes.h"
14
+
15
+ class SkImage;
16
+ struct SkImageInfo;
17
+
18
+ namespace skgpu::graphite {
19
+ class BackendTexture;
20
+ class Recorder;
21
+ } // namespace skgpu::graphite
22
+
23
+ namespace SkSurfaces {
24
+ /**
25
+ * The 'asImage' and 'makeImageCopy' API/entry points are currently only available for
26
+ * Graphite.
27
+ *
28
+ * In this API, SkSurface no longer supports copy-on-write behavior. Instead, when creating
29
+ * an image for a surface, the client must explicitly indicate if a copy should be made.
30
+ * In both of the below calls the resource backing the surface will never change.
31
+ *
32
+ * The 'AsImage' entry point has some major ramifications for the mutability of the
33
+ * returned SkImage. Since the originating surface and the returned image share the
34
+ * same backing, care must be taken by the client to ensure that the contents of the image
35
+ * reflect the desired contents when it is consumed by the gpu.
36
+ * Note: if the backing GPU buffer isn't textureable this method will return null. Graphite
37
+ * will not attempt to make a copy.
38
+ * Note: For 'AsImage', the mipmapping of the image will match that of the source surface.
39
+ *
40
+ * The 'AsImageCopy' entry point allows subsetting and the addition of mipmaps (since
41
+ * a copy is already being made).
42
+ *
43
+ * In Graphite, the legacy API call (i.e., makeImageSnapshot) will just always make a copy.
44
+ */
45
+ SK_API sk_sp<SkImage> AsImage(sk_sp<const SkSurface>);
46
+ SK_API sk_sp<SkImage> AsImageCopy(sk_sp<const SkSurface>,
47
+ const SkIRect* subset = nullptr,
48
+ skgpu::Mipmapped = skgpu::Mipmapped::kNo);
49
+
50
+ /**
51
+ * In Graphite, while clients hold a ref on an SkSurface, the backing gpu object does _not_
52
+ * count against the budget. Once an SkSurface is freed, the backing gpu object may or may
53
+ * not become a scratch (i.e., reusable) resource but, if it does, it will be counted against
54
+ * the budget.
55
+ */
56
+ SK_API sk_sp<SkSurface> RenderTarget(skgpu::graphite::Recorder*,
57
+ const SkImageInfo& imageInfo,
58
+ skgpu::Mipmapped = skgpu::Mipmapped::kNo,
59
+ const SkSurfaceProps* surfaceProps = nullptr);
60
+
61
+ /**
62
+ * Wraps a GPU-backed texture in an SkSurface. Depending on the backend gpu API, the caller may
63
+ * be required to ensure the texture is valid for the lifetime of the returned SkSurface. The
64
+ * required lifetimes for the specific apis are:
65
+ * Metal: Skia will call retain on the underlying MTLTexture so the caller can drop it once
66
+ * this call returns.
67
+ *
68
+ * SkSurface is returned if all the parameters are valid. The backendTexture is valid if its
69
+ * format agrees with colorSpace and recorder; for instance, if backendTexture has an sRGB
70
+ * configuration, then the recorder must support sRGB, and colorSpace must be present. Further,
71
+ * backendTexture's width and height must not exceed the recorder's capabilities, and the
72
+ * recorder must be able to support the back-end texture.
73
+ */
74
+ SK_API sk_sp<SkSurface> WrapBackendTexture(skgpu::graphite::Recorder*,
75
+ const skgpu::graphite::BackendTexture&,
76
+ SkColorType colorType,
77
+ sk_sp<SkColorSpace> colorSpace,
78
+ const SkSurfaceProps* props);
79
+ } // namespace SkSurfaces
80
+
81
+ #endif // skgpu_graphite_Surface_DEFINED
@@ -8,6 +8,7 @@
8
8
  #ifndef skgpu_graphite_TextureInfo_DEFINED
9
9
  #define skgpu_graphite_TextureInfo_DEFINED
10
10
 
11
+ #include "include/core/SkString.h"
11
12
  #include "include/gpu/graphite/GraphiteTypes.h"
12
13
 
13
14
  #ifdef SK_DAWN
@@ -76,13 +77,7 @@ public:
76
77
  Protected isProtected() const { return fProtected; }
77
78
 
78
79
  #ifdef SK_DAWN
79
- bool getDawnTextureInfo(DawnTextureInfo* info) const {
80
- if (!this->isValid() || fBackend != BackendApi::kDawn) {
81
- return false;
82
- }
83
- *info = DawnTextureSpecToTextureInfo(fDawnSpec, fSampleCount, fMipmapped);
84
- return true;
85
- }
80
+ bool getDawnTextureInfo(DawnTextureInfo* info) const;
86
81
  #endif
87
82
 
88
83
  #ifdef SK_METAL
@@ -105,6 +100,8 @@ public:
105
100
  }
106
101
  #endif
107
102
 
103
+ SkString toString() const;
104
+
108
105
  private:
109
106
  #ifdef SK_DAWN
110
107
  friend class DawnCaps;
@@ -154,6 +151,7 @@ private:
154
151
  #ifdef SK_VULKAN
155
152
  VulkanTextureSpec fVkSpec;
156
153
  #endif
154
+ void* fEnsureUnionNonEmpty;
157
155
  };
158
156
  };
159
157
 
@@ -39,7 +39,7 @@ public:
39
39
  */
40
40
  YUVABackendTextureInfo(const Recorder*,
41
41
  const SkYUVAInfo&,
42
- const TextureInfo[kMaxPlanes],
42
+ SkSpan<const TextureInfo>,
43
43
  Mipmapped);
44
44
 
45
45
  bool operator==(const YUVABackendTextureInfo&) const;
@@ -97,7 +97,7 @@ public:
97
97
  */
98
98
  YUVABackendTextures(const Recorder*,
99
99
  const SkYUVAInfo&,
100
- const BackendTexture[kMaxPlanes]);
100
+ SkSpan<const BackendTexture>);
101
101
 
102
102
  SkSpan<const BackendTexture> planeTextures() const {
103
103
  return SkSpan<const BackendTexture>(fPlaneTextures);
@@ -22,10 +22,12 @@ struct GrMockTextureInfo {
22
22
 
23
23
  GrMockTextureInfo(GrColorType colorType,
24
24
  SkTextureCompressionType compressionType,
25
- int id)
25
+ int id,
26
+ skgpu::Protected isProtected = skgpu::Protected::kNo)
26
27
  : fColorType(colorType)
27
28
  , fCompressionType(compressionType)
28
- , fID(id) {
29
+ , fID(id)
30
+ , fProtected(isProtected) {
29
31
  SkASSERT(fID);
30
32
  if (fCompressionType != SkTextureCompressionType::kNone) {
31
33
  SkASSERT(colorType == GrColorType::kUnknown);
@@ -35,7 +37,8 @@ struct GrMockTextureInfo {
35
37
  bool operator==(const GrMockTextureInfo& that) const {
36
38
  return fColorType == that.fColorType &&
37
39
  fCompressionType == that.fCompressionType &&
38
- fID == that.fID;
40
+ fID == that.fID &&
41
+ fProtected == that.fProtected;
39
42
  }
40
43
 
41
44
  GrBackendFormat getBackendFormat() const;
@@ -49,10 +52,14 @@ struct GrMockTextureInfo {
49
52
 
50
53
  int id() const { return fID; }
51
54
 
55
+ skgpu::Protected getProtected() const { return fProtected; }
56
+ bool isProtected() const { return fProtected == skgpu::Protected::kYes; }
57
+
52
58
  private:
53
59
  GrColorType fColorType;
54
60
  SkTextureCompressionType fCompressionType;
55
61
  int fID;
62
+ skgpu::Protected fProtected = skgpu::Protected::kNo;
56
63
  };
57
64
 
58
65
  struct GrMockRenderTargetInfo {
@@ -60,24 +67,32 @@ struct GrMockRenderTargetInfo {
60
67
  : fColorType(GrColorType::kUnknown)
61
68
  , fID(0) {}
62
69
 
63
- GrMockRenderTargetInfo(GrColorType colorType, int id)
70
+ GrMockRenderTargetInfo(GrColorType colorType,
71
+ int id,
72
+ skgpu::Protected isProtected = skgpu::Protected::kNo)
64
73
  : fColorType(colorType)
65
- , fID(id) {
74
+ , fID(id)
75
+ , fProtected(isProtected) {
66
76
  SkASSERT(fID);
67
77
  }
68
78
 
69
79
  bool operator==(const GrMockRenderTargetInfo& that) const {
70
80
  return fColorType == that.fColorType &&
71
- fID == that.fID;
81
+ fID == that.fID &&
82
+ fProtected == that.fProtected;
72
83
  }
73
84
 
74
85
  GrBackendFormat getBackendFormat() const;
75
86
 
76
87
  GrColorType colorType() const { return fColorType; }
77
88
 
89
+ skgpu::Protected getProtected() const { return fProtected; }
90
+ bool isProtected() const { return fProtected == skgpu::Protected::kYes; }
91
+
78
92
  private:
79
- GrColorType fColorType;
80
- int fID;
93
+ GrColorType fColorType;
94
+ int fID;
95
+ skgpu::Protected fProtected = skgpu::Protected::kNo;
81
96
  };
82
97
 
83
98
  struct GrMockSurfaceInfo {
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Copyright 2023 Google Inc.
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 SkTypeface_fontations_DEFINED
9
+ #define SkTypeface_fontations_DEFINED
10
+
11
+ #include "include/core/SkFontArguments.h"
12
+ #include "include/core/SkRefCnt.h"
13
+ #include "include/core/SkTypeface.h"
14
+ #include "include/core/SkTypes.h"
15
+
16
+ #include <memory>
17
+
18
+ SK_API sk_sp<SkTypeface> SkTypeface_Make_Fontations(std::unique_ptr<SkStreamAsset> fontData,
19
+ const SkFontArguments& args);
20
+
21
+ #endif
@@ -34,6 +34,8 @@
34
34
  * In the above math, log() is a natural logarithm and exp() is natural exponentiation. Note,
35
35
  * however, that the base used for the log() and exp() functions does not affect the results of
36
36
  * the computation (it cancels out, as long as the same base is used throughout).
37
+ *
38
+ * This product includes Gain Map technology under license by Adobe.
37
39
  */
38
40
  struct SkGainmapInfo {
39
41
  /**
@@ -9,6 +9,7 @@
9
9
  #define SkGainmapShader_DEFINED
10
10
 
11
11
  #include "include/core/SkRefCnt.h"
12
+ #include "include/private/base/SkAPI.h"
12
13
 
13
14
  class SkColorSpace;
14
15
  class SkShader;
@@ -19,7 +19,6 @@ struct SkGainmapInfo;
19
19
 
20
20
  /**
21
21
  * An interface that can be used to extract metadata from an encoded JPEG file.
22
- * TODO(https://crbug.com/1404000): Add interface for ICC profile and EXIF extraction.
23
22
  */
24
23
  class SK_API SkJpegMetadataDecoder {
25
24
  public:
@@ -48,6 +47,25 @@ public:
48
47
  */
49
48
  static std::unique_ptr<SkJpegMetadataDecoder> Make(std::vector<Segment> headerSegments);
50
49
 
50
+ /**
51
+ * Return the Exif data attached to the image (if any) and nullptr otherwise. If |copyData| is
52
+ * false, then the returned SkData may directly reference the data provided when this object was
53
+ * created.
54
+ */
55
+ virtual sk_sp<SkData> getExifMetadata(bool copyData) const = 0;
56
+
57
+ /**
58
+ * Return the ICC profile of the image if any, and nullptr otherwise. If |copyData| is false,
59
+ * then the returned SkData may directly reference the data provided when this object was
60
+ * created.
61
+ */
62
+ virtual sk_sp<SkData> getICCProfileData(bool copyData) const = 0;
63
+
64
+ /**
65
+ * Return true if there is a possibility that this image contains a gainmap image.
66
+ */
67
+ virtual bool mightHaveGainmapImage() const = 0;
68
+
51
69
  /**
52
70
  * Given a JPEG encoded image |baseImageData|, return in |outGainmapImageData| the JPEG encoded
53
71
  * gainmap image and return in |outGainmapInfo| its gainmap rendering parameters. Return true if
@@ -360,10 +360,12 @@ private:
360
360
  // The next two values don't matter unless fIsOval or fIsRRect are true.
361
361
  fRRectOrOvalIsCCW = false;
362
362
  fRRectOrOvalStartIdx = 0xAC;
363
- if (numPoints > 0)
364
- fPoints.reserve_back(numPoints);
365
- if (numVerbs > 0)
366
- fVerbs.reserve_back(numVerbs);
363
+ if (numPoints > 0) {
364
+ fPoints.reserve_exact(numPoints);
365
+ }
366
+ if (numVerbs > 0) {
367
+ fVerbs.reserve_exact(numVerbs);
368
+ }
367
369
  SkDEBUGCODE(fEditorsAttached.store(0);)
368
370
  SkDEBUGCODE(this->validate();)
369
371
  }
@@ -378,7 +380,7 @@ private:
378
380
  // called, if dirty, by getBounds()
379
381
  void computeBounds() const {
380
382
  SkDEBUGCODE(this->validate();)
381
- // TODO(mtklein): remove fBoundsIsDirty and fIsFinite,
383
+ // TODO: remove fBoundsIsDirty and fIsFinite,
382
384
  // using an inverted rect instead of fBoundsIsDirty and always recalculating fIsFinite.
383
385
  SkASSERT(fBoundsIsDirty);
384
386
 
@@ -424,18 +426,14 @@ private:
424
426
  * allocates space for reserveVerb additional verbs and reservePoints additional points.*/
425
427
  void resetToSize(int verbCount, int pointCount, int conicCount,
426
428
  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
- }
429
+ this->commonReset();
430
+ // Use reserve_exact() so the arrays are sized to exactly fit the data.
431
+ fPoints.reserve_exact(pointCount + reservePoints);
433
432
  fPoints.resize_back(pointCount);
434
- const int verbDelta = verbCount + reserveVerbs - fVerbs.size();
435
- if (verbDelta > 0) {
436
- fVerbs.reserve_back(verbDelta);
437
- }
433
+
434
+ fVerbs.reserve_exact(verbCount + reserveVerbs);
438
435
  fVerbs.resize_back(verbCount);
436
+
439
437
  fConicWeights.resize_back(conicCount);
440
438
  SkDEBUGCODE(this->validate();)
441
439
  }