Skip to content

Commit 09cae53

Browse files
authored
0.0.10 (#35)
* Add batch draw call in vue skia node update (#34) * chore: recover the lock at package ci * feat: add batch draw implement and draw call at vue skia surface and plugin * feat: update launch func of vue skia framework * test: vue playground without softlink use 0.0.10-dev.3 vue-skia * feat: upd check yml of workflow * Revert "test: vue playground without softlink use 0.0.10-dev.3 vue-skia" This reverts commit f5abcb9. * feat: upd vue-playground-without-softlink artifact * feat: upd version 0.0.10 * feat: playground without softlink ci should only pr or push
1 parent 821b60a commit 09cae53

File tree

10 files changed

+44
-25
lines changed

10 files changed

+44
-25
lines changed

.github/workflows/check.yml

+8
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,11 @@ jobs:
6767
name: soft-skia-wasm
6868
path: |
6969
soft-skia-wasm/pkg
70+
71+
- name: Archive vue-playground in monorepo artifacts
72+
uses: actions/upload-artifact@v3
73+
with:
74+
name: vue-playground
75+
path: |
76+
vue-playground
77+
!vue-playground/node_modules

.github/workflows/playground_without_softlink.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- '0\.*\.*'
87
pull_request:
98
branches:
109
- main
@@ -34,7 +33,7 @@ jobs:
3433
- name: Archive vue-playground results
3534
uses: actions/upload-artifact@v3
3635
with:
37-
name: vue-playground-use-latest
36+
name: vue-playground-without-softlink
3837
path: |
3938
vue-playground
4039
!vue-playground/node_modules

soft-skia-wasm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "soft-skia-wasm"
3-
version = "0.9.0"
3+
version = "0.10.0"
44
authors = ["meloalright <[email protected]>"]
55
edition = "2018"
66

soft-skia/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "soft_skia"
3-
version = "0.9.0"
3+
version = "0.10.0"
44
edition = "2021"
55
description="software rasterization skia binding"
66
license = "MIT"

vue-playground/package-ci.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-playground",
3-
"version": "0.9.0",
3+
"version": "0.10.0",
44
"private": true,
55
"scripts": {
66
"serve": "vue-cli-service serve",
@@ -12,9 +12,9 @@
1212
"core-js": "^3.8.3",
1313
"prism-themes": "^1.9.0",
1414
"prismjs": "^1.29.0",
15-
"vue": "3.3.4",
15+
"vue": "^3.2.13",
1616
"vue-live": "^2.5.4",
17-
"vue-skia": "0.0.9"
17+
"vue-skia": "0.0.10"
1818
},
1919
"devDependencies": {
2020
"@types/node": "^20.5.0",

vue-skia-framework/launch.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ const launch = function () {
88
if (SSWInitialHelper.initialStatus === 0) {
99
SSWInitialHelper.initialStatus = 1;
1010
const wasm = import("soft-skia-wasm/soft_skia_wasm.js");
11-
wasm.then((ssw) => {
12-
window.ssw = ssw;
13-
while (SSWInitialHelper.initialSucceedCallbackQueue.length) {
14-
SSWInitialHelper.initialSucceedCallbackQueue.pop()();
15-
}
16-
resolve(void 0)
11+
wasm.then(async (ssw) => {
12+
await ssw.default();
13+
window.ssw = ssw;
14+
while (SSWInitialHelper.initialSucceedCallbackQueue.length) {
15+
SSWInitialHelper.initialSucceedCallbackQueue.pop()();
16+
}
17+
resolve(void 0)
1718
})
1819
} else if (SSWInitialHelper.initialStatus === 1) {
1920
SSWInitialHelper.initialSucceedCallbackQueue.push(() => resolve(void 0));

vue-skia-framework/package-publish.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-skia",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"files": [
55
"lib",
66
"type.d.ts",
@@ -13,6 +13,6 @@
1313
"main": "./main.js",
1414
"module": "./main.js",
1515
"dependencies": {
16-
"soft-skia-wasm": "0.9.0"
16+
"soft-skia-wasm": "0.10.0"
1717
}
1818
}

vue-skia-framework/plugin/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const VSKNode = (name: string) => {
113113
(
114114
parent as ComponentInternalInstanceWithSoftSkiaWASM
115115
)._ssw_grouped?.(instance);
116+
root._ssw_batchDraw?.()
116117
});
117118

118119
onUpdated(() => {
@@ -123,6 +124,7 @@ const VSKNode = (name: string) => {
123124
}
124125
const core = root.ssw;
125126
updateInstance(core, name, instance, attrs);
127+
root._ssw_batchDraw?.()
126128
});
127129

128130
/**

vue-skia-framework/surface/index.ts

+18-10
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,35 @@ export default {
3333
const ssw = window.ssw;
3434
const rootID = SelfIncreaseCount.count;
3535
const core = new ssw.SoftSkiaWASM(rootID);
36+
37+
let waitingForDraw = false;
38+
3639
instance.ssw = core; // Save on component instance
3740
instance._ssw_id = rootID;
3841
core.setAttrBySerde(rootID, { attr: { R: { x: 0, y: 0, width: attrs.width, height: attrs.height, color: 'transparent', style: "fill" } } })
3942

43+
// batch draw func
44+
function batchDraw() {
45+
if (!waitingForDraw) {
46+
waitingForDraw = true;
47+
window.requestAnimationFrame(() => {
48+
const base64 = core.toBase64();
49+
container.value.setAttribute("src", base64);
50+
waitingForDraw = false;
51+
});
52+
}
53+
}
54+
instance._ssw_batchDraw = () => batchDraw();
4055

4156
onMounted(() => {
42-
const base64 = core.toBase64();
43-
container.value.setAttribute("src", base64);
57+
batchDraw();
4458
});
4559

4660
onUpdated(() => {
47-
const base64 = core.toBase64();
48-
// console.log(core.toDebug?.())
49-
container.value.setAttribute("src", base64);
61+
batchDraw();
5062
});
5163

52-
onBeforeUnmount(() => {
53-
// const instance = getCurrentInstance() as ComponentInternalInstanceWithSoftSkiaWASM;
54-
// const core = instance.ssw;
55-
// core.free();
56-
});
64+
onBeforeUnmount(() => {});
5765

5866

5967
return () => h('img', { ref: container }, slots.default?.());

vue-skia-framework/type.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type ComponentInternalInstanceWithSoftSkiaWASM = ComponentInternalInstanc
77
ssw: SoftSkiaWASM;
88
_ssw_id: number;
99
_ssw_grouped?: (instance: ComponentInternalInstanceWithSoftSkiaWASM) => void;
10+
_ssw_batchDraw?: () => void;
1011
}
1112

1213
declare global {

0 commit comments

Comments
 (0)