Commit Graph

71873 Commits

Author SHA1 Message Date
Christian Hergert
526f460d6b gsk/gl: add 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.
2022-04-06 23:59:47 -04:00
Christian Hergert
80b6a89a32 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.
2022-04-06 23:59:47 -04:00
Christian Hergert
0c192288cd build: add dependency on glyphy 2022-04-06 23:59:47 -04:00
Christian Hergert
d34035c22c gsk/gl: use consistent library naming 2022-04-06 23:59:47 -04:00
Christian Hergert
1f7588087a gsk/gl: make texture libraries more autonomous
This moves a lot of the texture atlas control out of the driver and into
the various texture libraries through their base GskGLTextureLibrary class.

Additionally, this gives more control to libraries on allocating which can
be necessary for some tooling such as future Glyphy integration.

As part of this, the 1x1 pixel initialization is moved to the Glyph library
which is the only place where it is actually needed.

The compact vfunc now is responsible for compaction and it allows for us
to iterate the atlas hashtable a single time instead of twice as we were
doing previously.

The init_atlas vfunc is used to do per-library initialization such as
adding a 1x1 pixel in the Glyph cache used for coloring lines.

The allocate vfunc purely allocates but does no upload. This can be useful
for situations where a library wants to reuse the allocator from the
base class but does not want to actually insert a key/value entry. The
glyph library uses this for it's 1x1 pixel.

In the future, we will also likely want to decouple the rectangle packing
implementation from the atlas structure, or at least move it into a union
so that we do not allocate unused memory for alternate allocators.
2022-04-06 23:59:47 -04:00
Christian Hergert
bef8d09040 gsk/gl: pin atlases to single texture library
This removes the sharing of atlases across various texture libraries. Doing
so is necessary so that atlases can have different semantics for how they
allocate within the texture as well as potentially allowing for different
formats of texture data.

For example, in the future we might store non-pixel data in the textures
such as Glyphy or even keep glyphs with color content separate from glyphs
which do not and can use alpha channel only.
2022-04-06 23:59:47 -04:00
Christian Hergert
6f1f1a7c89 gsk/gl: add more control over shader generation
This allows the gskglprograms.defs a bit more control over how a shader
will get generated and if it needs to combine sources. Currently, none of
the built-in shaders do that, but upcoming shaders which come from external
libraries will need the ability to inject additional sources in-between
layers.
2022-04-06 23:59:47 -04:00
Christian Hergert
4f5a2d7490 gsk/gl: rename glyphs to glyphs_library
This naming style is less likely to collide with shader naming and makes
it clear where it is consumed what it is.
2022-04-06 23:59:47 -04:00
Christian Hergert
8a8e165560 gsk/gl: allow configuring atlas size 2022-04-06 23:59:47 -04:00
Christian Hergert
0ec623da09 gsk/gl: check for format as well
This could potentially happen if a uniform had never been set.
2022-04-06 23:59:47 -04:00
Christian Hergert
3b147ad630 gsk/gl: only clear glyph cache durign reclaimation
We don't need to clear the front cache on every frame as we can clear it
specifically when we do reclaimation to avoid unnecessary memset() calls.
2022-04-06 23:59:47 -04:00
Christian Hergert
615cf2a782 gsk/gl: ignore max_entry_size when zero
If the max_entry_size is zero, then assume we can add anything to the
atlas. This allows for situations where we might be uploading an arc list
to the atlas instead of pixel data for GPU font rendering.
2022-04-06 23:59:47 -04:00
Christian Hergert
f9725cc536 gsk/gl: make max-frame-age configurable
This is nice for some texture libraries that we might want to keep around
for longer than say 60 frames such as a glyph cache.
2022-04-06 23:59:47 -04:00
Matthias Clasen
468863a8b9 gtk-demo: Don't hardcode a title font
We want a large font size, but we don't have to
hardcode Sans.
2022-04-06 23:59:47 -04:00
Matthias Clasen
95a3d3c26f Add a demo for path ops 2022-04-06 23:59:17 -04:00
Matthias Clasen
df1bca3027 Add some tests for pathops 2022-04-06 23:59:17 -04:00
Matthias Clasen
acf81a0377 path: Implement path ops
Implement boolean operations on paths.
2022-04-06 23:59:17 -04:00
Matthias Clasen
bf8fca391a path: Add gsk_path_transform
This is an obvious operation to want for paths.
2022-04-06 23:57:28 -04:00
Matthias Clasen
aa722dcfac path: Add gsk_path_is_convex
Add a function to compute whether a path is convex.
2022-04-06 23:52:03 -04:00
Matthias Clasen
f5ccf63550 path: Add gsk_path_get_flags
The flags contain some useful information.
2022-04-06 23:52:03 -04:00
Matthias Clasen
61f9b1d9e0 path: Add gsk_path_reverse
This is a natural operation, and useful for debugging things.
2022-04-06 23:52:03 -04:00
Matthias Clasen
aa8ba37a0f curve: Cosmetics 2022-04-06 23:47:35 -04:00
Matthias Clasen
86c1493b4b contour: Fix winding for circle contour
Test included.
2022-04-06 23:47:35 -04:00
Matthias Clasen
f58513e4dd path: Fix gsk_path_measure_in_fill
This was getting some simple polygon cases wrong :(

The problem here is a misunderstanding in line_get_crossing.
It was returning 'on edge' when a point of the polygon is
on the ray, which is not what 'on edge' is about.

Add some test cases involving horizontal edges that coincide
with the test point.
2022-04-06 23:47:35 -04:00
Matthias Clasen
c816eee4d1 curve: Add more line-curve intersection tests 2022-04-06 23:47:35 -04:00
Matthias Clasen
436fe18084 curve: Add another intersection test 2022-04-06 23:47:35 -04:00
Matthias Clasen
3ba2659860 curve: Specify tolerance for intersections
We had 0.1 hardcoded in a bunch of places.
2022-04-06 23:47:35 -04:00
Matthias Clasen
ffc5fdb9de Add a debug key for paths
Not used yet.
2022-04-06 23:47:35 -04:00
Matthias Clasen
e88cf34642 curve: Add gsk_curve_print for debugging 2022-04-06 23:47:35 -04:00
Matthias Clasen
5eb79b3b01 curve: Move some curve apis to gskcurve.c
Some of this will be reused elsewhere, so move
it out of gskpathstroke.c.
2022-04-06 23:47:35 -04:00
Matthias Clasen
cf793f94ac curve: Use GskBoundingBox 2022-04-06 23:47:35 -04:00
Matthias Clasen
ba405bfbf1 Add a bounding box type
graphene_rect_t does not quite work for this purpose.
2022-04-06 23:47:35 -04:00
Matthias Clasen
4b6223e07d curve: Handle self-intersection 2022-04-06 23:47:35 -04:00
Matthias Clasen
8637ea8fb8 curve: Small improvement 2022-04-06 23:47:35 -04:00
Matthias Clasen
ab8a32bc76 curve: Refine line-line intersection
For collinear line segments, return up to 2 intersections
for the endpoints of the intersection (which is also a
line segment in this case).

Tests included.
2022-04-06 23:47:35 -04:00
Matthias Clasen
6aa38e6b39 curve: Fix line-curve intersections 2022-04-06 23:47:35 -04:00
Matthias Clasen
46bef9b667 curve test: Fix the split test
We were misinterpreting the return value of
gsk_path_measure_get_closest_point.
2022-04-06 23:47:35 -04:00
Matthias Clasen
86862d56bd curve: Skip a failing test
We don't have a good error bound for approximating
conics. Until that changes, skip this test.
2022-04-06 23:47:35 -04:00
Matthias Clasen
1e5c025a1e curve: Add another intersection test 2022-04-06 23:47:35 -04:00
Matthias Clasen
60f87f2a7d path: Fix a typo 2022-04-06 23:47:35 -04:00
Matthias Clasen
001903aeef contour: Add some docs 2022-04-06 23:47:35 -04:00
Matthias Clasen
3b04f5a963 Allow showing points in curve2 test
This is useful for debugging intersections.
2022-04-06 23:47:35 -04:00
Matthias Clasen
de29a01682 gsk: Use stroke bounds in the stroke node
We can use gsk_path_get_stroke_bounds to get a
better estimate for the bounds of the stroke node.
2022-04-06 23:47:35 -04:00
Matthias Clasen
bd3b88b276 gtk-demo: Use gsk_path_builder_add_layout
We have an api now to hide the cairo use.
2022-04-06 23:47:35 -04:00
Matthias Clasen
e7a9030fb5 gsk: Add gsk_path_builder_add_layout
This api makes it easy to turn text into a path that
can be further manipulated. The implementation currently
goes via cairo.
2022-04-06 23:47:35 -04:00
Matthias Clasen
98aca9e2cd curve2: Show osculating circles 2022-04-06 23:47:35 -04:00
Matthias Clasen
6e8b23d485 Add gsk_path_measure_get_curvature 2022-04-06 23:47:35 -04:00
Matthias Clasen
05678d44ca 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.
2022-04-06 23:47:35 -04:00
Matthias Clasen
7b4bc08254 stroke: Make gsk_stroke_to_cairo public
It comes in handy, and does no harm.
2022-04-06 23:47:35 -04:00
Matthias Clasen
3b81a9e529 gtk-demo: Add a curve editor demo 2022-04-06 23:47:35 -04:00