Commit Graph

76884 Commits

Author SHA1 Message Date
Matthias Clasen
fbc8996830 Add an animated text example 2023-07-18 13:51:45 -04:00
Matthias Clasen
fb65628e9f Add a font rendering test 2023-07-18 13:51:44 -04:00
Matthias Clasen
4ca8911d2a glyphy: Implement synthetic italic
Use the font matrix found in the FcPattern to
transform the quads we use to render the glyphs.

This makes Cantarell Italic come out just like
it does with freetype.
2023-07-18 13:51:15 -04:00
Matthias Clasen
86481ebb91 glyphy: Update for api changes in glyphy
With this, synthetic bold fonts work as well
as they do with freetype.
2023-07-18 13:51:15 -04:00
Matthias Clasen
1c72bee109 glyphy: Implement synthetic bold
When the font appears to be synthetic bold (as
indicated by th embolden property in FcPattern),
use glyphys boldness uniform to render the font
bolder.
2023-07-18 13:51:15 -04:00
Matthias Clasen
4d9ee3883f glyphy: Remove glyphy debug code
We don't have a knob to turn this on, and it is
not really useful outside of glyphy itself, so
remove it.
2023-07-18 13:51:15 -04:00
Matthias Clasen
c0ec993f12 glyphy: Simplify the path
Use path ops to simplify the path we get from
harfbuzz, since variable fonts often have overlapping
contours, and the glyphy shader can't handle those.
2023-07-18 13:51:15 -04:00
Matthias Clasen
db7f38e550 build: Bump the harfbuzz requirement to 4.0
The hb_font_get_glyph_shape api was introduced
in 4.0.
2023-07-18 13:51:15 -04:00
Matthias Clasen
59e4f7b0da glyphy: Pencil in outline rendering 2023-07-18 13:51:15 -04:00
Christian Hergert
b7d9dbf6a5 gsk/gl: Fix output color of glyphy fragment shader
This copied more or less what the coloring vertex shader
was doing in that we premultiply alpha. That changes how
we apply alpha in the fragment shader to match.

This fixes a white halo around the fonts.
2023-07-18 13:51:15 -04:00
Matthias Clasen
09caa0632f glyphy: Make glyphy cache size-independent
Use a hb font at nominal size when generating sdf
contours, and use a cache key that is independent
of the size.
2023-07-18 13:51:15 -04:00
Christian Hergert
adcef23069 gsk/gl: Start on basic glyphy renderjob integration
This doesn't work correctly yet, as there are lots of
bumps along the way to still smooth out.
2023-07-18 13:51:15 -04:00
Christian Hergert
30b5186177 gsk/gl: Add a texture library for Glyphy
This adds a new texture library that can upload SDF data
from libglyphy into regions of a texture atlas so that it
can be accessed by Glyphy shaders in the appropriate place
and format.

Some of the placement positioning may seem odd in that it
needs to follow a certain format to be decoded from the
Glyphy shaders.
2023-07-18 13:51:15 -04:00
Christian Hergert
7020211944 gsk/gl: Dispatch text_node to legacy vs glyphy
If the text node has color glyphs, then we need to dispatch
to the legacy form of rendering which uses FreeType/Cairo/etc
to upload glyphs to a rendered glyph cache.

Otherwise, we can dispatch to a new function which will
eventually use Glyphy to shape to SDF content and upload
to an alternate texture atlas.
2023-07-18 13:51:15 -04:00
Matthias Clasen
a1c76751ab build: Add a dependency on glyphy
We have a subproject, and we link statically
if we can, to avoid depending on a project
that is not generally packaged in distros.
2023-07-18 13:51:15 -04:00
Matthias Clasen
3d33636795 ci: Add glut and glew to Fedora image
glyphy requires these.
2023-07-18 13:51:15 -04:00
Matthias Clasen
d116a04a9d tools: Add more commands to gtk4-path-tool
Add pathops.
2023-07-08 20:47:09 -04:00
Matthias Clasen
7c90961174 gtk-demo: Add a demo for path ops
This demo is called Glyphs, since that is what
it works with.
2023-07-08 20:47:09 -04:00
Matthias Clasen
a767a0495f Add API for boolean operations on paths
The new APIs here are:
gsk_path_union
gsk_path_intersection
gsk_path_difference
gsk_path_symmetric_difference
gsk_path_simplify
2023-07-08 20:46:53 -04:00
Matthias Clasen
a2c35d8682 Implement boolean operations on paths
Implement union, intersection, difference and
symmetric difference of two paths, as well as
simplification of a single path.
2023-07-08 20:45:42 -04:00
Matthias Clasen
0e6da01d05 gsk: Add gsk_stroke_node_get_stroke_path
We will implement stroking by filling the stroke path.

Compute the stroke path ahead of time, so we don't have
to do it over and over.

This may change in the future, at least for simple
strokes, so keep this private.
2023-07-08 20:44:37 -04:00
Matthias Clasen
ea28b804ce gtk-demo: Add a curve editor demo
This demo is called Curve, for obvious reasons.
2023-07-08 20:44:37 -04:00
Matthias Clasen
4a000213cd gtk-demo: Add a few path benchmarks
The Tiger and Graph examples in the fishbowl test
path handling.
2023-07-08 20:44:37 -04:00
Matthias Clasen
33c5dbf8c6 Add a gallery of tough strokes
Each of these defeated the stroker at some point.
2023-07-08 20:44:37 -04:00
Matthias Clasen
e2e6e6a8e5 Add an interactive path test
This one is for interactive exploring of svg paths.

You can enter an SVG path in the entry and hit Enter
to see how GSK renders it. If you click the button
in the headerbar, you can see what GTK thinks the
closest point, tangent and distance are wrt. to the
mouse position, and the bounding box of the path.

There's also stroke parameters to play with.
2023-07-08 20:44:37 -04:00
Matthias Clasen
124b76e6da tools: Add more commands to gtk4-path-tool
Add stroking and offsetting.
2023-07-08 20:44:37 -04:00
Matthias Clasen
fd714fb8be Add gsk_path_offset
Add a function that takes a path, and offsets it
by some distance, applying line-join parameters
as needed. The implementation is reusing the
infrastructure of the stroker.
2023-07-08 20:44:37 -04:00
Matthias Clasen
da354c08ff Add gsk_path_stroke
Implement stroking for paths.

The current implementation does not try to handle short
segments in the vicinity of sharp joins in any special
way, so there can be some artifacts in that situation.

There are special-case implementations for rectangle
and circle contours, since in many cases the outlines
of these contours just consist of two of the same
shapes.
2023-07-08 20:44:37 -04:00
Matthias Clasen
038b3ca184 Add more curve tests
These tests check that gsk_curve_intersect finds
the intersections we want and get_bounds returns
proper bounding boxes.

We also check a few simple cases of offset curves.
2023-07-08 20:44:37 -04:00
Matthias Clasen
c020eeac70 curve: Add gsk_curve_offset
This method creates an offset curve from an existing
curve by just moving the control points laterally.

This will be used in stroking.
2023-07-08 20:44:37 -04:00
Matthias Clasen
e5c97cc7fb curve: Add gsk_curve_intersect
Add a way to find the intersections of two curves.
We can handle some curve-line intersections directly,
the general case is handled via bisecting.

This will be used in stroking and path ops.
2023-07-08 20:44:37 -04:00
Matthias Clasen
ad01a9910e curve: Add utilities for cusps and inflections
Add functions to find cusps and inflection points of cubics.
These will be used for intersections and in the stroker.
2023-07-08 20:44:23 -04:00
Matthias Clasen
ac18bbe5ac curve: Add gsk_curve_get_bounds
Add getters for bounding boxes of curves.

We have cheap ones, which are just the bounding
box of the control points, and tighter ones, which
require finding the actual extrema.

Bounding boxes are needed to implement intersection
via bisecting.
2023-07-08 20:43:07 -04:00
Matthias Clasen
9f05e9357d Add a bounding box type
graphene_rect_t does not quite work for this purpose.
2023-07-08 20:41:37 -04:00
Matthias Clasen
3ae6e842aa tools: Add gtk4-path-tool
This comes in handy for testing, among other things.

For now, this supports decomposing,
reversing, restricting, rendering and preview.
2023-07-08 20:41:37 -04:00
Benjamin Otte
9b253738e4 demos: Add cute maze demo 2023-07-08 20:41:37 -04:00
Benjamin Otte
7065bc8efc demos: Add a text-on-path demo 2023-07-08 20:41:37 -04:00
Benjamin Otte
1eef220b19 demos: Add a simple demo filling a path 2023-07-08 20:41:37 -04:00
Benjamin Otte
739f4a699e WIP: css: Replace border rendering code with GskPath
The weight is wrong still, I need to compute the correct one to get real
45deg circle corners and not just roughly correct ones.
2023-07-08 20:41:37 -04:00
Matthias Clasen
4ced06d21c gsk: Add tests for gsk_path_dash 2023-07-08 20:41:37 -04:00
Matthias Clasen
94b34a2254 Add gsk_path_dash 2023-07-08 20:41:37 -04:00
Benjamin Otte
57263c6c6e snapshot: Add gtk_snapshot_push_stroke()
This is the obvious GtkSnapshot API to go
along with the new stroke nodes.
2023-07-08 20:41:37 -04:00
Benjamin Otte
7583851d1e gsk: Add GskStrokeNode
Take a rendernode as source and a GskPath and GskStroke,
and fill the area that is covered when stroking the path
with the given stroke parameters, like cairo_stroke() would.
2023-07-08 20:41:37 -04:00
Matthias Clasen
25842d9809 Add gsk_path_get_stroke_bounds
This is a help to compute the bounds for
stroke nodes. We keep it private for now.
2023-07-08 20:41:15 -04:00
Matthias Clasen
296230920b Add GskStroke
A GskStroke struct collects the parameters that are
needed for stroking a path.
2023-07-08 19:55:02 -04:00
Matthias Clasen
a473450930 Add another curve decomposition test
This one uses GskPathMeasure to check that
our conic approximations look roughly right.
2023-07-08 19:55:02 -04:00
Matthias Clasen
57a93b299a Add tests for GskPathMeasure 2023-07-08 19:55:02 -04:00
Matthias Clasen
ab7d9b0ef8 Add GskPathMeasure
An object to do measuring operations on paths - determining
their length, cutting off subpaths, things like that.
2023-07-08 19:55:01 -04:00
Benjamin Otte
1566c023c1 gtk: Add gtk_snapshot_push_fill()
This is the obvious GtkSnapshot API to go
along with the new fill nodes.
2023-07-08 19:53:59 -04:00
Benjamin Otte
d5e7eeeb6a gsk: Add GskFillNode
Take a rendernode as source and a GskPath and fill
the region in the path just like cairo_fill() would.
2023-07-08 19:53:59 -04:00