@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
@@ -8,23 +8,37 @@
8
8
  #ifndef GrSlug_DEFINED
9
9
  #define GrSlug_DEFINED
10
10
 
11
+ #include "include/core/SkData.h"
11
12
  #include "include/core/SkRect.h"
12
13
  #include "include/core/SkRefCnt.h"
13
14
 
14
15
  class SkCanvas;
16
+ class SkMatrix;
15
17
  class SkPaint;
16
18
  class SkTextBlob;
19
+ class SkReadBuffer;
20
+ class SkStrikeClient;
21
+ class SkWriteBuffer;
17
22
 
18
23
  // You can use GrSlug to simulate drawTextBlob by defining the following at compile time.
19
24
  // SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG
25
+ // You can use GrSlug serialization to simulate drawTextBlob by defining the following:
26
+ // SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE
20
27
  // For Skia, add this to your args.gn file.
21
28
  // extra_cflags = ["-D", "SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG"]
22
29
 
30
+ // Internal infrastructure for using SubRuns.
31
+ class SK_API GrTextReferenceFrame : public SkRefCnt {
32
+ public:
33
+ ~GrTextReferenceFrame() override;
34
+ virtual const SkMatrix& initialPositionMatrix() const = 0;
35
+ };
36
+
23
37
  // GrSlug encapsulates an SkTextBlob at a specific origin, using a specific paint. It can be
24
38
  // manipulated using matrix and clip changes to the canvas. If the canvas is transformed, then
25
39
  // the GrSlug will also transform with smaller glyphs using bi-linear interpolation to render. You
26
40
  // can think of a GrSlug as making a rubber stamp out of a SkTextBlob.
27
- class SK_API GrSlug : public SkRefCnt {
41
+ class SK_API GrSlug : public GrTextReferenceFrame {
28
42
  public:
29
43
  ~GrSlug() override;
30
44
  // Return nullptr if the blob would not draw. This is not because of clipping, but because of
@@ -32,10 +46,33 @@ public:
32
46
  static sk_sp<GrSlug> ConvertBlob(
33
47
  SkCanvas* canvas, const SkTextBlob& blob, SkPoint origin, const SkPaint& paint);
34
48
 
49
+ // Serialize the slug.
50
+ sk_sp<SkData> serialize() const;
51
+ size_t serialize(void* buffer, size_t size) const;
52
+
53
+ // Set the client parameter to the appropriate SkStrikeClient when typeface ID translation
54
+ // is needed.
55
+ static sk_sp<GrSlug> Deserialize(
56
+ const void* data, size_t size, const SkStrikeClient* client = nullptr);
57
+ static sk_sp<GrSlug> MakeFromBuffer(SkReadBuffer& buffer);
58
+
59
+
35
60
  // Draw the GrSlug obeying the canvas's mapping and clipping.
36
- void draw(SkCanvas* canvas);
61
+ void draw(SkCanvas* canvas) const;
37
62
 
38
63
  virtual SkRect sourceBounds() const = 0;
39
- virtual const SkPaint& paint() const = 0;
64
+
65
+ // The paint passed into ConvertBlob; this paint is used instead of the paint resulting from
66
+ // the call to aboutToDraw because when we call draw(), the initial paint is needed to call
67
+ // aboutToDraw again to get the layer right.
68
+ virtual const SkPaint& initialPaint() const = 0;
69
+
70
+ virtual void doFlatten(SkWriteBuffer&) const = 0;
71
+
72
+ uint32_t uniqueID() const { return fUniqueID; }
73
+
74
+ private:
75
+ static uint32_t NextUniqueID();
76
+ const uint32_t fUniqueID{NextUniqueID()};
40
77
  };
41
78
  #endif // GrSlug_DEFINED
@@ -15,8 +15,9 @@
15
15
  #include "include/core/SkRefCnt.h"
16
16
  #include "include/utils/SkNoDrawCanvas.h"
17
17
 
18
- class SkAutoDescriptor;
18
+ class GrSlug;
19
19
  struct SkPackedGlyphID;
20
+ class SkAutoDescriptor;
20
21
  class SkStrikeCache;
21
22
  class SkStrikeClientImpl;
22
23
  class SkStrikeServer;
@@ -93,7 +94,8 @@ public:
93
94
  kGlyphMetricsFallback = 4,
94
95
  kGlyphPathFallback = 5,
95
96
 
96
- kLast = kGlyphPath
97
+ kGlyphDrawable = 6,
98
+ kLast = kGlyphDrawable
97
99
  };
98
100
 
99
101
  // An interface to delete handles that may be pinned by the remote server.
@@ -133,11 +135,15 @@ public:
133
135
  // Returns false if the data is invalid.
134
136
  SK_SPI bool readStrikeData(const volatile void* memory, size_t memorySize);
135
137
 
138
+ // Given a descriptor re-write the Rec mapping the typefaceID from the renderer to the
139
+ // corresponding typefaceID on the GPU.
140
+ SK_SPI bool translateTypefaceID(SkAutoDescriptor* descriptor) const;
141
+
142
+ // Given a buffer, unflatten into a slug making sure to do the typefaceID translation from
143
+ // renderer to GPU. Returns nullptr if there was a problem.
144
+ sk_sp<GrSlug> deserializeSlug(const void* data, size_t size) const;
145
+
136
146
  private:
137
147
  std::unique_ptr<SkStrikeClientImpl> fImpl;
138
148
  };
139
-
140
- // For exposure to fuzzing only.
141
- bool SkFuzzDeserializeSkDescriptor(sk_sp<SkData> bytes, SkAutoDescriptor* ad);
142
-
143
149
  #endif // SkChromeRemoteGlyphCache_DEFINED
@@ -45,6 +45,13 @@ public:
45
45
 
46
46
  SK_API GrBackendFormat compressedBackendFormat(SkImage::CompressionType) const;
47
47
 
48
+ /**
49
+ * Gets the maximum supported sample count for a color type. 1 is returned if only non-MSAA
50
+ * rendering is supported for the color type. 0 is returned if rendering to this color type
51
+ * is not supported at all.
52
+ */
53
+ SK_API int maxSurfaceSampleCountForColorType(SkColorType colorType) const;
54
+
48
55
  // TODO: When the public version is gone, rename to refThreadSafeProxy and add raw ptr ver.
49
56
  sk_sp<GrContextThreadSafeProxy> threadSafeProxy();
50
57
 
@@ -38,6 +38,7 @@ public:
38
38
  GrGLenum fWrapT;
39
39
  GrGLfloat fMinLOD;
40
40
  GrGLfloat fMaxLOD;
41
+ GrGLfloat fMaxAniso;
41
42
  // We always want the border color to be transparent black, so no need to store 4 floats.
42
43
  // Just track if it's been invalidated and no longer the default
43
44
  bool fBorderColorInvalid;
@@ -8,8 +8,8 @@
8
8
  #ifndef GrImageContext_DEFINED
9
9
  #define GrImageContext_DEFINED
10
10
 
11
- #include "include/private/GrContext_Base.h"
12
- #include "include/private/GrSingleOwner.h"
11
+ #include "include/private/SingleOwner.h"
12
+ #include "include/private/gpu/ganesh/GrContext_Base.h"
13
13
 
14
14
  class GrImageContextPriv;
15
15
 
@@ -33,7 +33,7 @@ protected:
33
33
  SK_API virtual bool abandoned();
34
34
 
35
35
  /** This is only useful for debug purposes */
36
- GrSingleOwner* singleOwner() const { return &fSingleOwner; }
36
+ skgpu::SingleOwner* singleOwner() const { return &fSingleOwner; }
37
37
 
38
38
  GrImageContext* asImageContext() override { return this; }
39
39
 
@@ -47,7 +47,7 @@ private:
47
47
  // This guard is passed to the GrDrawingManager and, from there to all the
48
48
  // GrSurfaceDrawContexts. It is also passed to the GrResourceProvider and SkGpuDevice.
49
49
  // TODO: Move this down to GrRecordingContext.
50
- mutable GrSingleOwner fSingleOwner;
50
+ mutable skgpu::SingleOwner fSingleOwner;
51
51
 
52
52
  using INHERITED = GrContext_Base;
53
53
  };
@@ -45,10 +45,8 @@ enum class GrPrimitiveType : uint8_t {
45
45
  kPoints,
46
46
  kLines, // 1 pix wide only
47
47
  kLineStrip, // 1 pix wide only
48
- kPatches,
49
- kPath
50
48
  };
51
- static constexpr int kNumGrPrimitiveTypes = (int)GrPrimitiveType::kPath + 1;
49
+ static constexpr int kNumGrPrimitiveTypes = (int)GrPrimitiveType::kLineStrip + 1;
52
50
 
53
51
  static constexpr bool GrIsPrimTypeLines(GrPrimitiveType type) {
54
52
  return GrPrimitiveType::kLines == type || GrPrimitiveType::kLineStrip == type;
@@ -74,33 +72,6 @@ enum class GrDDLProvider : bool {
74
72
  kYes = true
75
73
  };
76
74
 
77
- /**
78
- * Formats for masks, used by the font cache. Important that these are 0-based.
79
- */
80
- enum GrMaskFormat {
81
- kA8_GrMaskFormat, //!< 1-byte per pixel
82
- kA565_GrMaskFormat, //!< 2-bytes per pixel, RGB represent 3-channel LCD coverage
83
- kARGB_GrMaskFormat, //!< 4-bytes per pixel, color format
84
-
85
- kLast_GrMaskFormat = kARGB_GrMaskFormat
86
- };
87
- static const int kMaskFormatCount = kLast_GrMaskFormat + 1;
88
-
89
- /**
90
- * Return the number of bytes-per-pixel for the specified mask format.
91
- */
92
- inline constexpr int GrMaskFormatBytesPerPixel(GrMaskFormat format) {
93
- SkASSERT(format < kMaskFormatCount);
94
- // kA8 (0) -> 1
95
- // kA565 (1) -> 2
96
- // kARGB (2) -> 4
97
- static_assert(kA8_GrMaskFormat == 0, "enum_order_dependency");
98
- static_assert(kA565_GrMaskFormat == 1, "enum_order_dependency");
99
- static_assert(kARGB_GrMaskFormat == 2, "enum_order_dependency");
100
-
101
- return SkTo<int>(1u << format);
102
- }
103
-
104
75
  /** Ownership rules for external GPU resources imported into Skia. */
105
76
  enum GrWrapOwnership {
106
77
  /** Skia will assume the client will keep the resource alive and Skia will not free it. */
@@ -257,18 +228,13 @@ enum class GrClampType {
257
228
  /**
258
229
  * A number of rectangle/quadrilateral drawing APIs can control anti-aliasing on a per edge basis.
259
230
  * These masks specify which edges are AA'ed. The intent for this is to support tiling with seamless
260
- * boundaries, where the inner edges are non-AA and the outer edges are AA. Regular draws (where AA
261
- * is specified by GrAA) is almost equivalent to kNone or kAll, with the exception of how MSAA is
262
- * handled.
263
- *
264
- * When tiling and there is MSAA, mixed edge rectangles are processed with MSAA, so in order for the
265
- * tiled edges to remain seamless, inner tiles with kNone must also be processed with MSAA. In
266
- * regular drawing, however, kNone should disable MSAA (if it's supported) to match the expected
267
- * appearance.
231
+ * boundaries, where the inner edges are non-AA and the outer edges are AA. Regular rectangle draws
232
+ * simply use kAll or kNone depending on if they want anti-aliasing or not.
268
233
  *
269
- * Therefore, APIs that use per-edge AA flags also take a GrAA value so that they can differentiate
270
- * between the regular and tiling use case behaviors. Tiling operations should always pass
271
- * GrAA::kYes while regular options should pass GrAA based on the SkPaint's anti-alias state.
234
+ * In APIs that support per-edge AA, GrQuadAAFlags is the only AA-control parameter that is
235
+ * provided (compared to the typical GrAA parameter). kNone is equivalent to GrAA::kNo, and any
236
+ * other set of edge flags would require GrAA::kYes (with rendering output dependent on how that
237
+ * maps to GrAAType for a given SurfaceDrawContext).
272
238
  *
273
239
  * These values are identical to SkCanvas::QuadAAFlags.
274
240
  */
@@ -288,56 +254,6 @@ static inline GrQuadAAFlags SkToGrQuadAAFlags(unsigned flags) {
288
254
  return static_cast<GrQuadAAFlags>(flags);
289
255
  }
290
256
 
291
- /**
292
- * Types of shader-language-specific boxed variables we can create.
293
- */
294
- enum GrSLType {
295
- kVoid_GrSLType,
296
- kBool_GrSLType,
297
- kBool2_GrSLType,
298
- kBool3_GrSLType,
299
- kBool4_GrSLType,
300
- kShort_GrSLType,
301
- kShort2_GrSLType,
302
- kShort3_GrSLType,
303
- kShort4_GrSLType,
304
- kUShort_GrSLType,
305
- kUShort2_GrSLType,
306
- kUShort3_GrSLType,
307
- kUShort4_GrSLType,
308
- kFloat_GrSLType,
309
- kFloat2_GrSLType,
310
- kFloat3_GrSLType,
311
- kFloat4_GrSLType,
312
- kFloat2x2_GrSLType,
313
- kFloat3x3_GrSLType,
314
- kFloat4x4_GrSLType,
315
- kHalf_GrSLType,
316
- kHalf2_GrSLType,
317
- kHalf3_GrSLType,
318
- kHalf4_GrSLType,
319
- kHalf2x2_GrSLType,
320
- kHalf3x3_GrSLType,
321
- kHalf4x4_GrSLType,
322
- kInt_GrSLType,
323
- kInt2_GrSLType,
324
- kInt3_GrSLType,
325
- kInt4_GrSLType,
326
- kUInt_GrSLType,
327
- kUInt2_GrSLType,
328
- kUInt3_GrSLType,
329
- kUInt4_GrSLType,
330
- kTexture2DSampler_GrSLType,
331
- kTextureExternalSampler_GrSLType,
332
- kTexture2DRectSampler_GrSLType,
333
- kTexture2D_GrSLType,
334
- kSampler_GrSLType,
335
- kInput_GrSLType,
336
-
337
- kLast_GrSLType = kInput_GrSLType
338
- };
339
- static const int kGrSLTypeCount = kLast_GrSLType + 1;
340
-
341
257
  /**
342
258
  * The type of texture. Backends other than GL currently only use the 2D value but the type must
343
259
  * still be known at the API-neutral layer as it used to determine whether MIP maps, renderability,
@@ -362,192 +278,10 @@ static const int kGrShaderTypeCount = kLastkFragment_GrShaderType + 1;
362
278
  enum GrShaderFlags {
363
279
  kNone_GrShaderFlags = 0,
364
280
  kVertex_GrShaderFlag = 1 << 0,
365
- kTessControl_GrShaderFlag = 1 << 1,
366
- kTessEvaluation_GrShaderFlag = 1 << 2,
367
- kFragment_GrShaderFlag = 1 << 3
281
+ kFragment_GrShaderFlag = 1 << 1
368
282
  };
369
283
  SK_MAKE_BITFIELD_OPS(GrShaderFlags)
370
284
 
371
- /** Is the shading language type float (including vectors/matrices)? */
372
- static constexpr bool GrSLTypeIsFloatType(GrSLType type) {
373
- switch (type) {
374
- case kFloat_GrSLType:
375
- case kFloat2_GrSLType:
376
- case kFloat3_GrSLType:
377
- case kFloat4_GrSLType:
378
- case kFloat2x2_GrSLType:
379
- case kFloat3x3_GrSLType:
380
- case kFloat4x4_GrSLType:
381
- case kHalf_GrSLType:
382
- case kHalf2_GrSLType:
383
- case kHalf3_GrSLType:
384
- case kHalf4_GrSLType:
385
- case kHalf2x2_GrSLType:
386
- case kHalf3x3_GrSLType:
387
- case kHalf4x4_GrSLType:
388
- return true;
389
-
390
- case kVoid_GrSLType:
391
- case kTexture2DSampler_GrSLType:
392
- case kTextureExternalSampler_GrSLType:
393
- case kTexture2DRectSampler_GrSLType:
394
- case kBool_GrSLType:
395
- case kBool2_GrSLType:
396
- case kBool3_GrSLType:
397
- case kBool4_GrSLType:
398
- case kShort_GrSLType:
399
- case kShort2_GrSLType:
400
- case kShort3_GrSLType:
401
- case kShort4_GrSLType:
402
- case kUShort_GrSLType:
403
- case kUShort2_GrSLType:
404
- case kUShort3_GrSLType:
405
- case kUShort4_GrSLType:
406
- case kInt_GrSLType:
407
- case kInt2_GrSLType:
408
- case kInt3_GrSLType:
409
- case kInt4_GrSLType:
410
- case kUInt_GrSLType:
411
- case kUInt2_GrSLType:
412
- case kUInt3_GrSLType:
413
- case kUInt4_GrSLType:
414
- case kTexture2D_GrSLType:
415
- case kSampler_GrSLType:
416
- case kInput_GrSLType:
417
- return false;
418
- }
419
- SkUNREACHABLE;
420
- }
421
-
422
- /** Is the shading language type integral (including vectors)? */
423
- static constexpr bool GrSLTypeIsIntegralType(GrSLType type) {
424
- switch (type) {
425
- case kShort_GrSLType:
426
- case kShort2_GrSLType:
427
- case kShort3_GrSLType:
428
- case kShort4_GrSLType:
429
- case kUShort_GrSLType:
430
- case kUShort2_GrSLType:
431
- case kUShort3_GrSLType:
432
- case kUShort4_GrSLType:
433
- case kInt_GrSLType:
434
- case kInt2_GrSLType:
435
- case kInt3_GrSLType:
436
- case kInt4_GrSLType:
437
- case kUInt_GrSLType:
438
- case kUInt2_GrSLType:
439
- case kUInt3_GrSLType:
440
- case kUInt4_GrSLType:
441
- return true;
442
-
443
- case kFloat_GrSLType:
444
- case kFloat2_GrSLType:
445
- case kFloat3_GrSLType:
446
- case kFloat4_GrSLType:
447
- case kFloat2x2_GrSLType:
448
- case kFloat3x3_GrSLType:
449
- case kFloat4x4_GrSLType:
450
- case kHalf_GrSLType:
451
- case kHalf2_GrSLType:
452
- case kHalf3_GrSLType:
453
- case kHalf4_GrSLType:
454
- case kHalf2x2_GrSLType:
455
- case kHalf3x3_GrSLType:
456
- case kHalf4x4_GrSLType:
457
- case kVoid_GrSLType:
458
- case kTexture2DSampler_GrSLType:
459
- case kTextureExternalSampler_GrSLType:
460
- case kTexture2DRectSampler_GrSLType:
461
- case kBool_GrSLType:
462
- case kBool2_GrSLType:
463
- case kBool3_GrSLType:
464
- case kBool4_GrSLType:
465
- case kTexture2D_GrSLType:
466
- case kSampler_GrSLType:
467
- case kInput_GrSLType:
468
- return false;
469
- }
470
- SkUNREACHABLE;
471
- }
472
-
473
- /**
474
- * Is the shading language type supported as a uniform (ie, does it have a corresponding set
475
- * function on GrGLSLProgramDataManager)?
476
- */
477
- static constexpr bool GrSLTypeCanBeUniformValue(GrSLType type) {
478
- return GrSLTypeIsFloatType(type) || GrSLTypeIsIntegralType(type);
479
- }
480
-
481
- /** If the type represents a single value or vector return the vector length, else -1. */
482
- static constexpr int GrSLTypeVecLength(GrSLType type) {
483
- switch (type) {
484
- case kFloat_GrSLType:
485
- case kHalf_GrSLType:
486
- case kBool_GrSLType:
487
- case kShort_GrSLType:
488
- case kUShort_GrSLType:
489
- case kInt_GrSLType:
490
- case kUInt_GrSLType:
491
- return 1;
492
-
493
- case kFloat2_GrSLType:
494
- case kHalf2_GrSLType:
495
- case kBool2_GrSLType:
496
- case kShort2_GrSLType:
497
- case kUShort2_GrSLType:
498
- case kInt2_GrSLType:
499
- case kUInt2_GrSLType:
500
- return 2;
501
-
502
- case kFloat3_GrSLType:
503
- case kHalf3_GrSLType:
504
- case kBool3_GrSLType:
505
- case kShort3_GrSLType:
506
- case kUShort3_GrSLType:
507
- case kInt3_GrSLType:
508
- case kUInt3_GrSLType:
509
- return 3;
510
-
511
- case kFloat4_GrSLType:
512
- case kHalf4_GrSLType:
513
- case kBool4_GrSLType:
514
- case kShort4_GrSLType:
515
- case kUShort4_GrSLType:
516
- case kInt4_GrSLType:
517
- case kUInt4_GrSLType:
518
- return 4;
519
-
520
- case kFloat2x2_GrSLType:
521
- case kFloat3x3_GrSLType:
522
- case kFloat4x4_GrSLType:
523
- case kHalf2x2_GrSLType:
524
- case kHalf3x3_GrSLType:
525
- case kHalf4x4_GrSLType:
526
- case kVoid_GrSLType:
527
- case kTexture2DSampler_GrSLType:
528
- case kTextureExternalSampler_GrSLType:
529
- case kTexture2DRectSampler_GrSLType:
530
- case kTexture2D_GrSLType:
531
- case kSampler_GrSLType:
532
- case kInput_GrSLType:
533
- return -1;
534
- }
535
- SkUNREACHABLE;
536
- }
537
-
538
- static inline GrSLType GrSLCombinedSamplerTypeForTextureType(GrTextureType type) {
539
- switch (type) {
540
- case GrTextureType::k2D:
541
- return kTexture2DSampler_GrSLType;
542
- case GrTextureType::kRectangle:
543
- return kTexture2DRectSampler_GrSLType;
544
- case GrTextureType::kExternal:
545
- return kTextureExternalSampler_GrSLType;
546
- default:
547
- SK_ABORT("Unexpected texture type");
548
- }
549
- }
550
-
551
285
  /** Rectangle and external textures only support the clamp wrap mode and do not support
552
286
  * MIP maps.
553
287
  */
@@ -564,56 +298,6 @@ static inline bool GrTextureTypeHasRestrictedSampling(GrTextureType type) {
564
298
  }
565
299
  }
566
300
 
567
- static constexpr bool GrSLTypeIsCombinedSamplerType(GrSLType type) {
568
- switch (type) {
569
- case kTexture2DSampler_GrSLType:
570
- case kTextureExternalSampler_GrSLType:
571
- case kTexture2DRectSampler_GrSLType:
572
- return true;
573
-
574
- case kVoid_GrSLType:
575
- case kFloat_GrSLType:
576
- case kFloat2_GrSLType:
577
- case kFloat3_GrSLType:
578
- case kFloat4_GrSLType:
579
- case kFloat2x2_GrSLType:
580
- case kFloat3x3_GrSLType:
581
- case kFloat4x4_GrSLType:
582
- case kHalf_GrSLType:
583
- case kHalf2_GrSLType:
584
- case kHalf3_GrSLType:
585
- case kHalf4_GrSLType:
586
- case kHalf2x2_GrSLType:
587
- case kHalf3x3_GrSLType:
588
- case kHalf4x4_GrSLType:
589
- case kInt_GrSLType:
590
- case kInt2_GrSLType:
591
- case kInt3_GrSLType:
592
- case kInt4_GrSLType:
593
- case kUInt_GrSLType:
594
- case kUInt2_GrSLType:
595
- case kUInt3_GrSLType:
596
- case kUInt4_GrSLType:
597
- case kBool_GrSLType:
598
- case kBool2_GrSLType:
599
- case kBool3_GrSLType:
600
- case kBool4_GrSLType:
601
- case kShort_GrSLType:
602
- case kShort2_GrSLType:
603
- case kShort3_GrSLType:
604
- case kShort4_GrSLType:
605
- case kUShort_GrSLType:
606
- case kUShort2_GrSLType:
607
- case kUShort3_GrSLType:
608
- case kUShort4_GrSLType:
609
- case kTexture2D_GrSLType:
610
- case kSampler_GrSLType:
611
- case kInput_GrSLType:
612
- return false;
613
- }
614
- SkUNREACHABLE;
615
- }
616
-
617
301
  //////////////////////////////////////////////////////////////////////////////
618
302
 
619
303
  /**
@@ -883,6 +567,7 @@ enum class GrColorType {
883
567
  kAlpha_8xxx,
884
568
  kAlpha_F32xxx,
885
569
  kGray_8xxx,
570
+ kR_8xxx,
886
571
 
887
572
  // Types used to initialize backend textures.
888
573
  kRGB_888,
@@ -920,12 +605,13 @@ static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct) {
920
605
  case GrColorType::kAlpha_8xxx: return kUnknown_SkColorType;
921
606
  case GrColorType::kAlpha_F32xxx: return kUnknown_SkColorType;
922
607
  case GrColorType::kGray_8xxx: return kUnknown_SkColorType;
608
+ case GrColorType::kR_8xxx: return kUnknown_SkColorType;
923
609
  case GrColorType::kAlpha_16: return kA16_unorm_SkColorType;
924
610
  case GrColorType::kRG_1616: return kR16G16_unorm_SkColorType;
925
611
  case GrColorType::kRGBA_16161616: return kR16G16B16A16_unorm_SkColorType;
926
612
  case GrColorType::kRG_F16: return kR16G16_float_SkColorType;
927
613
  case GrColorType::kRGB_888: return kUnknown_SkColorType;
928
- case GrColorType::kR_8: return kUnknown_SkColorType;
614
+ case GrColorType::kR_8: return kR8_unorm_SkColorType;
929
615
  case GrColorType::kR_16: return kUnknown_SkColorType;
930
616
  case GrColorType::kR_F16: return kUnknown_SkColorType;
931
617
  case GrColorType::kGray_F16: return kUnknown_SkColorType;
@@ -959,6 +645,7 @@ static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct) {
959
645
  case kA16_float_SkColorType: return GrColorType::kAlpha_F16;
960
646
  case kR16G16_float_SkColorType: return GrColorType::kRG_F16;
961
647
  case kR16G16B16A16_unorm_SkColorType: return GrColorType::kRGBA_16161616;
648
+ case kR8_unorm_SkColorType: return GrColorType::kR_8;
962
649
  }
963
650
  SkUNREACHABLE;
964
651
  }
@@ -985,6 +672,7 @@ static constexpr uint32_t GrColorTypeChannelFlags(GrColorType ct) {
985
672
  case GrColorType::kAlpha_8xxx: return kAlpha_SkColorChannelFlag;
986
673
  case GrColorType::kAlpha_F32xxx: return kAlpha_SkColorChannelFlag;
987
674
  case GrColorType::kGray_8xxx: return kGray_SkColorChannelFlag;
675
+ case GrColorType::kR_8xxx: return kRed_SkColorChannelFlag;
988
676
  case GrColorType::kAlpha_16: return kAlpha_SkColorChannelFlag;
989
677
  case GrColorType::kRG_1616: return kRG_SkColorChannelFlags;
990
678
  case GrColorType::kRGBA_16161616: return kRGBA_SkColorChannelFlags;
@@ -1135,6 +823,8 @@ static constexpr GrColorFormatDesc GrGetColorTypeDesc(GrColorType ct) {
1135
823
  return GrColorFormatDesc::MakeAlpha(32, GrColorTypeEncoding::kFloat);
1136
824
  case GrColorType::kGray_8xxx:
1137
825
  return GrColorFormatDesc::MakeGray(8, GrColorTypeEncoding::kUnorm);
826
+ case GrColorType::kR_8xxx:
827
+ return GrColorFormatDesc::MakeR(8, GrColorTypeEncoding::kUnorm);
1138
828
  case GrColorType::kAlpha_16:
1139
829
  return GrColorFormatDesc::MakeAlpha(16, GrColorTypeEncoding::kUnorm);
1140
830
  case GrColorType::kRG_1616:
@@ -1211,6 +901,7 @@ static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct) {
1211
901
  case GrColorType::kAlpha_8xxx: return 4;
1212
902
  case GrColorType::kAlpha_F32xxx: return 16;
1213
903
  case GrColorType::kGray_8xxx: return 4;
904
+ case GrColorType::kR_8xxx: return 4;
1214
905
  case GrColorType::kAlpha_16: return 2;
1215
906
  case GrColorType::kRG_1616: return 4;
1216
907
  case GrColorType::kRGBA_16161616: return 8;
@@ -1239,48 +930,6 @@ static constexpr SkColorType GrCompressionTypeToSkColorType(SkImage::Compression
1239
930
  SkUNREACHABLE;
1240
931
  }
1241
932
 
1242
- static constexpr GrColorType GrMaskFormatToColorType(GrMaskFormat format) {
1243
- switch (format) {
1244
- case kA8_GrMaskFormat:
1245
- return GrColorType::kAlpha_8;
1246
- case kA565_GrMaskFormat:
1247
- return GrColorType::kBGR_565;
1248
- case kARGB_GrMaskFormat:
1249
- return GrColorType::kRGBA_8888;
1250
- }
1251
- SkUNREACHABLE;
1252
- }
1253
-
1254
- /**
1255
- * Ref-counted object that calls a callback from its destructor.
1256
- */
1257
- class GrRefCntedCallback : public SkNVRefCnt<GrRefCntedCallback> {
1258
- public:
1259
- using Context = void*;
1260
- using Callback = void (*)(Context);
1261
-
1262
- static sk_sp<GrRefCntedCallback> Make(Callback proc, Context ctx) {
1263
- if (!proc) {
1264
- return nullptr;
1265
- }
1266
- return sk_sp<GrRefCntedCallback>(new GrRefCntedCallback(proc, ctx));
1267
- }
1268
-
1269
- ~GrRefCntedCallback() { fReleaseProc(fReleaseCtx); }
1270
-
1271
- Context context() const { return fReleaseCtx; }
1272
-
1273
- private:
1274
- GrRefCntedCallback(Callback proc, Context ctx) : fReleaseProc(proc), fReleaseCtx(ctx) {}
1275
- GrRefCntedCallback(const GrRefCntedCallback&) = delete;
1276
- GrRefCntedCallback(GrRefCntedCallback&&) = delete;
1277
- GrRefCntedCallback& operator=(const GrRefCntedCallback&) = delete;
1278
- GrRefCntedCallback& operator=(GrRefCntedCallback&&) = delete;
1279
-
1280
- Callback fReleaseProc;
1281
- Context fReleaseCtx;
1282
- };
1283
-
1284
933
  enum class GrDstSampleFlags {
1285
934
  kNone = 0,
1286
935
  kRequiresTextureBarrier = 1 << 0,
@@ -1325,6 +974,7 @@ static constexpr const char* GrColorTypeToStr(GrColorType ct) {
1325
974
  case GrColorType::kAlpha_8xxx: return "kAlpha_8xxx";
1326
975
  case GrColorType::kAlpha_F32xxx: return "kAlpha_F32xxx";
1327
976
  case GrColorType::kGray_8xxx: return "kGray_8xxx";
977
+ case GrColorType::kR_8xxx: return "kR_8xxx";
1328
978
  case GrColorType::kAlpha_16: return "kAlpha_16";
1329
979
  case GrColorType::kRG_1616: return "kRG_1616";
1330
980
  case GrColorType::kRGBA_16161616: return "kRGBA_16161616";
@@ -1349,6 +999,14 @@ static constexpr const char* GrCompressionTypeToStr(SkImage::CompressionType com
1349
999
  }
1350
1000
  SkUNREACHABLE;
1351
1001
  }
1002
+
1003
+ static constexpr const char* GrSurfaceOriginToStr(GrSurfaceOrigin origin) {
1004
+ switch (origin) {
1005
+ case kTopLeft_GrSurfaceOrigin: return "kTopLeft";
1006
+ case kBottomLeft_GrSurfaceOrigin: return "kBottomLeft";
1007
+ }
1008
+ SkUNREACHABLE;
1009
+ }
1352
1010
  #endif
1353
1011
 
1354
1012
  #endif