Skip to content

Commit

Permalink
feat: upgrade to chrome/m103 (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn authored May 29, 2022
1 parent 6dfbfa6 commit 1f73a77
Show file tree
Hide file tree
Showing 19 changed files with 1,192 additions and 1,191 deletions.
785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

786 changes: 786 additions & 0 deletions .yarn/releases/yarn-3.2.1.cjs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
yarnPath: .yarn/releases/yarn-3.2.0.cjs
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.2.1.cjs
20 changes: 14 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ crate-type = ["cdylib"]
anyhow = "1"
base64 = "0.13"
cssparser = "0.29"
napi = {version = "2", default-features = false, features = ["napi3", "serde-json", "compat-mode"]}
napi-derive = {version = "2", default-features = false, features = ["compat-mode"]}
napi = { version = "2", default-features = false, features = [
"napi3",
"serde-json",
"compat-mode",
] }
napi-derive = { version = "2", default-features = false, features = [
"compat-mode",
] }
nom = "7"
once_cell = "1"
ravif = "0.8"
Expand All @@ -23,14 +29,16 @@ serde_derive = "1"
serde_json = "1"
thiserror = "1"

[target.'cfg(all(target_arch = "x86_64", not(target_env = "musl")))'.dependencies]
mimalloc-rust = "0.1"
[target.'cfg(not(target_os = "linux"))'.dependencies]
mimalloc-rust = "0.2"

[target.'cfg(all(target_os = "linux", not(all(target_env = "musl", target_arch = "aarch64"))))'.dependencies]
mimalloc-rust = { version = "0.2", features = ["local-dynamic-tls"] }

[build-dependencies]
cc = "1"
napi-build = "1"
napi-build = "2"

[profile.release]
codegen-units = 1
lto = true
panic = "unwind"
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `skr canvas`

![CI](https://github.com/Brooooooklyn/canvas/workflows/CI/badge.svg)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm101-hotpink)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm103-hotpink)
[![install size](https://packagephobia.com/badge?p=@napi-rs/canvas)](https://packagephobia.com/result?p=@napi-rs/canvas)
[![Downloads](https://img.shields.io/npm/dm/@napi-rs/canvas.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/canvas?minimal=true)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `skr canvas`

![CI](https://github.com/Brooooooklyn/canvas/workflows/CI/badge.svg)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm101-hotpink)
![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm103-hotpink)
[![install size](https://packagephobia.com/badge?p=@napi-rs/canvas)](https://packagephobia.com/result?p=@napi-rs/canvas)
[![Downloads](https://img.shields.io/npm/dm/@napi-rs/canvas.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/canvas?minimal=true)

Expand Down
2 changes: 1 addition & 1 deletion __test__/svg-canvas.spec.ts.md

Large diffs are not rendered by default.

Binary file modified __test__/svg-canvas.spec.ts.snap
Binary file not shown.
5 changes: 2 additions & 3 deletions __test__/svg.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { join } from 'path'
import { readFileSync, promises as fs } from 'fs'
import { platform } from 'os'

import test from 'ava'

Expand All @@ -14,8 +13,8 @@ test('convertSVGTextToPath should work', async (t) => {
const result = convertSVGTextToPath(FIXTURE)
const outputPath = join(__dirname, 'text-to-path.svg')
const output = await fs.readFile(outputPath, 'utf8')
if (platform() === 'win32') {
t.true(result.toString('utf8').length > 13000)
if (process.platform === 'win32') {
t.pass('Skip on windows')
} else {
t.deepEqual(result.toString('utf8'), output)
}
Expand Down
14 changes: 7 additions & 7 deletions __test__/text-to-path.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn main() {
println!("cargo:rustc-link-lib=static=svg");
println!("cargo:rustc-link-lib=static=skia");
println!("cargo:rustc-link-lib=static=skiac");
println!("cargo:rustc-link-lib=skparagraph");
println!("cargo:rustc-link-lib=static=skparagraph");
println!("cargo:rustc-link-lib=skshaper");
println!("cargo:rustc-link-lib=static=skunicode");
}
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,34 @@
"@jimp/custom": "^0.16.1",
"@jimp/jpeg": "^0.16.1",
"@jimp/png": "^0.16.1",
"@napi-rs/cli": "^2.6.2",
"@napi-rs/cli": "^2.9.0",
"@octokit/rest": "^18.12.0",
"@swc-node/register": "^1.4.2",
"@types/lodash": "^4.14.181",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"ava": "^4.1.0",
"@swc-node/register": "^1.5.1",
"@types/lodash": "^4.14.182",
"@types/node": "^17.0.35",
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"ava": "^4.2.0",
"benny": "^3.7.1",
"canvas": "^2.9.1",
"canvaskit-wasm": "^0.34.0",
"colorette": "^2.0.16",
"conventional-changelog-cli": "^2.2.2",
"echarts": "^5.3.2",
"eslint": "^8.12.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-sonarjs": "^0.13.0",
"husky": "^8.0.0",
"lint-staged": "^12.3.7",
"husky": "^8.0.1",
"lint-staged": "^12.4.2",
"lodash": "^4.17.21",
"npm-run-all": "^4.1.5",
"pinst": "^3.0.0",
"png.js": "^0.2.1",
"prettier": "^2.6.2",
"putasset": "^6.0.0",
"skia-canvas": "^0.9.29",
"typescript": "^4.6.3"
"typescript": "^4.7.2"
},
"lint-staged": {
"*.@(js|ts|tsx|yml|yaml|md|json)": [
Expand Down Expand Up @@ -123,5 +123,5 @@
"singleQuote": true,
"arrowParens": "always"
},
"packageManager": "yarn@3.2.0"
"packageManager": "yarn@3.2.1"
}
2 changes: 2 additions & 0 deletions scripts/build-skia.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const GN_ARGS = [
`skia_use_freetype=true`,
`skia_use_freetype_woff2=true`,
`skia_use_fontconfig=false`,
`skia_use_x11=false`,
`skia_use_wuffs=true`,
`skia_use_system_freetype2=false`,
`skia_use_system_libjpeg_turbo=false`,
`skia_use_system_libpng=false`,
Expand Down
65 changes: 41 additions & 24 deletions scripts/release-skia-binary.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { execSync } = require('child_process')
const { promises: fs, copyFileSync } = require('fs')
const { promises: fs, copyFileSync, createReadStream, statSync } = require('fs')
const { platform } = require('os')
const { parse, join } = require('path')

Expand All @@ -26,32 +26,33 @@ const CLIENT = new Octokit({
})

async function upload() {
const putasset = require('putasset')
let release_id
let assets = []
try {
console.info(green(`Fetching release by tag: [${TAG}]`))
assets = (
await CLIENT.repos.getReleaseByTag({
repo: REPO,
owner: OWNER,
tag: TAG,
})
).data.assets
const release = await CLIENT.repos.getReleaseByTag({
repo: REPO,
owner: OWNER,
tag: TAG,
})
release_id = release.data.id
assets = release.data.assets
} catch (e) {
if (e.status === 404) {
console.info(green(`No release tag, creating release tag ${TAG}`))
await CLIENT.repos.createRelease({
const release = await CLIENT.repos.createRelease({
repo: REPO,
owner: OWNER,
tag_name: TAG,
name: TAG,
})
release_id = release.data.id
} else {
throw e
}
}
for (const lib of LIB) {
const { copy, binary } = libPath(lib, PLATFORM_NAME, TARGET_TRIPLE)
const { copy, binary, filename } = libPath(lib, PLATFORM_NAME, TARGET_TRIPLE)
console.info(green(`Copy [${binary}] to [${copy}]`))
await fs.copyFile(binary, copy)
console.info(green(`Uploading [${copy}] to github release: [${TAG}]`))
Expand All @@ -65,16 +66,25 @@ async function upload() {
asset_id: asset.id,
})
}
await putasset(process.env.GITHUB_TOKEN, {
owner: OWNER,
repo: REPO,
tag: TAG,
filename: copy,
}).catch((e) => {
execSync(`ls -la ./skia/out/Static`, { stdio: 'inherit' })
execSync(`ls -la .`, { stdio: 'inherit' })
throw e
})
const dstFileStats = statSync(copy)
await CLIENT.repos
.uploadReleaseAsset({
owner: OWNER,
repo: REPO,
name: filename,
release_id,
mediaType: { format: 'raw' },
headers: {
'content-length': dstFileStats.size,
'content-type': 'application/octet-stream',
},
data: createReadStream(copy),
})
.catch((e) => {
execSync(`ls -la ./skia/out/Static`, { stdio: 'inherit' })
execSync(`ls -la .`, { stdio: 'inherit' })
throw e
})
}
if (PLATFORM_NAME === 'win32') {
const icudtl = assets.find(({ name }) => name === ICU_DAT)
Expand All @@ -87,11 +97,18 @@ async function upload() {
})
}
console.info(green(`Uploading [${ICU_DAT}] to github release: [${TAG}]`))
await putasset(process.env.GITHUB_TOKEN, {
const icuDataPath = join(__dirname, '..', 'skia', 'out', 'Static', ICU_DAT)
await await CLIENT.repos.uploadReleaseAsset({
owner: OWNER,
repo: REPO,
tag: TAG,
filename: join(__dirname, '..', 'skia', 'out', 'Static', ICU_DAT),
name: ICU_DAT,
release_id,
mediaType: { format: 'raw' },
headers: {
'content-length': statSync(icuDataPath).size,
'content-type': 'application/octet-stream',
},
data: createReadStream(icuDataPath),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const TAG = `skia-${SHORT_HASH}`
* @param {string} lib Static lib name
* @param {string} hostPlatform require('os').platform()
* @param {string | undefined} triple rust target triple
* @returns {{ binary: string; copy: string; downloadUrl: string }}
* @returns {{ binary: string; copy: string; downloadUrl: string; filename: string }}
*/
function libPath(lib, hostPlatform, triple, tag = TAG) {
let platformName
Expand Down Expand Up @@ -61,7 +61,7 @@ function libPath(lib, hostPlatform, triple, tag = TAG) {

const copy = join(__dirname, '..', platformName)
const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${tag}/${platformName}`
return { binary, copy, downloadUrl }
return { binary, copy, downloadUrl, filename: platformName }
}

module.exports = { libPath, OWNER, REPO, TAG }
2 changes: 1 addition & 1 deletion skia
Submodule skia updated 3067 files
16 changes: 10 additions & 6 deletions skia-c/skia_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,19 @@ extern "C"
paragraph->getLineMetrics(metrics_vec);
auto line_metrics = metrics_vec[0];
auto run = paragraph->run(0);
auto first_char_bounds = run.getBounds(0);
auto glyphs = run.glyphs();
auto font = run.font();
auto glyphs_size = glyphs.size();
SkRect bounds[glyphs_size];
font.getBounds(glyphs.data(), glyphs_size, &bounds[0], nullptr);
auto first_char_bounds = bounds[0];
auto descent = first_char_bounds.fBottom;
auto ascent = first_char_bounds.fTop;
auto run_size = run.size();
auto last_char_bounds = run.getBounds(run_size - 1);
auto last_char_pos_x = run.positionX(run_size - 1);
for (size_t i = 1; i <= run_size - 1; ++i)
auto last_char_bounds = bounds[glyphs_size - 1];
auto last_char_pos_x = run.positionX(glyphs_size - 1);
for (size_t i = 1; i <= glyphs_size - 1; ++i)
{
auto char_bounds = run.getBounds(i);
auto char_bounds = bounds[i];
auto char_bottom = char_bounds.fBottom;
if (char_bottom > descent)
{
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ use rgb::FromSlice;
use sk::SkiaDataRef;

#[cfg(all(
target_arch = "x86_64",
not(target_env = "musl"),
not(all(target_os = "linux", target_env = "musl", target_arch = "aarch64")),
not(debug_assertions)
))]
#[global_allocator]
Expand Down
Loading

0 comments on commit 1f73a77

Please sign in to comment.