Commit Graph

1746 Commits

Author SHA1 Message Date
Matthias Clasen
c43e1f3d0a gsk: Quiet a compiler warning 2023-01-28 21:13:10 -05:00
Christian Hergert
fb12ad807a gsk/gl: fix warning when join_sources() is unused 2023-01-12 13:22:25 -08:00
Matthias Clasen
46e0fde606 css: Avoid more allocations for tokens
Make short string tokens static.
2023-01-12 00:12:09 -05:00
Carlos Garnacho
b9448b06b4 gsk: Extend the blur radius for outset shadow extents
By dividing the blur radius to obtain the clip radius, we may end up
with halved values that result in an overshunk clip mask. Extend this
so that we ensure to cover the last pixel.

Fixes artifacts seen with the cairo renderer in X11 when resizing
windows horizontally, a black 1px high line would be seen in the
top of the window due to these outset bounds being used in clipping.

More mysteriously, also seems to fix resize lag in the GL renderer
(also X11), if e.g. the bottom-right corner of a window is resized
diagonally in bottom-left -> top-right direction, or
bottom-right -> top-left.

Related: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175#note_1599335
2022-11-23 19:27:49 +01:00
Carlos Garnacho
35744d87a2 gsk: Also ceil() top side when converting graphene to cairo rectangles
The outset border for all sides is ceil()ed, except for the top side.
Most often values are already nicely rounded here, but this seems an
oversight.
2022-11-23 18:56:45 +01:00
Matthias Clasen
b441c684ab gsk: Avoid a crash with negative scales
Don't crash when both scale_x and scale_y are -1.

A test is included.
2022-11-20 12:13:02 -05:00
Matthias Clasen
ce57150203 gsk: Add an assertion to help static analysis
clang gets wild ideas about negative radii otherwise.
2022-11-18 00:04:23 -05:00
Matthias Clasen
b12d31d189 Fix spelling errors
These were pointed out by codespell.
2022-11-17 22:49:45 -05:00
Matthias Clasen
4aabc45685 Drop gdkintl.h
This header was merely including gi18n-lib.h.
Just do that directly.
2022-09-23 23:33:42 -04:00
Matthias Clasen
a8af7caae1 Rename gdk-private.h to gdkprivate.h
The extra - does not add any value.
2022-09-23 23:23:27 -04:00
Matthias Clasen
c24a69549d Rename gdkdebug.h to gdkdebugprivate.h
This is the naming convention for private headers.
2022-09-23 23:12:01 -04:00
Matthias Clasen
3688ece655 gsk: Dissolve gsk-autocleanup.h
Move the autocleanup declarations into their
respective headers.
2022-09-23 19:50:09 -04:00
Matthias Clasen
f33f55bcbb gtk: Use the new debug macros 2022-09-23 18:12:39 -04:00
Matthias Clasen
8a4fd30797 gsk: drop old debug macros
These are no longer used.
2022-09-23 18:11:48 -04:00
Matthias Clasen
9818ec4ad9 gsk: Use the new debug macros 2022-09-23 18:11:48 -04:00
Matthias Clasen
4d08eb264d gsk: Introduce new debug macros
Introduce GSK_RENDERER_DEBUG() and GSK_DEBUG(), which
mirror the new macros in gdk. They use the same helper
function gdk_debug_message().
2022-09-23 18:11:48 -04:00
Matthias Clasen
511a4ec475 gsk: Make glyph upload more similar to icons
When uploading glyphs to the atlas, clear
the padding bytes so that no dirt remains there.
2022-09-10 15:25:59 -04:00
Luca Bacci
bcccb46b7c GL Renderer: Ensure that GdkGLContext is current in gsk_gl_driver_shader_weak_cb
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5140
2022-08-27 13:58:17 +02:00
Sebastian Dröge
0cc2d5559b Mark gsk_rounded_clip_node_new() return value as (transfer full)
Like all the other constructors for nodes already do. Without this,
newly created rounded clip nodes are leaked in bindings.
2022-08-10 11:07:51 +03:00
Matthias Clasen
a4c6517d06 glshader: Add preconditions
Add preconditions to many of the glshader
uniform apis.
2022-07-15 15:47:11 -04:00
Matthias Clasen
7ebc5454f4 Drop an unused function 2022-07-15 15:47:11 -04:00
Matthias Clasen
2cbb955e49 rendernodeparser: Cosmetics 2022-07-15 15:46:06 -04:00
Matthias Clasen
00d45c6743 Merge branch 'update-initial-layout' into 'main'
vulkan: Set initial layout to undefined

See merge request GNOME/gtk!4706
2022-05-27 12:26:24 +00:00
Matthias Clasen
38b393ff5d Merge branch 'update-command-buffer-freeing' into 'main'
vulkan: Don't attempt to free 0 command buffers

See merge request GNOME/gtk!4705
2022-05-27 12:25:48 +00:00
Benjamin Otte
0410125f20 nodeparser: Fix parsing of color-matrix node
Negative offsets in the color matrix were inverted because it used the
rect parser.
2022-05-18 21:16:33 +02:00
Christian Hergert
654d74bfb8 gsk/gl: use critical instead of assert in dispose
Instead of asserting only in debug builds (which are generally not
shipped in distributions) we should deliver a critical log-level message
so that these can be found sooner when not developing with jhbuild,
Flatpak, etc.

Also assert that we've setup the state correctly when realizing the
GskGLRenderer object.

Fixes #4625
2022-05-16 10:50:48 -07:00
Matthias Clasen
dd16d7c4c8 gsk: Serialize float textures as tiff
Otherwise, we lose precision when converting them
to 16bit integers.
2022-05-13 12:34:24 -04:00
Sophie Herold
a546ae32d7 Remove all nicks and blurbs from param specs
Those property features don't seem to be in use anywhere.
They are redundant since the docs cover the same information
and more. They also created unnecessary translation work.

Closes #4904
2022-05-11 18:16:29 +02:00
TestingPlant
1c587c7d7f vulkan: Set initial layout to undefined
Having the initial layout set to VK_IMAGE_LAYOUT_GENERAL causes issues
when going from the final layout to the initial layout since the image
layout is expected to be the general layout. Setting the initial layout
to undefined doesn't have this restriction.
2022-05-08 05:39:36 +00:00
TestingPlant
2f98de06bc vulkan: Don't attempt to free 0 command buffers
vkFreeCommandBuffers can't be called with commandBufferCount set to 0.
2022-05-08 05:37:14 +00:00
Matthias Clasen
0da75b0bbf gsk: Check for half float support
The GL renderer currently relies on half float support
in vertex buffers, so check that we have it.

Related: #4894
2022-05-06 11:05:57 -04:00
Matthias Clasen
84b3b1fab5 gsk/gl: Typo fix 2022-04-08 11:20:12 -04:00
Matthias Clasen
8c548d5579 Merge branch 'nonoverlapping-containers' into 'main'
gsk/gl: Avoid offscreening in more cases

See merge request GNOME/gtk!4619
2022-04-07 14:32:53 +00:00
Matthias Clasen
d72ed045df gsk/gl: Use pre-collected opacity information
We now collect this information during node
construction, so use it here.

The concrete change here is that we now avoid
offscreens for container nodes with multiple children,
as long as they don't overlap. In particular, this
avoid offscreens for ellipsized dim labels.
2022-04-05 14:57:38 -04:00
Matthias Clasen
38eb182947 gsk: Collect opacity information
Collect information about whether to use offscreens
for opacity during node construction, so we don't
need to walk the tree repeatedly, later.
2022-04-05 14:57:38 -04:00
Matthias Clasen
0eba21b2b5 gsk: Track disjointness of container nodes
This can be used to optimize some things in the
GL renderer.
2022-04-05 14:57:38 -04:00
Matthias Clasen
21cba193ad Merge branch 'blurry-offscreen' into 'main'
gsk/gl: Always align offscreen rendering with the pixel grid

Closes #3833

See merge request GNOME/gtk!4621
2022-04-05 12:25:59 +00:00
Matthias Clasen
48dbbbc099 gl: Don't leak big glyphs
We were never resetting the accessed bit of
glyphs that are big enough to be stored individually,
so these would just accumulate and never be dropped.
2022-04-04 23:00:45 -04:00
Sebastian Keller
85a6517d65 gsk/gl: Always align offscreen rendering with the pixel grid
This fixes two issues with the offscreen rendering code for nodes with
bounds not aligned with the pixel grid:

1.) When drawing to an offscreen buffer the size of the offscreen buffer
was rounded up, but then later when used as texture the vertices
correspond to the original bounds with the unrounded size. This could
then result in the offscreen texture being drawn onscreen at a slightly
smaller size, which then lead to it being visually shifted and blurry.

This is fixed by adjusting the u/v coordinates to ignore the padding
region in the offscreen texture that got added by the size increase from
rounding.

2.) The viewport used when rendering to the offscreen buffer was not
aligned with the pixel grid for nodes at coordinates not aligned with
the pixel grid. Then because the content of the offscreen buffer is not
aligned with the pixel grid and later when used as textures sampling
from it will result in interpolated values for an onscreen pixel. This
could also result in shifting and blurriness, especially for nested
offscreen rendering at different offsets.

This is fixed by adding similar padding at the beginning of the
texture and also adjusting the u/v coordinates to ignore this region.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3833
2022-04-04 21:40:01 +02:00
Matthias Clasen
af20f7e9b5 gl: Don't leak big glyphs
We were never resetting the accessed bit of
glyphs that are big enough to be stored individually,
so these would just accumulate and never be dropped.
2022-04-03 20:25:22 -04:00
Matthias Clasen
2af8ac655b gsk: Plug a memory leak
This was introduced in 9defc7fc64.
2022-04-03 07:34:44 -04:00
Christian Hergert
cbbca38d88 gsk/gl: use consistent library naming 2022-03-18 14:59:49 -07:00
Christian Hergert
c64836e1c9 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-03-18 14:59:46 -07:00
Christian Hergert
6b23fe3aa7 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-03-18 12:48:43 -07:00
Christian Hergert
9defc7fc64 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-03-18 12:34:32 -07:00
Christian Hergert
9d56f44cdf 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-03-18 12:34:32 -07:00
Christian Hergert
1b9da2bb17 gsk/gl: allow configuring atlas size 2022-03-18 12:34:27 -07:00
Christian Hergert
2efc1729e2 gsk/gl: check for format as well
This could potentially happen if a uniform had never been set.
2022-03-18 12:33:33 -07:00
Christian Hergert
a66a0dde81 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-03-18 12:33:33 -07:00
Christian Hergert
7062411bad 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-03-18 12:33:33 -07:00