@shopify/react-native-skia 0.1.129 → 0.1.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,91 @@
1
+ /*
2
+ * Copyright 2021 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef skgpu_graphite_TextureInfo_DEFINED
9
+ #define skgpu_graphite_TextureInfo_DEFINED
10
+
11
+ #include "include/gpu/graphite/GraphiteTypes.h"
12
+
13
+ #ifdef SK_METAL
14
+ #include "include/private/gpu/graphite/MtlTypesPriv.h"
15
+ #endif
16
+
17
+ namespace skgpu::graphite {
18
+
19
+ // Forward declares so we can friend classes in other namespaces
20
+ #ifdef SK_METAL
21
+ namespace graphite {
22
+ class MtlCaps;
23
+ class MtlTexture;
24
+ }
25
+ #endif
26
+
27
+ class TextureInfo {
28
+ public:
29
+ TextureInfo() {}
30
+ #ifdef SK_METAL
31
+ TextureInfo(const MtlTextureInfo& mtlInfo)
32
+ : fBackend(BackendApi::kMetal)
33
+ , fValid(true)
34
+ , fSampleCount(mtlInfo.fSampleCount)
35
+ , fLevelCount(mtlInfo.fLevelCount)
36
+ , fProtected(Protected::kNo)
37
+ , fMtlSpec(mtlInfo) {}
38
+ #endif
39
+
40
+ ~TextureInfo() {}
41
+ TextureInfo(const TextureInfo&) = default;
42
+ TextureInfo& operator=(const TextureInfo&);
43
+
44
+ bool operator==(const TextureInfo&) const;
45
+ bool operator!=(const TextureInfo& that) const { return !(*this == that); }
46
+
47
+ bool isValid() const { return fValid; }
48
+ BackendApi backend() const { return fBackend; }
49
+
50
+ uint32_t numSamples() const { return fSampleCount; }
51
+ uint32_t numMipLevels() const { return fLevelCount; }
52
+ Protected isProtected() const { return fProtected; }
53
+
54
+ #ifdef SK_METAL
55
+ bool getMtlTextureInfo(MtlTextureInfo* info) const {
56
+ if (!this->isValid() || fBackend != BackendApi::kMetal) {
57
+ return false;
58
+ }
59
+ *info = MtlTextureSpecToTextureInfo(fMtlSpec, fSampleCount, fLevelCount);
60
+ return true;
61
+ }
62
+ #endif
63
+
64
+ private:
65
+ #ifdef SK_METAL
66
+ friend class MtlCaps;
67
+ friend class MtlGraphicsPipeline;
68
+ friend class MtlTexture;
69
+ const MtlTextureSpec& mtlTextureSpec() const {
70
+ SkASSERT(fValid && fBackend == BackendApi::kMetal);
71
+ return fMtlSpec;
72
+ }
73
+ #endif
74
+
75
+ BackendApi fBackend = BackendApi::kMock;
76
+ bool fValid = false;
77
+
78
+ uint32_t fSampleCount = 1;
79
+ uint32_t fLevelCount = 0;
80
+ Protected fProtected = Protected::kNo;
81
+
82
+ union {
83
+ #ifdef SK_METAL
84
+ MtlTextureSpec fMtlSpec;
85
+ #endif
86
+ };
87
+ };
88
+
89
+ } // namespace skgpu::graphite
90
+
91
+ #endif //skgpu_graphite_TextureInfo_DEFINED
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright 2021 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef skgpu_graphite_MtlBackendContext_DEFINED
9
+ #define skgpu_graphite_MtlBackendContext_DEFINED
10
+
11
+ #include "include/gpu/graphite/mtl/MtlTypes.h"
12
+
13
+ namespace skgpu::graphite {
14
+
15
+ // The MtlBackendContext contains all of the base Metal objects needed by the MtlGpu. The assumption
16
+ // is that the client will set these up and pass them to the MtlGpu constructor.
17
+ struct SK_API MtlBackendContext {
18
+ sk_cfp<CFTypeRef> fDevice;
19
+ sk_cfp<CFTypeRef> fQueue;
20
+ };
21
+
22
+ } // namespace skgpu::graphite
23
+
24
+ #endif // skgpu_graphite_MtlBackendContext_DEFINED
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Copyright 2021 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef skgpu_graphite_MtlTypes_DEFINED
9
+ #define skgpu_graphite_MtlTypes_DEFINED
10
+
11
+ #include "include/ports/SkCFObject.h"
12
+
13
+ ///////////////////////////////////////////////////////////////////////////////
14
+
15
+ #ifdef __APPLE__
16
+
17
+ #include <CoreFoundation/CoreFoundation.h>
18
+ #include <TargetConditionals.h>
19
+
20
+ #if TARGET_OS_SIMULATOR
21
+ #define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(13.0))
22
+ #else // TARGET_OS_SIMULATOR
23
+ #define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(8.0))
24
+ #endif // TARGET_OS_SIMULATOR
25
+
26
+ #endif // __APPLE__
27
+
28
+
29
+ namespace skgpu::graphite {
30
+
31
+ /**
32
+ * Declares typedefs for Metal types used in Graphite cpp code
33
+ */
34
+ using MtlPixelFormat = unsigned int;
35
+ using MtlTextureUsage = unsigned int;
36
+ using MtlStorageMode = unsigned int;
37
+ using MtlHandle = const void*;
38
+
39
+ struct MtlTextureInfo {
40
+ uint32_t fSampleCount = 1;
41
+ uint32_t fLevelCount = 0;
42
+
43
+ // Since we aren't in an Obj-C header we can't directly use Mtl types here. Each of these can
44
+ // cast to their mapped Mtl types list below.
45
+ MtlPixelFormat fFormat = 0; // MTLPixelFormat fFormat = MTLPixelFormatInvalid;
46
+ MtlTextureUsage fUsage = 0; // MTLTextureUsage fUsage = MTLTextureUsageUnknown;
47
+ MtlStorageMode fStorageMode = 0; // MTLStorageMode fStorageMode = MTLStorageModeShared;
48
+ bool fFramebufferOnly = false;
49
+
50
+ MtlTextureInfo() = default;
51
+ MtlTextureInfo(MtlHandle mtlTexture);
52
+ MtlTextureInfo(uint32_t sampleCount,
53
+ uint32_t levelCount,
54
+ MtlPixelFormat format,
55
+ MtlTextureUsage usage,
56
+ MtlStorageMode storageMode,
57
+ bool framebufferOnly)
58
+ : fSampleCount(sampleCount)
59
+ , fLevelCount(levelCount)
60
+ , fFormat(format)
61
+ , fUsage(usage)
62
+ , fStorageMode(storageMode)
63
+ , fFramebufferOnly(framebufferOnly) {}
64
+ };
65
+
66
+ } // namespace skgpu::graphite
67
+
68
+ #endif // skgpu_graphite_MtlTypes_DEFINED
@@ -9,7 +9,7 @@
9
9
  #define GrMockOptions_DEFINED
10
10
 
11
11
  #include "include/gpu/GrTypes.h"
12
- #include "include/private/GrTypesPriv.h"
12
+ #include "include/private/gpu/ganesh/GrTypesPriv.h"
13
13
 
14
14
  class GrBackendFormat;
15
15
 
@@ -125,7 +125,6 @@ struct GrMockOptions {
125
125
  int fMaxRenderTargetSize = 2048;
126
126
  int fMaxWindowRectangles = 0;
127
127
  int fMaxVertexAttributes = 16;
128
- int fMaxTessellationSegments = 0;
129
128
  ConfigOptions fConfigOptions[kGrColorTypeCnt];
130
129
  ConfigOptions fCompressedOptions[SkImage::kCompressionTypeCount];
131
130
 
@@ -176,9 +176,5 @@ template <typename T> sk_cfp<T> sk_ret_cfp(T obj) {
176
176
  return sk_cfp<T>(SkCFSafeRetain(obj));
177
177
  }
178
178
 
179
- // For Flutter.
180
- // TODO: migrate them away from this and remove
181
- template <typename T> using sk_cf_obj = sk_cfp<T>;
182
-
183
179
  #endif // __APPLE__
184
180
  #endif // SkCFObject_DEFINED
@@ -53,8 +53,8 @@ struct IDWriteFontCollection;
53
53
  struct IDWriteFontFallback;
54
54
 
55
55
  SK_API sk_sp<SkFontMgr> SkFontMgr_New_GDI();
56
- SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory = NULL,
57
- IDWriteFontCollection* collection = NULL);
56
+ SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory = nullptr,
57
+ IDWriteFontCollection* collection = nullptr);
58
58
  SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
59
59
  IDWriteFontCollection* collection,
60
60
  IDWriteFontFallback* fallback);
@@ -5,25 +5,30 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef GrSingleOwner_DEFINED
9
- #define GrSingleOwner_DEFINED
8
+ #ifndef skgpu_SingleOwner_DEFINED
9
+ #define skgpu_SingleOwner_DEFINED
10
10
 
11
11
  #include "include/core/SkTypes.h"
12
12
 
13
13
  #ifdef SK_DEBUG
14
14
  #include "include/private/SkMutex.h"
15
15
  #include "include/private/SkThreadID.h"
16
+ #endif
17
+
18
+ namespace skgpu {
16
19
 
17
- #define GR_ASSERT_SINGLE_OWNER(obj) \
18
- GrSingleOwner::AutoEnforce debug_SingleOwner(obj, __FILE__, __LINE__);
20
+ #ifdef SK_DEBUG
21
+
22
+ #define SKGPU_ASSERT_SINGLE_OWNER(obj) \
23
+ skgpu::SingleOwner::AutoEnforce debug_SingleOwner(obj, __FILE__, __LINE__);
19
24
 
20
25
  // This is a debug tool to verify an object is only being used from one thread at a time.
21
- class GrSingleOwner {
26
+ class SingleOwner {
22
27
  public:
23
- GrSingleOwner() : fOwner(kIllegalThreadID), fReentranceCount(0) {}
28
+ SingleOwner() : fOwner(kIllegalThreadID), fReentranceCount(0) {}
24
29
 
25
30
  struct AutoEnforce {
26
- AutoEnforce(GrSingleOwner* so, const char* file, int line)
31
+ AutoEnforce(SingleOwner* so, const char* file, int line)
27
32
  : fFile(file), fLine(line), fSO(so) {
28
33
  fSO->enter(file, line);
29
34
  }
@@ -31,7 +36,7 @@ public:
31
36
 
32
37
  const char* fFile;
33
38
  int fLine;
34
- GrSingleOwner* fSO;
39
+ SingleOwner* fSO;
35
40
  };
36
41
 
37
42
  private:
@@ -58,8 +63,10 @@ private:
58
63
  int fReentranceCount SK_GUARDED_BY(fMutex);
59
64
  };
60
65
  #else
61
- #define GR_ASSERT_SINGLE_OWNER(obj)
62
- class GrSingleOwner {}; // Provide a no-op implementation so we can pass pointers to constructors
66
+ #define SKGPU_ASSERT_SINGLE_OWNER(obj)
67
+ class SingleOwner {}; // Provide a no-op implementation so we can pass pointers to constructors
63
68
  #endif
64
69
 
70
+ } // namespace skgpu
71
+
65
72
  #endif
@@ -14,6 +14,9 @@
14
14
  #include "include/private/SkOpts_spi.h"
15
15
  #include "include/private/SkTLogic.h"
16
16
 
17
+ #include <string>
18
+ #include <string_view>
19
+
17
20
  class SkChecksum : SkNoncopyable {
18
21
  public:
19
22
  /**
@@ -61,6 +64,14 @@ struct SkGoodHash {
61
64
  uint32_t operator()(const SkString& k) const {
62
65
  return SkOpts::hash_fn(k.c_str(), k.size(), 0);
63
66
  }
67
+
68
+ uint32_t operator()(const std::string& k) const {
69
+ return SkOpts::hash_fn(k.c_str(), k.size(), 0);
70
+ }
71
+
72
+ uint32_t operator()(std::string_view k) const {
73
+ return SkOpts::hash_fn(k.data(), k.size(), 0);
74
+ }
64
75
  };
65
76
 
66
77
  #endif
@@ -10,6 +10,7 @@
10
10
 
11
11
  #include <memory>
12
12
 
13
+ #include "include/core/SkColorSpace.h"
13
14
  #include "include/core/SkData.h"
14
15
  #include "include/core/SkImageInfo.h"
15
16
  #include "include/third_party/skcms/skcms.h"
@@ -100,8 +101,15 @@ public:
100
101
  return Make(width, height, color, alpha, bitsPerComponent, nullptr);
101
102
  }
102
103
 
103
- static SkEncodedInfo Make(int width, int height, Color color, Alpha alpha,
104
- int bitsPerComponent, std::unique_ptr<ICCProfile> profile) {
104
+ static SkEncodedInfo Make(int width, int height, Color color,
105
+ Alpha alpha, int bitsPerComponent, std::unique_ptr<ICCProfile> profile) {
106
+ return Make(width, height, color, alpha, /*bitsPerComponent*/ bitsPerComponent,
107
+ std::move(profile), /*colorDepth*/ bitsPerComponent);
108
+ }
109
+
110
+ static SkEncodedInfo Make(int width, int height, Color color,
111
+ Alpha alpha, int bitsPerComponent, std::unique_ptr<ICCProfile> profile,
112
+ int colorDepth) {
105
113
  SkASSERT(1 == bitsPerComponent ||
106
114
  2 == bitsPerComponent ||
107
115
  4 == bitsPerComponent ||
@@ -150,7 +158,8 @@ public:
150
158
  break;
151
159
  }
152
160
 
153
- return SkEncodedInfo(width, height, color, alpha, bitsPerComponent, std::move(profile));
161
+ return SkEncodedInfo(width, height, color, alpha,
162
+ bitsPerComponent, colorDepth, std::move(profile));
154
163
  }
155
164
 
156
165
  /*
@@ -220,21 +229,28 @@ public:
220
229
 
221
230
  // Explicit copy method, to avoid accidental copying.
222
231
  SkEncodedInfo copy() const {
223
- auto copy = SkEncodedInfo::Make(fWidth, fHeight, fColor, fAlpha, fBitsPerComponent);
232
+ auto copy = SkEncodedInfo::Make(
233
+ fWidth, fHeight, fColor, fAlpha, fBitsPerComponent, nullptr, fColorDepth);
224
234
  if (fProfile) {
225
235
  copy.fProfile = std::make_unique<ICCProfile>(*fProfile);
226
236
  }
227
237
  return copy;
228
238
  }
229
239
 
240
+ // Return number of bits of R/G/B channel
241
+ uint8_t getColorDepth() const {
242
+ return fColorDepth;
243
+ }
244
+
230
245
  private:
231
246
  SkEncodedInfo(int width, int height, Color color, Alpha alpha,
232
- uint8_t bitsPerComponent, std::unique_ptr<ICCProfile> profile)
247
+ uint8_t bitsPerComponent, uint8_t colorDepth, std::unique_ptr<ICCProfile> profile)
233
248
  : fWidth(width)
234
249
  , fHeight(height)
235
250
  , fColor(color)
236
251
  , fAlpha(alpha)
237
252
  , fBitsPerComponent(bitsPerComponent)
253
+ , fColorDepth(colorDepth)
238
254
  , fProfile(std::move(profile))
239
255
  {}
240
256
 
@@ -243,6 +259,7 @@ private:
243
259
  Color fColor;
244
260
  Alpha fAlpha;
245
261
  uint8_t fBitsPerComponent;
262
+ uint8_t fColorDepth;
246
263
  std::unique_ptr<ICCProfile> fProfile;
247
264
  };
248
265
 
@@ -17,15 +17,6 @@
17
17
  #include <cstring>
18
18
  #include <limits>
19
19
 
20
-
21
- #if defined(SK_LEGACY_FLOAT_RSQRT)
22
- #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1
23
- #include <xmmintrin.h>
24
- #elif defined(SK_ARM_HAS_NEON)
25
- #include <arm_neon.h>
26
- #endif
27
- #endif
28
-
29
20
  constexpr float SK_FloatSqrt2 = 1.41421356f;
30
21
  constexpr float SK_FloatPI = 3.14159265f;
31
22
  constexpr double SK_DoublePI = 3.14159265358979323846264338327950288;
@@ -171,53 +162,9 @@ static inline float sk_double_to_float(double x) {
171
162
  // Returns true if count is 0
172
163
  bool sk_floats_are_unit(const float array[], size_t count);
173
164
 
174
- #if defined(SK_LEGACY_FLOAT_RSQRT)
175
- static inline float sk_float_rsqrt_portable(float x) {
176
- // Get initial estimate.
177
- int i;
178
- memcpy(&i, &x, 4);
179
- i = 0x5F1FFFF9 - (i>>1);
180
- float estimate;
181
- memcpy(&estimate, &i, 4);
182
-
183
- // One step of Newton's method to refine.
184
- const float estimate_sq = estimate*estimate;
185
- estimate *= 0.703952253f*(2.38924456f-x*estimate_sq);
186
- return estimate;
187
- }
188
-
189
- // Fast, approximate inverse square root.
190
- // Compare to name-brand "1.0f / sk_float_sqrt(x)". Should be around 10x faster on SSE, 2x on NEON.
191
- static inline float sk_float_rsqrt(float x) {
192
- // We want all this inlined, so we'll inline SIMD and just take the hit when we don't know we've got
193
- // it at compile time. This is going to be too fast to productively hide behind a function pointer.
194
- //
195
- // We do one step of Newton's method to refine the estimates in the NEON and portable paths. No
196
- // refinement is faster, but very innacurate. Two steps is more accurate, but slower than 1/sqrt.
197
- //
198
- // Optimized constants in the portable path courtesy of http://rrrola.wz.cz/inv_sqrt.html
199
- #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1
200
- return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x)));
201
- #elif defined(SK_ARM_HAS_NEON)
202
- // Get initial estimate.
203
- const float32x2_t xx = vdup_n_f32(x); // Clever readers will note we're doing everything 2x.
204
- float32x2_t estimate = vrsqrte_f32(xx);
205
-
206
- // One step of Newton's method to refine.
207
- const float32x2_t estimate_sq = vmul_f32(estimate, estimate);
208
- estimate = vmul_f32(estimate, vrsqrts_f32(xx, estimate_sq));
209
- return vget_lane_f32(estimate, 0); // 1 will work fine too; the answer's in both places.
210
- #else
211
- return sk_float_rsqrt_portable(x);
212
- #endif
213
- }
214
- #else
215
-
216
165
  static inline float sk_float_rsqrt_portable(float x) { return 1.0f / sk_float_sqrt(x); }
217
166
  static inline float sk_float_rsqrt (float x) { return 1.0f / sk_float_sqrt(x); }
218
167
 
219
- #endif
220
-
221
168
  // Returns the log2 of the provided value, were that value to be rounded up to the next power of 2.
222
169
  // Returns 0 if value <= 0:
223
170
  // Never returns a negative number, even if value is NaN.
@@ -35,6 +35,7 @@ static inline uint32_t SkColorTypeChannelFlags(SkColorType ct) {
35
35
  case kR16G16_float_SkColorType: return kRG_SkColorChannelFlags;
36
36
  case kR16G16B16A16_unorm_SkColorType: return kRGBA_SkColorChannelFlags;
37
37
  case kSRGBA_8888_SkColorType: return kRGBA_SkColorChannelFlags;
38
+ case kR8_unorm_SkColorType: return kRed_SkColorChannelFlag;
38
39
  }
39
40
  SkUNREACHABLE;
40
41
  }
@@ -71,6 +72,7 @@ static int SkColorTypeShiftPerPixel(SkColorType ct) {
71
72
  case kR16G16_float_SkColorType: return 2;
72
73
  case kR16G16B16A16_unorm_SkColorType: return 3;
73
74
  case kSRGBA_8888_SkColorType: return 2;
75
+ case kR8_unorm_SkColorType: return 0;
74
76
  }
75
77
  SkUNREACHABLE;
76
78
  }
@@ -110,11 +112,14 @@ static inline bool SkColorTypeIsNormalized(SkColorType ct) {
110
112
  case kA16_float_SkColorType: /*subtle... alpha is always [0,1]*/
111
113
  case kR16G16_unorm_SkColorType:
112
114
  case kR16G16B16A16_unorm_SkColorType:
113
- case kSRGBA_8888_SkColorType: return true;
115
+ case kSRGBA_8888_SkColorType:
116
+ case kR8_unorm_SkColorType:
117
+ return true;
114
118
 
115
119
  case kRGBA_F16_SkColorType:
116
120
  case kRGBA_F32_SkColorType:
117
- case kR16G16_float_SkColorType: return false;
121
+ case kR16G16_float_SkColorType:
122
+ return false;
118
123
  }
119
124
  SkUNREACHABLE;
120
125
  }
@@ -137,6 +142,7 @@ static inline int SkColorTypeMaxBitsPerChannel(SkColorType ct) {
137
142
  case kGray_8_SkColorType:
138
143
  case kR8G8_unorm_SkColorType:
139
144
  case kSRGBA_8888_SkColorType:
145
+ case kR8_unorm_SkColorType:
140
146
  return 8;
141
147
 
142
148
  case kRGBA_1010102_SkColorType:
@@ -7,6 +7,8 @@
7
7
  #ifndef SkMacros_DEFINED
8
8
  #define SkMacros_DEFINED
9
9
 
10
+ #include <type_traits>
11
+
10
12
  /*
11
13
  * Usage: SK_MACRO_CONCAT(a, b) to construct the symbol ab
12
14
  *
@@ -47,38 +49,31 @@
47
49
  * bitfield.
48
50
  */
49
51
  #define SK_MAKE_BITFIELD_OPS(X) \
52
+ inline X operator ~(X a) { \
53
+ using U = std::underlying_type_t<X>; \
54
+ return (X) (~static_cast<U>(a)); \
55
+ } \
50
56
  inline X operator |(X a, X b) { \
51
- return (X) (+a | +b); \
57
+ using U = std::underlying_type_t<X>; \
58
+ return (X) (static_cast<U>(a) | static_cast<U>(b)); \
52
59
  } \
53
60
  inline X& operator |=(X& a, X b) { \
54
61
  return (a = a | b); \
55
62
  } \
56
63
  inline X operator &(X a, X b) { \
57
- return (X) (+a & +b); \
64
+ using U = std::underlying_type_t<X>; \
65
+ return (X) (static_cast<U>(a) & static_cast<U>(b)); \
58
66
  } \
59
67
  inline X& operator &=(X& a, X b) { \
60
68
  return (a = a & b); \
61
- } \
62
- template <typename T> \
63
- inline X operator &(T a, X b) { \
64
- return (X) (+a & +b); \
65
- } \
66
- template <typename T> \
67
- inline X operator &(X a, T b) { \
68
- return (X) (+a & +b); \
69
- } \
69
+ }
70
70
 
71
71
  #define SK_DECL_BITFIELD_OPS_FRIENDS(X) \
72
+ friend X operator ~(X a); \
72
73
  friend X operator |(X a, X b); \
73
74
  friend X& operator |=(X& a, X b); \
74
75
  \
75
76
  friend X operator &(X a, X b); \
76
- friend X& operator &=(X& a, X b); \
77
- \
78
- template <typename T> \
79
- friend X operator &(T a, X b); \
80
- \
81
- template <typename T> \
82
- friend X operator &(X a, T b); \
77
+ friend X& operator &=(X& a, X b);
83
78
 
84
79
  #endif // SkMacros_DEFINED
@@ -18,6 +18,10 @@ class SK_CAPABILITY("mutex") SkMutex {
18
18
  public:
19
19
  constexpr SkMutex() = default;
20
20
 
21
+ ~SkMutex() {
22
+ this->assertNotHeld();
23
+ }
24
+
21
25
  void acquire() SK_ACQUIRE() {
22
26
  fSemaphore.wait();
23
27
  SkDEBUGCODE(fOwner = SkGetThreadID();)
@@ -33,6 +37,10 @@ public:
33
37
  SkASSERT(fOwner == SkGetThreadID());
34
38
  }
35
39
 
40
+ void assertNotHeld() {
41
+ SkASSERT(fOwner == kIllegalThreadID);
42
+ }
43
+
36
44
  private:
37
45
  SkSemaphore fSemaphore{1};
38
46
  SkDEBUGCODE(SkThreadID fOwner{kIllegalThreadID};)
@@ -10,7 +10,6 @@
10
10
 
11
11
  #include "include/core/SkMatrix.h"
12
12
  #include "include/core/SkPoint.h"
13
- #include "include/core/SkRRect.h"
14
13
  #include "include/core/SkRect.h"
15
14
  #include "include/core/SkRefCnt.h"
16
15
  #include "include/private/SkIDChangeListener.h"
@@ -25,6 +24,7 @@
25
24
 
26
25
  class SkRBuffer;
27
26
  class SkWBuffer;
27
+ class SkRRect;
28
28
 
29
29
  enum class SkPathConvexity {
30
30
  kConvex,
@@ -246,21 +246,7 @@ public:
246
246
  return SkToBool(fIsOval);
247
247
  }
248
248
 
249
- bool isRRect(SkRRect* rrect, bool* isCCW, unsigned* start) const {
250
- if (fIsRRect) {
251
- if (rrect) {
252
- *rrect = this->getRRect();
253
- }
254
- if (isCCW) {
255
- *isCCW = SkToBool(fRRectOrOvalIsCCW);
256
- }
257
- if (start) {
258
- *start = fRRectOrOvalStartIdx;
259
- }
260
- }
261
- return SkToBool(fIsRRect);
262
- }
263
-
249
+ bool isRRect(SkRRect* rrect, bool* isCCW, unsigned* start) const;
264
250
 
265
251
  bool hasComputedBounds() const {
266
252
  return !fBoundsIsDirty;
@@ -22,7 +22,15 @@ class Expression;
22
22
  class Statement;
23
23
 
24
24
  using ComponentArray = SkSTArray<4, int8_t>; // for Swizzles
25
- using ExpressionArray = SkSTArray<2, std::unique_ptr<Expression>>;
25
+
26
+ class ExpressionArray : public SkSTArray<2, std::unique_ptr<Expression>> {
27
+ public:
28
+ using SkSTArray::SkSTArray;
29
+
30
+ /** Returns a new ExpressionArray containing a clone of every element. */
31
+ ExpressionArray clone() const;
32
+ };
33
+
26
34
  using StatementArray = SkSTArray<2, std::unique_ptr<Statement>>;
27
35
 
28
36
  // Functions larger than this (measured in IR nodes) will not be inlined. This growth factor
@@ -10,6 +10,7 @@
10
10
 
11
11
  #include "include/private/SkSLString.h"
12
12
  #include "include/private/SkTArray.h"
13
+ #include "include/sksl/SkSLPosition.h"
13
14
  #include "src/sksl/SkSLLexer.h"
14
15
  #include "src/sksl/SkSLModifiersPool.h"
15
16
  #include "src/sksl/SkSLPool.h"
@@ -41,18 +42,18 @@ class IRNode : public Poolable {
41
42
  public:
42
43
  virtual ~IRNode() {}
43
44
 
44
- virtual String description() const = 0;
45
+ virtual std::string description() const = 0;
45
46
 
46
47
  // No copy construction or assignment
47
48
  IRNode(const IRNode&) = delete;
48
49
  IRNode& operator=(const IRNode&) = delete;
49
50
 
50
- // line of this element within the program being compiled, for error reporting purposes
51
- int fLine;
51
+ // position of this element within the program being compiled, for error reporting purposes
52
+ Position fPosition;
52
53
 
53
54
  protected:
54
- IRNode(int line, int kind)
55
- : fLine(line)
55
+ IRNode(Position position, int kind)
56
+ : fPosition(position)
56
57
  , fKind(kind) {}
57
58
 
58
59
  int fKind;