@shopify/react-native-skia 0.1.197 → 0.1.199

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 +3 -4
  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,49 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+ #ifndef SkRawDecoder_DEFINED
8
+ #define SkRawDecoder_DEFINED
9
+
10
+ #include "include/codec/SkCodec.h"
11
+ #include "include/core/SkRefCnt.h"
12
+
13
+ class SkData;
14
+ class SkStream;
15
+
16
+ #include <memory>
17
+
18
+ namespace SkRawDecoder {
19
+
20
+ inline bool IsRaw(const void*, size_t) {
21
+ // Raw formats are tricky to detect just by reading in the first several bytes.
22
+ // For example, PIEX might need to read 10k bytes to detect Sony's arw format
23
+ // https://github.com/google/piex/blob/f1e15dd837c04347504149f71db67a78fbeddc73/src/image_type_recognition/image_type_recognition_lite.cc#L152
24
+ // Thus, we just assume everything might be a RAW file and check it last.
25
+ return true;
26
+ }
27
+
28
+ /**
29
+ * Attempts to decode the given bytes as a raw image.
30
+ *
31
+ * If the bytes are not a raw, returns nullptr.
32
+ *
33
+ * DecodeContext is ignored
34
+ */
35
+ SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
36
+ SkCodec::Result*,
37
+ SkCodecs::DecodeContext = nullptr);
38
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
39
+ SkCodec::Result*,
40
+ SkCodecs::DecodeContext = nullptr);
41
+
42
+ // This decoder will always be checked last, no matter when it is registered.
43
+ inline SkCodecs::Decoder Decoder() {
44
+ return { "raw", IsRaw, Decode };
45
+ }
46
+
47
+ } // namespace SkRawDecoder
48
+
49
+ #endif // SkRawDecoder_DEFINED
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+ #ifndef SkWbmpDecoder_DEFINED
8
+ #define SkWbmpDecoder_DEFINED
9
+
10
+ #include "include/codec/SkCodec.h"
11
+ #include "include/core/SkRefCnt.h"
12
+
13
+ class SkData;
14
+ class SkStream;
15
+
16
+ #include <memory>
17
+
18
+ namespace SkWbmpDecoder {
19
+
20
+ /** Returns true if this data claims to be a WBMP image. */
21
+ SK_API bool IsWbmp(const void*, size_t);
22
+
23
+ /**
24
+ * Attempts to decode the given bytes as a WBMP.
25
+ *
26
+ * If the bytes are not a WBMP, returns nullptr.
27
+ *
28
+ * DecodeContext is ignored
29
+ */
30
+ SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
31
+ SkCodec::Result*,
32
+ SkCodecs::DecodeContext = nullptr);
33
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SkCodec::Result*,
35
+ SkCodecs::DecodeContext = nullptr);
36
+
37
+ inline SkCodecs::Decoder Decoder() {
38
+ return { "wbmp", IsWbmp, Decode };
39
+ }
40
+
41
+ } // namespace SkWbmpDecoder
42
+
43
+ #endif // SkWbmpDecoder_DEFINED
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+ #ifndef SkWebpDecoder_DEFINED
8
+ #define SkWebpDecoder_DEFINED
9
+
10
+ #include "include/codec/SkCodec.h"
11
+ #include "include/core/SkRefCnt.h"
12
+
13
+ class SkData;
14
+ class SkStream;
15
+
16
+ #include <memory>
17
+
18
+ namespace SkWebpDecoder {
19
+
20
+ /** Returns true if this data claims to be a WEBP image. */
21
+ SK_API bool IsWebp(const void*, size_t);
22
+
23
+ /**
24
+ * Attempts to decode the given bytes as a WEBP.
25
+ *
26
+ * If the bytes are not a WEBP, returns nullptr.
27
+ *
28
+ * DecodeContext is ignored
29
+ */
30
+ SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
31
+ SkCodec::Result*,
32
+ SkCodecs::DecodeContext = nullptr);
33
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SkCodec::Result*,
35
+ SkCodecs::DecodeContext = nullptr);
36
+
37
+ inline SkCodecs::Decoder Decoder() {
38
+ return { "webp", IsWebp, Decode };
39
+ }
40
+
41
+ } // namespace SkWebpDecoder
42
+
43
+ #endif // SkWebpDecoder_DEFINED
@@ -8,9 +8,13 @@
8
8
  #ifndef SkBBHFactory_DEFINED
9
9
  #define SkBBHFactory_DEFINED
10
10
 
11
- #include "include/core/SkRect.h"
12
11
  #include "include/core/SkRefCnt.h"
13
12
  #include "include/core/SkTypes.h"
13
+
14
+ // TODO(kjlubick) fix client users and then make this a forward declare
15
+ #include "include/core/SkRect.h" // IWYU pragma: keep
16
+
17
+ #include <cstddef>
14
18
  #include <vector>
15
19
 
16
20
  class SkBBoxHierarchy : public SkRefCnt {
@@ -26,8 +26,6 @@ public:
26
26
  private:
27
27
  SkBlender() = default;
28
28
  friend class SkBlenderBase;
29
-
30
- using INHERITED = SkFlattenable;
31
29
  };
32
30
 
33
31
  #endif
@@ -74,15 +74,6 @@ namespace skgpu::graphite { class Recorder; }
74
74
  namespace sktext::gpu { class Slug; }
75
75
  namespace SkRecords { class Draw; }
76
76
 
77
- #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(SK_GANESH)
78
- class GrBackendRenderTarget;
79
- #endif
80
-
81
- // TODO:
82
- // This is not ideal but Chrome is depending on a forward decl of GrSlug here.
83
- // It should be removed once Chrome has migrated to sktext::gpu::Slug.
84
- using GrSlug = sktext::gpu::Slug;
85
-
86
77
  /** \class SkCanvas
87
78
  SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
88
79
  SkCanvas contains a stack of SkMatrix and clip values.
@@ -2183,12 +2174,6 @@ public:
2183
2174
 
2184
2175
  ///////////////////////////////////////////////////////////////////////////
2185
2176
 
2186
- #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(SK_GANESH)
2187
- // These methods exist to support WebView in Android Framework.
2188
- SkIRect topLayerBounds() const;
2189
- GrBackendRenderTarget topLayerBackendRenderTarget() const;
2190
- #endif
2191
-
2192
2177
  /**
2193
2178
  * Returns the global clip as a region. If the clip contains AA, then only the bounds
2194
2179
  * of the clip may be returned.
@@ -2300,16 +2285,14 @@ protected:
2300
2285
 
2301
2286
  virtual void onDiscard();
2302
2287
 
2303
- #if (defined(SK_GANESH) || defined(SK_GRAPHITE))
2304
- /** Experimental
2288
+ /**
2305
2289
  */
2306
2290
  virtual sk_sp<sktext::gpu::Slug> onConvertGlyphRunListToSlug(
2307
2291
  const sktext::GlyphRunList& glyphRunList, const SkPaint& paint);
2308
2292
 
2309
- /** Experimental
2293
+ /**
2310
2294
  */
2311
2295
  virtual void onDrawSlug(const sktext::gpu::Slug* slug);
2312
- #endif
2313
2296
 
2314
2297
  private:
2315
2298
 
@@ -2457,19 +2440,17 @@ private:
2457
2440
  SkCanvas& operator=(SkCanvas&&) = delete;
2458
2441
  SkCanvas& operator=(const SkCanvas&) = delete;
2459
2442
 
2460
- #if (defined(SK_GANESH) || defined(SK_GRAPHITE))
2461
2443
  friend class sktext::gpu::Slug;
2462
- /** Experimental
2444
+ /**
2463
2445
  * Convert a SkTextBlob to a sktext::gpu::Slug using the current canvas state.
2464
2446
  */
2465
2447
  sk_sp<sktext::gpu::Slug> convertBlobToSlug(const SkTextBlob& blob, SkPoint origin,
2466
2448
  const SkPaint& paint);
2467
2449
 
2468
- /** Experimental
2450
+ /**
2469
2451
  * Draw an sktext::gpu::Slug given the current canvas state.
2470
2452
  */
2471
2453
  void drawSlug(const sktext::gpu::Slug* slug);
2472
- #endif
2473
2454
 
2474
2455
  /** Experimental
2475
2456
  * Saves the specified subset of the current pixels in the current layer,
@@ -8,12 +8,20 @@
8
8
  #ifndef SkColorFilter_DEFINED
9
9
  #define SkColorFilter_DEFINED
10
10
 
11
- #include "include/core/SkBlendMode.h"
12
11
  #include "include/core/SkColor.h"
13
12
  #include "include/core/SkFlattenable.h"
13
+ #include "include/core/SkRefCnt.h"
14
+ #include "include/private/base/SkAPI.h"
15
+
16
+ #include <cstddef>
17
+ #include <cstdint>
14
18
 
15
19
  class SkColorMatrix;
16
20
  class SkColorSpace;
21
+ class SkColorTable;
22
+
23
+ enum class SkBlendMode;
24
+ struct SkDeserialProcs;
17
25
 
18
26
  /**
19
27
  * ColorFilters are optional objects in the drawing pipeline. When present in
@@ -113,6 +121,11 @@ public:
113
121
  const uint8_t tableG[256],
114
122
  const uint8_t tableB[256]);
115
123
 
124
+ /**
125
+ * Create a table colorfilter that holds a ref to the shared color table.
126
+ */
127
+ static sk_sp<SkColorFilter> Table(sk_sp<SkColorTable> table);
128
+
116
129
  /**
117
130
  * Create a colorfilter that multiplies the RGB channels by one color, and
118
131
  * then adds a second color, pinning the result for each component to
@@ -0,0 +1,59 @@
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 SkColorTable_DEFINED
9
+ #define SkColorTable_DEFINED
10
+
11
+ #include "include/core/SkBitmap.h"
12
+ #include "include/core/SkRefCnt.h"
13
+
14
+ class SkReadBuffer;
15
+ class SkWriteBuffer;
16
+
17
+ /**
18
+ * SkColorTable holds the lookup tables for each channel (ARGB) used to define the filter behavior
19
+ * of `SkColorFilters::Table`, and provides a way to share the table data between client code and
20
+ * the returned SkColorFilter. Once created, an SkColorTable is immutable.
21
+ */
22
+ class SkColorTable : public SkRefCnt {
23
+ public:
24
+ // Creates a new SkColorTable with 'table' used for all four channels. The table is copied into
25
+ // the SkColorTable.
26
+ static sk_sp<SkColorTable> Make(const uint8_t table[256]) {
27
+ return Make(table, table, table, table);
28
+ }
29
+
30
+ // Creates a new SkColorTable with the per-channel lookup tables. Each non-null table is copied
31
+ // into the SkColorTable. Null parameters are interpreted as the identity table.
32
+ static sk_sp<SkColorTable> Make(const uint8_t tableA[256],
33
+ const uint8_t tableR[256],
34
+ const uint8_t tableG[256],
35
+ const uint8_t tableB[256]);
36
+
37
+ // Per-channel constant value lookup (0-255).
38
+ const uint8_t* alphaTable() const { return fTable.getAddr8(0, 0); }
39
+ const uint8_t* redTable() const { return fTable.getAddr8(0, 1); }
40
+ const uint8_t* greenTable() const { return fTable.getAddr8(0, 2); }
41
+ const uint8_t* blueTable() const { return fTable.getAddr8(0, 3); }
42
+
43
+ void flatten(SkWriteBuffer& buffer) const;
44
+
45
+ static sk_sp<SkColorTable> Deserialize(SkReadBuffer& buffer);
46
+
47
+ private:
48
+ friend class SkTableColorFilter; // for bitmap()
49
+
50
+ SkColorTable(const SkBitmap& table) : fTable(table) {}
51
+
52
+ // The returned SkBitmap is immutable; attempting to modify its pixel data will trigger asserts
53
+ // in debug builds and cause undefined behavior in release builds.
54
+ const SkBitmap& bitmap() const { return fTable; }
55
+
56
+ SkBitmap fTable; // A 256x4 A8 image
57
+ };
58
+
59
+ #endif // SkColorTable_DEFINED
@@ -102,6 +102,9 @@ public:
102
102
  SkContourMeasureIter(const SkPath& path, bool forceClosed, SkScalar resScale = 1);
103
103
  ~SkContourMeasureIter();
104
104
 
105
+ SkContourMeasureIter(SkContourMeasureIter&&);
106
+ SkContourMeasureIter& operator=(SkContourMeasureIter&&);
107
+
105
108
  /**
106
109
  * Reset the Iter with a path.
107
110
  * The parts of the path that are needed are copied, so the client is free to modify/delete
@@ -5,107 +5,11 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef SkDeferredDisplayList_DEFINED
9
- #define SkDeferredDisplayList_DEFINED
10
-
11
- #include "include/core/SkRefCnt.h"
12
- #include "include/core/SkSurfaceCharacterization.h"
13
- #include "include/core/SkTypes.h"
14
-
15
- class SkDeferredDisplayListPriv;
16
- class SkPromiseImageTexture;
17
-
18
- #if defined(SK_GANESH)
19
- #include "include/gpu/GrRecordingContext.h"
20
- #include "include/private/base/SkTArray.h"
21
- #include <map>
22
- class GrRenderTask;
23
- class GrRenderTargetProxy;
24
- #else
25
- using GrRenderTargetProxy = SkRefCnt;
26
- #endif
27
-
28
- /*
29
- * This class contains pre-processed gpu operations that can be replayed into
30
- * an SkSurface via SkSurface::draw(SkDeferredDisplayList*).
31
- */
32
- class SkDeferredDisplayList : public SkNVRefCnt<SkDeferredDisplayList> {
33
- public:
34
- SK_API ~SkDeferredDisplayList();
35
-
36
- SK_API const SkSurfaceCharacterization& characterization() const {
37
- return fCharacterization;
38
- }
39
-
40
- #if defined(SK_GANESH)
41
- /**
42
- * Iterate through the programs required by the DDL.
43
- */
44
- class SK_API ProgramIterator {
45
- public:
46
- ProgramIterator(GrDirectContext*, SkDeferredDisplayList*);
47
- ~ProgramIterator();
48
-
49
- // This returns true if any work was done. Getting a cache hit does not count as work.
50
- bool compile();
51
- bool done() const;
52
- void next();
53
-
54
- private:
55
- GrDirectContext* fDContext;
56
- const skia_private::TArray<GrRecordingContext::ProgramData>& fProgramData;
57
- int fIndex;
58
- };
59
- #endif
60
-
61
- // Provides access to functions that aren't part of the public API.
62
- SkDeferredDisplayListPriv priv();
63
- const SkDeferredDisplayListPriv priv() const; // NOLINT(readability-const-return-type)
64
-
65
- private:
66
- friend class GrDrawingManager; // for access to 'fRenderTasks', 'fLazyProxyData', 'fArenas'
67
- friend class SkDeferredDisplayListRecorder; // for access to 'fLazyProxyData'
68
- friend class SkDeferredDisplayListPriv;
69
-
70
- // This object is the source from which the lazy proxy backing the DDL will pull its backing
71
- // texture when the DDL is replayed. It has to be separately ref counted bc the lazy proxy
72
- // can outlive the DDL.
73
- class LazyProxyData : public SkRefCnt {
74
- #if defined(SK_GANESH)
75
- public:
76
- // Upon being replayed - this field will be filled in (by the DrawingManager) with the
77
- // proxy backing the destination SkSurface. Note that, since there is no good place to
78
- // clear it, it can become a dangling pointer. Additionally, since the renderTargetProxy
79
- // doesn't get a ref here, the SkSurface that owns it must remain alive until the DDL
80
- // is flushed.
81
- // TODO: the drawing manager could ref the renderTargetProxy for the DDL and then add
82
- // a renderingTask to unref it after the DDL's ops have been executed.
83
- GrRenderTargetProxy* fReplayDest = nullptr;
84
- #endif
85
- };
86
-
87
- SK_API SkDeferredDisplayList(const SkSurfaceCharacterization& characterization,
88
- sk_sp<GrRenderTargetProxy> fTargetProxy,
89
- sk_sp<LazyProxyData>);
90
-
91
- #if defined(SK_GANESH)
92
- const skia_private::TArray<GrRecordingContext::ProgramData>& programData() const {
93
- return fProgramData;
94
- }
95
- #endif
96
-
97
- const SkSurfaceCharacterization fCharacterization;
98
-
99
- #if defined(SK_GANESH)
100
- // These are ordered such that the destructor cleans op tasks up first (which may refer back
101
- // to the arena and memory pool in their destructors).
102
- GrRecordingContext::OwnedArenas fArenas;
103
- skia_private::TArray<sk_sp<GrRenderTask>> fRenderTasks;
104
-
105
- skia_private::TArray<GrRecordingContext::ProgramData> fProgramData;
106
- sk_sp<GrRenderTargetProxy> fTargetProxy;
107
- sk_sp<LazyProxyData> fLazyProxyData;
108
- #endif
109
- };
110
-
111
- #endif
8
+ // TODO(kjlubick, robertphillips) migrate Chromium to use the new location and name
9
+ #include "include/private/chromium/GrDeferredDisplayList.h" // IWYU pragma: export
10
+
11
+ class GrDeferredDisplayListRecorder;
12
+ class GrSurfaceCharacterization;
13
+ using SkDeferredDisplayList = GrDeferredDisplayList;
14
+ using SkDeferredDisplayListRecorder = GrDeferredDisplayListRecorder;
15
+ using SkSurfaceCharacterization = GrSurfaceCharacterization;
@@ -5,94 +5,11 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef SkDeferredDisplayListRecorder_DEFINED
9
- #define SkDeferredDisplayListRecorder_DEFINED
10
-
11
- #include "include/core/SkDeferredDisplayList.h"
12
- #include "include/core/SkImage.h"
13
- #include "include/core/SkImageInfo.h"
14
- #include "include/core/SkRefCnt.h"
15
- #include "include/core/SkSurfaceCharacterization.h"
16
- #include "include/core/SkTypes.h"
17
-
18
- class GrBackendFormat;
19
- class GrBackendTexture;
20
- class GrRecordingContext;
21
- class GrYUVABackendTextureInfo;
22
- class SkCanvas;
23
- class SkSurface;
24
-
25
- /*
26
- * This class is intended to be used as:
27
- * Get an SkSurfaceCharacterization representing the intended gpu-backed destination SkSurface
28
- * Create one of these (an SkDeferredDisplayListRecorder) on the stack
29
- * Get the canvas and render into it
30
- * Snap off and hold on to an SkDeferredDisplayList
31
- * Once your app actually needs the pixels, call SkSurface::draw(SkDeferredDisplayList*)
32
- *
33
- * This class never accesses the GPU but performs all the cpu work it can. It
34
- * is thread-safe (i.e., one can break a scene into tiles and perform their cpu-side
35
- * work in parallel ahead of time).
36
- */
37
- class SK_API SkDeferredDisplayListRecorder {
38
- public:
39
- SkDeferredDisplayListRecorder(const SkSurfaceCharacterization&);
40
- ~SkDeferredDisplayListRecorder();
41
-
42
- const SkSurfaceCharacterization& characterization() const {
43
- return fCharacterization;
44
- }
45
-
46
- // The backing canvas will become invalid (and this entry point will return
47
- // null) once 'detach' is called.
48
- // Note: ownership of the SkCanvas is not transferred via this call.
49
- SkCanvas* getCanvas();
50
-
51
- sk_sp<SkDeferredDisplayList> detach();
52
-
53
- #if defined(SK_GANESH)
54
- using PromiseImageTextureContext = void*;
55
- using PromiseImageTextureFulfillProc =
56
- sk_sp<SkPromiseImageTexture> (*)(PromiseImageTextureContext);
57
- using PromiseImageTextureReleaseProc = void (*)(PromiseImageTextureContext);
58
-
59
- #ifndef SK_MAKE_PROMISE_TEXTURE_DISABLE_LEGACY_API
60
- /** Deprecated: Use SkImages::PromiseTextureFrom instead. */
61
- sk_sp<SkImage> makePromiseTexture(const GrBackendFormat& backendFormat,
62
- int width,
63
- int height,
64
- GrMipmapped mipmapped,
65
- GrSurfaceOrigin origin,
66
- SkColorType colorType,
67
- SkAlphaType alphaType,
68
- sk_sp<SkColorSpace> colorSpace,
69
- PromiseImageTextureFulfillProc textureFulfillProc,
70
- PromiseImageTextureReleaseProc textureReleaseProc,
71
- PromiseImageTextureContext textureContext);
72
-
73
- /** Deprecated: Use SkImages::PromiseTextureFromYUVA instead. */
74
- sk_sp<SkImage> makeYUVAPromiseTexture(const GrYUVABackendTextureInfo& yuvaBackendTextureInfo,
75
- sk_sp<SkColorSpace> imageColorSpace,
76
- PromiseImageTextureFulfillProc textureFulfillProc,
77
- PromiseImageTextureReleaseProc textureReleaseProc,
78
- PromiseImageTextureContext textureContexts[]);
79
- #endif // SK_MAKE_PROMISE_TEXTURE_DISABLE_LEGACY_API
80
- #endif // defined(SK_GANESH)
81
-
82
- private:
83
- SkDeferredDisplayListRecorder(const SkDeferredDisplayListRecorder&) = delete;
84
- SkDeferredDisplayListRecorder& operator=(const SkDeferredDisplayListRecorder&) = delete;
85
-
86
- bool init();
87
-
88
- const SkSurfaceCharacterization fCharacterization;
89
-
90
- #if defined(SK_GANESH)
91
- sk_sp<GrRecordingContext> fContext;
92
- sk_sp<GrRenderTargetProxy> fTargetProxy;
93
- sk_sp<SkDeferredDisplayList::LazyProxyData> fLazyProxyData;
94
- sk_sp<SkSurface> fSurface;
95
- #endif
96
- };
97
-
98
- #endif
8
+ // TODO(kjlubick, robertphillips) migrate Chromium to use the new location
9
+ #include "include/private/chromium/GrDeferredDisplayListRecorder.h" // IWYU pragma: export
10
+
11
+ class GrDeferredDisplayList;
12
+ class GrSurfaceCharacterization;
13
+ using SkDeferredDisplayList = GrDeferredDisplayList;
14
+ using SkDeferredDisplayListRecorder = GrDeferredDisplayListRecorder;
15
+ using SkSurfaceCharacterization = GrSurfaceCharacterization;
@@ -93,7 +93,10 @@ public:
93
93
  return this->onSnapGpuDrawHandler(backendApi, matrix, clipBounds, bufferInfo);
94
94
  }
95
95
 
96
- SkPicture* newPictureSnapshot();
96
+ /**
97
+ * Returns an SkPicture with the contents of this SkDrawable.
98
+ */
99
+ sk_sp<SkPicture> makePictureSnapshot();
97
100
 
98
101
  /**
99
102
  * Return a unique value for this instance. If two calls to this return the same value,
@@ -166,7 +169,7 @@ protected:
166
169
  * of their drawable. Note: this picture must draw the same as what would be drawn from
167
170
  * onDraw().
168
171
  */
169
- virtual SkPicture* onNewPictureSnapshot();
172
+ virtual sk_sp<SkPicture> onMakePictureSnapshot();
170
173
 
171
174
  private:
172
175
  int32_t fGenerationID;
@@ -74,6 +74,13 @@ public:
74
74
  */
75
75
  static void PurgeFontCache();
76
76
 
77
+ /**
78
+ * If the strike cache is above the cache limit, attempt to purge strikes
79
+ * with pinners. This should be called after clients release locks on
80
+ * pinned strikes.
81
+ */
82
+ static void PurgePinnedFontCache();
83
+
77
84
  /**
78
85
  * This function returns the memory used for temporary images and other resources.
79
86
  */
@@ -147,25 +154,6 @@ public:
147
154
  * Call early in main() to allow Skia to use a JIT to accelerate CPU-bound operations.
148
155
  */
149
156
  static void AllowJIT();
150
-
151
- /**
152
- * To override the default AA algorithm choice in the CPU backend, provide a function that
153
- * returns whether to use analytic (true) or supersampled (false) for a given path.
154
- *
155
- * NOTE: This is a temporary API, intended for migration of all clients to one algorithm,
156
- * and should not be used.
157
- */
158
- typedef bool (*PathAnalyticAADeciderProc)(const SkPath&);
159
- static void SetPathAnalyticAADecider(PathAnalyticAADeciderProc);
160
-
161
- /*
162
- * Similar to above, but simply forces the CPU backend to always use analytic AA.
163
- *
164
- * NOTE: This is a temporary API, intended for migration of all clients to one algorithm.
165
- * If the PathAnalyticAADeciderProc is *also* set, this setting has no effect.
166
- * Unlike that API, this function is thread-safe.
167
- */
168
- static void SetForceAnalyticAA(bool);
169
157
  };
170
158
 
171
159
  class SkAutoGraphics {