Skip to content

Commit 92c8f04

Browse files
committed
Prefer use of gtk_snapshot_set_snap()
See: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/8494
1 parent 13560a8 commit 92c8f04

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ configure_file(
4141

4242
# need vips_thread_execute()
4343
vips_dep = dependency('vips', version: '>=8.17')
44-
glib_dep = dependency('glib-2.0')
45-
gtk_dep = dependency('gtk4')
44+
gtk_dep = dependency('gtk4', version: '>=4.10')
4645
m_dep = cc.find_library('m')
4746

47+
glib_dep = dependency('glib-2.0')
4848
if not cc.has_header_symbol('glib.h', 'g_autofree', dependencies : glib_dep)
4949
error('vipsdisp requires the GNU C "cleanup" attribute.')
5050
endif

src/imagedisplay.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,13 @@ imagedisplay_snapshot(GtkWidget *widget, GtkSnapshot *snapshot)
651651

652652
GTK_WIDGET_CLASS(imagedisplay_parent_class)->snapshot(widget, snapshot);
653653

654+
#ifdef GSK_RECT_SNAP_ROUND
655+
/* Round tile bounds to the closest pixel edge on all sides to prevent
656+
* seams.
657+
*/
658+
gtk_snapshot_set_snap(snapshot, GSK_RECT_SNAP_ROUND);
659+
#endif
660+
654661
/* Clip to the widget area, or we may paint over the display control
655662
* bar.
656663
*/

src/tile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ tile_touch(Tile *tile)
8787
}
8888

8989
/* Make a tile on an image. left/top in this image's coordinates (not level0
90-
* coordfinates).
90+
* coordinates).
9191
*/
9292
Tile *
9393
tile_new(VipsImage *level, int left, int top, int z)

src/tilecache.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,12 +1023,17 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
10231023

10241024
graphene_rect_t bounds;
10251025

1026-
// +1 to hide tile boundaries
10271026
bounds.origin.x = tile->bounds.left * scale - x + paint->origin.x;
10281027
bounds.origin.y = tile->bounds.top * scale - y + paint->origin.y;
1028+
#ifdef GSK_RECT_SNAP_ROUND
1029+
// gtk_snapshot_set_snap() is available
1030+
bounds.size.width = tile->bounds.width * scale;
1031+
bounds.size.height = tile->bounds.height * scale;
1032+
#else
1033+
// +1 to hide tile boundaries
10291034
bounds.size.width = tile->bounds.width * scale + 1;
10301035
bounds.size.height = tile->bounds.height * scale + 1;
1031-
1036+
#endif
10321037
gtk_snapshot_append_scaled_texture(snapshot,
10331038
tile_get_texture(tile), filter, &bounds);
10341039

src/vipsdisp.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
*/
2929
#define MAX_TILES (2 * (4096 / TILE_SIZE) * (2048 / TILE_SIZE))
3030

31-
/* We GtkInfoBar, which is going away in gtk5.
32-
*/
33-
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
34-
3531
#define FREESID(SID, OBJ) \
3632
G_STMT_START \
3733
{ \

0 commit comments

Comments
 (0)