@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,217 @@
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 SkSurfaceGanesh_DEFINED
9
+ #define SkSurfaceGanesh_DEFINED
10
+
11
+ #include "include/core/SkImageInfo.h"
12
+ #include "include/core/SkRefCnt.h"
13
+ #include "include/core/SkSurface.h"
14
+ #include "include/gpu/GrTypes.h"
15
+ #include "include/private/base/SkAPI.h"
16
+
17
+ class GrBackendRenderTarget;
18
+ class GrBackendTexture;
19
+ class GrRecordingContext;
20
+ class SkColorSpace;
21
+ class GrSurfaceCharacterization;
22
+ class SkSurfaceProps;
23
+ enum SkColorType : int;
24
+ namespace skgpu {
25
+ enum class Budgeted : bool;
26
+ }
27
+
28
+ namespace SkSurfaces {
29
+
30
+ /** Caller data passed to RenderTarget/TextureReleaseProc; may be nullptr. */
31
+ using ReleaseContext = void*;
32
+
33
+ /** User function called when supplied render target may be deleted. */
34
+ using RenderTargetReleaseProc = void (*)(ReleaseContext);
35
+
36
+ /** User function called when supplied texture may be deleted. */
37
+ using TextureReleaseProc = void (*)(ReleaseContext);
38
+
39
+ /** Returns SkSurface on GPU indicated by context. Allocates memory for
40
+ pixels, based on the width, height, and SkColorType in SkImageInfo. budgeted
41
+ selects whether allocation for pixels is tracked by context. imageInfo
42
+ describes the pixel format in SkColorType, and transparency in
43
+ SkAlphaType, and color matching in SkColorSpace.
44
+
45
+ sampleCount requests the number of samples per pixel.
46
+ Pass zero to disable multi-sample anti-aliasing. The request is rounded
47
+ up to the next supported count, or rounded down if it is larger than the
48
+ maximum supported count.
49
+
50
+ surfaceOrigin pins either the top-left or the bottom-left corner to the origin.
51
+
52
+ shouldCreateWithMips hints that SkImage returned by makeImageSnapshot() is mip map.
53
+
54
+ @param context GPU context
55
+ @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace;
56
+ width, or height, or both, may be zero
57
+ @param sampleCount samples per pixel, or 0 to disable full scene anti-aliasing
58
+ @param surfaceOrigin How to align the pixel data.
59
+ @param surfaceProps LCD striping orientation and setting for device independent
60
+ fonts; may be nullptr
61
+ @param shouldCreateWithMips hint that SkSurface will host mip map images
62
+ @return SkSurface if all parameters are valid; otherwise, nullptr
63
+ */
64
+ SK_API sk_sp<SkSurface> RenderTarget(GrRecordingContext* context,
65
+ skgpu::Budgeted budgeted,
66
+ const SkImageInfo& imageInfo,
67
+ int sampleCount,
68
+ GrSurfaceOrigin surfaceOrigin,
69
+ const SkSurfaceProps* surfaceProps,
70
+ bool shouldCreateWithMips = false);
71
+ inline sk_sp<SkSurface> RenderTarget(GrRecordingContext* context,
72
+ skgpu::Budgeted budgeted,
73
+ const SkImageInfo& imageInfo,
74
+ int sampleCount,
75
+ const SkSurfaceProps* surfaceProps) {
76
+ return RenderTarget(
77
+ context, budgeted, imageInfo, sampleCount, kBottomLeft_GrSurfaceOrigin, surfaceProps);
78
+ }
79
+ inline sk_sp<SkSurface> RenderTarget(GrRecordingContext* context,
80
+ skgpu::Budgeted budgeted,
81
+ const SkImageInfo& imageInfo) {
82
+ if (!imageInfo.width() || !imageInfo.height()) {
83
+ return nullptr;
84
+ }
85
+ return RenderTarget(context, budgeted, imageInfo, 0, kBottomLeft_GrSurfaceOrigin, nullptr);
86
+ }
87
+
88
+ /** Returns SkSurface on GPU indicated by context that is compatible with the provided
89
+ characterization. budgeted selects whether allocation for pixels is tracked by context.
90
+
91
+ @param context GPU context
92
+ @param characterization description of the desired SkSurface
93
+ @return SkSurface if all parameters are valid; otherwise, nullptr
94
+ */
95
+ SK_API sk_sp<SkSurface> RenderTarget(GrRecordingContext* context,
96
+ const GrSurfaceCharacterization& characterization,
97
+ skgpu::Budgeted budgeted);
98
+
99
+ /** Wraps a GPU-backed texture into SkSurface. Caller must ensure the texture is
100
+ valid for the lifetime of returned SkSurface. If sampleCnt greater than zero,
101
+ creates an intermediate MSAA SkSurface which is used for drawing backendTexture.
102
+
103
+ SkSurface is returned if all parameters are valid. backendTexture is valid if
104
+ its pixel configuration agrees with colorSpace and context; for instance, if
105
+ backendTexture has an sRGB configuration, then context must support sRGB,
106
+ and colorSpace must be present. Further, backendTexture width and height must
107
+ not exceed context capabilities, and the context must be able to support
108
+ back-end textures.
109
+
110
+ Upon success textureReleaseProc is called when it is safe to delete the texture in the
111
+ backend API (accounting only for use of the texture by this surface). If SkSurface creation
112
+ fails textureReleaseProc is called before this function returns.
113
+
114
+ @param context GPU context
115
+ @param backendTexture texture residing on GPU
116
+ @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
117
+ @param colorSpace range of colors; may be nullptr
118
+ @param surfaceProps LCD striping orientation and setting for device independent
119
+ fonts; may be nullptr
120
+ @param textureReleaseProc function called when texture can be released
121
+ @param releaseContext state passed to textureReleaseProc
122
+ @return SkSurface if all parameters are valid; otherwise, nullptr
123
+ */
124
+ SK_API sk_sp<SkSurface> WrapBackendTexture(GrRecordingContext* context,
125
+ const GrBackendTexture& backendTexture,
126
+ GrSurfaceOrigin origin,
127
+ int sampleCnt,
128
+ SkColorType colorType,
129
+ sk_sp<SkColorSpace> colorSpace,
130
+ const SkSurfaceProps* surfaceProps,
131
+ TextureReleaseProc textureReleaseProc = nullptr,
132
+ ReleaseContext releaseContext = nullptr);
133
+
134
+ /** Wraps a GPU-backed buffer into SkSurface. Caller must ensure backendRenderTarget
135
+ is valid for the lifetime of returned SkSurface.
136
+
137
+ SkSurface is returned if all parameters are valid. backendRenderTarget is valid if
138
+ its pixel configuration agrees with colorSpace and context; for instance, if
139
+ backendRenderTarget has an sRGB configuration, then context must support sRGB,
140
+ and colorSpace must be present. Further, backendRenderTarget width and height must
141
+ not exceed context capabilities, and the context must be able to support
142
+ back-end render targets.
143
+
144
+ Upon success releaseProc is called when it is safe to delete the render target in the
145
+ backend API (accounting only for use of the render target by this surface). If SkSurface
146
+ creation fails releaseProc is called before this function returns.
147
+
148
+ @param context GPU context
149
+ @param backendRenderTarget GPU intermediate memory buffer
150
+ @param colorSpace range of colors
151
+ @param surfaceProps LCD striping orientation and setting for device independent
152
+ fonts; may be nullptr
153
+ @param releaseProc function called when backendRenderTarget can be released
154
+ @param releaseContext state passed to releaseProc
155
+ @return SkSurface if all parameters are valid; otherwise, nullptr
156
+ */
157
+ SK_API sk_sp<SkSurface> WrapBackendRenderTarget(GrRecordingContext* context,
158
+ const GrBackendRenderTarget& backendRenderTarget,
159
+ GrSurfaceOrigin origin,
160
+ SkColorType colorType,
161
+ sk_sp<SkColorSpace> colorSpace,
162
+ const SkSurfaceProps* surfaceProps,
163
+ RenderTargetReleaseProc releaseProc = nullptr,
164
+ ReleaseContext releaseContext = nullptr);
165
+
166
+ using BackendHandleAccess = SkSurface::BackendHandleAccess;
167
+
168
+ /** Retrieves the back-end texture. If SkSurface has no back-end texture, an invalid
169
+ object is returned. Call GrBackendTexture::isValid to determine if the result
170
+ is valid.
171
+
172
+ The returned GrBackendTexture should be discarded if the SkSurface is drawn to or deleted.
173
+
174
+ @return GPU texture reference; invalid on failure
175
+ */
176
+ SK_API GrBackendTexture GetBackendTexture(SkSurface*, BackendHandleAccess);
177
+
178
+ /** Retrieves the back-end render target. If SkSurface has no back-end render target, an invalid
179
+ object is returned. Call GrBackendRenderTarget::isValid to determine if the result
180
+ is valid.
181
+
182
+ The returned GrBackendRenderTarget should be discarded if the SkSurface is drawn to
183
+ or deleted.
184
+
185
+ @return GPU render target reference; invalid on failure
186
+ */
187
+ SK_API GrBackendRenderTarget GetBackendRenderTarget(SkSurface*, BackendHandleAccess);
188
+
189
+ /** If a surface is a Ganesh-backed surface, is being drawn with MSAA, and there is a resolve
190
+ texture, this call will insert a resolve command into the stream of gpu commands. In order
191
+ for the resolve to actually have an effect, the work still needs to be flushed and submitted
192
+ to the GPU after recording the resolve command. If a resolve is not supported or the
193
+ SkSurface has no dirty work to resolve, then this call is a no-op.
194
+
195
+ This call is most useful when the SkSurface is created by wrapping a single sampled gpu
196
+ texture, but asking Skia to render with MSAA. If the client wants to use the wrapped texture
197
+ outside of Skia, the only way to trigger a resolve is either to call this command or use
198
+ GrDirectContext::flush.
199
+ */
200
+ SK_API void ResolveMSAA(SkSurface* surface);
201
+ inline void ResolveMSAA(sk_sp<SkSurface> surface) {
202
+ return ResolveMSAA(surface.get());
203
+ }
204
+
205
+ } // namespace SkSurfaces
206
+
207
+ namespace skgpu::ganesh {
208
+ // Clients should strive to call GrDirectContext::flush directly. However, there exist some
209
+ // places where the GrDirectContext is hard to find, these helpers allow for the flushing of the
210
+ // provided surface. This is a no-op if the surface is nullptr or not GPU backed.
211
+ SK_API GrSemaphoresSubmitted Flush(sk_sp<SkSurface>);
212
+ SK_API GrSemaphoresSubmitted Flush(SkSurface*);
213
+ SK_API void FlushAndSubmit(sk_sp<SkSurface>);
214
+ SK_API void FlushAndSubmit(SkSurface*);
215
+ } // namespace skgpu::ganesh
216
+
217
+ #endif
@@ -0,0 +1,73 @@
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 SkSurfaceMetal_DEFINED
9
+ #define SkSurfaceMetal_DEFINED
10
+
11
+ #include "include/core/SkRefCnt.h"
12
+ #include "include/core/SkSurface.h"
13
+ #include "include/gpu/GrTypes.h"
14
+ #include "include/gpu/ganesh/SkSurfaceGanesh.h"
15
+ #include "include/gpu/mtl/GrMtlTypes.h"
16
+
17
+ namespace SkSurfaces {
18
+ /** Creates SkSurface from CAMetalLayer.
19
+ Returned SkSurface takes a reference on the CAMetalLayer. The ref on the layer will be
20
+ released when the SkSurface is destroyed.
21
+
22
+ Only available when Metal API is enabled.
23
+
24
+ Will grab the current drawable from the layer and use its texture as a backendRT to
25
+ create a renderable surface.
26
+
27
+ @param context GPU context
28
+ @param layer GrMTLHandle (expected to be a CAMetalLayer*)
29
+ @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
30
+ @param colorSpace range of colors; may be nullptr
31
+ @param surfaceProps LCD striping orientation and setting for device independent
32
+ fonts; may be nullptr
33
+ @param drawable Pointer to drawable to be filled in when this surface is
34
+ instantiated; may not be nullptr
35
+ @return created SkSurface, or nullptr
36
+ */
37
+ SK_API sk_sp<SkSurface> WrapCAMetalLayer(GrRecordingContext* context,
38
+ GrMTLHandle layer,
39
+ GrSurfaceOrigin origin,
40
+ int sampleCnt,
41
+ SkColorType colorType,
42
+ sk_sp<SkColorSpace> colorSpace,
43
+ const SkSurfaceProps* surfaceProps,
44
+ GrMTLHandle* drawable) SK_API_AVAILABLE_CA_METAL_LAYER;
45
+
46
+ /** Creates SkSurface from MTKView.
47
+ Returned SkSurface takes a reference on the MTKView. The ref on the layer will be
48
+ released when the SkSurface is destroyed.
49
+
50
+ Only available when Metal API is enabled.
51
+
52
+ Will grab the current drawable from the layer and use its texture as a backendRT to
53
+ create a renderable surface.
54
+
55
+ @param context GPU context
56
+ @param layer GrMTLHandle (expected to be a MTKView*)
57
+ @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
58
+ @param colorSpace range of colors; may be nullptr
59
+ @param surfaceProps LCD striping orientation and setting for device independent
60
+ fonts; may be nullptr
61
+ @return created SkSurface, or nullptr
62
+ */
63
+ SK_API sk_sp<SkSurface> WrapMTKView(GrRecordingContext* context,
64
+ GrMTLHandle mtkView,
65
+ GrSurfaceOrigin origin,
66
+ int sampleCnt,
67
+ SkColorType colorType,
68
+ sk_sp<SkColorSpace> colorSpace,
69
+ const SkSurfaceProps* surfaceProps)
70
+ SK_API_AVAILABLE(macos(10.11), ios(9.0));
71
+ } // namespace SkSurfaces
72
+
73
+ #endif
@@ -181,19 +181,30 @@ struct GrGLTextureInfo {
181
181
  GrGLenum fTarget;
182
182
  GrGLuint fID;
183
183
  GrGLenum fFormat = 0;
184
+ skgpu::Protected fProtected = skgpu::Protected::kNo;
184
185
 
185
186
  bool operator==(const GrGLTextureInfo& that) const {
186
- return fTarget == that.fTarget && fID == that.fID && fFormat == that.fFormat;
187
+ return fTarget == that.fTarget &&
188
+ fID == that.fID &&
189
+ fFormat == that.fFormat &&
190
+ fProtected == that.fProtected;
187
191
  }
192
+
193
+ bool isProtected() const { return fProtected == skgpu::Protected::kYes; }
188
194
  };
189
195
 
190
196
  struct GrGLFramebufferInfo {
191
197
  GrGLuint fFBOID;
192
198
  GrGLenum fFormat = 0;
199
+ skgpu::Protected fProtected = skgpu::Protected::kNo;
193
200
 
194
201
  bool operator==(const GrGLFramebufferInfo& that) const {
195
- return fFBOID == that.fFBOID && fFormat == that.fFormat;
202
+ return fFBOID == that.fFBOID &&
203
+ fFormat == that.fFormat &&
204
+ fProtected == that.fProtected;
196
205
  }
206
+
207
+ bool isProtected() const { return fProtected == skgpu::Protected::kYes; }
197
208
  };
198
209
 
199
210
  struct GrGLSurfaceInfo {
@@ -0,0 +1,78 @@
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_BackendSemaphore_DEFINED
9
+ #define skgpu_graphite_BackendSemaphore_DEFINED
10
+
11
+ #include "include/core/SkRefCnt.h"
12
+ #include "include/gpu/graphite/GraphiteTypes.h"
13
+
14
+ #ifdef SK_METAL
15
+ #include "include/gpu/graphite/mtl/MtlGraphiteTypes.h"
16
+ #endif
17
+
18
+ #ifdef SK_VULKAN
19
+ #include "include/private/gpu/vk/SkiaVulkan.h"
20
+ #endif
21
+
22
+ namespace skgpu::graphite {
23
+
24
+ class SK_API BackendSemaphore {
25
+ public:
26
+ BackendSemaphore();
27
+ #ifdef SK_METAL
28
+ // TODO: Determine creator's responsibility for setting refcnt.
29
+ BackendSemaphore(MtlHandle mtlEvent, uint64_t value);
30
+ #endif
31
+
32
+ #ifdef SK_VULKAN
33
+ BackendSemaphore(VkSemaphore semaphore);
34
+ #endif
35
+
36
+ BackendSemaphore(const BackendSemaphore&);
37
+
38
+ ~BackendSemaphore();
39
+
40
+ BackendSemaphore& operator=(const BackendSemaphore&);
41
+
42
+ bool isValid() const { return fIsValid; }
43
+ BackendApi backend() const { return fBackend; }
44
+
45
+ #ifdef SK_METAL
46
+ MtlHandle getMtlEvent() const;
47
+ uint64_t getMtlValue() const;
48
+ #endif
49
+
50
+ #ifdef SK_VULKAN
51
+ VkSemaphore getVkSemaphore() const;
52
+ #endif
53
+
54
+ private:
55
+ // TODO: For now, implement as a union until we figure out the plan for this and BackendTexture.
56
+ union {
57
+ #ifdef SK_DAWN
58
+ // TODO: WebGPU doesn't seem to have the notion of an Event or Semaphore
59
+ #endif
60
+ #ifdef SK_METAL
61
+ struct {
62
+ MtlHandle fMtlEvent; // Expected to be an id<MTLEvent>
63
+ uint64_t fMtlValue;
64
+ };
65
+ #endif
66
+ #ifdef SK_VULKAN
67
+ VkSemaphore fVkSemaphore;
68
+ #endif
69
+ void* fEnsureUnionNonEmpty;
70
+ };
71
+ bool fIsValid = false;
72
+ BackendApi fBackend;
73
+ };
74
+
75
+ } // namespace skgpu::graphite
76
+
77
+ #endif // skgpu_graphite_BackendSemaphore_DEFINED
78
+
@@ -131,6 +131,7 @@ private:
131
131
  #ifdef SK_VULKAN
132
132
  VkImage fVkImage;
133
133
  #endif
134
+ void* fEnsureUnionNonEmpty;
134
135
  };
135
136
  };
136
137