gtk/gsk
Simon McVittie 214f5a6f98 gskpathop: Introduce a type to represent an aligned graphene_point_t
When we allocate a graphene_point_t on the stack, there's no guarantee
that it will be aligned at an 8-byte boundary, which is an assumption
made by gsk_pathop_encode() (which wants to use the lowest 3 bits to
encode the operation). In the places where it matters, force the
points on the stack and embedded in structs to be nicely aligned.

By using a distinct type for this (a union with a suitable size and
alignment), we ensure that the compiler will warn or error whenever we
can't prove that a particular point is, in fact, suitably aligned.
We can go from a `GskAlignedPoint *` to a `graphene_point_t *`
(which is always valid, because the `GskAlignedPoint` is aligned)
via &aligned_points[0].pt, but we cannot go back the other way
(which is not always valid, because the `graphene_point_t` is not
necessarily aligned nicely) without a cast.

In practice, it seems that a graphene_point_t on x86_64 *is* usually
placed at an 8-byte boundary, but this is not the case on 32-bit
architectures or on s390x.

In many cases we can avoid needing an explicit reference to the more
complicated type by making use of a transparent union. There's already
at least one transparent union in GSK's public API, so it's presumably
portable enough to match GTK's requirements.

Increasing the alignment of GskAlignedPoint also requires adjusting how
a GskStandardContour is allocated and initialized. This data structure
allocates extra memory to hold an array of GskAlignedPoint outside the
bounds of the struct itself, and that array now needs to be aligned
suitably. Previously the array started with at next byte after the
flexible array of gskpathop, but the alignment of a gskpathop is only
4 bytes on 32-bit architectures, so depending on the number of gskpathop
in the trailing flexible array, that pointer might be an unsuitable
location to allocate a GskAlignedPoint.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6395
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-07-28 17:31:41 +01:00
..
broadway gdk: Add color state arg to gdk_texture_download_surface() 2024-07-11 14:57:20 +02:00
gl gsk, testsuite: Avoid undefined behaviour in half_to_float_one() 2024-07-27 20:22:09 +01:00
gpu gpu: Don't mess up color states 2024-07-26 17:34:48 -04:00
gen-gsk-gresources-xml.py gpu: Add ability to run shaders 2024-01-07 07:22:49 +01:00
gsk.h gsk: Include GL renderer in gsk.h 2024-01-07 14:47:22 +01:00
gskboundingboxprivate.h Add gsk_bounding_box_get_corner 2023-09-16 21:57:31 -04:00
gskcairoblur.c Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
gskcairoblurprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gskcairorenderer.c cairo: Use the draw context's color state 2024-07-11 14:57:20 +02:00
gskcairorenderer.h gsk: Add header guard to missing header 2024-01-07 07:22:49 +01:00
gskcontour.c gskpathop: Introduce a type to represent an aligned graphene_point_t 2024-07-28 17:31:41 +01:00
gskcontourprivate.h gskpathop: Introduce a type to represent an aligned graphene_point_t 2024-07-28 17:31:41 +01:00
gskcurve-ct-values.c curve: Reduce the order of our approximation 2023-08-26 10:23:02 -04:00
gskcurve.c gskpathop: Introduce a type to represent an aligned graphene_point_t 2024-07-28 17:31:41 +01:00
gskcurveprivate.h gskpathop: Introduce a type to represent an aligned graphene_point_t 2024-07-28 17:31:41 +01:00
gskdebug.c gsk: Rename GSK_DEBUG=glyphcache to GSK_DEBUG=cache 2024-07-07 05:24:45 +02:00
gskdebugprivate.h gsk: Rename GSK_DEBUG=glyphcache to GSK_DEBUG=cache 2024-07-07 05:24:45 +02:00
gskdiff.c gsk: Stop using g_slice 2023-03-14 14:56:42 -04:00
gskdiffprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gskenums.h Add Since annotations to enums 2023-12-22 08:47:47 -05:00
gskenumtypes.c.template types: fix various use of volatile in type registration 2020-11-18 20:21:33 -08:00
gskenumtypes.h.template Use @basename@ in enumeration type templates 2019-02-04 14:02:45 +01:00
gskglshader.c gskglshader: Fix typo in deprecation docs 2024-07-08 09:21:43 +03:00
gskglshader.h gsk: Deprecate GskGLShader and the rendernode 2024-07-04 21:28:06 +02:00
gskglshaderprivate.h gsk: Deprecate GskGLShader and the rendernode 2024-07-04 21:28:06 +02:00
gskoffload.c Take all transforms into account 2024-07-10 22:11:13 +02:00
gskoffloadprivate.h gdk: Rename GdkTextureTransform to GdkDihedral 2024-07-10 12:36:07 +02:00
gskpath.c gskpathop: Introduce a type to represent an aligned graphene_point_t 2024-07-28 17:31:41 +01:00
gskpath.h Change gsk_path_get_closest_point to return distance 2023-08-28 11:22:30 -04:00
gskpathbuilder.c gskpathop: Introduce a type to represent an aligned graphene_point_t 2024-07-28 17:31:41 +01:00
gskpathbuilder.h pathbuilder: Add rel-variants for arc-to 2023-08-25 09:45:45 -04:00
gskpathmeasure.c measure: Cosmetics 2023-08-28 21:14:28 -04:00
gskpathmeasure.h Add GskPathMeasure 2023-08-25 20:16:49 -04:00
gskpathopprivate.h gskpathop: Introduce a type to represent an aligned graphene_point_t 2024-07-28 17:31:41 +01:00
gskpathparser.c path: Fix parsing rounded rects 2023-09-17 17:01:44 -04:00
gskpathpoint.c gskpathpoint: Document copy and free 2024-05-31 11:47:29 +02:00
gskpathpoint.h Add a few annotations 2023-12-26 21:57:04 -05:00
gskpathpointprivate.h Improve precondition checks for path points 2023-08-28 00:07:50 -04:00
gskpathprivate.h path: document enum 2024-04-28 08:33:03 +02:00
gskprivate.c Bump the pango dep 2024-04-04 00:56:24 +02:00
gskprivate.h Drop unused private API 2024-04-03 10:53:55 +02:00
gskprofiler.c Fix various bitfield warnings 2023-04-27 13:42:03 +02:00
gskprofilerprivate.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gskrectprivate.h transform: Implement transform_bounds() for dihedrals 2024-07-10 21:34:12 +02:00
gskrenderer.c gsk: Require dmabuf support for Vulkan 2024-05-05 15:19:17 -04:00
gskrenderer.h API: Add gsk_renderer_realize_for_display() 2024-01-07 14:47:22 +01:00
gskrendererprivate.h renderer: Pass the display as part of the vfunc 2024-01-07 14:47:22 +01:00
gskrendernode.c cairo: Add colorstate to GskRenderNode::draw and use it 2024-07-11 14:57:20 +02:00
gskrendernode.h gsk: Add gsk_render_node_get_opaque_rect() 2024-07-08 15:28:14 +02:00
gskrendernodeimpl.c cairo: Add colorstate to GskRenderNode::draw and use it 2024-07-11 14:57:20 +02:00
gskrendernodeparser.c gdk: Add color state arg to gdk_texture_download_surface() 2024-07-11 14:57:20 +02:00
gskrendernodeparserprivate.h gsk: Allow custom fonts in node files 2024-01-15 18:58:17 -05:00
gskrendernodeprivate.h cairo: Add colorstate to GskRenderNode::draw and use it 2024-07-11 14:57:20 +02:00
gskroundedrect.c Add gdk_dihedral_swaps_xy 2024-07-10 21:34:12 +02:00
gskroundedrect.h gsk: Move GskRoundedRect typedef 2023-09-15 03:46:27 +02:00
gskroundedrectprivate.h gpu: Implement transform support for dihedral transforms 2024-07-10 21:34:12 +02:00
gskstroke.c gskstroke: Add missing return annotations 2024-06-01 10:01:19 +02:00
gskstroke.h Add GskStroke 2023-08-07 13:02:57 -04:00
gskstrokeprivate.h stroke: Turn stroke copy intialization into a macro 2023-12-28 07:35:46 +01:00
gsktransform.c transform: Implement transform_point() for dihedrals 2024-07-10 21:34:12 +02:00
gsktransform.h Convert headers to #pragma once 2023-03-31 15:11:10 -04:00
gsktransformprivate.h transform: Add gsk_transform_to_dihedral() 2024-07-10 14:38:48 +02:00
gsktypes.h gsk: Move GskRoundedRect typedef 2023-09-15 03:46:27 +02:00
meson.build gsk: Add a cicp convert shader 2024-07-24 08:16:08 -06:00