Skip to content

Commit 886f9a1

Browse files
committed
Fix tile seam issue in nip4 and vipsdisp
By removing the 1 pixel tile stretch and applying a patch to GTK.
1 parent 908d7b5 commit 886f9a1

File tree

3 files changed

+132
-2
lines changed

3 files changed

+132
-2
lines changed

build/patches/nip4-9-fixes.patch

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Kleis Auke Wolthuizen <[email protected]>
3+
Date: Thu, 26 Jun 2025 14:30:22 +0200
4+
Subject: [PATCH 1/1] Remove 1 pixel tile stretch
5+
6+
Upstream-Status: Pending [https://github.com/jcupitt/nip4/issues/17]
7+
8+
diff --git a/src/tilecache.c b/src/tilecache.c
9+
index 1111111..2222222 100644
10+
--- a/src/tilecache.c
11+
+++ b/src/tilecache.c
12+
@@ -1023,11 +1023,10 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
13+
14+
graphene_rect_t bounds;
15+
16+
- // +1 to hide tile boundaries
17+
bounds.origin.x = tile->bounds.left * scale - x + paint->origin.x;
18+
bounds.origin.y = tile->bounds.top * scale - y + paint->origin.y;
19+
- bounds.size.width = tile->bounds.width * scale + 1;
20+
- bounds.size.height = tile->bounds.height * scale + 1;
21+
+ bounds.size.width = tile->bounds.width * scale;
22+
+ bounds.size.height = tile->bounds.height * scale;
23+
24+
gtk_snapshot_append_scaled_texture(snapshot,
25+
tile_get_texture(tile), filter, &bounds);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Kleis Auke Wolthuizen <[email protected]>
3+
Date: Thu, 26 Jun 2025 14:30:22 +0200
4+
Subject: [PATCH 1/1] Remove 1 pixel tile stretch
5+
6+
Upstream-Status: Submitted [https://github.com/jcupitt/vipsdisp/pull/47]
7+
8+
diff --git a/src/tilecache.c b/src/tilecache.c
9+
index 1111111..2222222 100644
10+
--- a/src/tilecache.c
11+
+++ b/src/tilecache.c
12+
@@ -1032,11 +1032,10 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
13+
14+
graphene_rect_t bounds;
15+
16+
- // +1 to hide tile boundaries
17+
bounds.origin.x = tile->bounds.left * scale - x + paint->origin.x;
18+
bounds.origin.y = tile->bounds.top * scale - y + paint->origin.y;
19+
- bounds.size.width = tile->bounds.width * scale + 1;
20+
- bounds.size.height = tile->bounds.height * scale + 1;
21+
+ bounds.size.width = tile->bounds.width * scale;
22+
+ bounds.size.height = tile->bounds.height * scale;
23+
24+
gtk_snapshot_append_scaled_texture(snapshot,
25+
tile_get_texture(tile), filter, &bounds);

build/plugins/gtk4/patches/gtk-4-fixes.patch

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: Kleis Auke Wolthuizen <[email protected]>
33
Date: Thu, 26 Oct 2023 17:00:00 +0200
4-
Subject: [PATCH 1/2] Make gtk4-builder-tool optional
4+
Subject: [PATCH 1/3] Make gtk4-builder-tool optional
55

66

77
diff --git a/docs/reference/gtk/images/meson.build b/docs/reference/gtk/images/meson.build
@@ -24,7 +24,7 @@ index 1111111..2222222 100644
2424
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2525
From: Christoph Reiter <[email protected]>
2626
Date: Sat, 7 Sep 2024 13:39:22 +0200
27-
Subject: [PATCH 2/2] Disable automatic font rendering settings
27+
Subject: [PATCH 2/3] Disable automatic font rendering settings
2828

2929
To restore the old code taking Windows settings into account.
3030

@@ -44,3 +44,83 @@ index 1111111..2222222 100644
4444
GTK_PARAM_READWRITE);
4545

4646
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, pspecs);
47+
48+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
49+
From: Kleis Auke Wolthuizen <[email protected]>
50+
Date: Thu, 26 Jun 2025 14:50:16 +0200
51+
Subject: [PATCH 3/3] gpu: Snap texture scale nodes to grid
52+
53+
Upstream-Status: Inappropriate [other]
54+
This patch is effectively equivalent to calling
55+
`gtk_snapshot_set_snap(snapshot, GSK_RECT_SNAP_ROUND)` when
56+
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/8494 lands.
57+
58+
diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c
59+
index 1111111..2222222 100644
60+
--- a/gsk/gpu/gskgpunodeprocessor.c
61+
+++ b/gsk/gpu/gskgpunodeprocessor.c
62+
@@ -2289,6 +2289,7 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
63+
GdkColorState *image_cs;
64+
GskScalingFilter scaling_filter;
65+
gboolean need_mipmap, need_offscreen;
66+
+ graphene_rect_t bounds;
67+
68+
texture = gsk_texture_scale_node_get_texture (node);
69+
scaling_filter = gsk_texture_scale_node_get_filter (node);
70+
@@ -2352,6 +2353,8 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
71+
return;
72+
}
73+
74+
+ gsk_rect_snap_to_grid_round (&node->bounds, &self->scale, &self->offset, &bounds);
75+
+
76+
if ((gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_STRAIGHT_ALPHA) ||
77+
(need_mipmap && !(gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_CAN_MIPMAP)) ||
78+
!gdk_color_state_equal (image_cs, self->ccs))
79+
@@ -2368,13 +2371,13 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
80+
gsk_gpu_mipmap_op (self->frame, image);
81+
82+
gsk_gpu_texture_op (self->frame,
83+
- gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &node->bounds),
84+
+ gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &bounds),
85+
&self->offset,
86+
&(GskGpuShaderImage) {
87+
image,
88+
gsk_gpu_sampler_for_scaling_filter (scaling_filter),
89+
- &node->bounds,
90+
- &node->bounds,
91+
+ &bounds,
92+
+ &bounds,
93+
});
94+
95+
g_object_unref (image);
96+
diff --git a/gsk/gskrectprivate.h b/gsk/gskrectprivate.h
97+
index 1111111..2222222 100644
98+
--- a/gsk/gskrectprivate.h
99+
+++ b/gsk/gskrectprivate.h
100+
@@ -199,6 +199,26 @@ gsk_rect_snap_to_grid (const graphene_rect_t *src,
101+
(ceilf ((src->origin.y + grid_offset->y + src->size.height) * yscale) - y) / yscale);
102+
}
103+
104+
+static inline void
105+
+gsk_rect_snap_to_grid_round (const graphene_rect_t *src,
106+
+ const graphene_vec2_t *grid_scale,
107+
+ const graphene_point_t *grid_offset,
108+
+ graphene_rect_t *dest)
109+
+{
110+
+ float x, y, xscale, yscale;
111+
+
112+
+ xscale = graphene_vec2_get_x (grid_scale);
113+
+ yscale = graphene_vec2_get_y (grid_scale);
114+
+
115+
+ x = round ((src->origin.x + grid_offset->x) * xscale);
116+
+ y = round ((src->origin.y + grid_offset->y) * yscale);
117+
+ *dest = GRAPHENE_RECT_INIT (
118+
+ x / xscale - grid_offset->x,
119+
+ y / yscale - grid_offset->y,
120+
+ (round ((src->origin.x + grid_offset->x + src->size.width) * xscale) - x) / xscale,
121+
+ (round ((src->origin.y + grid_offset->y + src->size.height) * yscale) - y) / yscale);
122+
+}
123+
+
124+
static inline gboolean G_GNUC_PURE
125+
gsk_rect_is_empty (const graphene_rect_t *rect)
126+
{

0 commit comments

Comments
 (0)