Commit Graph

62 Commits

Author SHA1 Message Date
Patrick Walton a2522e3845 wip 2018-11-14 10:33:53 -08:00
Paul Rouget 6d7dd604f8 Euclid and lyon updates 2018-07-27 11:40:45 +02:00
Nicolas Silva 46d1878ef5 Update lyon and euclid dependencies. 2018-07-11 00:27:42 +02:00
Patrick Walton d66a5b6c54 Update to `env-logger` 0.5 2018-03-30 14:25:52 -07:00
Patrick Walton dcc3a0fc94 Update to bincode 1.0 2018-03-22 15:03:25 -07:00
Patrick Walton 64c818e530 Construct meshes independently of mesh libraries (renamed to "mesh
packs").

This fits in better with the way WebRender does things. It simplifies
the code too.
2018-03-08 15:10:29 -08:00
Patrick Walton db6986ca1f Take the orientation of a path into account when computing normals 2018-03-07 11:21:08 -08:00
Patrick Walton 6c2c34aa3c Make the mesh library serializable and deserializable.
This is needed for the new WebRender infrastructure.
2018-03-06 15:12:47 -08:00
Patrick Walton 18121208d4 Update euclid to 0.17 and Lyon to 0.10 2018-03-06 15:06:06 -08:00
Patrick Walton f718aa9ce3 Make the FreeType API match the Core Graphics one 2018-03-05 17:15:17 -08:00
Patrick Walton 5d3c1f6d59 Abstract away `FontKey` so WebRender can more easily use this; switch
from angle measurement to scale-dependent hull height
2018-03-05 11:27:18 -08:00
Patrick Walton a84b7c7cbd Replace ECAA with "Stencil AAA", a distance-based antialiasing
technique similar to the new MCAA.

This new technique simplifies the code significantly by unifying lines,
curves, and transformed curves. Blog posts forthcoming.
2018-02-17 10:45:25 -08:00
Patrick Walton 87eb3038eb Make the cubic Bézier approximation tolerance proportional to the SVG
view box size instead of hardcoding it.

Reduces the vertex shading load by approximately half on many of the
"Massively Parallel Vector Graphics" test cases.

Partially addresses #67.
2018-02-08 20:00:14 -08:00
Patrick Walton 5879d9778d Replace the MCAA shader with an extended Loop-Blinn approach and an
approximation of area based on approximate first-order line distance.

This enables support for full affine transforms in MCAA. It also greatly
simplifies the shader and reduces the amount of work that the GPU needs
to do for fragment shading.

Experimental testing has shown the area approximation to be accurate to
about 4%.
2018-02-02 18:28:41 -08:00
Patrick Walton 5bd68dec65 Port Pathfinder to use Lyon for Bézier curve math.
This removes a whole lot of code from `pathfinder_path_utils`. Hopefully
the remaining code can go upstream.

These changes regress quality of stroke widths for cubic curves, because
they move fill-to-stroke conversion before cubic-to-quadratic
conversion. To fix that, we will need to recursively subdivide when
doing fill-to-stroke conversion.
2018-01-29 12:47:47 -08:00
Patrick Walton d8c590867d Stop computing B-vertex normals, which are no longer used.
6x improvement in partitioning time (because atan2 is dog slow).
2018-01-21 11:41:26 -08:00
Patrick Walton 6a640eca74 Simplify the B-quad vertex position VBO to have a uniform format, and
enable early Z for SVG.

Additionally, this switches the B-quad patches for XCAA to be convex
hulls instead of bounding boxes, reducing fragment shader load.

This is a large speedup for the Ghostscript tiger demo: 5x or more.

Closes #33.
2018-01-11 19:25:02 -08:00
Patrick Walton 67dd6cd8ed Add some simple overview documentation to the partitioner crate 2018-01-05 18:40:36 -08:00
Patrick Walton 11913a20f1 Merge MCAA monochrome and multicolor shaders.
Not only is this a lot simpler, it's faster too!
2018-01-03 15:22:28 -08:00
Patrick Walton 0ec5b74851 Start a Cargo workspace and generate documentation for it 2017-12-23 18:01:55 -05:00
Patrick Walton 2deb4fae2a Use binary search to find line intersections to reduce floating point error.
This is probably improvable, but let's do the safe thing for now.

Closes #57.
Closes #58.
2017-12-21 13:22:32 -08:00
Patrick Walton 4c2d0cb5ab Use homogeneous coordinates to reduce floating point error when computing the intersection of self-intersecting line segments.
Partially addresses #57.
2017-12-20 13:42:20 -08:00
Patrick Walton cfe72f486e Use a single-pass pixel-snapping MCAA algorithm instead of a multipass
ECAA algorithm for multicolor SVG.

This is much faster than both Skia and the previous XCAA algorithm
while maintaining slightly higher quality than the latter.

There are a couple of known issues:

* Vertical inflection points of hairlines with very steep slopes can
  become very light or even drop out occasionally. I suspect this is due
  to floating point error.

* Rarely, single columns of pixels can disappear from a mesh. Cause TBD.

Besides these bugs, this technique can be cleaned up and probably made
faster, but it's a sizable improvement as is.
2017-12-18 17:37:14 -08:00
Patrick Walton 2975038891 Reenable early Z.
It regressed again!
2017-11-11 14:04:57 -08:00
Patrick Walton 8e7eb6ca60 Support stem darkening in SSAA mode.
The normals are incorrect right now in some cases, but it looks OK-ish.
2017-11-09 16:20:15 -08:00
Patrick Walton 572b7cdd4a Encode path IDs using a sparse representation, not a dense one.
This reduces the size of serialized mesh libraries. It also makes it
much easier to expand meshes and select individual paths for rendering.
2017-11-02 16:08:31 -07:00
Patrick Walton bf3779bf89 Calculate normals for B-vertices.
I'm planning to use this for fixing hairlines in XCAA.
2017-10-27 15:12:33 -07:00
Patrick Walton 0b179f3a40 Add preliminary DirectWrite support on Windows.
This will eventually need to call into GDI to do hinting, but it's good
enough for now.
2017-10-25 13:01:36 -07:00
Patrick Walton 9c470e77c1 Make macOS font rendering not depend on FreeType 2017-10-20 12:10:57 -07:00
Patrick Walton 314185684c Implement stem darkening and split ECAA into ECAA and MCAA.
We now implement stem darkening (also known as font dilation) like
macOS and FreeType under certain configurations. This pushes out font
outlines along their normals slightly in order to make small text easier
to read. This is especially important when performing gamma correction,
as otherwise text can end up too light.

Because the stem darkening is implemented in the vertex shader, it can
easily break the mesh. Therefore, I needed to implement a new rendering
mode that does not use the mesh. It's a variant of ECAA, and for
clarity's sake I've renamed the related antialiasing methods:

* MCAA stands for "mesh coverage antialiasing" and is the new name for
what was called "ECAA" prior to this patch.

* ECAA now stands for "edge coverage antialiasing". It does not use the
mesh but rather computes winding numbers from scratch for every pixel.
Surprisingly, despite being worse asymptotically, this usually ends up
being faster than MCAA at small font sizes, presumably because there are
fewer vertices to transform.

* XCAA, "exact coverage antialiasing" is a generic term that refers to
both ECAA and MCAA. References to ECAA have been changed to XCAA as
needed.
2017-10-15 13:28:49 -07:00
Patrick Walton 2a236319d4 Use regular VBOs instead of textures to store vertex positions for ECAA.
This improves performance at small font sizes a bit by reducing vertex
shading load.
2017-10-06 16:42:51 -07:00
Patrick Walton b631fec80f Cache font mesh libraries on the server 2017-10-02 19:58:38 -07:00
Patrick Walton 092b46e056 Reenable early Z optimizations 2017-10-02 15:36:39 -07:00
Patrick Walton f3f893302a Introduce a simple file format for serializing meshes, and use it in the demo 2017-10-02 15:17:21 -07:00
Patrick Walton 475f5dca71 Introduce a new mesh library abstraction for holding meshes.
Simplifies the server code and allows avoiding copying indices all the time.

Closes #29.
2017-10-02 14:03:56 -07:00
Patrick Walton 8c6110a388 Remove the duplicated de Casteljau subdivision code in
`partitioner::geometry`
2017-10-02 11:45:34 -07:00
Patrick Walton 705274997d Remove the now-obsolete path legalizer 2017-10-02 11:40:11 -07:00
Patrick Walton 613bc7c29d Don't start subdividing active edges until we're sure an entire B-quad
will be emitted.

Otherwise it messes up the parity.

Fixes the bottom curve of the lowercase "p" in Open Sans when rendered
with Loop-Blinn.
2017-09-29 13:25:19 -07:00
Patrick Walton c37fd1f1e8 Ignore intersections beyond the sweep line.
Improves the outer stroke of the tiger.
2017-09-25 19:15:36 -07:00
Patrick Walton 93de8383f9 Replace the implicitization algorithm for curve intersection with a
simpler one based on binary search and the quadratic formula.

This does a better job avoiding floating point error and improves the
rendering of the tiger.
2017-09-25 18:51:02 -07:00
Patrick Walton 2a906569e5 Emit B-quads around both self-intersecting active edges.
Improves one of the whiskers in the tiger.
2017-09-25 12:58:42 -07:00
Patrick Walton db32009d7b Create fewer useless B-vertices 2017-09-22 19:15:58 -07:00
Patrick Walton 2039051f01 Remove bogus fast path that tried to avoid active edge order calculation.
It was causing us to miss a bunch of crossings in the tiger whiskers.
2017-09-22 13:42:20 -07:00
Patrick Walton be1b100826 Split B-quads whose curves' convex hulls intersect in most cases.
Avoids some rendering artefacts with Loop-Blinn, improving the tiger.
2017-09-21 22:47:00 -07:00
Patrick Walton a126e1248e Don't structure fills around the even-odd rule.
Improves self-intersecting paths under the winding rule.
2017-09-21 14:54:04 -07:00
Patrick Walton 4ac11e9010 Switch to a more robust intersection algorithm based on implicitization 2017-09-20 21:23:56 -07:00
Patrick Walton b732878532 Encapsulate the file picker code into a view class.
This will allow the mesh debugger to use it.
2017-09-20 11:51:20 -07:00
Patrick Walton 72d9ad7de0 Handle path self intersection 2017-09-19 11:43:39 -07:00
Patrick Walton d644f1b6a6 Implement curve-curve and curve-line intersection, untested as of yet 2017-09-18 21:00:34 -07:00
Patrick Walton dbd83d17ef Implement the winding fill rule for real 2017-09-18 15:34:36 -07:00
Patrick Walton e5f9b56a1d Implement the winding fill rule 2017-09-18 14:19:28 -07:00
Patrick Walton a7d75f913c Split paths into monotonic segments before partitioning them in the demo 2017-09-12 09:35:57 -07:00
Patrick Walton 3e5b53f13c Partially refactor the path APIs to be streaming, like Lyon 2017-09-08 13:09:00 -07:00
Patrick Walton 444e7bbf96 Use the Citardauq Formula in the partitioner as well as the shader to avoid precision problems.
Addresses the issue with the Nimbus Sans "o" mentioned in #24.
2017-09-01 23:45:51 -07:00
Patrick Walton 52afa359b4 Render a line of text using the atlas 2017-08-22 18:25:32 -07:00
Patrick Walton 93277c7c11 Allow multiple glyphs to be rendered simultaneously 2017-08-19 16:34:02 -07:00
Patrick Walton ec78a632dc Split path IDs and Loop-Blinn data into separate VBOs 2017-08-17 12:47:50 -07:00
Patrick Walton 5f89f7ba50 Fix compile errors in shaders 2017-08-13 13:39:51 -07:00
Patrick Walton 57ebbf8281 Split out B-vertex positions and info so that they're easier to pack into textures 2017-08-11 15:56:07 -07:00
Patrick Walton 3fcd4d472b Shuffle `BQuad` fields around for better alignment in GLSL 2017-08-10 17:47:46 -07:00
Patrick Walton 0ad2f9abfe Initial implementation of the Rocket-based demo server 2017-08-10 15:26:27 -07:00
Patrick Walton 95b356435e Rename `partitionfinder` to `partitioner` and remove the old tessellator 2017-08-08 11:32:51 -07:00