Skip to content

Commit

Permalink
[go] update @shopify/react-native-skia to 0.1.193 (expo#22900)
Browse files Browse the repository at this point in the history
# Why

update @shopify/react-native-skia vendoring module for sdk 49

# How

- [tools] update patch
- `et uvm -m @shopify/react-native-skia -c 0.1.193`
- backport skia chrome/m114 to sdk47 and sdk48 code. reference changes from Shopify/react-native-skia#1604 

# Test Plan

- versioned expo go + unversioned ncl skia
- versioned expo go + sdk 48 ncl skia
  • Loading branch information
Kudo authored Jun 19, 2023
1 parent 5b07ee5 commit 7980d26
Show file tree
Hide file tree
Showing 1,309 changed files with 30,167 additions and 39,877 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include <SkBase64.h>
#include <SkImage.h>
#include <SkStream.h>
#include <include/codec/SkCodec.h>
#include <codec/SkEncodedImageFormat.h>
#include <include/encode/SkJpegEncoder.h>
#include <include/encode/SkPngEncoder.h">

#pragma clang diagnostic pop

Expand Down Expand Up @@ -69,7 +71,15 @@ namespace RNSkia
auto quality = count == 2 ? arguments[1].asNumber() : 100.0;

// Get data
auto data = getObject()->encodeToData(format, quality);
sk_sp<SkData> data;
if (format == SkEncodedImageFormat::kJPEG) {
SkJpegEncoder::Options options;
options.fQuality = quality;
data = SkJpegEncoder::Encode(nullptr, getObject().get(), options);
} else {
SkPngEncoder::Options options;
data = SkPngEncoder::Encode(nullptr, getObject().get(), options);
}
auto arrayCtor = runtime.global().getPropertyAsFunction(runtime, "Uint8Array");
size_t size = data->size();

Expand All @@ -90,8 +100,19 @@ namespace RNSkia
auto format = count >= 1 ? static_cast<SkEncodedImageFormat>(arguments[0].asNumber()) : SkEncodedImageFormat::kPNG;

auto quality = count == 2 ? arguments[1].asNumber() : 100.0;

auto data = getObject()->encodeToData(format, quality);
auto image = getObject();
if (image->isTextureBacked()) {
image = image->makeNonTextureImage();
}
sk_sp<SkData> data;
if (format == SkEncodedImageFormat::kJPEG) {
SkJpegEncoder::Options options;
options.fQuality = quality;
data = SkJpegEncoder::Encode(nullptr, image.get(), options);
} else {
SkPngEncoder::Options options;
data = SkPngEncoder::Encode(nullptr, image.get(), options);
}
auto len = SkBase64::Encode(data->bytes(), data->size(), nullptr);
auto buffer = std::string(len, 0);
SkBase64::Encode(data->bytes(), data->size(), (void *)&buffer[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace RNSkia {
public:
JSI_HOST_FUNCTION(MakeImageFromEncoded) {
auto data = JsiSkData::fromValue(runtime, arguments[0]);
auto image = SkImage::MakeFromEncoded(data);
auto image = SkImages::DeferredFromEncodedData(data);
if(image == nullptr) {
return jsi::Value::null();
}
Expand All @@ -30,7 +30,7 @@ namespace RNSkia {
auto imageInfo = JsiSkImageInfo::fromValue(runtime, arguments[0]);
auto pixelData = JsiSkData::fromValue(runtime, arguments[1]);
auto bytesPerRow = arguments[2].asNumber();
auto image = SkImage::MakeRasterData(*imageInfo, pixelData, bytesPerRow);
auto image = SkImages::RasterFromData(*imageInfo, pixelData, bytesPerRow);
if(image == nullptr) {
return jsi::Value::null();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <jsi/jsi.h>

#include "JsiSkHostObjects.h"
#include "JsiSkMatrix.h"
#include "JsiSkPoint.h"
#include "JsiSkRRect.h"
#include "JsiSkRect.h"
Expand All @@ -19,6 +20,7 @@
#include <SkPath.h>
#include <SkPathOps.h>
#include <SkPathTypes.h>
#include <SkPathUtils.h>
#include <SkStrokeRec.h>
#include <SkTextUtils.h>
#include <SkTrimPathEffect.h>
Expand Down Expand Up @@ -269,8 +271,11 @@ class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPath> {

auto jsiPrecision = opts.getProperty(runtime, "precision");
auto precision = jsiPrecision.isUndefined() ? 1 : jsiPrecision.asNumber();
auto result = p.getFillPath(path, &path, nullptr, precision);
getObject()->swap(path);
auto result =
skpathutils::FillPathWithPaint(path, p, &path, nullptr, precision);
if (result) {
getObject()->swap(path);
}
return result ? thisValue.getObject(runtime) : jsi::Value::null();
}

Expand Down Expand Up @@ -305,8 +310,7 @@ class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPath> {

JSI_HOST_FUNCTION(toSVGString) {
SkPath path = *getObject();
SkString s;
SkParsePath::ToSVGString(path, &s);
auto s = SkParsePath::ToSVGString(path);
return jsi::String::createFromUtf8(runtime, s.c_str());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include "SkBase64.h"
#include "SkImage.h"
#include "SkStream.h"
#include <include/codec/SkCodec.h>
#include "codec/SkEncodedImageFormat.h"
#include "include/encode/SkJpegEncoder.h"
#include "include/encode/SkPngEncoder.h"

#pragma clang diagnostic pop

Expand Down Expand Up @@ -70,7 +72,15 @@ class JsiSkImage : public JsiSkWrappingSkPtrHostObject<SkImage> {
auto quality = count == 2 ? arguments[1].asNumber() : 100.0;

// Get data
auto data = getObject()->encodeToData(format, quality);
sk_sp<SkData> data;
if (format == SkEncodedImageFormat::kJPEG) {
SkJpegEncoder::Options options;
options.fQuality = quality;
data = SkJpegEncoder::Encode(nullptr, getObject().get(), options);
} else {
SkPngEncoder::Options options;
data = SkPngEncoder::Encode(nullptr, getObject().get(), options);
}
auto arrayCtor =
runtime.global().getPropertyAsFunction(runtime, "Uint8Array");
size_t size = data->size();
Expand All @@ -95,8 +105,19 @@ class JsiSkImage : public JsiSkWrappingSkPtrHostObject<SkImage> {
: SkEncodedImageFormat::kPNG;

auto quality = count == 2 ? arguments[1].asNumber() : 100.0;

auto data = getObject()->encodeToData(format, quality);
auto image = getObject();
if (image->isTextureBacked()) {
image = image->makeNonTextureImage();
}
sk_sp<SkData> data;
if (format == SkEncodedImageFormat::kJPEG) {
SkJpegEncoder::Options options;
options.fQuality = quality;
data = SkJpegEncoder::Encode(nullptr, image.get(), options);
} else {
SkPngEncoder::Options options;
data = SkPngEncoder::Encode(nullptr, image.get(), options);
}
auto len = SkBase64::Encode(data->bytes(), data->size(), nullptr);
auto buffer = std::string(len, 0);
SkBase64::Encode(data->bytes(), data->size(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JsiSkImageFactory : public JsiSkHostObject {
public:
JSI_HOST_FUNCTION(MakeImageFromEncoded) {
auto data = JsiSkData::fromValue(runtime, arguments[0]);
auto image = SkImage::MakeFromEncoded(data);
auto image = SkImages::DeferredFromEncodedData(data);
if (image == nullptr) {
return jsi::Value::null();
}
Expand All @@ -30,7 +30,7 @@ class JsiSkImageFactory : public JsiSkHostObject {
auto imageInfo = JsiSkImageInfo::fromValue(runtime, arguments[0]);
auto pixelData = JsiSkData::fromValue(runtime, arguments[1]);
auto bytesPerRow = arguments[2].asNumber();
auto image = SkImage::MakeRasterData(*imageInfo, pixelData, bytesPerRow);
auto image = SkImages::RasterFromData(*imageInfo, pixelData, bytesPerRow);
if (image == nullptr) {
return jsi::Value::null();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <jsi/jsi.h>

#include "JsiSkHostObjects.h"
#include "JsiSkMatrix.h"
#include "JsiSkPoint.h"
#include "JsiSkRRect.h"
#include "JsiSkRect.h"
Expand All @@ -20,6 +21,7 @@
#include "SkPathEffect.h"
#include "SkPathOps.h"
#include "SkPathTypes.h"
#include "SkPathUtils.h"
#include "SkString.h"
#include "SkStrokeRec.h"
#include "SkTextUtils.h"
Expand Down Expand Up @@ -289,8 +291,11 @@ class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPath> {

auto jsiPrecision = opts.getProperty(runtime, "precision");
auto precision = jsiPrecision.isUndefined() ? 1 : jsiPrecision.asNumber();
auto result = p.getFillPath(path, &path, nullptr, precision);
getObject()->swap(path);
auto result =
skpathutils::FillPathWithPaint(path, p, &path, nullptr, precision);
if (result) {
getObject()->swap(path);
}
return result ? thisValue.getObject(runtime) : jsi::Value::null();
}

Expand Down Expand Up @@ -325,8 +330,7 @@ class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPath> {

JSI_HOST_FUNCTION(toSVGString) {
SkPath path = *getObject();
SkString s;
SkParsePath::ToSVGString(path, &s);
auto s = SkParsePath::ToSVGString(path);
return jsi::String::createFromUtf8(runtime, s.c_str());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"

#include <SkBlurTypes.h>
#include <SkMaskFilter.h>

#pragma clang diagnostic pop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class JsiPathNode : public JsiDomDrawingNode,
// _path is const so we can't mutate it directly, let's replace the
// path like this:
auto p = std::make_shared<SkPath>(*_path.get());
if (!strokePaint.getFillPath(*_path.get(), p.get(), nullptr,
precision)) {
if (!skpathutils::FillPathWithPaint(*_path.get(), strokePaint,
p.get(), nullptr, precision)) {
_path = nullptr;
} else {
_path = std::const_pointer_cast<const SkPath>(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <memory>
#include <utility>

#include <SkBlurTypes.h>

namespace RNSkia {

class BoxShadowProps : public DerivedProp<SkPaint> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ cmake_minimum_required(VERSION 3.4.1)

set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSK_GL -DSK_BUILD_FOR_ANDROID -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DON_ANDROID -DONANDROID")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSK_GL -DSK_GANESH -DSK_BUILD_FOR_ANDROID -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DON_ANDROID -DONANDROID")

set (PACKAGE_NAME "reactskia")
set (PACKAGE_NAME "rnskia")
set (SKIA_LIB "skia")
set (SKIA_SVG_LIB "svg")
set (SKIA_SKSHAPER_LIB "skshaper")
Expand All @@ -31,7 +31,7 @@ link_directories(../libs/android/${ANDROID_ABI}/)

if(${REACT_NATIVE_VERSION} LESS 66)
file(
TO_CMAKE_PATH
TO_CMAKE_PATH
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
INCLUDE_JSI_CPP
)
Expand All @@ -49,16 +49,19 @@ add_library(

"${PROJECT_SOURCE_DIR}/../cpp/jsi/JsiHostObject.cpp"
"${PROJECT_SOURCE_DIR}/../cpp/jsi/JsiValue.cpp"
"${PROJECT_SOURCE_DIR}/../cpp/jsi/RuntimeLifecycleMonitor.cpp"
"${PROJECT_SOURCE_DIR}/../cpp/jsi/RuntimeAwareCache.cpp"

"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkManager.cpp"
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkJsView.cpp"
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkDomView.cpp"
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkDispatchQueue.cpp"

"${PROJECT_SOURCE_DIR}/../cpp/rnskia/dom/base/DrawingContext.cpp"
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/dom/base/ConcatablePaint.cpp"

"${PROJECT_SOURCE_DIR}/../cpp/api/third_party/CSSColorParser.cpp"

)

target_include_directories(
Expand Down Expand Up @@ -91,7 +94,7 @@ target_include_directories(
${PROJECT_SOURCE_DIR}/../cpp/rnskia/dom/base
${PROJECT_SOURCE_DIR}/../cpp/rnskia/dom/nodes
${PROJECT_SOURCE_DIR}/../cpp/rnskia/dom/props
${PROJECT_SOURCE_DIR}/../cpp/utils
${PROJECT_SOURCE_DIR}/../cpp/utils

${libfbjni_include_DIRS}
)
Expand Down
Loading

0 comments on commit 7980d26

Please sign in to comment.