Skip to content

Commit 565f354

Browse files
committed
fix tile edges
see libvips/vipsdisp#47 thanks @kleisauke!
1 parent e5d0945 commit 565f354

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## master
22

33
- better power of two detection in openslideload
4+
- fix tile edges with gtk_snapshot_set_snap() [kleisauke]
45

56
## 9.0.11 2025/07/21
67

meson.build

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ config_h.set('HAVE_SYS_RESOURCE_H', cc.has_header('sys/resource.h'))
7171
config_h.set('HAVE_GETRLIMIT', cc.has_function('getrlimit'))
7272
config_h.set('HAVE_REALLOCARRAY', cc.has_function('reallocarray', prefix: '#include <stdlib.h>', args: default_source_flag))
7373

74+
gtk_dep = dependency('gtk4', version: '>=4.14')
75+
# use this to fix tile alignment, not yet merged
76+
config_h.set('HAVE_GTK_SNAPSHOT_SET_SNAP', cc.has_header_symbol('gtk.h', 'gtk_snapshot_set_snap', dependencies : gtk_dep))
77+
7478
config_file = configure_file(
7579
output: 'config.h',
7680
configuration: config_h,
@@ -84,7 +88,7 @@ nip4_deps += declare_dependency(
8488

8589
# need vips_thread_execute()
8690
nip4_deps += dependency('vips', version: '>=8.16')
87-
nip4_deps += dependency('gtk4', version: '>=4.14')
91+
nip4_deps += gtk_dep
8892
nip4_deps += dependency('gsl')
8993
nip4_deps += dependency('libxml-2.0')
9094

src/imagedisplay.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,10 @@ imagedisplay_snapshot(GtkWidget *widget, GtkSnapshot *snapshot)
649649

650650
GTK_WIDGET_CLASS(imagedisplay_parent_class)->snapshot(widget, snapshot);
651651

652+
#ifdef HAVE_GTK_SNAPSHOT_SET_SNAP
653+
gtk_snapshot_set_snap(snapshot, GSK_RECT_SNAP_ROUND);
654+
#endif /*HAVE_GTK_SNAPSHOT_SET_SNAP*/
655+
652656
/* Clip to the widget area, or we may paint over the display control
653657
* bar.
654658
*/

src/nip4.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@
130130
*/
131131
#define MAX_LINELENGTH (120)
132132

133-
/* We use various gtk4 features (GtkInfoBar, GtkDialog) which are going away
134-
* in gtk5.
135-
*/
136-
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
137-
138133
// various forward typdefs
139134

140135
typedef struct _BuiltinInfo BuiltinInfo;

src/tilecache.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,16 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
944944
// +1 to hide tile boundaries
945945
bounds.origin.x = tile->bounds0.left * scale - x + paint->origin.x;
946946
bounds.origin.y = tile->bounds0.top * scale - y + paint->origin.y;
947-
bounds.size.width = tile->bounds0.width * scale + 1;
948-
bounds.size.height = tile->bounds0.height * scale + 1;
947+
bounds.size.width = tile->bounds0.width * scale;
948+
bounds.size.height = tile->bounds0.height * scale;
949+
950+
#ifdef HAVE_GTK_SNAPSHOT_SET_SNAP
951+
/* Without set snap, we have to hide tile edges by expanding the
952+
* tile.
953+
*/
954+
bounds.size.width += 1;
955+
bounds.size.height = += 1;
956+
#endif /*HAVE_GTK_SNAPSHOT_SET_SNAP*/
949957

950958
gtk_snapshot_append_scaled_texture(snapshot,
951959
tile_get_texture(tile), filter, &bounds);

src/tilesource.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
/*
3131
#define DEBUG_VERBOSE
3232
#define DEBUG_MAKE
33-
*/
3433
#define DEBUG
34+
*/
3535

3636
#include "nip4.h"
3737

0 commit comments

Comments
 (0)