Skip to content

[Gtk4] Fix blurry images on widgets at HiDPI#3397

Open
akurtakov wants to merge 1 commit into
eclipse-platform:masterfrom
akurtakov:blurry
Open

[Gtk4] Fix blurry images on widgets at HiDPI#3397
akurtakov wants to merge 1 commit into
eclipse-platform:masterfrom
akurtakov:blurry

Conversation

@akurtakov

Copy link
Copy Markdown
Member

On GTK4, GtkPicture measures a GdkTexture by its device-pixel intrinsic size, which inflated widgets at HiDPI.

Introduce a custom scale-aware Gtk4-only GdkPaintable (SwtScaledPaintable) that reports the logical intrinsic size while drawing the full-resolution texture, giving crisp images at the correct widget size.

Use that paintable into the GtkPicture consumers (Button, Label, ExpandItem, ToolItem) and remove the GTK4 downscale in ImageList.

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Test Results (linux)

  103 files  ±0    103 suites  ±0   15m 21s ⏱️ +20s
4 608 tests ±0  4 382 ✅ ±0  226 💤 ±0  0 ❌ ±0 
3 413 runs  ±0  3 335 ✅ ±0   78 💤 ±0  0 ❌ ±0 

Results for commit 39bc65b. ± Comparison against base commit 450ece0.

♻️ This comment has been updated with latest results.

@jonahgraham jonahgraham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks ok to me. I have an open question, which I think isn't relevant, but I thought best to check.


static GdkPaintableFlags swt_scaled_paintable_get_flags (GdkPaintable* paintable)
{
return GDK_PAINTABLE_STATIC_SIZE | GDK_PAINTABLE_STATIC_CONTENTS;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the gdk_paintable_snapshot (GDK_PAINTABLE (self->texture)... ever paint differently or need to invalidate? i.e. is the texture always static contents too?

Ref is this demo from GTK4 which checks the child paintable for static

https://gitlab.gnome.org/GNOME/gtk/-/blob/eddff506651609ff02c641066f51f1c32f1b2fd6/demos/gtk-demo/paintable_emblem.c#L115-121

I am not sure this is wrong as we tend to have the paintables (texture) be rather static and recreated when changed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is always static as GdkTexture is wrapped (https://docs.gtk.org/gdk4/class.Texture.html) and it's clearly stated in its documentation "It is primarily meant for pixel data that will not change over multiple frames, and will be used for a long time." . What's in the demo is due to it handling other types of GdkPaintable e.g https://gnome.pages.gitlab.gnome.org/gdk-pixbuf/gdk-pixbuf/class.PixbufAnimation.html or https://docs.gtk.org/gtk4/class.MediaStream.html but it's not our case.

On GTK4, GtkPicture measures a GdkTexture by its device-pixel intrinsic
size, which inflated widgets at HiDPI.

Introduce a custom scale-aware Gtk4-only GdkPaintable
(SwtScaledPaintable) that reports the logical intrinsic size while
drawing the full-resolution texture, giving crisp images at the correct
widget size.

Use that paintable into the GtkPicture consumers (Button, Label,
ExpandItem, ToolItem) and remove the GTK4 downscale in ImageList.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants