Commit Graph

77149 Commits

Author SHA1 Message Date
Matthias Clasen
de08441d4d 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-19 00:26:02 -04:00
Matthias Clasen
8a438c46ae glyphy: Update for api changes in glyphy
With this, synthetic bold fonts work as well
as they do with freetype.
2023-07-19 00:26:02 -04:00
Matthias Clasen
5fb1a572c6 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-19 00:26:02 -04:00
Matthias Clasen
1ab45331c0 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-19 00:26:02 -04:00
Matthias Clasen
23e36c9245 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-19 00:26:02 -04:00
Matthias Clasen
0beb416b53 build: Bump the harfbuzz requirement to 4.0
The hb_font_get_glyph_shape api was introduced
in 4.0.
2023-07-19 00:26:02 -04:00
Matthias Clasen
3d27f67107 glyphy: Pencil in outline rendering 2023-07-19 00:26:02 -04:00
Matthias Clasen
9574e49df6 glyphy: Declare that we are using dFdx
GLES2 does not have these by default :(
2023-07-19 00:26:02 -04:00
Christian Hergert
0347e4cd76 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-19 00:25:03 -04:00
Matthias Clasen
14a8321b02 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-19 00:25:03 -04:00
Christian Hergert
5bb4846442 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-19 00:25:03 -04:00
Christian Hergert
4715afc822 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-19 00:25:03 -04:00
Christian Hergert
9f58740486 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-19 00:25:03 -04:00
Matthias Clasen
7088acb88b 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-19 00:25:03 -04:00
Matthias Clasen
732a607127 Make path tests build as internal tests 2023-07-19 00:25:03 -04:00
Matthias Clasen
e8ef875a7b Drop all path api 2023-07-19 00:25:03 -04:00
Matthias Clasen
56b17715f1 path: Make GskFillRule available 2023-07-18 21:31:16 -04:00
Matthias Clasen
6775a22cff 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-18 21:31:16 -04:00
Matthias Clasen
380ac5804d 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-18 21:02:38 -04:00
Matthias Clasen
241c6811f9 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-18 21:02:38 -04:00
Matthias Clasen
ba442fc24e 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-18 21:02:38 -04:00
Matthias Clasen
9d5c23f342 Add a bounding box type
graphene_rect_t does not quite work for this purpose.
2023-07-18 21:02:38 -04:00
Matthias Clasen
568ac6b7f6 Add another curve decomposition test
This one uses GskPathMeasure to check that
our conic approximations look roughly right.
2023-07-18 21:02:38 -04:00
Matthias Clasen
a94cc20067 Add tests for GskPathMeasure 2023-07-18 21:02:38 -04:00
Matthias Clasen
638a91451a Add GskPathMeasure
An object to do measuring operations on paths - determining
their length, cutting off subpaths, things like that.
2023-07-18 21:02:38 -04:00
Matthias Clasen
769679d111 gsk: Add tests for GskPath 2023-07-18 21:02:38 -04:00
Matthias Clasen
306f524e59 gsk: Add tests for GskCurve 2023-07-18 21:02:38 -04:00
Matthias Clasen
e86281d81c Add GskPath and GskPathBuilder
GskPath is a data structure for paths that consists
of contours, which in turn might contain Bézier curves.

The data structure is inspired by Skia, with separate
arrays for points and operations. One advantage of this
arrangement is that start and end points are shared
between adjacent curves.

In addition to the usual contours comprised of Bézier
segments, GskPath supports certain special contours
directly, such as rectangles, rounded rectangles and
circles.
2023-07-18 21:02:37 -04:00
Benjamin Otte
2e6b7b5b78 Merge branch 'wip/otte/vulkan-for-main' into 'main'
vulkan: Make RenderOps into proper structs

See merge request GNOME/gtk!6188
2023-07-16 12:22:35 +00:00
Benjamin Otte
90e933a6aa vulkan: Rebuild the shaders
Just to be sure I didn't forget rebuilding some shader at some point.
2023-07-16 13:52:15 +02:00
Benjamin Otte
e7549f3359 vulkan: Redo barriers
We now store all the relevant state of the image inside the VulkanImage
struct, so we can delay barriers for as long as possible.

Whenever we want to use an image, we call the new
gsk_vulkan_image_transition() and it will add a barrier to the desired
state if one is necessary.
2023-07-16 13:16:43 +02:00
Benjamin Otte
fee497f9e1 vulkan: Track the current pipeline stage of images
This way, we can in theory properly transition images because we know
which stage to transition from.

IN practice this is happening in future commits.
2023-07-16 13:16:43 +02:00
Benjamin Otte
ef4930723b vulkan: Handle images in the ShaderOp
This looks more convoluted in this commit, but future commits will
hopefully make up for it.
2023-07-16 13:16:43 +02:00
Benjamin Otte
a8ff291a12 vulkan: Make clip type an enum
and add gsk_vulkan_shader_op_alloc() that sets it properly.
2023-07-16 13:16:43 +02:00
Benjamin Otte
f366ccc0b2 vulkan: Introduce GskVulkanShaderOp
It's the new base class for shaders now.

We're doing deep inheritance now, woohoo!

Also, port all the shader ops to it.
2023-07-16 13:16:43 +02:00
Benjamin Otte
ca69fd2b7a vulkan: Remove GskVulkanUploader
... and all the remaining functions still using it.

It's all unused and has been replaced by upload and download ops.

With this change, all GPU operations now go via GskVulkanOp.command()
and no more side channels exist.
2023-07-16 13:16:43 +02:00
Benjamin Otte
db2029d931 vulkan: Add GskVulkanDownloadOp
This op queues a download of an image. The image will only be available
once the commands finished executing, so it requires waiting for the
render to finish, which makes the API a bit awkward.

Included is also a download_png_op() useful for debugging.
2023-07-16 13:16:43 +02:00
Benjamin Otte
6f2fd001a0 vulkan: Properly update image layouts
The render pass ops were not updating the image's layout to the final
layout when a render pass ends.

Fix that.

Also make the layouts explicit arguments to the render pass op.
2023-07-16 13:16:43 +02:00
Benjamin Otte
3327a6ba08 vulkan: Simplify render API
Merge reset() and draw() into a single render() function.

Also clean up some naming on the way.
2023-07-16 13:16:43 +02:00
Benjamin Otte
4954e6962f vulkan: Remove the VulkanOp.upload() vfunc
It's not used anymore.
2023-07-16 13:16:43 +02:00
Benjamin Otte
93db1cc89e vulkan: Add an UploadGlyphOp
Now all the uploads have their own op.
2023-07-16 13:16:43 +02:00
Benjamin Otte
68b337d457 vulkan: Split out a function
Split out the function that uploads using a buffer, so that it can be
used with an area to only update parts of the image.

That feature is not used yet, but will be in future commits.
2023-07-16 13:16:43 +02:00
Benjamin Otte
0d5e54986a vulkan: Remove unused functions 2023-07-16 13:16:43 +02:00
Benjamin Otte
822641c161 vulkan: Merge the two upload ops
Now they both use the same upload code.
2023-07-16 13:16:43 +02:00
Benjamin Otte
385ab74922 vulkan: Merge te 2 upload ops
They are about to share a ton of code, sothey should be in the same
source file.

This commit just does the copying, no functional changes.
2023-07-16 13:16:43 +02:00
Benjamin Otte
fcf65c7caa vulkan: Fold functions into only caller
Now that the VulkanOp does begin/end of render passes, there's no need
to have a renderpass function for it anymore.
2023-07-16 13:16:43 +02:00
Benjamin Otte
ece4e59e99 tests: Reduce number of random fonts
We were clowing through all the Pango caches for no benefit.

It made the test generation stuck in fontconfig loops instead of
quickly generating tests.

So don't do that and limit the different fonts to some reasonable list
of options.
2023-07-16 13:16:43 +02:00
Benjamin Otte
6eea08ff99 vulkan: Don't merge too many drawing commands
If a command takes too long to execute, Vulkan drivers will think they
are inflooping and abort what they were doing.

For the simple color shader with smallish nodes, this happens around
10M instances, as tested with the output of
  ./tests/rendernode-create-tests 10000000 colors.node

So just limit it to way lower, so that we barely never hit it, ut still
pick a big number so this optimization stays noticable.
2023-07-16 13:16:43 +02:00
Benjamin Otte
372dcba9c9 vulkan: Simplify
The renderpassop always has a matching end op, so there is no need to
check for the end of operations and emit one manually.
2023-07-16 13:16:43 +02:00
Benjamin Otte
af817a3362 vulkan: Merge function into only caller
The renderpass reshuffling means we can move a bunch of functions now.

This is one of them.
2023-07-16 13:16:43 +02:00