Commit Graph

156 Commits

Author SHA1 Message Date
Patrick Walton bbf4c88d0d Add an example showing how to use the Pathfinder C API with GLFW
Closes #258.
2020-05-08 15:09:21 -07: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 da2f65ddf4 Fix `surfman` reference in `Cargo.toml` 2020-04-30 15:04:49 -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 956b9020e8 Rename `overpass-regular.otf` to `Overpass-Regular.otf` 2020-04-01 13:22:29 -07:00
Patrick Walton cedc5595db Fix `canvas_moire` 2020-04-01 13:03:58 -07:00
Patrick Walton bf6890b341 Fix `canvas_minimal` 2020-03-31 20:21:27 -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 9723fa441b Update `image`, `glutin`, and `jni` crates.
From #277.
2020-03-27 15:49:26 -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 4933efb513 Add Lighten and Darken composite ops 2020-02-20 20:38:43 -08:00
Patrick Walton 25f9346160 Add an incomplete port of the NanoVG example app 2020-02-19 11:00:03 -08:00
Emmanuel Gil Peyrot 6ce416e77c Bump all outdated dependencies
I’m pleasantly surprised that none of these required any (visible) code
change, but tests pass so let’s go with that. :)
2020-02-06 09:39:50 +01:00
Emmanuel Gil Peyrot 03e3a9fded Bump glutin dependency in the example
The API of winit has changed quite a lot in their 0.20 release.
2020-02-06 09:39:50 +01:00
Emmanuel Gil Peyrot fb22aafada Update swf-related crates
swf-tree got renamed into swf-types for their 0.10 release.
2020-02-06 09:39:50 +01:00
Patrick Walton 2db43797c3 Split colors out into their own crate.
A lot of downstream consumers of `pathfinder_gpu` want to use colors without
the path stuff.
2020-01-31 09:17:04 +01:00
Patrick Walton 0662f6433f Allow any texture format to be uploaded; fix Metal compilation on newer rustcs 2019-12-20 11:48:51 -08:00
Kamal Ahmad 29713c5cd9 Bump lyon, font-kit and skribo versions to fix crashes 2019-11-20 22:51:03 +05:00
est31 3928e8d964 Rename the feature text → pf-text 2019-08-05 22:49:08 +02:00
est31 fa1a32bdbb Make text rendering optional in pathfinder_canvas 2019-07-27 06:13:02 +02:00
Patrick Walton 2c984de1ea Add convenience translation, rotation, and scaling methods to `Transform2D` 2019-07-12 11:34:48 -07:00
Patrick Walton 1eb28a5539 Fix incorrect definition of 2D transform multiplication 2019-07-12 11:26:09 -07:00
Patrick Walton bcac119324 Rename `Transform2DF` to `Transform2F` and `Transform3DF` to `Transform4F` 2019-07-11 14:59:10 -07:00
Patrick Walton 4d866f4a75 Move `svg2pdf` to `utils/` 2019-06-24 23:05:09 -07:00
Patrick Walton ad858564a9 Add a minimal macOS example app using the C Metal API 2019-06-24 23:03:37 -07:00
Patrick Walton a8d20cb37f Add transform support to the C API, and fix build problems 2019-06-24 14:03:26 -07:00
Sebastian Köln 0e08bc6696 fix warning 2019-06-24 20:20:15 +03:00
Sebastian Köln 0a5c4007f9 merge with master 2019-06-24 18:31:13 +03:00
Patrick Walton 2c49a3360e Add Metal support to the C API 2019-06-21 13:37:17 -07:00
Patrick Walton 1caad35b46 Use `cbindgen` instead of hand-writing a header file 2019-06-21 11:35:18 -07:00
Patrick Walton 431dcf3d2e Rename `pathfinder_geometry::basic` to simply `pathfinder_geometry`, and move
the remaining code in that crate to a new crate, `pathfinder_content`

The old hierarchy was confusing.
2019-06-21 10:06:19 -07:00
Patrick Walton b16300bf02 Move the SWF assets into `resources/`. 2019-06-21 09:32:48 -07:00
Patrick Walton 336f2ca302 Rename `pathfinder_flash` to `pathfinder_swf` for consistency with other crates
in the Rust Flash ecosystem
2019-06-21 09:28:15 -07:00
Patrick Walton 82b0826407 Merge remote-tracking branch 'hardiesoft/swf_renderer' 2019-06-21 09:25:00 -07:00
Patrick Walton 0012f09eeb Fix examples 2019-06-20 21:43:57 -07:00
Jon Hardie 4d53ab60fc [WIP] Updating to master 2019-06-21 11:10:26 +12:00
Jon Hardie ba1ff45cb2 Merge branch 'master' of https://github.com/servo/pathfinder into swf_renderer 2019-06-21 10:58:52 +12:00
Patrick Walton 487577a11b Add Metal support.
This commit substantially reworks the `pathfinder_gpu` API to better support
modern APIs like Metal. It should open the door to `gfx-rs`, `wgpu`, Vulkan,
and D3D12 backends relatively straightforwardly.

A new example, `canvas_metal_minimal`, has been added.

Note that the new Metal shaders require a patched version of `spirv-cross` to
build properly. An upstream patch is forthcoming.
2019-06-20 11:47:22 -07:00
Sebastian Köln 4039658155 add a simple PDF export 2019-06-15 17:50:25 +03:00
Jon Hardie 96f0ed0926 Merge branch 'master' of https://github.com/servo/pathfinder into swf_renderer 2019-06-15 16:22:45 +12:00
Jon Hardie 5d698998e9 [WIP] Initial support for rendering graphic symbols from swf files. 2019-06-15 16:08:46 +12:00
Patrick Walton 5dfe14ebc4 Add a minimal `glutin` example 2019-06-12 10:50:24 -07:00
Patrick Walton a1b0df0a42 Rename `Point2DF` to `Vector2F`, `Point3DF` to `Vector4F`, and `LineSegmentF`
to `LineSegment2F`.

Straw poll on Twitter suggested that these names were preferred.
2019-06-03 12:39:29 -07:00
Patrick Walton 95f3337c6f Add the `ellipse` method to canvas paths 2019-05-30 17:24:12 -07:00
Patrick Walton 607a518544 Implement canvas text align 2019-05-30 15:08:15 -07:00
Patrick Walton 9138e1e0bb Pass in the font context to the canvas rendering context constructor so that it
can be reused.

Creating a system font source can do I/O on some platforms, so obviously we
don't want to do it every frame.
2019-05-29 21:15:42 -07:00
Patrick Walton e1bcc11ace Change the `F32` and `I32` suffixes to `F` and `I` to match the C API.
They're shorter and less noisy.
2019-05-29 19:17:16 -07:00
Patrick Walton a75b635722 Implement round joins 2019-05-29 19:09:15 -07:00
Patrick Walton e04cc273ee Add enough C bindings to recreate `canvas_minimal` in C.
Closes #12.
2019-05-25 20:21:38 -07:00
Patrick Walton 8c4f05ce39 Initial rudimentary Lottie parsing code 2019-05-23 18:03:09 -07:00
Patrick Walton 6eab3fa2d8 Implement `globalAlpha` for canvas 2019-05-14 18:26:10 -07:00
Patrick Walton 7518fa65c0 Update dependencies 2019-05-13 18:47:19 -07:00
Patrick Walton 89ca998fa8 Add a convenience method for creating a scene proxy with an empty scene.
This makes animation rendering loops a bit easier for users.
2019-05-13 18:29:57 -07:00
Patrick Walton f24d93819b Add arc building methods and switch the Moiré demo to use them.
Also, stop taking points by reference in many methods, for consistency.
2019-05-13 12:42:13 -07:00
Patrick Walton 639a8f39e8 Add Moiré demo 2019-05-11 11:53:50 -07:00
Patrick Walton a078766dc6 Implement basic text rendering in canvas with `skribo` and `font-kit`.
Skribo currently writes some debugging info to standard output. A patch is
forthcoming to fix that.
2019-05-09 15:21:18 -07:00
Patrick Walton 9de7d95d33 Start a simple HTML canvas-like API, and add a minimal example to show how to
use it.
2019-05-03 14:15:38 -07:00