Skip to content

Commit 61172a3

Browse files
committed
oops, should be 1.0 / scale
1 parent 929b91c commit 61172a3

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/imagedisplay.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,16 +666,17 @@ imagedisplay_snapshot(GtkWidget *widget, GtkSnapshot *snapshot)
666666
paint.size.width = imagedisplay->paint_rect.width;
667667
paint.size.height = imagedisplay->paint_rect.height;
668668

669-
/* Used for tile snapping if there's no gtk snapshot system.
669+
/* If there's no gtk snapping, we do our own based on the hardware pixel
670+
* size for the surface this snapshot will be rendered to.
670671
*/
671672
GtkNative *native = gtk_widget_get_native(widget);
672673
GdkSurface *surface = gtk_native_get_surface(native);
673-
double scale_factor = gdk_surface_get_scale_factor(surface);
674+
double pixel_size = 1.0 / gdk_surface_get_scale_factor(surface);
674675

675676
if (imagedisplay->tilecache &&
676677
imagedisplay->tilecache->n_levels > 0)
677678
tilecache_snapshot(imagedisplay->tilecache, snapshot,
678-
scale_factor,
679+
pixel_size,
679680
imagedisplay->scale, imagedisplay->x, imagedisplay->y,
680681
&paint, imagedisplay->debug);
681682

src/tilecache.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -841,14 +841,14 @@ tilecache_draw_bounds(GtkSnapshot *snapshot,
841841
* white lines on tile edges.
842842
*/
843843
static void
844-
tilecache_snap_rect_to_boundary(graphene_rect_t *bounds, double scale)
844+
tilecache_snap_rect_to_boundary(graphene_rect_t *bounds, double pixel_size)
845845
{
846-
double left = rint(bounds->origin.x * scale) / scale;
847-
double top = rint(bounds->origin.y * scale) / scale;
846+
double left = rint(bounds->origin.x * pixel_size) / pixel_size;
847+
double top = rint(bounds->origin.y * pixel_size) / pixel_size;
848848
double right =
849-
rint((bounds->origin.x + bounds->size.width) * scale) / scale;
849+
rint((bounds->origin.x + bounds->size.width) * pixel_size) / pixel_size;
850850
double bottom =
851-
rint((bounds->origin.y + bounds->size.height) * scale) / scale;
851+
rint((bounds->origin.y + bounds->size.height) * pixel_size) / pixel_size;
852852

853853
bounds->origin.x = left;
854854
bounds->origin.y = top;
@@ -869,7 +869,7 @@ tilecache_snap_rect_to_boundary(graphene_rect_t *bounds, double scale)
869869
*/
870870
void
871871
tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
872-
double scale_factor,
872+
double pixel_size,
873873
double scale, double x, double y, graphene_rect_t *paint, gboolean debug)
874874
{
875875
/* In debug mode, scale and offset so we can see tile clipping.
@@ -975,7 +975,7 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
975975
#ifndef HAVE_GTK_SNAPSHOT_SET_SNAP
976976
/* Without gtk snap, we have to snap tiles edges ourselves.
977977
*/
978-
tilecache_snap_rect_to_boundary(&bounds, scale_factor);
978+
tilecache_snap_rect_to_boundary(&bounds, pixel_size);
979979
#endif /*!HAVE_GTK_SNAPSHOT_SET_SNAP*/
980980

981981
gtk_snapshot_append_scaled_texture(snapshot,

src/tilecache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Tilecache *tilecache_new();
110110
/* Render the tiles to a snapshot.
111111
*/
112112
void tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
113-
double scale_factor,
113+
double pixel_size,
114114
double scale, double x, double y, graphene_rect_t *paint, gboolean debug);
115115

116116
#endif /*__TILECACHE_H*/

0 commit comments

Comments
 (0)