@shopify/react-native-skia 0.1.129 → 0.1.130

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +1 -0
  2. package/cpp/api/JsiSkRuntimeEffect.h +7 -9
  3. package/cpp/api/JsiSkVertices.h +0 -2
  4. package/cpp/rnskia/values/RNSkValue.h +1 -1
  5. package/cpp/skia/include/codec/SkCodec.h +7 -1
  6. package/cpp/skia/include/core/SkAlphaType.h +45 -0
  7. package/cpp/skia/include/core/SkBitmap.h +4 -2
  8. package/cpp/skia/include/core/SkCanvas.h +31 -20
  9. package/cpp/skia/include/core/SkColor.h +1 -1
  10. package/cpp/skia/include/core/SkColorFilter.h +1 -0
  11. package/cpp/skia/include/core/SkColorType.h +66 -0
  12. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +1 -1
  13. package/cpp/skia/include/core/SkDrawable.h +7 -0
  14. package/cpp/skia/include/core/SkEncodedImageFormat.h +1 -0
  15. package/cpp/skia/include/core/SkFont.h +4 -3
  16. package/cpp/skia/include/core/SkFontArguments.h +33 -1
  17. package/cpp/skia/include/core/SkGraphics.h +13 -0
  18. package/cpp/skia/include/core/SkImage.h +67 -22
  19. package/cpp/skia/include/core/SkImageEncoder.h +0 -3
  20. package/cpp/skia/include/core/SkImageGenerator.h +4 -3
  21. package/cpp/skia/include/core/SkImageInfo.h +35 -142
  22. package/cpp/skia/include/core/SkMesh.h +303 -0
  23. package/cpp/skia/include/core/SkMilestone.h +1 -1
  24. package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +30 -0
  25. package/cpp/skia/include/core/SkPaint.h +4 -19
  26. package/cpp/skia/include/core/SkPath.h +20 -33
  27. package/cpp/skia/include/core/SkPathBuilder.h +1 -6
  28. package/cpp/skia/include/core/SkPixelRef.h +1 -1
  29. package/cpp/skia/include/core/SkPixmap.h +3 -2
  30. package/cpp/skia/include/core/SkRSXform.h +1 -1
  31. package/cpp/skia/include/core/SkSamplingOptions.h +16 -5
  32. package/cpp/skia/include/core/SkSpan.h +5 -5
  33. package/cpp/skia/include/core/SkString.h +5 -8
  34. package/cpp/skia/include/core/SkSurface.h +21 -0
  35. package/cpp/skia/include/core/SkTypeface.h +20 -4
  36. package/cpp/skia/include/core/SkTypes.h +9 -5
  37. package/cpp/skia/include/effects/SkGradientShader.h +9 -18
  38. package/cpp/skia/include/effects/SkRuntimeEffect.h +16 -12
  39. package/cpp/skia/include/gpu/GpuTypes.h +32 -0
  40. package/cpp/skia/include/gpu/GrBackendSemaphore.h +1 -1
  41. package/cpp/skia/include/gpu/GrBackendSurface.h +6 -5
  42. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +1 -1
  43. package/cpp/skia/include/gpu/GrContextOptions.h +11 -20
  44. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +7 -0
  45. package/cpp/skia/include/gpu/GrDirectContext.h +16 -11
  46. package/cpp/skia/include/gpu/GrDriverBugWorkaroundsAutogen.h +0 -2
  47. package/cpp/skia/include/gpu/GrRecordingContext.h +14 -7
  48. package/cpp/skia/include/gpu/GrSurfaceInfo.h +6 -6
  49. package/cpp/skia/include/gpu/dawn/GrDawnTypes.h +1 -1
  50. package/cpp/skia/include/gpu/gl/GrGLFunctions.h +3 -1
  51. package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -2
  52. package/cpp/skia/include/gpu/graphite/BackendTexture.h +64 -0
  53. package/cpp/skia/include/gpu/graphite/Context.h +124 -0
  54. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +71 -0
  55. package/cpp/skia/include/gpu/graphite/Recorder.h +104 -0
  56. package/cpp/skia/include/gpu/graphite/Recording.h +39 -0
  57. package/cpp/skia/include/gpu/graphite/SkStuff.h +47 -0
  58. package/cpp/skia/include/gpu/graphite/TextureInfo.h +91 -0
  59. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +24 -0
  60. package/cpp/skia/include/gpu/graphite/mtl/MtlTypes.h +68 -0
  61. package/cpp/skia/include/gpu/mock/GrMockTypes.h +1 -2
  62. package/cpp/skia/include/ports/SkCFObject.h +0 -4
  63. package/cpp/skia/include/ports/SkTypeface_win.h +2 -2
  64. package/cpp/skia/include/private/{GrSingleOwner.h → SingleOwner.h} +17 -10
  65. package/cpp/skia/include/private/SkChecksum.h +11 -0
  66. package/cpp/skia/include/private/SkEncodedInfo.h +22 -5
  67. package/cpp/skia/include/private/SkFloatingPoint.h +0 -53
  68. package/cpp/skia/include/private/SkImageInfoPriv.h +8 -2
  69. package/cpp/skia/include/private/SkMacros.h +13 -18
  70. package/cpp/skia/include/private/SkMutex.h +8 -0
  71. package/cpp/skia/include/private/SkPathRef.h +2 -16
  72. package/cpp/skia/include/private/SkSLDefines.h +9 -1
  73. package/cpp/skia/include/private/SkSLIRNode.h +6 -5
  74. package/cpp/skia/include/private/SkSLLayout.h +11 -10
  75. package/cpp/skia/include/private/SkSLModifiers.h +4 -3
  76. package/cpp/skia/include/private/SkSLProgramElement.h +2 -2
  77. package/cpp/skia/include/private/SkSLProgramKind.h +8 -5
  78. package/cpp/skia/include/private/SkSLStatement.h +2 -3
  79. package/cpp/skia/include/private/SkSLString.h +17 -56
  80. package/cpp/skia/include/private/SkSLSymbol.h +4 -4
  81. package/cpp/skia/include/private/SkShadowFlags.h +3 -1
  82. package/cpp/skia/include/private/SkStringView.h +47 -0
  83. package/cpp/skia/include/private/SkTArray.h +4 -3
  84. package/cpp/skia/include/private/SkTHash.h +66 -24
  85. package/cpp/skia/include/private/SkTLogic.h +2 -32
  86. package/cpp/skia/include/private/SkTemplates.h +2 -2
  87. package/cpp/skia/include/private/SkThreadAnnotations.h +4 -4
  88. package/cpp/skia/include/private/SkVx.h +28 -28
  89. package/cpp/skia/include/private/chromium/GrSlug.h +40 -3
  90. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +12 -6
  91. package/cpp/skia/include/private/{GrContext_Base.h → gpu/ganesh/GrContext_Base.h} +7 -0
  92. package/cpp/skia/include/private/{GrD3DTypesMinimal.h → gpu/ganesh/GrD3DTypesMinimal.h} +0 -0
  93. package/cpp/skia/include/private/{GrDawnTypesPriv.h → gpu/ganesh/GrDawnTypesPriv.h} +0 -0
  94. package/cpp/skia/include/private/{GrGLTypesPriv.h → gpu/ganesh/GrGLTypesPriv.h} +1 -0
  95. package/cpp/skia/include/private/{GrImageContext.h → gpu/ganesh/GrImageContext.h} +4 -4
  96. package/cpp/skia/include/private/{GrMockTypesPriv.h → gpu/ganesh/GrMockTypesPriv.h} +0 -0
  97. package/cpp/skia/include/private/{GrMtlTypesPriv.h → gpu/ganesh/GrMtlTypesPriv.h} +0 -0
  98. package/cpp/skia/include/private/{GrTypesPriv.h → gpu/ganesh/GrTypesPriv.h} +25 -367
  99. package/cpp/skia/include/private/{GrVkTypesPriv.h → gpu/ganesh/GrVkTypesPriv.h} +0 -0
  100. package/cpp/skia/include/private/gpu/graphite/MtlTypesPriv.h +74 -0
  101. package/cpp/skia/include/sksl/DSL.h +4 -0
  102. package/cpp/skia/include/sksl/DSLBlock.h +8 -3
  103. package/cpp/skia/include/sksl/DSLCase.h +6 -6
  104. package/cpp/skia/include/sksl/DSLCore.h +89 -78
  105. package/cpp/skia/include/sksl/DSLExpression.h +78 -45
  106. package/cpp/skia/include/sksl/DSLFunction.h +23 -18
  107. package/cpp/skia/include/sksl/DSLLayout.h +14 -16
  108. package/cpp/skia/include/sksl/DSLModifiers.h +7 -5
  109. package/cpp/skia/include/sksl/DSLRuntimeEffects.h +1 -1
  110. package/cpp/skia/include/sksl/DSLStatement.h +16 -10
  111. package/cpp/skia/include/sksl/DSLSymbols.h +7 -7
  112. package/cpp/skia/include/sksl/DSLType.h +27 -23
  113. package/cpp/skia/include/sksl/DSLVar.h +72 -61
  114. package/cpp/skia/include/sksl/SkSLErrorReporter.h +12 -49
  115. package/cpp/skia/include/sksl/SkSLOperator.h +151 -0
  116. package/cpp/skia/include/sksl/SkSLPosition.h +102 -0
  117. package/cpp/skia/include/svg/SkSVGCanvas.h +5 -1
  118. package/cpp/skia/include/utils/SkAnimCodecPlayer.h +7 -0
  119. package/cpp/skia/include/utils/SkCamera.h +2 -0
  120. package/cpp/skia/include/utils/SkCanvasStateUtils.h +4 -1
  121. package/cpp/skia/include/utils/SkCustomTypeface.h +6 -4
  122. package/cpp/skia/include/utils/SkNWayCanvas.h +34 -0
  123. package/cpp/skia/include/utils/SkNullCanvas.h +5 -1
  124. package/cpp/skia/include/utils/SkOrderedFontMgr.h +12 -0
  125. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +30 -1
  126. package/cpp/skia/include/utils/SkParse.h +2 -0
  127. package/cpp/skia/include/utils/SkShadowUtils.h +3 -2
  128. package/cpp/skia/include/utils/SkTextUtils.h +8 -4
  129. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +27 -1
  130. package/cpp/skia/modules/svg/include/SkSVGDOM.h +4 -0
  131. package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +32 -0
  132. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
  133. package/cpp/skia/modules/svg/include/SkSVGSVG.h +2 -0
  134. package/cpp/skia/modules/svg/include/SkSVGTypes.h +48 -9
  135. package/ios/RNSkia-iOS/PlatformContext.h +1 -1
  136. package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +1 -0
  137. package/ios/RNSkia-iOS/SkiaDrawView.mm +1 -1
  138. package/lib/commonjs/renderer/components/shaders/Shader.js +1 -2
  139. package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
  140. package/lib/module/renderer/components/shaders/Shader.js +1 -2
  141. package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
  142. package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +0 -1
  143. package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +2 -4
  144. package/libs/android/arm64-v8a/libskia.a +0 -0
  145. package/libs/android/arm64-v8a/libsvg.a +0 -0
  146. package/libs/android/armeabi-v7a/libskia.a +0 -0
  147. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  148. package/libs/android/x86/libskia.a +0 -0
  149. package/libs/android/x86/libsvg.a +0 -0
  150. package/libs/android/x86_64/libskia.a +0 -0
  151. package/libs/android/x86_64/libsvg.a +0 -0
  152. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  153. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  154. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  155. package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
  156. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  157. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  158. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  159. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  160. package/package.json +2 -2
  161. package/src/renderer/components/shaders/Shader.tsx +1 -3
  162. package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -8
  163. package/cpp/skia/include/core/SkCustomMesh.h +0 -202
  164. package/cpp/skia/include/core/SkStringView.h +0 -185
  165. package/cpp/skia/include/private/SkPaintParamsKey.h +0 -110
  166. package/cpp/skia/include/private/SkShaderCodeDictionary.h +0 -63
  167. package/cpp/skia/include/private/SkTOptional.h +0 -362
@@ -15,6 +15,7 @@
15
15
 
16
16
  #include "include/gpu/GrDirectContext.h"
17
17
  #include "include/gpu/gl/GrGLInterface.h"
18
+ #include <SkColorSpace.h>
18
19
  #include <SkCanvas.h>
19
20
  #include <SkSurface.h>
20
21
  #include <SkPicture.h>
@@ -44,12 +44,11 @@ namespace RNSkia
44
44
  JSI_HOST_FUNCTION(makeShader)
45
45
  {
46
46
  auto uniforms = castUniforms(runtime, arguments[0]);
47
- auto isOpaque = count >= 2 && arguments[1].isBool() ? arguments[1].getBool() : false;
48
- auto matrix = count >= 3 && !arguments[2].isUndefined() && !arguments[2].isNull() ? JsiSkMatrix::fromValue(runtime, arguments[2]).get() : nullptr;
47
+
48
+ auto matrix = count >= 2 && !arguments[1].isUndefined() && !arguments[1].isNull() ? JsiSkMatrix::fromValue(runtime, arguments[1]).get() : nullptr;
49
49
 
50
50
  // Create and return shader as host object
51
- auto shader = getObject()->makeShader(std::move(uniforms), nullptr,
52
- 0, matrix, isOpaque);
51
+ auto shader = getObject()->makeShader(std::move(uniforms), nullptr, 0, matrix);
53
52
 
54
53
  return jsi::Object::createFromHostObject(
55
54
  runtime, std::make_shared<JsiSkShader>(getContext(), std::move(shader)));
@@ -58,11 +57,10 @@ namespace RNSkia
58
57
  JSI_HOST_FUNCTION(makeShaderWithChildren)
59
58
  {
60
59
  auto uniforms = castUniforms(runtime, arguments[0]);
61
- auto isOpaque = count >= 2 && arguments[1].isBool() ? arguments[1].getBool() : false;
62
-
60
+
63
61
  // Children
64
62
  std::vector<sk_sp<SkShader>> children;
65
- auto jsiChildren = arguments[2].asObject(runtime).asArray(runtime);
63
+ auto jsiChildren = arguments[1].asObject(runtime).asArray(runtime);
66
64
  auto jsiChildCount = jsiChildren.size(runtime);
67
65
  children.reserve(jsiChildCount);
68
66
  for (int i = 0; i < jsiChildCount; i++)
@@ -74,11 +72,11 @@ namespace RNSkia
74
72
  children.push_back(shader);
75
73
  }
76
74
 
77
- auto matrix = count >= 4 && !arguments[3].isUndefined() && !arguments[3].isNull() ? JsiSkMatrix::fromValue(runtime, arguments[3]).get() : nullptr;
75
+ auto matrix = count >= 3 && !arguments[2].isUndefined() && !arguments[2].isNull() ? JsiSkMatrix::fromValue(runtime, arguments[2]).get() : nullptr;
78
76
 
79
77
  // Create and return shader as host object
80
78
  auto shader = getObject()->makeShader(std::move(uniforms), children.data(),
81
- children.size(), matrix, isOpaque);
79
+ children.size(), matrix);
82
80
 
83
81
  return jsi::Object::createFromHostObject(
84
82
  runtime, std::make_shared<JsiSkShader>(getContext(), std::move(shader)));
@@ -4,8 +4,6 @@
4
4
  #include <utility>
5
5
  #include <jsi/jsi.h>
6
6
 
7
- #include <jsi/jsi.h>
8
-
9
7
  #include "JsiSkHostObjects.h"
10
8
 
11
9
  #pragma clang diagnostic push
@@ -43,7 +43,7 @@ public:
43
43
  unsubscribe();
44
44
 
45
45
  // Verify input
46
- if(value.isObject() && value.asObject(runtime).isHostObject(runtime)) {
46
+ if(value.isObject() && value.asObject(runtime).isHostObject<RNSkAnimation>(runtime)) {
47
47
  auto animation = value.asObject(runtime).getHostObject<RNSkAnimation>(runtime);
48
48
  if(animation != nullptr) {
49
49
  // Now we have a value animation - let us connect and start
@@ -758,6 +758,12 @@ protected:
758
758
  std::unique_ptr<SkStream>,
759
759
  SkEncodedOrigin = kTopLeft_SkEncodedOrigin);
760
760
 
761
+ void setSrcXformFormat(XformFormat pixelFormat);
762
+
763
+ XformFormat getSrcXformFormat() const {
764
+ return fSrcXformFormat;
765
+ }
766
+
761
767
  virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
762
768
  // By default, scaling is not supported.
763
769
  return this->dimensions();
@@ -876,7 +882,7 @@ protected:
876
882
 
877
883
  private:
878
884
  const SkEncodedInfo fEncodedInfo;
879
- const XformFormat fSrcXformFormat;
885
+ XformFormat fSrcXformFormat;
880
886
  std::unique_ptr<SkStream> fStream;
881
887
  bool fNeedsRewind;
882
888
  const SkEncodedOrigin fOrigin;
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright 2022 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 SkAlphaType_DEFINED
9
+ #define SkAlphaType_DEFINED
10
+
11
+ /** \enum SkAlphaType
12
+ Describes how to interpret the alpha component of a pixel. A pixel may
13
+ be opaque, or alpha, describing multiple levels of transparency.
14
+
15
+ In simple blending, alpha weights the draw color and the destination
16
+ color to create a new color. If alpha describes a weight from zero to one:
17
+
18
+ new color = draw color * alpha + destination color * (1 - alpha)
19
+
20
+ In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.
21
+
22
+ RGB may have alpha included in each component value; the stored
23
+ value is the original RGB multiplied by alpha. Premultiplied color
24
+ components improve performance.
25
+ */
26
+ enum SkAlphaType : int {
27
+ kUnknown_SkAlphaType, //!< uninitialized
28
+ kOpaque_SkAlphaType, //!< pixel is opaque
29
+ kPremul_SkAlphaType, //!< pixel components are premultiplied by alpha
30
+ kUnpremul_SkAlphaType, //!< pixel components are independent of alpha
31
+ kLastEnum_SkAlphaType = kUnpremul_SkAlphaType, //!< last valid value
32
+ };
33
+
34
+ /** Returns true if SkAlphaType equals kOpaque_SkAlphaType.
35
+
36
+ kOpaque_SkAlphaType is a hint that the SkColorType is opaque, or that all
37
+ alpha values are set to their 1.0 equivalent. If SkAlphaType is
38
+ kOpaque_SkAlphaType, and SkColorType is not opaque, then the result of
39
+ drawing any pixel with a alpha value less than 1.0 is undefined.
40
+ */
41
+ static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) {
42
+ return kOpaque_SkAlphaType == at;
43
+ }
44
+
45
+ #endif
@@ -18,6 +18,7 @@
18
18
  #include "include/core/SkTileMode.h"
19
19
 
20
20
  class SkBitmap;
21
+ class SkColorSpace;
21
22
  struct SkMask;
22
23
  class SkMipmap;
23
24
  struct SkIRect;
@@ -158,7 +159,7 @@ public:
158
159
 
159
160
  @return SkColorSpace in SkImageInfo, or nullptr
160
161
  */
161
- SkColorSpace* colorSpace() const { return fPixmap.colorSpace(); }
162
+ SkColorSpace* colorSpace() const;
162
163
 
163
164
  /** Returns smart pointer to SkColorSpace, the range of colors, associated with
164
165
  SkImageInfo. The smart pointer tracks the number of objects sharing this
@@ -168,7 +169,7 @@ public:
168
169
 
169
170
  @return SkColorSpace in SkImageInfo wrapped in a smart pointer
170
171
  */
171
- sk_sp<SkColorSpace> refColorSpace() const { return fPixmap.info().refColorSpace(); }
172
+ sk_sp<SkColorSpace> refColorSpace() const;
172
173
 
173
174
  /** Returns number of bytes per pixel required by SkColorType.
174
175
  Returns zero if colorType( is kUnknown_SkColorType.
@@ -1190,6 +1191,7 @@ private:
1190
1191
 
1191
1192
  friend class SkImage_Raster;
1192
1193
  friend class SkReadBuffer; // unflatten
1194
+ friend class GrProxyProvider; // fMips
1193
1195
  };
1194
1196
 
1195
1197
  ///////////////////////////////////////////////////////////////////////////////
@@ -31,6 +31,7 @@
31
31
 
32
32
  #include <cstring>
33
33
  #include <memory>
34
+ #include <optional>
34
35
  #include <vector>
35
36
 
36
37
  #ifndef SK_SUPPORT_LEGACY_GETTOTALMATRIX
@@ -58,16 +59,15 @@ class SkPixmap;
58
59
  class SkRegion;
59
60
  class SkRRect;
60
61
  struct SkRSXform;
61
- struct SkCustomMesh;
62
+ class SkMesh;
62
63
  class SkSpecialImage;
63
64
  class SkSurface;
64
65
  class SkSurface_Base;
65
66
  class SkTextBlob;
66
67
  class SkVertices;
67
68
 
68
- namespace skstd {
69
- template<typename T> class optional;
70
- }
69
+ namespace skgpu::graphite { class Recorder; }
70
+ namespace SkRecords { class Draw; }
71
71
 
72
72
  /** \class SkCanvas
73
73
  SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
@@ -300,6 +300,12 @@ public:
300
300
  */
301
301
  virtual GrRecordingContext* recordingContext();
302
302
 
303
+ /** Returns Recorder for the GPU surface associated with SkCanvas.
304
+
305
+ @return Recorder, if available; nullptr otherwise
306
+ */
307
+ virtual skgpu::graphite::Recorder* recorder();
308
+
303
309
  /** Sometimes a canvas is owned by a surface. If it is, getSurface() will return a bare
304
310
  * pointer to that surface, else this will return nullptr.
305
311
  */
@@ -1438,7 +1444,8 @@ public:
1438
1444
  /** \enum SkCanvas::SrcRectConstraint
1439
1445
  SrcRectConstraint controls the behavior at the edge of source SkRect,
1440
1446
  provided to drawImageRect() when there is any filtering. If kStrict is set,
1441
- then extra code is used to ensure it nevers samples outside of the src-rect.
1447
+ then extra code is used to ensure it never samples outside of the src-rect.
1448
+ kStrict_SrcRectConstraint disables the use of mipmaps and anisotropic filtering.
1442
1449
  */
1443
1450
  enum SrcRectConstraint {
1444
1451
  kStrict_SrcRectConstraint, //!< sample only inside bounds; slower
@@ -1953,9 +1960,9 @@ public:
1953
1960
  /**
1954
1961
  Experimental, under active development, and subject to change without notice.
1955
1962
 
1956
- Draws a mesh using a user-defined specification (see SkCustomMeshSpecification).
1963
+ Draws a mesh using a user-defined specification (see SkMeshSpecification).
1957
1964
 
1958
- SkBlender is ignored if SkCustomMesh's specification does not output fragment shader color.
1965
+ SkBlender is ignored if SkMesh's specification does not output fragment shader color.
1959
1966
  Otherwise, it combines
1960
1967
  - the SkShader if SkPaint contains SkShader
1961
1968
  - or the opaque SkPaint color if SkPaint does not contain SkShader
@@ -1963,13 +1970,13 @@ public:
1963
1970
 
1964
1971
  SkMaskFilter, SkPathEffect, and antialiasing on SkPaint are ignored.
1965
1972
 
1966
- @param cm the custom mesh vertices and compatible specification.
1973
+ @param mesh the mesh vertices and compatible specification.
1967
1974
  @param blender combines vertices colors with SkShader if present or SkPaint opaque color
1968
1975
  if not. Ignored if the custom mesh does not output color. Defaults to
1969
1976
  SkBlendMode::kModulate if nullptr.
1970
1977
  @param paint specifies the SkShader, used as SkVertices texture, may be nullptr
1971
1978
  */
1972
- void drawCustomMesh(SkCustomMesh cm, sk_sp<SkBlender> blender, const SkPaint& paint);
1979
+ void drawMesh(const SkMesh& mesh, sk_sp<SkBlender> blender, const SkPaint& paint);
1973
1980
  #endif
1974
1981
 
1975
1982
  /** Draws a Coons patch: the interpolation of four cubics with shared corners,
@@ -2193,7 +2200,7 @@ protected:
2193
2200
 
2194
2201
  #ifndef SK_ENABLE_EXPERIMENTAL_CUSTOM_MESH
2195
2202
  // Define this in protected so we can still access internally for testing.
2196
- void drawCustomMesh(SkCustomMesh cm, sk_sp<SkBlender> blender, const SkPaint& paint);
2203
+ void drawMesh(const SkMesh& mesh, sk_sp<SkBlender> blender, const SkPaint& paint);
2197
2204
  #endif
2198
2205
 
2199
2206
  // NOTE: If you are adding a new onDraw virtual to SkCanvas, PLEASE add an override to
@@ -2237,7 +2244,7 @@ protected:
2237
2244
  virtual void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
2238
2245
  const SkPaint& paint);
2239
2246
  #ifdef SK_ENABLE_SKSL
2240
- virtual void onDrawCustomMesh(SkCustomMesh, sk_sp<SkBlender>, const SkPaint&);
2247
+ virtual void onDrawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&);
2241
2248
  #endif
2242
2249
  virtual void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value);
2243
2250
  virtual void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&);
@@ -2266,12 +2273,12 @@ protected:
2266
2273
  #if SK_SUPPORT_GPU
2267
2274
  /** Experimental
2268
2275
  */
2269
- virtual sk_sp<GrSlug> doConvertBlobToSlug(
2270
- const SkTextBlob& blob, SkPoint origin, const SkPaint& paint);
2276
+ virtual sk_sp<GrSlug> onConvertGlyphRunListToSlug(
2277
+ const SkGlyphRunList& glyphRunList, const SkPaint& paint);
2271
2278
 
2272
2279
  /** Experimental
2273
2280
  */
2274
- virtual void doDrawSlug(GrSlug* slug);
2281
+ virtual void onDrawSlug(const GrSlug* slug);
2275
2282
  #endif
2276
2283
 
2277
2284
  private:
@@ -2293,7 +2300,7 @@ private:
2293
2300
  kYes = true
2294
2301
  };
2295
2302
  // call the appropriate predrawNotify and create a layer if needed.
2296
- skstd::optional<AutoLayerForImageFilter> aboutToDraw(
2303
+ std::optional<AutoLayerForImageFilter> aboutToDraw(
2297
2304
  SkCanvas* canvas,
2298
2305
  const SkPaint& paint,
2299
2306
  const SkRect* rawBounds = nullptr,
@@ -2355,16 +2362,16 @@ private:
2355
2362
  void reset(SkBaseDevice* device);
2356
2363
  };
2357
2364
 
2358
- SkDeque fMCStack;
2359
- // points to top of stack
2360
- MCRec* fMCRec;
2361
-
2362
2365
  // the first N recs that can fit here mean we won't call malloc
2363
2366
  static constexpr int kMCRecSize = 96; // most recent measurement
2364
2367
  static constexpr int kMCRecCount = 32; // common depth for save/restores
2365
2368
 
2366
2369
  intptr_t fMCRecStorage[kMCRecSize * kMCRecCount / sizeof(intptr_t)];
2367
2370
 
2371
+ SkDeque fMCStack;
2372
+ // points to top of stack
2373
+ MCRec* fMCRec;
2374
+
2368
2375
  // Installed via init()
2369
2376
  sk_sp<SkBaseDevice> fBaseDevice;
2370
2377
  const SkSurfaceProps fProps;
@@ -2397,6 +2404,10 @@ private:
2397
2404
  friend class SkPictureRecord; // predrawNotify (why does it need it? <reed>)
2398
2405
  friend class SkOverdrawCanvas;
2399
2406
  friend class SkRasterHandleAllocator;
2407
+ friend class SkRecords::Draw;
2408
+ template <typename Key>
2409
+ friend class SkTestCanvas;
2410
+
2400
2411
  protected:
2401
2412
  // For use by SkNoDrawCanvas (via SkCanvasVirtualEnforcer, which can't be a friend)
2402
2413
  SkCanvas(const SkIRect& bounds);
@@ -2419,7 +2430,7 @@ private:
2419
2430
  /** Experimental
2420
2431
  * Draw an GrSlug given the current canvas state.
2421
2432
  */
2422
- void drawSlug(GrSlug* slug);
2433
+ void drawSlug(const GrSlug* slug);
2423
2434
  #endif
2424
2435
 
2425
2436
  /** Experimental
@@ -8,7 +8,7 @@
8
8
  #ifndef SkColor_DEFINED
9
9
  #define SkColor_DEFINED
10
10
 
11
- #include "include/core/SkImageInfo.h"
11
+ #include "include/core/SkAlphaType.h"
12
12
  #include "include/core/SkScalar.h"
13
13
  #include "include/core/SkTypes.h"
14
14
 
@@ -13,6 +13,7 @@
13
13
  #include "include/core/SkFlattenable.h"
14
14
 
15
15
  class SkColorMatrix;
16
+ class SkColorSpace;
16
17
 
17
18
  /**
18
19
  * ColorFilters are optional objects in the drawing pipeline. When present in
@@ -0,0 +1,66 @@
1
+ /*
2
+ * Copyright 2022 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 SkColorType_DEFINED
9
+ #define SkColorType_DEFINED
10
+
11
+ #include "include/core/SkTypes.h"
12
+
13
+ /** \enum SkColorType
14
+ Describes how pixel bits encode color. A pixel may be an alpha mask, a grayscale, RGB, or ARGB.
15
+
16
+ kN32_SkColorType selects the native 32-bit ARGB format for the current configuration. This can
17
+ lead to inconsistent results across platforms, so use with caution.
18
+ */
19
+ enum SkColorType : int {
20
+ kUnknown_SkColorType, //!< uninitialized
21
+ kAlpha_8_SkColorType, //!< pixel with alpha in 8-bit byte
22
+ kRGB_565_SkColorType, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
23
+ kARGB_4444_SkColorType, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word
24
+ kRGBA_8888_SkColorType, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word
25
+ kRGB_888x_SkColorType, //!< pixel with 8 bits each for red, green, blue; in 32-bit word
26
+ kBGRA_8888_SkColorType, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word
27
+ kRGBA_1010102_SkColorType, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
28
+ kBGRA_1010102_SkColorType, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
29
+ kRGB_101010x_SkColorType, //!< pixel with 10 bits each for red, green, blue; in 32-bit word
30
+ kBGR_101010x_SkColorType, //!< pixel with 10 bits each for blue, green, red; in 32-bit word
31
+ kGray_8_SkColorType, //!< pixel with grayscale level in 8-bit byte
32
+ kRGBA_F16Norm_SkColorType, //!< pixel with half floats in [0,1] for red, green, blue, alpha;
33
+ // in 64-bit word
34
+ kRGBA_F16_SkColorType, //!< pixel with half floats for red, green, blue, alpha;
35
+ // in 64-bit word
36
+ kRGBA_F32_SkColorType, //!< pixel using C float for red, green, blue, alpha; in 128-bit word
37
+
38
+ // The following 6 colortypes are just for reading from - not for rendering to
39
+ kR8G8_unorm_SkColorType, //!< pixel with a uint8_t for red and green
40
+
41
+ kA16_float_SkColorType, //!< pixel with a half float for alpha
42
+ kR16G16_float_SkColorType, //!< pixel with a half float for red and green
43
+
44
+ kA16_unorm_SkColorType, //!< pixel with a little endian uint16_t for alpha
45
+ kR16G16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red and green
46
+ kR16G16B16A16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red, green, blue
47
+ // and alpha
48
+
49
+ kSRGBA_8888_SkColorType,
50
+ kR8_unorm_SkColorType,
51
+
52
+ kLastEnum_SkColorType = kR8_unorm_SkColorType, //!< last valid value
53
+
54
+ #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
55
+ kN32_SkColorType = kBGRA_8888_SkColorType,//!< native 32-bit BGRA encoding
56
+
57
+ #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
58
+ kN32_SkColorType = kRGBA_8888_SkColorType,//!< native 32-bit RGBA encoding
59
+
60
+ #else
61
+ #error "SK_*32_SHIFT values must correspond to BGRA or RGBA byte order"
62
+ #endif
63
+ };
64
+ static constexpr int kSkColorTypeCnt = static_cast<int>(kLastEnum_SkColorType) + 1;
65
+
66
+ #endif
@@ -60,7 +60,7 @@ public:
60
60
  sk_sp<SkImage> makePromiseTexture(const GrBackendFormat& backendFormat,
61
61
  int width,
62
62
  int height,
63
- GrMipmapped mipMapped,
63
+ GrMipmapped mipmapped,
64
64
  GrSurfaceOrigin origin,
65
65
  SkColorType colorType,
66
66
  SkAlphaType alphaType,
@@ -103,6 +103,12 @@ public:
103
103
  */
104
104
  SkRect getBounds();
105
105
 
106
+ /**
107
+ * Return approximately how many bytes would be freed if this drawable is destroyed.
108
+ * The base implementation returns 0 to indicate that this is unknown.
109
+ */
110
+ size_t approximateBytesUsed();
111
+
106
112
  /**
107
113
  * Calling this invalidates the previous generation ID, and causes a new one to be computed
108
114
  * the next time getGenerationID() is called. Typically this is called by the object itself,
@@ -132,6 +138,7 @@ protected:
132
138
  SkDrawable();
133
139
 
134
140
  virtual SkRect onGetBounds() = 0;
141
+ virtual size_t onApproximateBytesUsed();
135
142
  virtual void onDraw(SkCanvas*) = 0;
136
143
 
137
144
  virtual std::unique_ptr<GpuDrawHandler> onSnapGpuDrawHandler(GrBackendApi, const SkMatrix&,
@@ -30,6 +30,7 @@ enum class SkEncodedImageFormat {
30
30
  kDNG,
31
31
  kHEIF,
32
32
  kAVIF,
33
+ kJPEGXL,
33
34
  };
34
35
 
35
36
  #endif // SkEncodedImageFormat_DEFINED
@@ -331,7 +331,7 @@ public:
331
331
  @param text character storage encoded with SkTextEncoding
332
332
  @param byteLength length of character storage in bytes
333
333
  @param bounds returns bounding box relative to (0, 0) if not nullptr
334
- @return number of glyphs represented by text of length byteLength
334
+ @return the sum of the default advance widths
335
335
  */
336
336
  SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding,
337
337
  SkRect* bounds = nullptr) const {
@@ -347,7 +347,7 @@ public:
347
347
  @param byteLength length of character storage in bytes
348
348
  @param bounds returns bounding box relative to (0, 0) if not nullptr
349
349
  @param paint optional; may be nullptr
350
- @return number of glyphs represented by text of length byteLength
350
+ @return the sum of the default advance widths
351
351
  */
352
352
  SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding,
353
353
  SkRect* bounds, const SkPaint* paint) const;
@@ -527,8 +527,9 @@ private:
527
527
  bool hasSomeAntiAliasing() const;
528
528
 
529
529
  friend class SkFontPriv;
530
- friend class SkGlyphRunListPainter;
530
+ friend class SkGlyphRunListPainterCPU;
531
531
  friend class SkStrikeSpec;
532
+ friend class SkRemoteGlyphCacheTest;
532
533
  };
533
534
 
534
535
  #endif
@@ -8,6 +8,7 @@
8
8
  #ifndef SkFontArguments_DEFINED
9
9
  #define SkFontArguments_DEFINED
10
10
 
11
+ #include "include/core/SkColor.h"
11
12
  #include "include/core/SkScalar.h"
12
13
  #include "include/core/SkTypes.h"
13
14
 
@@ -22,7 +23,27 @@ struct SkFontArguments {
22
23
  int coordinateCount;
23
24
  };
24
25
 
25
- SkFontArguments() : fCollectionIndex(0), fVariationDesignPosition{nullptr, 0} {}
26
+ /** Specify a palette to use and overrides for palette entries.
27
+ *
28
+ * `overrides` is a list of pairs of palette entry index and color.
29
+ * The overriden palette entries will use the associated color.
30
+ * Override pairs with palette entry indices out of range will not be applied.
31
+ * Later override entries override earlier ones.
32
+ */
33
+ struct Palette {
34
+ struct Override {
35
+ int index;
36
+ SkColor color;
37
+ };
38
+ int index;
39
+ const Override* overrides;
40
+ int overrideCount;
41
+ };
42
+
43
+ SkFontArguments()
44
+ : fCollectionIndex(0)
45
+ , fVariationDesignPosition{nullptr, 0}
46
+ , fPalette{0, nullptr, 0} {}
26
47
 
27
48
  /** Specify the index of the desired font.
28
49
  *
@@ -54,9 +75,20 @@ struct SkFontArguments {
54
75
  VariationPosition getVariationDesignPosition() const {
55
76
  return fVariationDesignPosition;
56
77
  }
78
+
79
+ SkFontArguments& setPalette(Palette palette) {
80
+ fPalette.index = palette.index;
81
+ fPalette.overrides = palette.overrides;
82
+ fPalette.overrideCount = palette.overrideCount;
83
+ return *this;
84
+ }
85
+
86
+ Palette getPalette() const { return fPalette; }
87
+
57
88
  private:
58
89
  int fCollectionIndex;
59
90
  VariationPosition fVariationDesignPosition;
91
+ Palette fPalette;
60
92
  };
61
93
 
62
94
  #endif
@@ -12,6 +12,7 @@
12
12
 
13
13
  class SkData;
14
14
  class SkImageGenerator;
15
+ class SkOpenTypeSVGDecoder;
15
16
  class SkTraceMemoryDump;
16
17
 
17
18
  class SK_API SkGraphics {
@@ -137,6 +138,18 @@ public:
137
138
  static ImageGeneratorFromEncodedDataFactory
138
139
  SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory);
139
140
 
141
+ /**
142
+ * To draw OpenType SVG data, Skia will look at this runtime function pointer. If this function
143
+ * pointer is set, the SkTypeface implementations which support OpenType SVG will call this
144
+ * function to create an SkOpenTypeSVGDecoder to decode the OpenType SVG and draw it as needed.
145
+ * If this function is not set, the SkTypeface implementations will generally not support
146
+ * OpenType SVG and attempt to use other glyph representations if available.
147
+ */
148
+ using OpenTypeSVGDecoderFactory =
149
+ std::unique_ptr<SkOpenTypeSVGDecoder> (*)(const uint8_t* svg, size_t length);
150
+ static OpenTypeSVGDecoderFactory SetOpenTypeSVGDecoderFactory(OpenTypeSVGDecoderFactory);
151
+ static OpenTypeSVGDecoderFactory GetOpenTypeSVGDecoderFactory();
152
+
140
153
  /**
141
154
  * Call early in main() to allow Skia to use a JIT to accelerate CPU-bound operations.
142
155
  */