Ibiyemi Abiodun
474458725e
updated canvas_nanovg example
2021-06-05 18:23:10 -04:00
Patrick Walton
d01bc5d002
Make the fields of `TextMetrics` lazily calculated, and add an API that
...
eliminates double layouts.
This adds an extension to the HTML canvas API that allows you to pass the
`TextMetrics` object returned by `measure_text()` to `fill_text()` and/or
`stroke_text()` to draw the measured text without laying it out again. It
improves performance on the `canvas_nanovg` demo.
2020-07-21 19:33:15 -07:00
Patrick Walton
bb89f52d39
Cache images from frame to frame.
...
Images are cached for one frame; if they are not used the next frame, they're
freed.
2020-07-15 12:36:52 -07:00
Patrick Walton
42289eec6e
Fix Metal memory management and the `canvas_metal_minimal`, `canvas_nanovg`,
...
and `macos_app` examples.
`winit` does not create an autorelease pool, so the Metal backend had not taken
the presence of one into account. Now the Metal backend creates and flushes
autorelease pools as necessary.
Closes #334 .
Closes #376 .
2020-06-29 12:48:49 -07:00
Patrick Walton
9ff46b39cd
Update examples
2020-06-23 13:31:53 -07:00
Patrick Walton
abecb697be
Quit the NanoVG demo when pressing Escape, not any key.
...
The previous setup was making it hard to take screenshots.
2020-05-15 19:14:32 -07:00
Patrick Walton
deee2436c1
Make the NanoVG demo use the filesystem resource loader.
...
The embedded resource loader doesn't have the needed fonts.
2020-05-15 19:14:08 -07:00
Corey Farwell
e1ec307b3f
Switch to the embedded loader for the examples.
2020-05-08 21:17:23 -04:00
Patrick Walton
41c0c5f071
Upgrade to the latest master surfman
2020-05-08 12:47:58 -07:00
Patrick Walton
90fb36f199
Switch to using surfman in X11 mode.
...
Partially addresses #310 .
2020-05-08 12:22:46 -07:00
Patrick Walton
ac83f79d94
Add a compute shader path, optimize GPU memory management, and switch from SDL
...
to `surfman`.
This is a large commit; explanations of each change follow.
This adds an optional compute shader path, off by default, for rendering fills
to alpha masks. It usually does not improve performance at present, but it
provides a good baseline for further optimizations. Later improvements will
likely aim to avoid writes to the mask texture entirely. Supporting
infrastructure for compute shader has been added to `pathfinder_gpu` for the
OpenGL and Metal backends.
The Metal backend has been optimized to avoid unneccessary buffer allocations
and reflection. As part of this, argument buffers have been removed, as the
current SPIRV-Cross compiler no longer requires them.
The GPU renderer has been improved to avoid stalls. Now, separate buffers are
allocated for each fill batch and for each frame. This can be extended in the
future to allow for separate buffers for tile draw operations as well.
SDL usage has been removed in favor of the native Rust `surfman` and `winit`.
Because `surfman` allows for selection of the integrated GPU on multi-GPU
system, it is chosen by default. The demo supports a new
`--high-performance-gpu` option to opt into the discrete GPU.
2020-04-30 13:33:29 -07:00
Patrick Walton
0b43f629cd
Cache loaded fonts and glyph outlines.
...
Approximately a 70% CPU time improvement on the NanoVG demo.
2020-04-16 16:28:44 -07:00
Patrick Walton
83c05e9f77
Improve the fidelity of the NanoVG demo some more
2020-04-14 18:49:47 -07:00
Patrick Walton
b1d8e0526e
Make some shadow blurs match the original NanoVG demo better
2020-04-14 16:13:12 -07:00
Patrick Walton
39f84b287d
Make the paragraph color and line height in the NanoVG demo match the original
...
more
2020-04-14 15:21:01 -07:00
Patrick Walton
5efdf2a04a
Implement the missing pieces of `TextMetrics` for canvas.
...
This required a `font-kit` upgrade, and with it a `skribo` upgrade.
2020-04-14 15:01:30 -07:00
Patrick Walton
fda9b8b9e1
Make the clip example match the NanoVG example
2020-04-11 19:08:20 -07:00
Patrick Walton
3e9558957f
Add a shadow to the color wheel marker in the NanoVG demo
2020-04-11 19:08:00 -07:00
Patrick Walton
def7da5de2
Remove obsolete TODOs in the NanoVG demo
2020-04-11 19:07:50 -07:00
Patrick Walton
15101e90dd
Draw caret position in the NanoVG demo
2020-04-10 18:13:42 -07:00
Patrick Walton
ca0e9e9e14
Draw the paragraph gutter in the NanoVG demo
2020-04-10 16:00:25 -07:00
Patrick Walton
4f1d376fe5
Refactor paragraph layout in the NanoVG demo; fix BG/FG draw order
2020-04-10 15:30:12 -07:00
Patrick Walton
df08d76627
Make the color wheel animation in the NanoVG demo match NanoVG
2020-04-10 13:37:06 -07:00
Patrick Walton
ca36fed47b
Fix calculation of wallclock time in the NanoVG demo
2020-04-09 18:01:12 -07:00
Patrick Walton
47919db8f3
Fix frame time measurement in the GL backend, and add it to the NanoVG demo
2020-04-09 17:49:28 -07:00
Patrick Walton
19aa9c8e54
Only paint text backgrounds up to the appropriate width in the NanoVG demo
2020-04-09 12:33:16 -07:00
Patrick Walton
a196f1eff8
Fix spriting imperfections in the thumbnails in the NanoVG
2020-04-09 12:15:39 -07:00
Patrick Walton
895f73096e
Switch back to instanced drawing for tiles.
...
Improves tile build time by something around 2x in the NanoVG demo.
2020-04-08 17:16:54 -07:00
Patrick Walton
941abd202e
Add the tooltip to the NanoVG demo
2020-04-03 15:38:14 -07:00
Patrick Walton
b38f75a38d
Add line widths to the NanoVG demo
2020-04-03 14:51:37 -07:00
Patrick Walton
ad61b78e39
Remove box gradients from the NanoVG demo in favor of shadows
2020-04-03 14:33:00 -07:00
Patrick Walton
eb2b622615
Remove `draw_render_target()` in favor of the standard tile-based rendering
...
path
2020-04-03 13:05:53 -07:00
Patrick Walton
ba7fe4be39
Add the ability to merge scenes together, and expose it to the canvas API.
...
Closes #268 .
2020-04-02 14:04:58 -07:00
Patrick Walton
5d43eedf20
Replace a drop shadow with a box gradient
2020-04-02 11:59:35 -07:00
Patrick Walton
542d2c27fa
Add `translate`, `rotate`, and `scale` methods to `CanvasRenderingContext2D`.
2020-04-02 11:40:53 -07:00
Patrick Walton
8f2fabbc47
Add icons to the NanoVG demo from Noto Emoji
2020-04-01 20:20:32 -07:00
Patrick Walton
e05b5df562
Stop duplicating font names everywhere in the NanoVG demo
2020-04-01 17:31:16 -07:00
Patrick Walton
da9b944e77
Clean up a few uses of `RectF::contract()` and `RectF::dilate()`
2020-04-01 17:27:08 -07:00
Patrick Walton
794dd55038
Add some implicit conversions between scalars and vectors where appropriate
2020-04-01 17:20:32 -07:00
Patrick Walton
40bd13aa5a
Add convenience color construction methods
2020-04-01 16:37:36 -07:00
Patrick Walton
ae97ccea5a
Improve ergonomics of the canvas font interface, and use the right fonts in the
...
NanoVG demo.
2020-04-01 16:25:13 -07:00
Patrick Walton
7c5c43b50f
Use HiDPI and a larger window size in the NanoVG demo
2020-03-31 20:18:25 -07:00
Patrick Walton
bbcd371efc
Show the progress spinners behind thumbnail images in the NanoVG demo
2020-03-31 17:14:06 -07:00
Patrick Walton
2db4cfcfed
Uncomment round join code in the NanoVG demo now that it doesn't crash
2020-03-31 13:32:23 -07:00
Patrick Walton
93f5fbc6d2
Add convenience constructors: `vec2f`, `vec2i`, `Vector2F::zero()`,
...
`Vector2I::zero()`
2020-03-31 11:29:21 -07:00
Patrick Walton
4af74f225d
Add support to canvas for the commonly-used `textBaseline` values
2020-03-30 22:00:13 -07:00
Patrick Walton
9a0fbe1d11
Flesh out the NanoVG demo yet more
2020-03-30 21:33:20 -07:00
Patrick Walton
a1f0ae097a
Add thumbnail images to the NanoVG demo
2020-03-30 16:18:41 -07:00
Patrick Walton
257067e368
Flesh out the NanoVG example even more
2020-03-28 12:45:23 -07:00
Patrick Walton
ed2807eb84
Flesh out the NanoVG demo some more
2020-03-27 20:53:57 -07:00
Patrick Walton
55df287fec
Move radial gradients from the CPU to the GPU
2020-03-26 21:24:20 -07:00
Patrick Walton
f607b607b0
Composite render targets using tiles, taking the Z-buffer into account.
...
We can do more tile-based optimization, but this should be enough to ensure a
correct rendering.
This temporarily breaks subpixel AA, but it should be fixable by modifying
`blur.fs.glsl`.
Closes #271 .
2020-03-02 20:10:10 -08:00
Patrick Walton
0f35d9c817
Add an embedded resource loader that places resources directly in the binary.
...
This is useful for WebGL and for downstream crates.io use.
2020-02-28 17:10:53 -08:00
Patrick Walton
5421525eaa
Implement the HSL filters (called "non-separable blend modes" in the spec).
...
These cannot be implemented with the standard OpenGL blending functions, so we
have to do them manually in a shader, which requires a good deal of machinery
to create intermediate framebuffers and so forth.
2020-02-24 15:37:44 -08:00
Patrick Walton
3245796445
Add support for multiple paint texture pages.
...
This avoids arbitrary limits on the number of images, gradients, etc. you can
have.
2020-02-21 14:46:10 -08:00
Patrick Walton
25f9346160
Add an incomplete port of the NanoVG example app
2020-02-19 11:00:03 -08:00