@shopify/react-native-skia 2.6.0 → 2.6.1
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.
- package/android/CMakeLists.txt +0 -1
- package/android/cpp/jni/JniWebGPUView.cpp +3 -3
- package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
- package/apple/MetalContext.h +5 -6
- package/apple/MetalWindowContext.mm +3 -4
- package/apple/RNSkApplePlatformContext.h +1 -1
- package/apple/RNSkApplePlatformContext.mm +4 -3
- package/apple/SkiaCVPixelBufferUtils.h +1 -1
- package/apple/SkiaCVPixelBufferUtils.mm +31 -30
- package/apple/SkiaPlatformContext.mm +2 -2
- package/apple/SkiaUIView.mm +1 -1
- package/apple/SkiaWebGPUView.mm +8 -4
- package/apple/WebGPUMetalView.h +1 -1
- package/apple/WebGPUMetalView.mm +1 -1
- package/cpp/api/JsiSkColor.h +8 -4
- package/cpp/api/JsiSkContourMeasure.h +4 -3
- package/cpp/api/JsiSkImage.h +17 -9
- package/cpp/api/JsiSkParagraphBuilder.h +14 -1
- package/cpp/api/JsiSkPath.h +71 -81
- package/cpp/api/JsiSkPathEffectFactory.h +2 -1
- package/cpp/api/JsiSkPathFactory.h +48 -52
- package/cpp/api/JsiSkShader.h +1 -1
- package/cpp/api/JsiSkShaderFactory.h +50 -26
- package/cpp/api/JsiSkSurfaceFactory.h +2 -1
- package/cpp/api/recorder/Drawings.h +5 -7
- package/cpp/api/recorder/Shaders.h +77 -22
- package/cpp/jsi2/JSIConverter.h +1 -1
- package/cpp/rnskia/RNDawnContext.h +14 -15
- package/cpp/rnskia/RNDawnUtils.h +14 -17
- package/cpp/rnskia/RNDawnWindowContext.h +1 -1
- package/cpp/rnskia/RNSkManager.cpp +5 -4
- package/cpp/rnskia/RNSkPlatformContext.h +2 -2
- package/cpp/rnwgpu/api/GPU.cpp +21 -0
- package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
- package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
- package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
- package/cpp/rnwgpu/api/GPUTexture.h +14 -2
- package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
- package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
- package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
- package/cpp/skia/include/android/SkImageAndroid.h +7 -2
- package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
- package/cpp/skia/include/codec/SkCodec.h +42 -15
- package/cpp/skia/include/config/SkUserConfig.h +8 -0
- package/cpp/skia/include/core/SkBitmap.h +0 -5
- package/cpp/skia/include/core/SkCanvas.h +2 -39
- package/cpp/skia/include/core/SkColor.h +12 -0
- package/cpp/skia/include/core/SkColorSpace.h +9 -0
- package/cpp/skia/include/core/SkContourMeasure.h +1 -5
- package/cpp/skia/include/core/SkData.h +8 -0
- package/cpp/skia/include/core/SkFont.h +1 -55
- package/cpp/skia/include/core/SkFontArguments.h +15 -0
- package/cpp/skia/include/core/SkGraphics.h +0 -5
- package/cpp/skia/include/core/SkImage.h +0 -4
- package/cpp/skia/include/core/SkImageGenerator.h +1 -4
- package/cpp/skia/include/core/SkMatrix.h +0 -37
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPath.h +11 -911
- package/cpp/skia/include/core/SkPathBuilder.h +42 -32
- package/cpp/skia/include/core/SkPathEffect.h +0 -9
- package/cpp/skia/include/core/SkPathMeasure.h +1 -4
- package/cpp/skia/include/core/SkPathUtils.h +0 -10
- package/cpp/skia/include/core/SkRect.h +0 -12
- package/cpp/skia/include/core/SkRegion.h +1 -6
- package/cpp/skia/include/core/SkSerialProcs.h +4 -5
- package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
- package/cpp/skia/include/core/SkTextBlob.h +0 -22
- package/cpp/skia/include/core/SkTypeface.h +14 -32
- package/cpp/skia/include/core/SkTypes.h +0 -8
- package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
- package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
- package/cpp/skia/include/effects/SkGradient.h +206 -0
- package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
- package/cpp/skia/include/gpu/GpuTypes.h +2 -0
- package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
- package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
- package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
- package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
- package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
- package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
- package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
- package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
- package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
- package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
- package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
- package/cpp/skia/include/private/SkPathRef.h +0 -457
- package/cpp/skia/include/private/base/SkFeatures.h +4 -0
- package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
- package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
- package/cpp/skia/include/private/base/SkLog.h +68 -0
- package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
- package/cpp/skia/include/private/base/SkMacros.h +9 -0
- package/cpp/skia/include/private/base/SkTArray.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
- package/cpp/skia/include/utils/SkEventTracer.h +5 -7
- package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
- package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
- package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
- package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
- package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
- package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
- package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
- package/cpp/skia/src/base/SkMathPriv.h +27 -132
- package/package.json +5 -5
- package/cpp/skia/include/effects/SkGradientShader.h +0 -359
- package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
// Include this to set reasonable defaults (e.g. for SK_CPU_LENDIAN)
|
|
11
11
|
#include "include/private/base/SkFeatures.h"
|
|
12
|
+
// Include this so that users can define the lowest active log priority in their config
|
|
13
|
+
#include "include/private/base/SkLogPriority.h" // IWYU pragma: keep
|
|
12
14
|
|
|
13
15
|
// Allows embedders that want to disable macros that take arguments to just
|
|
14
16
|
// define that symbol to be one of these
|
|
@@ -17,7 +19,6 @@
|
|
|
17
19
|
#define SK_NOTHING_ARG3(arg1, arg2, arg3)
|
|
18
20
|
|
|
19
21
|
// IWYU pragma: begin_exports
|
|
20
|
-
|
|
21
22
|
// Note: SK_USER_CONFIG_HEADER will not work with Bazel builds and some C++ compilers.
|
|
22
23
|
#if defined(SK_USER_CONFIG_HEADER)
|
|
23
24
|
#include SK_USER_CONFIG_HEADER
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 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 SkLog_DEFINED
|
|
9
|
+
#define SkLog_DEFINED
|
|
10
|
+
|
|
11
|
+
#include <cstdarg>
|
|
12
|
+
|
|
13
|
+
#include "include/private/base/SkAPI.h"
|
|
14
|
+
#include "include/private/base/SkAttributes.h"
|
|
15
|
+
#include "include/private/base/SkLoadUserConfig.h" // IWYU pragma: keep
|
|
16
|
+
#include "include/private/base/SkLogPriority.h"
|
|
17
|
+
|
|
18
|
+
#if !defined(SkLog)
|
|
19
|
+
// To be implemented per platform.
|
|
20
|
+
void SkLogVAList(SkLogPriority priority, const char format[], va_list args) SK_PRINTF_LIKE(2, 0);
|
|
21
|
+
void SK_SPI SkLog(SkLogPriority priority, const char format[], ...) SK_PRINTF_LIKE(2, 3);
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* TODO (b/469441457): SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY Was the config used to set the log
|
|
26
|
+
* priority, so we check for that define as well. Eventually, we should move clients using this
|
|
27
|
+
* define to the new one.
|
|
28
|
+
*/
|
|
29
|
+
#if defined(SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY)
|
|
30
|
+
static constexpr SkLogPriority MapGraphitePriority(skgpu::graphite::LogPriority priority) {
|
|
31
|
+
switch (priority) {
|
|
32
|
+
case skgpu::graphite::LogPriority::kError: return SkLogPriority::kError;
|
|
33
|
+
case skgpu::graphite::LogPriority::kWarning: return SkLogPriority::kWarning;
|
|
34
|
+
case skgpu::graphite::LogPriority::kInfo: return SkLogPriority::kInfo;
|
|
35
|
+
case skgpu::graphite::LogPriority::kDebug: return SkLogPriority::kDebug;
|
|
36
|
+
default: return SkLogPriority::kDebug;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
#define SKIA_LOWEST_ACTIVE_LOG_PRIORITY MapGraphitePriority(SKGPU_GRAPHITE_LOWEST_ACTIVE_LOG_PRIORITY)
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
#if !defined(SKIA_LOWEST_ACTIVE_LOG_PRIORITY)
|
|
43
|
+
#ifdef SK_DEBUG
|
|
44
|
+
#define SKIA_LOWEST_ACTIVE_LOG_PRIORITY SkLogPriority::kDebug
|
|
45
|
+
#else
|
|
46
|
+
#define SKIA_LOWEST_ACTIVE_LOG_PRIORITY SkLogPriority::kInfo
|
|
47
|
+
#endif
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
#define SKIA_LOG(priority, fmt, ...) \
|
|
51
|
+
do { \
|
|
52
|
+
if constexpr (priority <= SKIA_LOWEST_ACTIVE_LOG_PRIORITY) { \
|
|
53
|
+
if constexpr (priority == SkLogPriority::kFatal) { \
|
|
54
|
+
SK_ABORT("[skia] " fmt, ##__VA_ARGS__); \
|
|
55
|
+
} \
|
|
56
|
+
else { \
|
|
57
|
+
SkLog(priority, "[skia] " fmt "\n", ##__VA_ARGS__); \
|
|
58
|
+
} \
|
|
59
|
+
} \
|
|
60
|
+
} while (0)
|
|
61
|
+
|
|
62
|
+
#define SKIA_LOG_F(fmt, ...) SKIA_LOG(SkLogPriority::kFatal, "** ERROR ** " fmt, ##__VA_ARGS__)
|
|
63
|
+
#define SKIA_LOG_E(fmt, ...) SKIA_LOG(SkLogPriority::kError, "** ERROR ** " fmt, ##__VA_ARGS__)
|
|
64
|
+
#define SKIA_LOG_W(fmt, ...) SKIA_LOG(SkLogPriority::kWarning, "WARNING - " fmt, ##__VA_ARGS__)
|
|
65
|
+
#define SKIA_LOG_I(fmt, ...) SKIA_LOG(SkLogPriority::kInfo, fmt, ##__VA_ARGS__)
|
|
66
|
+
#define SKIA_LOG_D(fmt, ...) SKIA_LOG(SkLogPriority::kDebug, fmt, ##__VA_ARGS__)
|
|
67
|
+
|
|
68
|
+
#endif // SkLog_DEFINED
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 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 SkLogPriority_DEFINED
|
|
9
|
+
#define SkLogPriority_DEFINED
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Note: this file may be included in clients' SkUserConfig.h files, so including any other headers
|
|
13
|
+
* in this file should be avoided.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* SKIA_LOWEST_ACTIVE_LOG_PRIORITY can be defined to one of these values (in
|
|
18
|
+
* SkUserConfig.h) to control Skia's logging behavior.
|
|
19
|
+
*
|
|
20
|
+
* For example:
|
|
21
|
+
* ```
|
|
22
|
+
* #define SKIA_LOWEST_ACTIVE_LOG_PRIORITY SkLogPriority::kWarning
|
|
23
|
+
* ```
|
|
24
|
+
* Would cause Skia to log warnings, non-fatal errors, and fatal errors.
|
|
25
|
+
* However, debug logs would be omitted.
|
|
26
|
+
*/
|
|
27
|
+
enum class SkLogPriority : int {
|
|
28
|
+
kFatal = 0,
|
|
29
|
+
kError = 1,
|
|
30
|
+
kWarning = 2,
|
|
31
|
+
kInfo = 3,
|
|
32
|
+
kDebug = 4,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
#endif // SkLogPriority_DEFINED
|
|
@@ -28,6 +28,15 @@
|
|
|
28
28
|
|
|
29
29
|
#define SK_MACRO_APPEND_COUNTER(name) SK_MACRO_CONCAT(name, __COUNTER__)
|
|
30
30
|
|
|
31
|
+
/*
|
|
32
|
+
* Makes a string of X, where X is expanded before conversion to a string if X itself contains
|
|
33
|
+
* macros.
|
|
34
|
+
*
|
|
35
|
+
* Usage: SK_MACRO_STRINGIFY(__LINE__) to make "123", where 123 is the current line number.
|
|
36
|
+
*/
|
|
37
|
+
#define SK_MACRO_STRINGIFY(X) SK_MACRO_STRINGIFY_IMPL_PRIV(X)
|
|
38
|
+
#define SK_MACRO_STRINGIFY_IMPL_PRIV(X) #X
|
|
39
|
+
|
|
31
40
|
////////////////////////////////////////////////////////////////////////////////
|
|
32
41
|
|
|
33
42
|
// Can be used to bracket data types that must be dense/packed, e.g. hash keys.
|
|
@@ -595,7 +595,7 @@ private:
|
|
|
595
595
|
|
|
596
596
|
void poison() {
|
|
597
597
|
#ifdef SK_SANITIZE_ADDRESS
|
|
598
|
-
if (fData && fCapacity > fSize) {
|
|
598
|
+
if (fData && fCapacity > SkToUInt(fSize)) {
|
|
599
599
|
// SkDebugf(" POISONING %p : %zu -> %zu\n", fData, Bytes(fSize), Bytes(fCapacity));
|
|
600
600
|
sk_asan_poison_memory_region(this->end(), Bytes(fCapacity - fSize));
|
|
601
601
|
fPoisoned = true;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#include "include/core/SkRefCnt.h"
|
|
14
14
|
|
|
15
15
|
#include <dxgiformat.h>
|
|
16
|
+
#include <memory>
|
|
16
17
|
|
|
17
18
|
#include "include/gpu/ganesh/GrTypes.h"
|
|
18
19
|
|
|
@@ -31,19 +32,18 @@ struct GrD3DFenceInfo;
|
|
|
31
32
|
// track the current D3D12_RESOURCE_STATES which can be shared with an internal GrD3DTextureResource
|
|
32
33
|
// so that state updates can be seen by all users of the texture.
|
|
33
34
|
struct GrD3DBackendSurfaceInfo {
|
|
34
|
-
GrD3DBackendSurfaceInfo(const GrD3DTextureResourceInfo& info, GrD3DResourceState
|
|
35
|
+
GrD3DBackendSurfaceInfo(const GrD3DTextureResourceInfo& info, sk_sp<GrD3DResourceState> state);
|
|
36
|
+
~GrD3DBackendSurfaceInfo();
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
GrD3DBackendSurfaceInfo(const GrD3DBackendSurfaceInfo&);
|
|
39
|
+
GrD3DBackendSurfaceInfo& operator=(const GrD3DBackendSurfaceInfo&);
|
|
37
40
|
|
|
38
|
-
GrD3DBackendSurfaceInfo
|
|
39
|
-
|
|
40
|
-
// Assigns the passed in GrD3DBackendSurfaceInfo to this object. if isValid is true we will also
|
|
41
|
-
// attempt to unref the old fLayout on this object.
|
|
42
|
-
void assign(const GrD3DBackendSurfaceInfo&, bool isValid);
|
|
41
|
+
GrD3DBackendSurfaceInfo(GrD3DBackendSurfaceInfo&&);
|
|
42
|
+
GrD3DBackendSurfaceInfo& operator=(GrD3DBackendSurfaceInfo&&);
|
|
43
43
|
|
|
44
44
|
void setResourceState(GrD3DResourceStateEnum state);
|
|
45
45
|
|
|
46
|
-
sk_sp<GrD3DResourceState>
|
|
46
|
+
sk_sp<GrD3DResourceState> getResourceState() const;
|
|
47
47
|
|
|
48
48
|
GrD3DTextureResourceInfo snapTextureResourceInfo() const;
|
|
49
49
|
|
|
@@ -53,22 +53,8 @@ struct GrD3DBackendSurfaceInfo {
|
|
|
53
53
|
#endif
|
|
54
54
|
|
|
55
55
|
private:
|
|
56
|
-
GrD3DTextureResourceInfo
|
|
57
|
-
GrD3DResourceState
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
struct GrD3DTextureResourceSpecHolder {
|
|
61
|
-
public:
|
|
62
|
-
GrD3DTextureResourceSpecHolder(const GrD3DSurfaceInfo&);
|
|
63
|
-
|
|
64
|
-
void cleanup();
|
|
65
|
-
|
|
66
|
-
GrD3DSurfaceInfo getSurfaceInfo(uint32_t sampleCount,
|
|
67
|
-
uint32_t levelCount,
|
|
68
|
-
skgpu::Protected isProtected) const;
|
|
69
|
-
|
|
70
|
-
private:
|
|
71
|
-
GrD3DTextureResourceSpec* fSpec;
|
|
56
|
+
std::unique_ptr<GrD3DTextureResourceInfo> fTextureResourceInfo;
|
|
57
|
+
sk_sp<GrD3DResourceState> fResourceState;
|
|
72
58
|
};
|
|
73
59
|
|
|
74
60
|
#endif
|
|
@@ -28,15 +28,13 @@ public:
|
|
|
28
28
|
/**
|
|
29
29
|
* If this is the first call to SetInstance or GetInstance then the passed instance is
|
|
30
30
|
* installed and true is returned. Otherwise, false is returned. In either case ownership of the
|
|
31
|
-
* tracer is transferred
|
|
31
|
+
* tracer is transferred.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @param leakTracer Do not delete tracer on process exit.
|
|
33
|
+
* On failure, the tracer is deleted; on success the tracer will be held until process exit, and
|
|
34
|
+
* will not have its destructor run. This avoids race conditions when using Skia from multiple
|
|
35
|
+
* threads in the midst of application teardown.
|
|
38
36
|
*/
|
|
39
|
-
static bool SetInstance(SkEventTracer
|
|
37
|
+
static bool SetInstance(SkEventTracer*);
|
|
40
38
|
|
|
41
39
|
/**
|
|
42
40
|
* Gets the event tracer. If this is the first call to SetInstance or GetIntance then a default
|
|
@@ -185,13 +185,6 @@ public:
|
|
|
185
185
|
static Result Shape(const SkString& text, const TextDesc& desc, const SkRect& box,
|
|
186
186
|
const sk_sp<SkFontMgr>&, const sk_sp<SkShapers::Factory>&);
|
|
187
187
|
|
|
188
|
-
#if !defined(SK_DISABLE_LEGACY_SHAPER_FACTORY)
|
|
189
|
-
static Result Shape(const SkString& text, const TextDesc& desc, const SkPoint& point,
|
|
190
|
-
const sk_sp<SkFontMgr>&);
|
|
191
|
-
static Result Shape(const SkString& text, const TextDesc& desc, const SkRect& box,
|
|
192
|
-
const sk_sp<SkFontMgr>&);
|
|
193
|
-
#endif
|
|
194
|
-
|
|
195
188
|
private:
|
|
196
189
|
Shaper() = delete;
|
|
197
190
|
};
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
#include "modules/skparagraph/include/FontArguments.h"
|
|
12
12
|
#include "modules/skparagraph/include/ParagraphCache.h"
|
|
13
13
|
#include "modules/skparagraph/include/TextStyle.h"
|
|
14
|
-
#include "src/core/SkTHash.h"
|
|
15
14
|
|
|
16
15
|
namespace skia {
|
|
17
16
|
namespace textlayout {
|
|
@@ -21,6 +20,7 @@ class Paragraph;
|
|
|
21
20
|
class FontCollection : public SkRefCnt {
|
|
22
21
|
public:
|
|
23
22
|
FontCollection();
|
|
23
|
+
~FontCollection() override;
|
|
24
24
|
|
|
25
25
|
size_t getFontManagersCount() const;
|
|
26
26
|
|
|
@@ -36,7 +36,9 @@ public:
|
|
|
36
36
|
std::vector<sk_sp<SkTypeface>> findTypefaces(const std::vector<SkString>& familyNames, SkFontStyle fontStyle);
|
|
37
37
|
std::vector<sk_sp<SkTypeface>> findTypefaces(const std::vector<SkString>& familyNames, SkFontStyle fontStyle, const std::optional<FontArguments>& fontArgs);
|
|
38
38
|
|
|
39
|
-
sk_sp<SkTypeface> defaultFallback(SkUnichar unicode,
|
|
39
|
+
sk_sp<SkTypeface> defaultFallback(SkUnichar unicode, const std::vector<SkString>& families,
|
|
40
|
+
SkFontStyle fontStyle, const SkString& locale,
|
|
41
|
+
const std::optional<FontArguments>& fontArgs);
|
|
40
42
|
sk_sp<SkTypeface> defaultEmojiFallback(SkUnichar emojiStart, SkFontStyle fontStyle, const SkString& locale);
|
|
41
43
|
sk_sp<SkTypeface> defaultFallback();
|
|
42
44
|
|
|
@@ -53,25 +55,9 @@ private:
|
|
|
53
55
|
|
|
54
56
|
sk_sp<SkTypeface> matchTypeface(const SkString& familyName, SkFontStyle fontStyle);
|
|
55
57
|
|
|
56
|
-
struct
|
|
57
|
-
|
|
58
|
-
: fFamilyNames(familyNames), fFontStyle(style), fFontArguments(args) {}
|
|
59
|
-
|
|
60
|
-
FamilyKey() {}
|
|
61
|
-
|
|
62
|
-
std::vector<SkString> fFamilyNames;
|
|
63
|
-
SkFontStyle fFontStyle;
|
|
64
|
-
std::optional<FontArguments> fFontArguments;
|
|
65
|
-
|
|
66
|
-
bool operator==(const FamilyKey& other) const;
|
|
67
|
-
|
|
68
|
-
struct Hasher {
|
|
69
|
-
size_t operator()(const FamilyKey& key) const;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
58
|
+
struct FaceCache;
|
|
59
|
+
std::unique_ptr<FaceCache> fFaceCache;
|
|
73
60
|
bool fEnableFontFallback;
|
|
74
|
-
skia_private::THashMap<FamilyKey, std::vector<sk_sp<SkTypeface>>, FamilyKey::Hasher> fTypefaces;
|
|
75
61
|
sk_sp<SkFontMgr> fDefaultFontManager;
|
|
76
62
|
sk_sp<SkFontMgr> fAssetFontManager;
|
|
77
63
|
sk_sp<SkFontMgr> fDynamicFontManager;
|
|
@@ -84,15 +84,9 @@ public:
|
|
|
84
84
|
// been added, but keeping the initial ParagraphStyle.
|
|
85
85
|
virtual void Reset() = 0;
|
|
86
86
|
|
|
87
|
-
// Just until we fix all the google3 code
|
|
88
87
|
static std::unique_ptr<ParagraphBuilder> make(const ParagraphStyle& style,
|
|
89
88
|
sk_sp<FontCollection> fontCollection,
|
|
90
89
|
sk_sp<SkUnicode> unicode);
|
|
91
|
-
|
|
92
|
-
#if !defined(SK_DISABLE_LEGACY_PARAGRAPH_UNICODE)
|
|
93
|
-
static std::unique_ptr<ParagraphBuilder> make(const ParagraphStyle& style,
|
|
94
|
-
sk_sp<FontCollection> fontCollection);
|
|
95
|
-
#endif
|
|
96
90
|
};
|
|
97
91
|
} // namespace textlayout
|
|
98
92
|
} // namespace skia
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
#define ParagraphCache_DEFINED
|
|
4
4
|
|
|
5
5
|
#include "include/private/base/SkMutex.h"
|
|
6
|
-
#include "src/core/SkLRUCache.h"
|
|
7
6
|
#include <functional> // std::function
|
|
8
7
|
|
|
9
8
|
#define PARAGRAPH_CACHE_STATS
|
|
@@ -12,8 +11,6 @@ namespace skia {
|
|
|
12
11
|
namespace textlayout {
|
|
13
12
|
|
|
14
13
|
class ParagraphImpl;
|
|
15
|
-
class ParagraphCacheKey;
|
|
16
|
-
class ParagraphCacheValue;
|
|
17
14
|
|
|
18
15
|
class ParagraphCache {
|
|
19
16
|
public:
|
|
@@ -30,8 +27,8 @@ public:
|
|
|
30
27
|
fChecker = std::move(checker);
|
|
31
28
|
}
|
|
32
29
|
void printStatistics();
|
|
33
|
-
void turnOn(bool value)
|
|
34
|
-
int count()
|
|
30
|
+
void turnOn(bool value);
|
|
31
|
+
int count();
|
|
35
32
|
|
|
36
33
|
bool isPossiblyTextEditing(ParagraphImpl* paragraph);
|
|
37
34
|
|
|
@@ -44,21 +41,9 @@ public:
|
|
|
44
41
|
mutable SkMutex fParagraphMutex;
|
|
45
42
|
std::function<void(ParagraphImpl* impl, const char*, bool)> fChecker;
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
struct Cache;
|
|
45
|
+
std::unique_ptr<Cache> fCache;
|
|
48
46
|
|
|
49
|
-
struct KeyHash {
|
|
50
|
-
uint32_t operator()(const ParagraphCacheKey& key) const;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
SkLRUCache<ParagraphCacheKey, std::unique_ptr<Entry>, KeyHash> fLRUCacheMap;
|
|
54
|
-
bool fCacheIsOn;
|
|
55
|
-
ParagraphCacheValue* fLastCachedValue;
|
|
56
|
-
|
|
57
|
-
#ifdef PARAGRAPH_CACHE_STATS
|
|
58
|
-
int fTotalRequests;
|
|
59
|
-
int fCacheMisses;
|
|
60
|
-
int fHashMisses; // cache hit but hash table missed
|
|
61
|
-
#endif
|
|
62
47
|
};
|
|
63
48
|
|
|
64
49
|
} // namespace textlayout
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
#include "include/core/SkStream.h"
|
|
8
8
|
#include "include/core/SkString.h"
|
|
9
9
|
#include "include/private/base/SkTArray.h"
|
|
10
|
-
#include "src/core/SkTHash.h"
|
|
11
10
|
|
|
12
11
|
#include <string>
|
|
13
12
|
#include <unordered_map>
|
|
@@ -69,8 +68,8 @@ public:
|
|
|
69
68
|
sk_sp<SkTypeface> onLegacyMakeTypeface(const char[], SkFontStyle) const override;
|
|
70
69
|
|
|
71
70
|
private:
|
|
72
|
-
|
|
73
|
-
skia_private::TArray<
|
|
71
|
+
std::unordered_map<std::string, sk_sp<TypefaceFontStyleSet>> fRegisteredFamilies;
|
|
72
|
+
skia_private::TArray<std::string> fFamilyNames;
|
|
74
73
|
};
|
|
75
74
|
|
|
76
75
|
} // namespace textlayout
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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 SkUnicode_icu_DEFINED
|
|
9
|
+
#define SkUnicode_icu_DEFINED
|
|
10
|
+
|
|
11
|
+
#include "include/core/SkRefCnt.h"
|
|
12
|
+
#include "modules/skunicode/include/SkUnicode.h"
|
|
13
|
+
|
|
14
|
+
namespace SkUnicodes::ICU {
|
|
15
|
+
SKUNICODE_API sk_sp<SkUnicode> Make();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#endif //SkUnicode_icu_DEFINED
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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 SkUnicode_libgrapheme_DEFINED
|
|
9
|
+
#define SkUnicode_libgrapheme_DEFINED
|
|
10
|
+
|
|
11
|
+
#include "modules/skunicode/include/SkUnicode.h"
|
|
12
|
+
|
|
13
|
+
#include <memory>
|
|
14
|
+
|
|
15
|
+
namespace SkUnicodes::Libgrapheme {
|
|
16
|
+
SKUNICODE_API sk_sp<SkUnicode> Make();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#endif
|
|
@@ -12,9 +12,31 @@
|
|
|
12
12
|
#include "include/private/base/SkCPUTypes.h"
|
|
13
13
|
#include "include/private/base/SkTemplates.h"
|
|
14
14
|
|
|
15
|
+
#include <bit>
|
|
15
16
|
#include <cstddef>
|
|
16
17
|
#include <cstdint>
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Return the number of leading zero bits.
|
|
21
|
+
*/
|
|
22
|
+
static constexpr int SkCLZ(uint32_t x) {
|
|
23
|
+
return std::countl_zero<uint32_t>(x);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Return the number of trailing zero bits.
|
|
28
|
+
*/
|
|
29
|
+
static constexpr int SkCTZ(uint32_t x) {
|
|
30
|
+
return std::countr_zero<uint32_t>(x);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* Return the number of set bits (i.e., the population count) in the provided uint32_t.
|
|
35
|
+
*/
|
|
36
|
+
static constexpr int SkPopCount(uint32_t x) {
|
|
37
|
+
return std::popcount<uint32_t>(x);
|
|
38
|
+
}
|
|
39
|
+
|
|
18
40
|
/**
|
|
19
41
|
* Return the integer square root of value, with a bias of bitBias
|
|
20
42
|
*/
|
|
@@ -123,113 +145,6 @@ static inline unsigned SkDiv255Round(unsigned prod) {
|
|
|
123
145
|
static inline uint32_t SkBSwap32(uint32_t v) { return __builtin_bswap32(v); }
|
|
124
146
|
#endif
|
|
125
147
|
|
|
126
|
-
/*
|
|
127
|
-
* Return the number of set bits (i.e., the population count) in the provided uint32_t.
|
|
128
|
-
*/
|
|
129
|
-
int SkPopCount_portable(uint32_t n);
|
|
130
|
-
|
|
131
|
-
#if defined(__GNUC__) || defined(__clang__)
|
|
132
|
-
static inline int SkPopCount(uint32_t n) {
|
|
133
|
-
return __builtin_popcount(n);
|
|
134
|
-
}
|
|
135
|
-
#else
|
|
136
|
-
static inline int SkPopCount(uint32_t n) {
|
|
137
|
-
return SkPopCount_portable(n);
|
|
138
|
-
}
|
|
139
|
-
#endif
|
|
140
|
-
|
|
141
|
-
/*
|
|
142
|
-
* Return the 0-based index of the nth bit set in target
|
|
143
|
-
* Returns 32 if there is no nth bit set.
|
|
144
|
-
*/
|
|
145
|
-
int SkNthSet(uint32_t target, int n);
|
|
146
|
-
|
|
147
|
-
//! Returns the number of leading zero bits (0...32)
|
|
148
|
-
// From Hacker's Delight 2nd Edition
|
|
149
|
-
constexpr int SkCLZ_portable(uint32_t x) {
|
|
150
|
-
int n = 32;
|
|
151
|
-
uint32_t y = x >> 16; if (y != 0) {n -= 16; x = y;}
|
|
152
|
-
y = x >> 8; if (y != 0) {n -= 8; x = y;}
|
|
153
|
-
y = x >> 4; if (y != 0) {n -= 4; x = y;}
|
|
154
|
-
y = x >> 2; if (y != 0) {n -= 2; x = y;}
|
|
155
|
-
y = x >> 1; if (y != 0) {return n - 2;}
|
|
156
|
-
return n - static_cast<int>(x);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
static_assert(32 == SkCLZ_portable(0));
|
|
160
|
-
static_assert(31 == SkCLZ_portable(1));
|
|
161
|
-
static_assert( 1 == SkCLZ_portable(1 << 30));
|
|
162
|
-
static_assert( 1 == SkCLZ_portable((1 << 30) | (1 << 24) | 1));
|
|
163
|
-
static_assert( 0 == SkCLZ_portable(~0U));
|
|
164
|
-
|
|
165
|
-
#if defined(SK_BUILD_FOR_WIN)
|
|
166
|
-
#include <intrin.h>
|
|
167
|
-
|
|
168
|
-
static inline int SkCLZ(uint32_t mask) {
|
|
169
|
-
if (mask) {
|
|
170
|
-
unsigned long index = 0;
|
|
171
|
-
_BitScanReverse(&index, mask);
|
|
172
|
-
// Suppress this bogus /analyze warning. The check for non-zero
|
|
173
|
-
// guarantees that _BitScanReverse will succeed.
|
|
174
|
-
#pragma warning(push)
|
|
175
|
-
#pragma warning(suppress : 6102) // Using 'index' from failed function call
|
|
176
|
-
return static_cast<int>(index ^ 0x1F);
|
|
177
|
-
#pragma warning(pop)
|
|
178
|
-
} else {
|
|
179
|
-
return 32;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
#elif defined(SK_CPU_ARM32) || defined(__GNUC__) || defined(__clang__)
|
|
183
|
-
static inline int SkCLZ(uint32_t mask) {
|
|
184
|
-
// __builtin_clz(0) is undefined, so we have to detect that case.
|
|
185
|
-
return mask ? __builtin_clz(mask) : 32;
|
|
186
|
-
}
|
|
187
|
-
#else
|
|
188
|
-
static inline int SkCLZ(uint32_t mask) {
|
|
189
|
-
return SkCLZ_portable(mask);
|
|
190
|
-
}
|
|
191
|
-
#endif
|
|
192
|
-
|
|
193
|
-
//! Returns the number of trailing zero bits (0...32)
|
|
194
|
-
// From Hacker's Delight 2nd Edition
|
|
195
|
-
constexpr int SkCTZ_portable(uint32_t x) {
|
|
196
|
-
return 32 - SkCLZ_portable(~x & (x - 1));
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
static_assert(32 == SkCTZ_portable(0));
|
|
200
|
-
static_assert( 0 == SkCTZ_portable(1));
|
|
201
|
-
static_assert(30 == SkCTZ_portable(1 << 30));
|
|
202
|
-
static_assert( 2 == SkCTZ_portable((1 << 30) | (1 << 24) | (1 << 2)));
|
|
203
|
-
static_assert( 0 == SkCTZ_portable(~0U));
|
|
204
|
-
|
|
205
|
-
#if defined(SK_BUILD_FOR_WIN)
|
|
206
|
-
#include <intrin.h>
|
|
207
|
-
|
|
208
|
-
static inline int SkCTZ(uint32_t mask) {
|
|
209
|
-
if (mask) {
|
|
210
|
-
unsigned long index = 0;
|
|
211
|
-
_BitScanForward(&index, mask);
|
|
212
|
-
// Suppress this bogus /analyze warning. The check for non-zero
|
|
213
|
-
// guarantees that _BitScanReverse will succeed.
|
|
214
|
-
#pragma warning(push)
|
|
215
|
-
#pragma warning(suppress : 6102) // Using 'index' from failed function call
|
|
216
|
-
return static_cast<int>(index);
|
|
217
|
-
#pragma warning(pop)
|
|
218
|
-
} else {
|
|
219
|
-
return 32;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
#elif defined(SK_CPU_ARM32) || defined(__GNUC__) || defined(__clang__)
|
|
223
|
-
static inline int SkCTZ(uint32_t mask) {
|
|
224
|
-
// __builtin_ctz(0) is undefined, so we have to detect that case.
|
|
225
|
-
return mask ? __builtin_ctz(mask) : 32;
|
|
226
|
-
}
|
|
227
|
-
#else
|
|
228
|
-
static inline int SkCTZ(uint32_t mask) {
|
|
229
|
-
return SkCTZ_portable(mask);
|
|
230
|
-
}
|
|
231
|
-
#endif
|
|
232
|
-
|
|
233
148
|
/**
|
|
234
149
|
* Returns the log2 of the specified value, were that value to be rounded up
|
|
235
150
|
* to the next power of 2. It is undefined to pass 0. Examples:
|
|
@@ -239,16 +154,11 @@ static_assert( 0 == SkCTZ_portable(~0U));
|
|
|
239
154
|
* SkNextLog2(4) -> 2
|
|
240
155
|
* SkNextLog2(5) -> 3
|
|
241
156
|
*/
|
|
242
|
-
static
|
|
157
|
+
static constexpr int SkNextLog2(uint32_t value) {
|
|
243
158
|
SkASSERT(value != 0);
|
|
244
159
|
return 32 - SkCLZ(value - 1);
|
|
245
160
|
}
|
|
246
161
|
|
|
247
|
-
constexpr int SkNextLog2_portable(uint32_t value) {
|
|
248
|
-
SkASSERT(value != 0);
|
|
249
|
-
return 32 - SkCLZ_portable(value - 1);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
162
|
/**
|
|
253
163
|
* Returns the log2 of the specified value, were that value to be rounded down
|
|
254
164
|
* to the previous power of 2. It is undefined to pass 0. Examples:
|
|
@@ -258,52 +168,37 @@ constexpr int SkNextLog2_portable(uint32_t value) {
|
|
|
258
168
|
* SkPrevLog2(4) -> 2
|
|
259
169
|
* SkPrevLog2(5) -> 2
|
|
260
170
|
*/
|
|
261
|
-
static
|
|
171
|
+
static constexpr int SkPrevLog2(uint32_t value) {
|
|
262
172
|
SkASSERT(value != 0);
|
|
263
173
|
return 32 - SkCLZ(value >> 1);
|
|
264
174
|
}
|
|
265
175
|
|
|
266
|
-
constexpr int SkPrevLog2_portable(uint32_t value) {
|
|
267
|
-
SkASSERT(value != 0);
|
|
268
|
-
return 32 - SkCLZ_portable(value >> 1);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
176
|
/**
|
|
272
177
|
* Returns the smallest power-of-2 that is >= the specified value. If value
|
|
273
178
|
* is already a power of 2, then it is returned unchanged. It is undefined
|
|
274
179
|
* if value is <= 0.
|
|
275
180
|
*/
|
|
276
|
-
static
|
|
181
|
+
static constexpr int SkNextPow2(int value) {
|
|
277
182
|
SkASSERT(value > 0);
|
|
278
183
|
return 1 << SkNextLog2(static_cast<uint32_t>(value));
|
|
279
184
|
}
|
|
280
185
|
|
|
281
|
-
constexpr int SkNextPow2_portable(int value) {
|
|
282
|
-
SkASSERT(value > 0);
|
|
283
|
-
return 1 << SkNextLog2_portable(static_cast<uint32_t>(value));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
186
|
/**
|
|
287
187
|
* Returns the largest power-of-2 that is <= the specified value. If value
|
|
288
188
|
* is already a power of 2, then it is returned unchanged. It is undefined
|
|
289
189
|
* if value is <= 0.
|
|
290
190
|
*/
|
|
291
|
-
static
|
|
191
|
+
static constexpr int SkPrevPow2(int value) {
|
|
292
192
|
SkASSERT(value > 0);
|
|
293
193
|
return 1 << SkPrevLog2(static_cast<uint32_t>(value));
|
|
294
194
|
}
|
|
295
195
|
|
|
296
|
-
constexpr int SkPrevPow2_portable(int value) {
|
|
297
|
-
SkASSERT(value > 0);
|
|
298
|
-
return 1 << SkPrevLog2_portable(static_cast<uint32_t>(value));
|
|
299
|
-
}
|
|
300
|
-
|
|
301
196
|
///////////////////////////////////////////////////////////////////////////////
|
|
302
197
|
|
|
303
198
|
/**
|
|
304
199
|
* Returns the next power of 2 >= n or n if the next power of 2 can't be represented by size_t.
|
|
305
200
|
*/
|
|
306
|
-
constexpr size_t SkNextSizePow2(size_t n) {
|
|
201
|
+
static constexpr size_t SkNextSizePow2(size_t n) {
|
|
307
202
|
constexpr int kNumSizeTBits = 8 * sizeof(size_t);
|
|
308
203
|
constexpr size_t kHighBitSet = size_t(1) << (kNumSizeTBits - 1);
|
|
309
204
|
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"setup-skia-web": "scripts/setup-canvaskit.js"
|
|
10
10
|
},
|
|
11
11
|
"title": "React Native Skia",
|
|
12
|
-
"version": "2.6.
|
|
12
|
+
"version": "2.6.1",
|
|
13
13
|
"description": "High-performance React Native Graphics using Skia",
|
|
14
14
|
"main": "lib/module/index.js",
|
|
15
15
|
"react-native": "src/index.ts",
|
|
@@ -129,10 +129,10 @@
|
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
131
|
"canvaskit-wasm": "0.41.0",
|
|
132
|
-
"react-native-skia-android": "
|
|
133
|
-
"react-native-skia-apple-ios": "
|
|
134
|
-
"react-native-skia-apple-macos": "
|
|
135
|
-
"react-native-skia-apple-tvos": "
|
|
132
|
+
"react-native-skia-android": "147.0.0",
|
|
133
|
+
"react-native-skia-apple-ios": "147.0.0",
|
|
134
|
+
"react-native-skia-apple-macos": "147.0.0",
|
|
135
|
+
"react-native-skia-apple-tvos": "147.0.0",
|
|
136
136
|
"react-reconciler": "0.31.0"
|
|
137
137
|
},
|
|
138
138
|
"eslintIgnore": [
|