Skip to content

Commit 0475a3a

Browse files
authored
Merge pull request samizdatco#108 from samizdatco/gpu-window
Add support for GUI windows, animation, and interactivity
2 parents 4d55e61 + 8e112d2 commit 0475a3a

30 files changed

+3387
-372
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,11 @@ jobs:
2727
with:
2828
path: skia-canvas
2929

30-
- name: Determine current upstream version
31-
id: rust-skia
32-
run: |
33-
export TAG=$(make -sC skia-canvas skia-version)
34-
echo "::set-output name=VERSION::$TAG"
35-
36-
- name: Checkout rust-skia
37-
if: ${{ matrix.libc == 'musl' }}
38-
uses: actions/checkout@v2
39-
with:
40-
repository: rust-skia/rust-skia
41-
ref: ${{ steps.rust-skia.outputs.VERSION }}
42-
submodules: true
43-
path: rust-skia
44-
45-
- name: Patch build files
46-
if: ${{ matrix.libc == 'musl' }}
47-
run: |
48-
patch -p0 < /code/alpine-build.patch
49-
make -sC skia-canvas with-local-skia
50-
5130
- name: Build module
5231
run: |
5332
cd skia-canvas
5433
npm ci --ignore-scripts
55-
npm run build -- --release --features skia-safe/embed-freetype
34+
npm run build -- --release --features vulkan,window,skia-safe/embed-freetype
5635
5736
- name: Package module
5837
run: |
@@ -99,7 +78,7 @@ jobs:
9978
SERVER: ${{ github.server_url }}
10079
REPO: ${{ github.repository }}
10180
run: |
102-
git clone --depth 1 ${SERVER}/${REPO} skia-canvas
81+
git clone --depth 1 --branch ${GITHUB_REF_NAME} ${SERVER}/${REPO} skia-canvas
10382
export TAG=$(make -sC skia-canvas skia-version)
10483
make -sC skia-canvas with-local-skia
10584
echo "::set-output name=VERSION::$TAG"
@@ -111,11 +90,6 @@ jobs:
11190
git submodule update --init --depth 1 skia-bindings/skia
11291
git submodule update --init --depth 1 skia-bindings/depot_tools
11392
114-
- name: Apply patches
115-
if: ${{ matrix.libc == 'musl' }}
116-
run: |
117-
patch -p0 < /code/alpine-build.patch
118-
11993
- name: Use system GN
12094
if: ${{ matrix.libc == 'musl' }}
12195
run: |
@@ -125,7 +99,7 @@ jobs:
12599
run: |
126100
cd skia-canvas
127101
npm ci --ignore-scripts
128-
npm run build -- --release --features skia-safe/embed-freetype
102+
npm run build -- --release --features vulkan,window,skia-safe/embed-freetype
129103
130104
- name: Package module
131105
run: |
@@ -196,7 +170,7 @@ jobs:
196170
run: |
197171
cd skia-canvas
198172
npm ci --ignore-scripts
199-
npm run build -- --release --features skia-safe/embed-freetype
173+
npm run build -- --release --features vulkan,window,skia-safe/embed-freetype
200174
201175
- name: Package module
202176
run: |
@@ -234,7 +208,7 @@ jobs:
234208
MACOSX_DEPLOYMENT_TARGET: 10.13
235209
run: |
236210
npm ci --ignore-scripts
237-
npm run build -- --release
211+
npm run build -- --release --features metal,window
238212
239213
- name: Package module
240214
run: |
@@ -277,7 +251,7 @@ jobs:
277251
MACOSX_DEPLOYMENT_TARGET: 11.1
278252
run: |
279253
npm ci --ignore-scripts
280-
npm run build -- --release --target aarch64-apple-darwin
254+
npm run build -- --release --features metal,window --target aarch64-apple-darwin
281255
sed -i.bak 's/"package_name":.*/"package_name": "{platform}-arm64-{node_napi_label}-{libc}.tar.gz",/' package.json
282256
npm run package
283257
@@ -309,7 +283,7 @@ jobs:
309283
- name: Build module
310284
run: |
311285
npm ci --ignore-scripts
312-
npm run build -- --release
286+
npm run build -- --release --features vulkan,window
313287
314288
- name: Package module
315289
run: |

.github/workflows/test.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,17 @@ jobs:
3535
with:
3636
toolchain: stable
3737

38-
- name: Build module
38+
- name: Build for Metal
39+
if: ${{ matrix.os == 'macos-latest' }}
3940
run: |
4041
npm ci --ignore-scripts
41-
npm run build -- --release
42+
npm run build -- --release --features metal,window
43+
44+
- name: Build for Vulkan
45+
if: ${{ matrix.os != 'macos-latest' }}
46+
run: |
47+
npm ci --ignore-scripts
48+
npm run build -- --release --features vulkan,window
4249
4350
- name: Run tests
4451
run: npm test

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
## 🥚 ⟩ [Unreleased]
44

55
### New Features
6-
- Rendering now occurs on the GPU by default and can be configured using the **Canvas**'s [`.gpu`][canvas_gpu] property. If the platform supports hardware-accelerated rendering (using Metal on macOS and Vulkan on Linux & Windows), the property will be `true` by default and can be set to `false` to use the software renderer.
6+
- The new [Window][window] class can display a **Canvas** on screen, respond to mouse and keyboard input, and fluidly [animate][window_anim] by calling user-defined [event handlers][window_events].
7+
- Bitmap rendering now occurs on the GPU by default and can be configured using the **Canvas**'s [`.gpu`][canvas_gpu] property. If the platform supports hardware-accelerated rendering (using Metal on macOS and Vulkan on Linux & Windows), the property will be `true` by default and can be set to `false` to use the software renderer.
8+
- Added support for recent Chrome features:
9+
- the [`reset()`][chrome_reset] context method which erases the canvas, resets the transformation state, and clears the current path
10+
- the [`roundRect()`][chrome_rrect] method on contexts and **Path2D** objects which adds a rounded rectangle using 1–4 corner radii (provided as a single value or an array of numbers and/or **DOMPoint** objects)
711

812
### Bugfixes
913
- The `FontLibrary.reset()` method didn't actually remove previously installed fonts that had already been drawn with (and thus cached). It now clears those caches, which also means previously used fonts can now be replaced by calling `.use()` again with the same family name.
@@ -12,9 +16,16 @@
1216
### Misc. Improvements
1317
- The [`.filter`][filter] property's `"blur(…)"` and `"drop-shadow(…)"` effects now match browser behavior much more closely and scale appropriately with the `density` export option.
1418
- Antialiasing is smoother, particularly when down-scaling images, thanks to the use of mipmaps rather than Skia's (apparently buggy?) implementation of bucubic interpolation.
19+
- Calling `clearRect()` with dimensions that fully enclose the canvas will now discard all the vector objects that have been drawn so far (rather than simply covering them up).
20+
- Upgraded Skia to milestone 103
1521

22+
[window]: https://github.com/samizdatco/skia-canvas#window
23+
[window_anim]: https://github.com/samizdatco/skia-canvas#events--animation
24+
[window_events]: https://github.com/samizdatco/skia-canvas#on--off--once
1625
[canvas_gpu]: https://github.com/samizdatco/skia-canvas#gpu
1726
[filter]: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter
27+
[chrome_reset]: https://developer.chrome.com/blog/canvas2d/#context-reset
28+
[chrome_rrect]: https://developer.chrome.com/blog/canvas2d/#round-rect
1829

1930
## 📦 ⟩ [v0.9.30] ⟩ Jun 7, 2022
2031

0 commit comments

Comments
 (0)