Commit Graph

186 Commits

Author SHA1 Message Date
Sebastian K 7b244cad68 Add `recip`, `angle` and `angle_between` methods to `Vector2F` 2020-06-24 17:57:37 -07:00
Patrick Walton b8055c38c1 Update `pathfinder_geometry` 2020-06-23 13:15:59 -07:00
Patrick Walton 440510a126 Add an `abs` method to `Vector2F` 2020-05-15 19:11:39 -07:00
Patrick Walton 3433545a76 Minor cleanup in the `line_segment` module 2020-05-15 19:10:56 -07:00
Patrick Walton c61f3e5ae8 Add some new operators to `RectI` 2020-05-15 19:08:39 -07:00
Corey Farwell e993e350e2 Implement {Add,Sub,Mul}Assign for RectF 2020-05-08 21:25:45 -04:00
Patrick Walton 6c996981a3 Fix some transform issues and implement transformed radial gradients in SVG.
In particular, this fixes the usvg-to-Pathfinder transform conversion and the
definition of `Transform2F::row_major()`.

Makes `drops.svg` from the MPVG samples work.
2020-04-20 16:40:02 -07:00
Patrick Walton 1cd5966d3d Publish `pathfinder_content` and `pathfinder_renderer` to crates.io 2020-04-17 13:23:45 -07:00
Patrick Walton 15101e90dd Draw caret position in the NanoVG demo 2020-04-10 18:13:42 -07:00
Patrick Walton e598249186 Use column vector length to extract scale from matrices.
Closes #298.
2020-04-10 13:38:25 -07:00
Patrick Walton 0399061a70 Bump versions of `pathfinder_simd` and `pathfinder_geometry` 2020-04-09 10:31:18 -07:00
Patrick Walton 205a63340c
Merge pull request #296 from servo/jdm-patch-1
Add arm64 CI and fix build errors
2020-04-09 10:28:55 -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
Josh Matthews 3a8339fece
Allow dividing a Vector2F by an f32 value. 2020-04-07 15:36:46 -04:00
Patrick Walton 404d536254 Add some more operators to rects and vectors 2020-04-02 11:59:11 -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 40377d657a Prevent taking the square root of a negative number in the half-angle formula 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 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 0b0c45a49a Collapse linear gradients down to a single 256x1 sliver instead of a 256x256
square
2020-03-05 16:58:26 -08:00
Patrick Walton fd070d7a24 Start an `angle` module in `pathfinder_geometry` 2020-02-19 10:59:40 -08:00
Patrick Walton df150dea8a Add a method to fetch the center of a rect 2020-02-18 14:36:10 -08:00
Patrick Walton 90445bac7e Implement basic support for non-repeating image patterns. 2020-02-11 17:20:21 -08:00
Patrick Walton aad467e716 Implement basic radial gradients.
This doesn't handle the case where the circles are not concentric yet.
2020-02-10 22:15:50 -08:00
Patrick Walton 5a21557a6d Implement basic linear gradients.
This is not a very efficient implementation yet, but it seems to work.
2020-02-10 16:01:05 -08:00
Patrick Walton 740597d886
Merge pull request #254 from arturoc/remove-log-restriction
Remove log restriction
2020-02-06 08:38:08 -08:00
Patrick Walton a66ed4c073 Specify tile texture coordinates as an affine transform.
Part of the groundwork for gradients.
2020-02-05 13:59:32 -08:00
Arturo Castro 7213b3e1cb Remove log restriction
pathfinder-geometry enabled a log feature that restricts logging
to warn for any binary using it.
2020-01-28 12:07:03 +01:00
Patrick Walton 5ea86ccba8 Bump `pathfinder_geometry` and `pathfinder_simd` to version 0.4 2020-01-23 18:24:56 -08:00
Patrick Walton 3f72847294 Add a few missing methods to geometry and SIMD; fix SIMD tests 2020-01-14 21:31:22 -08:00
Patrick Walton 986792349f Use the SSE2 `_mm_movemask_ps` on x86 instead of the SSE4.1 `_mm_test_all_ones`
and `_mm_test_all_zeros`.

Partially addresses #241.
2019-12-29 12:13:58 -08:00
Patrick Walton 9124d9856a Add some more methods to 3D vectors, and a `gluLookAt()` workalike 2019-12-18 15:19:42 -08:00
Patrick Walton 8dabd0a7ea Add RGBA32F support 2019-12-14 13:58:02 -08:00
Patrick Walton 521ab3b5ba Add a 3D vector type 2019-12-07 11:52:35 -08:00
Patrick Walton 9260dbce93 Fix Cargo.toml in `pathfinder_geometry` 2019-11-10 10:33:34 -08:00
Patrick Walton 586d974b7d Update `Cargo.toml`s in preparation for publishing SIMD and geometry 2019-11-10 10:32:41 -08:00
Patrick Walton ff212dce36 Add 2D matrix uniform types and a couple more useful geometry methods 2019-11-10 10:28:20 -08:00
Patrick Walton 652a03eb2b Fix tests 2019-07-12 12:00:49 -07:00
Patrick Walton e9c3fe6f31 Allow overloaded `*` to work between transforms and line segments and
transforms and rects
2019-07-12 11:59:04 -07:00
Patrick Walton 437eda96da Overload `*` between transforms and points 2019-07-12 11:55:01 -07: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 96758dfc17 Add `rotate` and `scale` methods to `Transform4F` 2019-07-11 15:57:45 -07:00
Patrick Walton 3f91206d57 Add a `translate` method to 3D transforms 2019-07-11 15:44:01 -07:00
Patrick Walton bcac119324 Rename `Transform2DF` to `Transform2F` and `Transform3DF` to `Transform4F` 2019-07-11 14:59:10 -07:00
Patrick Walton 55825cbc6a Switch scale and translation constructors for `Transform3DF` over to use vectors 2019-07-11 14:58:45 -07:00
Patrick Walton eb0a61679d Use operator overloading for 3D matrix multiplication 2019-07-11 13:59:39 -07:00
Patrick Walton b886c157c1 Use 2-lane instead of 4-lane SIMD types for 2D vectors.
Also, this commit rewrites the `add_fill()` method to stop using shuffle
instructions, which can be slow and make the code overly complicated. The
shuffle instructions have been removed from the various SIMD backends.
2019-06-26 16:38:37 -07:00
Patrick Walton 222fa89b23 Use a 3D transform in the tile vertex shaders.
This opens the door to caching tiles at different zoom levels (issue #191).
2019-06-25 11:32:39 -07:00
Patrick Walton a8d20cb37f Add transform support to the C API, and fix build problems 2019-06-24 14:03:26 -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 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
Alan Jeffrey a507e1955e Set the scene transform by linear iterpolation of the eye transforms 2019-06-07 12:02:30 -05:00
Patrick Walton 7973148603 Implement basic shadows (no blur yet) 2019-06-03 21:09:04 -07:00
Patrick Walton bd248bf850 Implement line dash offset 2019-06-03 19:36:08 -07:00
Patrick Walton dc45dc459e Remove unused `LineSegment2F::cross` and vector cross product functions 2019-06-03 15:50:39 -07:00
Patrick Walton 1a42bbf4d3 Implement dashing for line segments (no curves yet) 2019-06-03 14:16:58 -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 678b6f12c7 Add support for counterclockwise winding to arcs 2019-06-01 12:56:31 -07:00
Patrick Walton 99c1cca05c Clean up `Outline::push_segment` and `Outline::push_full_segment` 2019-06-01 12:03:03 -07:00
Patrick Walton 44167beff5 Implement `Path2D::arc_to`. 2019-05-31 16:01:53 -07:00
Patrick Walton f20d41800c Use a correct algorithm for approximating arcs with Bézier curves 2019-05-31 16:01:28 -07:00
Patrick Walton 712c69faf1 Precompute the curve for a quarter-circle arc 2019-05-30 21:20:32 -07:00
Patrick Walton 9756aa89f9 Base the core arc primitive on a unit chord and transform.
This lets us handle ellipses better.
2019-05-30 17:19:21 -07:00
Patrick Walton 5974aeba7b Implement miter limit 2019-05-30 13:08:30 -07:00
Patrick Walton ce127caf76 Fix drawing of full circles 2019-05-30 10:56:19 -07:00
Patrick Walton d5ba6ab6da Change the core arc primitive to chord and radius, not chord and center.
This makes it harder to call the function with illegal arguments and simplifies
the join/cap code.
2019-05-30 10:17:17 -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 339397bf23 Revert accidental change 2019-05-29 15:21:02 -07:00
Patrick Walton 51877426ea Take paths by reference, not by value, in outline stroke-to-fill. 2019-05-29 15:15:40 -07:00
Patrick Walton 5133bbfe1a Use unit vectors instead of angles for arcs.
This makes things faster and will also simplify the implementation of round
joins.
2019-05-29 12:14:47 -07:00
Patrick Walton cd23d62f3d Fix off-by-epsilon error in `push_arc` that was breaking the Moiré demo 2019-05-21 20:24:04 -07:00
Patrick Walton 2131724a2a Implement round line caps 2019-05-21 20:21:46 -07:00
Patrick Walton 197f01d56a Write in the line segment intersection code in matrix form 2019-05-21 14:51:50 -07:00
Patrick Walton c6fc853579 Don't miter join on stroke endpoints.
Fixes the Moiré demo.
2019-05-21 14:49:01 -07:00
Patrick Walton cba5444f03 Add miter joins at endpoints 2019-05-16 12:47:18 -07:00
Patrick Walton e282eb57d5 Implement interior miter line joins (not yet endpoints) 2019-05-16 11:10:15 -07:00
Patrick Walton 272b63a017 Implement square line caps 2019-05-16 10:43:43 -07:00
Patrick Walton 1b9cfa98a9 Stroke closed paths properly 2019-05-16 08:35:14 -07:00
Patrick Walton c7382a8b2c Add affine transform support to the canvas implementation 2019-05-13 18:40:25 -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 3310b15826 Fall back to Newton's method instead of dividing by zero when finding critical
points during curve monotonic conversion.

Closes #146.
2019-05-08 17:51:12 -07:00
Patrick Walton 5568e6f64f Remove unused `monotonic` module 2019-05-08 13:37:17 -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
Patrick Walton 0da11ffe01 Run `rustfmt` on the geometry crate 2019-04-29 16:46:35 -07:00
Patrick Walton 8606cd013e Replace commented out printlns with proper debug statements 2019-04-29 16:43:24 -07:00
Patrick Walton d06746f28d Remove barrel distortion.
It was a toy implementation and isn't the approach I want to go with.
2019-04-29 16:05:42 -07:00
Patrick Walton 6c31e1bc01 In VR mode, render one eye and then reproject to both eyes instead of rendering
twice.

This reduces both CPU and GPU time a lot in exchange for a small loss in
quality.
2019-04-26 17:22:54 -07:00
Patrick Walton c688d04412 Remove the scene assembly thread, and pipeline only fills instead of alpha
tiles.

Removing a thread should make it easier to manually assign threads to CPUs, as
is necessary on devices with poor schedulers like Magic Leap 1.
2019-04-18 13:50:26 -07:00
Patrick Walton 224c8e85b9 Create separate shaders for monochrome and multicolor tiles.
This is preparation for fixing subpixel AA.
2019-03-22 14:28:31 -07:00
Patrick Walton 26fea26f87 Allow construction of a `Transform3DF32` from a quaternion describing a
rotation.

Closes #111.
2019-03-20 16:27:28 -07:00
Patrick Walton a0aeb124ad
Merge pull request #112 from asajeffrey/geometry-perspective-post-mul
Add Perspective::post_mul
2019-03-20 14:26:11 -07:00
Patrick Walton 6ca5dc5f62 Add basic barrel distortion support for VR 2019-03-20 13:41:04 -07:00
Alan Jeffrey 1769246e5a Add Perspective::post_mul 2019-03-20 13:59:55 -05:00
Patrick Walton e212a839b4 Get device orientation changes partially working 2019-03-14 19:13:27 -07:00