@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
package/android/CMakeLists.txt
CHANGED
|
@@ -214,7 +214,6 @@ set_property(TARGET pathops PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libpat
|
|
|
214
214
|
add_library(jsonreader STATIC IMPORTED)
|
|
215
215
|
set_property(TARGET jsonreader PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libjsonreader.a")
|
|
216
216
|
|
|
217
|
-
# Dawn library for Graphite builds (contains dawn::native symbols)
|
|
218
217
|
if(SK_GRAPHITE)
|
|
219
218
|
add_library(dawn_combined STATIC IMPORTED)
|
|
220
219
|
set_property(TARGET dawn_combined PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libdawn_combined.a")
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#include <jni.h>
|
|
2
1
|
#include <android/native_window_jni.h>
|
|
2
|
+
#include <jni.h>
|
|
3
3
|
|
|
4
4
|
#ifdef SK_GRAPHITE
|
|
5
|
-
#include "webgpu/webgpu_cpp.h"
|
|
6
|
-
#include "rnwgpu/SurfaceRegistry.h"
|
|
7
5
|
#include "rnskia/RNDawnContext.h"
|
|
6
|
+
#include "rnwgpu/SurfaceRegistry.h"
|
|
7
|
+
#include "webgpu/webgpu_cpp.h"
|
|
8
8
|
#endif
|
|
9
9
|
|
|
10
10
|
extern "C" JNIEXPORT void JNICALL
|
|
@@ -59,7 +59,7 @@ public:
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
sk_sp<SkSurface> MakeOffscreen(int width, int height,
|
|
62
|
-
|
|
62
|
+
bool useP3ColorSpace = false) {
|
|
63
63
|
auto colorType = kRGBA_8888_SkColorType;
|
|
64
64
|
|
|
65
65
|
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
|
|
@@ -91,10 +91,9 @@ public:
|
|
|
91
91
|
.texture = texture};
|
|
92
92
|
|
|
93
93
|
sk_sp<SkColorSpace> colorSpace =
|
|
94
|
-
useP3ColorSpace
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
: nullptr;
|
|
94
|
+
useP3ColorSpace ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
|
|
95
|
+
SkNamedGamut::kDisplayP3)
|
|
96
|
+
: nullptr;
|
|
98
97
|
|
|
99
98
|
// Create a SkSurface from the GrBackendTexture
|
|
100
99
|
return SkSurfaces::WrapBackendTexture(
|
|
@@ -51,7 +51,7 @@ public:
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
sk_sp<SkSurface> makeOffscreenSurface(int width, int height,
|
|
54
|
-
|
|
54
|
+
bool useP3ColorSpace = false) override {
|
|
55
55
|
#if defined(SK_GRAPHITE)
|
|
56
56
|
return DawnContext::getInstance().MakeOffscreen(width, height,
|
|
57
57
|
useP3ColorSpace);
|
package/apple/MetalContext.h
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
#include "include/core/SkSurface.h"
|
|
7
7
|
|
|
8
|
+
#include "include/core/SkColorSpace.h"
|
|
8
9
|
#import <include/gpu/ganesh/GrBackendSurface.h>
|
|
9
10
|
#import <include/gpu/ganesh/GrDirectContext.h>
|
|
10
11
|
#import <include/gpu/ganesh/SkImageGanesh.h>
|
|
@@ -13,7 +14,6 @@
|
|
|
13
14
|
#import <include/gpu/ganesh/mtl/GrMtlBackendSurface.h>
|
|
14
15
|
#import <include/gpu/ganesh/mtl/GrMtlDirectContext.h>
|
|
15
16
|
#import <include/gpu/ganesh/mtl/SkSurfaceMetal.h>
|
|
16
|
-
#include "include/core/SkColorSpace.h"
|
|
17
17
|
|
|
18
18
|
struct OffscreenRenderContext {
|
|
19
19
|
id<MTLTexture> texture;
|
|
@@ -46,7 +46,7 @@ public:
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
sk_sp<SkSurface> MakeOffscreen(int width, int height,
|
|
49
|
-
|
|
49
|
+
bool useP3ColorSpace = false) {
|
|
50
50
|
auto device = _device;
|
|
51
51
|
auto ctx = new OffscreenRenderContext(device, _directContext, _commandQueue,
|
|
52
52
|
width, height);
|
|
@@ -58,10 +58,9 @@ public:
|
|
|
58
58
|
GrBackendTextures::MakeMtl(width, height, skgpu::Mipmapped::kNo, info);
|
|
59
59
|
|
|
60
60
|
sk_sp<SkColorSpace> colorSpace =
|
|
61
|
-
useP3ColorSpace
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
: nullptr;
|
|
61
|
+
useP3ColorSpace ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
|
|
62
|
+
SkNamedGamut::kDisplayP3)
|
|
63
|
+
: nullptr;
|
|
65
64
|
|
|
66
65
|
// Create a SkSurface from the GrBackendTexture
|
|
67
66
|
auto surface = SkSurfaces::WrapBackendTexture(
|
|
@@ -72,10 +72,9 @@ sk_sp<SkSurface> MetalWindowContext::getSurface() {
|
|
|
72
72
|
_layer.drawableSize.width, _layer.drawableSize.height, fbInfo);
|
|
73
73
|
|
|
74
74
|
sk_sp<SkColorSpace> skColorSpace =
|
|
75
|
-
_useP3ColorSpace
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
: nullptr;
|
|
75
|
+
_useP3ColorSpace ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
|
|
76
|
+
SkNamedGamut::kDisplayP3)
|
|
77
|
+
: nullptr;
|
|
79
78
|
_skSurface = SkSurfaces::WrapBackendRenderTarget(
|
|
80
79
|
_directContext, backendRT, kTopLeft_GrSurfaceOrigin,
|
|
81
80
|
kBGRA_8888_SkColorType, skColorSpace, nullptr);
|
|
@@ -70,7 +70,7 @@ public:
|
|
|
70
70
|
|
|
71
71
|
void raiseError(const std::exception &err) override;
|
|
72
72
|
sk_sp<SkSurface> makeOffscreenSurface(int width, int height,
|
|
73
|
-
|
|
73
|
+
bool useP3ColorSpace = false) override;
|
|
74
74
|
|
|
75
75
|
sk_sp<SkFontMgr> createFontMgr() override;
|
|
76
76
|
|
|
@@ -251,11 +251,12 @@ void RNSkApplePlatformContext::raiseError(const std::exception &err) {
|
|
|
251
251
|
RCTFatal(RCTErrorWithMessage([NSString stringWithUTF8String:err.what()]));
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
sk_sp<SkSurface>
|
|
255
|
-
|
|
254
|
+
sk_sp<SkSurface>
|
|
255
|
+
RNSkApplePlatformContext::makeOffscreenSurface(int width, int height,
|
|
256
|
+
bool useP3ColorSpace) {
|
|
256
257
|
#if defined(SK_GRAPHITE)
|
|
257
258
|
return DawnContext::getInstance().MakeOffscreen(width, height,
|
|
258
|
-
|
|
259
|
+
useP3ColorSpace);
|
|
259
260
|
#else
|
|
260
261
|
return MetalContext::getInstance().MakeOffscreen(width, height,
|
|
261
262
|
useP3ColorSpace);
|
|
@@ -31,16 +31,12 @@
|
|
|
31
31
|
#include <cmath>
|
|
32
32
|
#if TARGET_RT_BIG_ENDIAN
|
|
33
33
|
#define FourCC2Str(fourcc) \
|
|
34
|
-
(const char[])
|
|
35
|
-
|
|
36
|
-
*(((char *)&fourcc) + 3), 0 \
|
|
37
|
-
}
|
|
34
|
+
(const char[]){*((char *)&fourcc), *(((char *)&fourcc) + 1), \
|
|
35
|
+
*(((char *)&fourcc) + 2), *(((char *)&fourcc) + 3), 0}
|
|
38
36
|
#else
|
|
39
37
|
#define FourCC2Str(fourcc) \
|
|
40
|
-
(const char[])
|
|
41
|
-
|
|
42
|
-
*(((char *)&fourcc) + 1), *(((char *)&fourcc) + 0), 0 \
|
|
43
|
-
}
|
|
38
|
+
(const char[]){*(((char *)&fourcc) + 3), *(((char *)&fourcc) + 2), \
|
|
39
|
+
*(((char *)&fourcc) + 1), *(((char *)&fourcc) + 0), 0}
|
|
44
40
|
#endif
|
|
45
41
|
|
|
46
42
|
// pragma MARK: TextureHolder
|
|
@@ -270,19 +266,20 @@ SkiaCVPixelBufferUtils::YUV::getSubsampling(OSType pixelFormat) {
|
|
|
270
266
|
|
|
271
267
|
// pragma MARK: YUV getColorspace()
|
|
272
268
|
|
|
273
|
-
SkYUVColorSpace
|
|
274
|
-
|
|
269
|
+
SkYUVColorSpace
|
|
270
|
+
SkiaCVPixelBufferUtils::YUV::getColorspace(CVPixelBufferRef pixelBuffer) {
|
|
275
271
|
const OSType pixelFormat = CVPixelBufferGetPixelFormatType(pixelBuffer);
|
|
276
272
|
|
|
277
|
-
CFTypeRef matrixAttachment =
|
|
278
|
-
|
|
273
|
+
CFTypeRef matrixAttachment = CVBufferCopyAttachment(
|
|
274
|
+
pixelBuffer, kCVImageBufferYCbCrMatrixKey, nullptr);
|
|
279
275
|
CFStringRef matrix = nullptr;
|
|
280
276
|
if (matrixAttachment != nullptr &&
|
|
281
277
|
CFGetTypeID(matrixAttachment) == CFStringGetTypeID()) {
|
|
282
278
|
matrix = reinterpret_cast<CFStringRef>(matrixAttachment);
|
|
283
279
|
}
|
|
284
280
|
|
|
285
|
-
SkYUVColorSpace colorspace =
|
|
281
|
+
SkYUVColorSpace colorspace =
|
|
282
|
+
getSkYUVColorSpaceFromMatrix(matrix, pixelFormat);
|
|
286
283
|
if (matrixAttachment != nullptr) {
|
|
287
284
|
CFRelease(matrixAttachment);
|
|
288
285
|
}
|
|
@@ -320,8 +317,9 @@ bool SkiaCVPixelBufferUtils::YUV::isTenBitYUVFormat(OSType pixelFormat) {
|
|
|
320
317
|
}
|
|
321
318
|
}
|
|
322
319
|
|
|
323
|
-
SkYUVColorSpace
|
|
324
|
-
|
|
320
|
+
SkYUVColorSpace
|
|
321
|
+
SkiaCVPixelBufferUtils::YUV::getSkYUVColorSpaceFromMatrix(CFStringRef matrix,
|
|
322
|
+
OSType pixelFormat) {
|
|
325
323
|
const bool isFullRange = isFullRangeYUVFormat(pixelFormat);
|
|
326
324
|
const bool isTenBit = isTenBitYUVFormat(pixelFormat);
|
|
327
325
|
|
|
@@ -381,10 +379,11 @@ TextureHolder *SkiaCVPixelBufferUtils::getSkiaTextureForCVPixelBufferPlane(
|
|
|
381
379
|
"Requested out-of-bounds plane index " + std::to_string(planeIndex) +
|
|
382
380
|
" for pixel buffer with " + std::to_string(planesCount) + " planes.");
|
|
383
381
|
}
|
|
384
|
-
size_t width = planesCount > 0
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
382
|
+
size_t width = planesCount > 0
|
|
383
|
+
? CVPixelBufferGetWidthOfPlane(pixelBuffer, planeIndex)
|
|
384
|
+
: CVPixelBufferGetWidth(pixelBuffer);
|
|
385
|
+
size_t height = planesCount > 0
|
|
386
|
+
? CVPixelBufferGetHeightOfPlane(pixelBuffer, planeIndex)
|
|
388
387
|
: CVPixelBufferGetHeight(pixelBuffer);
|
|
389
388
|
MTLPixelFormat pixelFormat =
|
|
390
389
|
getMTLPixelFormatForCVPixelBufferPlane(pixelBuffer, planeIndex);
|
|
@@ -424,12 +423,12 @@ SkiaCVPixelBufferUtils::getTextureCache(id<MTLDevice> device) {
|
|
|
424
423
|
MTLPixelFormat SkiaCVPixelBufferUtils::getMTLPixelFormatForCVPixelBufferPlane(
|
|
425
424
|
CVPixelBufferRef pixelBuffer, size_t planeIndex) {
|
|
426
425
|
const OSType format = CVPixelBufferGetPixelFormatType(pixelBuffer);
|
|
427
|
-
auto throwInvalidPlaneIndexForFormat =
|
|
428
|
-
-> MTLPixelFormat {
|
|
426
|
+
auto throwInvalidPlaneIndexForFormat =
|
|
427
|
+
[&](size_t expectedPlanes) -> MTLPixelFormat {
|
|
429
428
|
throw std::runtime_error(
|
|
430
429
|
"Invalid plane index " + std::to_string(planeIndex) +
|
|
431
|
-
" for pixel format " + std::string(FourCC2Str(format)) +
|
|
432
|
-
std::to_string(expectedPlanes - 1) + ").");
|
|
430
|
+
" for pixel format " + std::string(FourCC2Str(format)) +
|
|
431
|
+
" (expected 0.." + std::to_string(expectedPlanes - 1) + ").");
|
|
433
432
|
};
|
|
434
433
|
|
|
435
434
|
switch (format) {
|
|
@@ -495,17 +494,18 @@ MTLPixelFormat SkiaCVPixelBufferUtils::getMTLPixelFormatForCVPixelBufferPlane(
|
|
|
495
494
|
planesCount > 0 ? CVPixelBufferGetWidthOfPlane(pixelBuffer, planeIndex)
|
|
496
495
|
: CVPixelBufferGetWidth(pixelBuffer);
|
|
497
496
|
const size_t bytesPerRow =
|
|
498
|
-
planesCount > 0
|
|
499
|
-
|
|
497
|
+
planesCount > 0
|
|
498
|
+
? CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, planeIndex)
|
|
499
|
+
: CVPixelBufferGetBytesPerRow(pixelBuffer);
|
|
500
500
|
if (width == 0) [[unlikely]] {
|
|
501
501
|
throw std::runtime_error("Invalid plane width for pixel format " +
|
|
502
502
|
std::string(FourCC2Str(format)) + "!");
|
|
503
503
|
}
|
|
504
504
|
if (bytesPerRow % width != 0) [[unlikely]] {
|
|
505
|
-
throw std::runtime_error(
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
505
|
+
throw std::runtime_error("Invalid bytes per row! Bytes per row must be "
|
|
506
|
+
"evenly divisible by width "
|
|
507
|
+
"for pixel format " +
|
|
508
|
+
std::string(FourCC2Str(format)) + "!");
|
|
509
509
|
}
|
|
510
510
|
const size_t bytesPerPixel = bytesPerRow / width;
|
|
511
511
|
if (bytesPerPixel == 1) {
|
|
@@ -519,6 +519,7 @@ MTLPixelFormat SkiaCVPixelBufferUtils::getMTLPixelFormatForCVPixelBufferPlane(
|
|
|
519
519
|
}
|
|
520
520
|
|
|
521
521
|
[[unlikely]] throw std::runtime_error(
|
|
522
|
-
"Invalid bytes per row! Expected 1 (R), 2 (RG) or 4 (RGBA), but
|
|
522
|
+
"Invalid bytes per row! Expected 1 (R), 2 (RG) or 4 (RGBA), but "
|
|
523
|
+
"received " +
|
|
523
524
|
std::to_string(bytesPerPixel));
|
|
524
525
|
}
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
namespace rnwgpu {
|
|
8
8
|
|
|
9
9
|
wgpu::Surface SkiaPlatformContext::makeSurface(wgpu::Instance instance,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
void *surface, int width,
|
|
11
|
+
int height) {
|
|
12
12
|
wgpu::SurfaceSourceMetalLayer metalSurfaceDesc;
|
|
13
13
|
metalSurfaceDesc.layer = surface;
|
|
14
14
|
wgpu::SurfaceDescriptor surfaceDescriptor;
|
package/apple/SkiaUIView.mm
CHANGED
package/apple/SkiaWebGPUView.mm
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
#import <react/renderer/components/rnskia/Props.h>
|
|
8
8
|
#import <react/renderer/components/rnskia/RCTComponentViewHelpers.h>
|
|
9
9
|
|
|
10
|
-
#import "WebGPUMetalView.h"
|
|
11
10
|
#import "RCTFabricComponentsPlugins.h"
|
|
11
|
+
#import "WebGPUMetalView.h"
|
|
12
12
|
|
|
13
13
|
using namespace facebook::react;
|
|
14
14
|
|
|
@@ -16,14 +16,16 @@ using namespace facebook::react;
|
|
|
16
16
|
|
|
17
17
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
18
18
|
if (self = [super initWithFrame:frame]) {
|
|
19
|
-
static const auto defaultProps =
|
|
19
|
+
static const auto defaultProps =
|
|
20
|
+
std::make_shared<const SkiaWebGPUViewProps>();
|
|
20
21
|
_props = defaultProps;
|
|
21
22
|
}
|
|
22
23
|
return self;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
26
|
-
return concreteComponentDescriptorProvider<
|
|
27
|
+
return concreteComponentDescriptorProvider<
|
|
28
|
+
SkiaWebGPUViewComponentDescriptor>();
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
- (void)prepareForRecycle {
|
|
@@ -72,6 +74,8 @@ using namespace facebook::react;
|
|
|
72
74
|
|
|
73
75
|
@end
|
|
74
76
|
|
|
75
|
-
Class<RCTComponentViewProtocol> SkiaWebGPUViewCls(void) {
|
|
77
|
+
Class<RCTComponentViewProtocol> SkiaWebGPUViewCls(void) {
|
|
78
|
+
return SkiaWebGPUView.class;
|
|
79
|
+
}
|
|
76
80
|
|
|
77
81
|
#endif // RCT_NEW_ARCH_ENABLED
|
package/apple/WebGPUMetalView.h
CHANGED
package/apple/WebGPUMetalView.mm
CHANGED
package/cpp/api/JsiSkColor.h
CHANGED
|
@@ -103,10 +103,14 @@ public:
|
|
|
103
103
|
"Expected array of length 4 for color, got " +
|
|
104
104
|
std::to_string(arr.size(runtime)));
|
|
105
105
|
}
|
|
106
|
-
auto r =
|
|
107
|
-
|
|
108
|
-
auto
|
|
109
|
-
|
|
106
|
+
auto r =
|
|
107
|
+
static_cast<float>(arr.getValueAtIndex(runtime, 0).asNumber());
|
|
108
|
+
auto g =
|
|
109
|
+
static_cast<float>(arr.getValueAtIndex(runtime, 1).asNumber());
|
|
110
|
+
auto b =
|
|
111
|
+
static_cast<float>(arr.getValueAtIndex(runtime, 2).asNumber());
|
|
112
|
+
auto a =
|
|
113
|
+
static_cast<float>(arr.getValueAtIndex(runtime, 3).asNumber());
|
|
110
114
|
|
|
111
115
|
// Create Float32Array and populate
|
|
112
116
|
auto result = runtime.global()
|
|
@@ -58,12 +58,13 @@ public:
|
|
|
58
58
|
auto start = arguments[0].asNumber();
|
|
59
59
|
auto end = arguments[1].asNumber();
|
|
60
60
|
auto startWithMoveTo = arguments[2].getBool();
|
|
61
|
-
|
|
62
|
-
auto result =
|
|
61
|
+
SkPathBuilder builder;
|
|
62
|
+
auto result =
|
|
63
|
+
getObject()->getSegment(start, end, &builder, startWithMoveTo);
|
|
63
64
|
if (!result) {
|
|
64
65
|
throw jsi::JSError(runtime, "getSegment() failed");
|
|
65
66
|
}
|
|
66
|
-
return JsiSkPath::toValue(runtime, getContext(),
|
|
67
|
+
return JsiSkPath::toValue(runtime, getContext(), builder.snapshot());
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
size_t getMemoryPressure() const override { return 1024; }
|
package/cpp/api/JsiSkImage.h
CHANGED
|
@@ -46,30 +46,35 @@
|
|
|
46
46
|
// recognise the canonical Apple profile, not Skia's mathematically equivalent
|
|
47
47
|
// but non-standard one. Pixel values are untouched — zero quality loss.
|
|
48
48
|
static sk_sp<SkData> replaceJpegICCWithAppleP3(sk_sp<SkData> jpegData) {
|
|
49
|
-
if (!jpegData || jpegData->size() < 4)
|
|
49
|
+
if (!jpegData || jpegData->size() < 4)
|
|
50
|
+
return jpegData;
|
|
50
51
|
|
|
51
52
|
const uint8_t *src = jpegData->bytes();
|
|
52
53
|
size_t srcLen = jpegData->size();
|
|
53
|
-
if (src[0] != 0xFF || src[1] != 0xD8)
|
|
54
|
+
if (src[0] != 0xFF || src[1] != 0xD8)
|
|
55
|
+
return jpegData; // not a JPEG
|
|
54
56
|
|
|
55
57
|
CGColorSpaceRef p3 = CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3);
|
|
56
|
-
if (!p3)
|
|
58
|
+
if (!p3)
|
|
59
|
+
return jpegData;
|
|
57
60
|
CFDataRef cfICC = CGColorSpaceCopyICCData(p3);
|
|
58
61
|
CGColorSpaceRelease(p3);
|
|
59
|
-
if (!cfICC)
|
|
62
|
+
if (!cfICC)
|
|
63
|
+
return jpegData;
|
|
60
64
|
|
|
61
65
|
const uint8_t *iccBytes = CFDataGetBytePtr(cfICC);
|
|
62
66
|
size_t iccLen = (size_t)CFDataGetLength(cfICC);
|
|
63
67
|
|
|
64
68
|
// "ICC_PROFILE\0" APP2 marker signature (12 bytes)
|
|
65
69
|
static const uint8_t iccSig[] = {0x49, 0x43, 0x43, 0x5F, 0x50, 0x52,
|
|
66
|
-
|
|
70
|
+
0x4F, 0x46, 0x49, 0x4C, 0x45, 0x00};
|
|
67
71
|
|
|
68
72
|
SkDynamicMemoryWStream out;
|
|
69
73
|
|
|
70
74
|
out.write(src, 2); // SOI
|
|
71
75
|
|
|
72
|
-
// Structure: marker(2) + length(2) + "ICC_PROFILE\0"(12) + chunk[1,1](2) +
|
|
76
|
+
// Structure: marker(2) + length(2) + "ICC_PROFILE\0"(12) + chunk[1,1](2) +
|
|
77
|
+
// profile
|
|
73
78
|
size_t iccContentLen = sizeof(iccSig) + 2 + iccLen;
|
|
74
79
|
size_t segLen = iccContentLen + 2; // length field includes itself
|
|
75
80
|
uint8_t app2hdr[4] = {0xFF, 0xE2, (uint8_t)(segLen >> 8),
|
|
@@ -83,12 +88,15 @@ static sk_sp<SkData> replaceJpegICCWithAppleP3(sk_sp<SkData> jpegData) {
|
|
|
83
88
|
// Copy all header segments except any existing ICC APP2
|
|
84
89
|
size_t i = 2;
|
|
85
90
|
while (i + 3 < srcLen) {
|
|
86
|
-
if (src[i] != 0xFF)
|
|
91
|
+
if (src[i] != 0xFF)
|
|
92
|
+
break;
|
|
87
93
|
uint8_t marker = src[i + 1];
|
|
88
|
-
if (marker == 0xDA || marker == 0xD9)
|
|
94
|
+
if (marker == 0xDA || marker == 0xD9)
|
|
95
|
+
break; // SOS / EOI
|
|
89
96
|
size_t segLenVal = (size_t(src[i + 2]) << 8) | src[i + 3];
|
|
90
97
|
size_t end = i + 2 + segLenVal;
|
|
91
|
-
if (end > srcLen)
|
|
98
|
+
if (end > srcLen)
|
|
99
|
+
break;
|
|
92
100
|
bool isICC = marker == 0xE2 && end > i + 4 + sizeof(iccSig) &&
|
|
93
101
|
memcmp(src + i + 4, iccSig, sizeof(iccSig)) == 0;
|
|
94
102
|
if (!isICC) {
|
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
|
|
20
20
|
#include "modules/skparagraph/include/ParagraphBuilder.h"
|
|
21
21
|
|
|
22
|
+
#ifdef __APPLE__
|
|
23
|
+
#include "modules/skunicode/include/SkUnicode_libgrapheme.h"
|
|
24
|
+
#else
|
|
25
|
+
#include "modules/skunicode/include/SkUnicode_icu.h"
|
|
26
|
+
#endif
|
|
27
|
+
|
|
22
28
|
#pragma clang diagnostic pop
|
|
23
29
|
|
|
24
30
|
namespace RNSkia {
|
|
@@ -125,7 +131,14 @@ public:
|
|
|
125
131
|
_fontCollection->setAssetFontManager(fontManager);
|
|
126
132
|
}
|
|
127
133
|
_fontCollection->enableFontFallback();
|
|
128
|
-
|
|
134
|
+
sk_sp<SkUnicode> unicode;
|
|
135
|
+
#ifdef __APPLE__
|
|
136
|
+
unicode = SkUnicodes::Libgrapheme::Make();
|
|
137
|
+
#else
|
|
138
|
+
unicode = SkUnicodes::ICU::Make();
|
|
139
|
+
#endif
|
|
140
|
+
_builder =
|
|
141
|
+
para::ParagraphBuilder::make(paragraphStyle, _fontCollection, unicode);
|
|
129
142
|
}
|
|
130
143
|
|
|
131
144
|
private:
|