@@ -860,8 +860,9 @@ tilecache_snap_rect_to_boundary(graphene_rect_t *bounds, double pixel_size)
860860/* Scale is how much the level0 image has been scaled, x/y is the position of
861861 * the top-left corner of @paint in the scaled image.
862862 *
863- * @pixel_scale is gdk_surface_get_scale() for the surface this snapshot will
864- * be rendered to.
863+ * @pixel_size is the size of hardware pixels, so at 200% desktop scaling,
864+ * for example, this will be 0.5. In this case, we'd need to draw tiles half
865+ * size to get 1 image pixel == 1 display pixel.
865866 *
866867 * @paint is the pixel area in gtk coordinates that we paint in the widget.
867868 *
@@ -893,12 +894,12 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
893894 tilecache , scale , x , y );
894895#endif /*DEBUG*/
895896
896- #ifdef DEBUG_VERBOSE
897+ #ifdef DEBUG
897898 printf (" paint x = %g, y = %g, "
898899 "width = %g, height = %g\n" ,
899900 paint -> origin .x , paint -> origin .y ,
900901 paint -> size .width , paint -> size .height );
901- #endif /*DEBUG_VERBOSE */
902+ #endif /*DEBUG */
902903
903904#ifdef DEBUG_VERBOSE
904905 printf ("tilecache_snapshot: %p tiles are:\n" , tilecache );
@@ -915,13 +916,23 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
915916 else
916917 z = VIPS_CLIP (0 , log (1.0 / scale ) / log (2.0 ), tilecache -> n_levels - 1 );
917918
918- /* paint_rect in level0 coordinates.
919+ /* paint_rect in image level0 coordinates. We want 1 image pixel == 1
920+ * display hardware pixel, so we need to also scale by pixel_size.
919921 */
920922 graphene_rect_t viewport ;
921- viewport .origin .x = x / scale ;
922- viewport .origin .y = y / scale ;
923- viewport .size .width = VIPS_MAX (1 , paint -> size .width / scale );
924- viewport .size .height = VIPS_MAX (1 , paint -> size .height / scale );
923+ viewport .origin .x = x / (scale * pixel_size );
924+ viewport .origin .y = y / (scale * pixel_size );
925+ viewport .size .width =
926+ VIPS_MAX (1 , paint -> size .width / (scale * pixel_size ));
927+ viewport .size .height =
928+ VIPS_MAX (1 , paint -> size .height / (scale * pixel_size ));
929+
930+ #ifdef DEBUG
931+ printf (" viewport image0 coordinates x = %g, y = %g, "
932+ "width = %g, height = %g\n" ,
933+ viewport .origin .x , viewport .origin .y ,
934+ viewport .size .width , viewport .size .height );
935+ #endif /*DEBUG*/
925936
926937 /* Fetch any tiles we are missing, update any tiles we have that have
927938 * been flagged as having pixels ready for fetching.
@@ -964,16 +975,18 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
964975 /* If we are zooming in beyond 1:1, we want nearest so we don't
965976 * blur the image. For zooming out, we want trilinear to get
966977 * mipmaps and antialiasing.
967- */
968978 GskScalingFilter filter = scale > 1.0 ?
969979 GSK_SCALING_FILTER_NEAREST : GSK_SCALING_FILTER_TRILINEAR;
980+ */
981+ GskScalingFilter filter = GSK_SCALING_FILTER_NEAREST ;
970982
971983 graphene_rect_t bounds ;
972-
973- bounds .origin .x = tile -> bounds0 .left * scale - x + paint -> origin .x ;
974- bounds .origin .y = tile -> bounds0 .top * scale - y + paint -> origin .y ;
975- bounds .size .width = tile -> bounds0 .width * scale ;
976- bounds .size .height = tile -> bounds0 .height * scale ;
984+ bounds .origin .x =
985+ tile -> bounds0 .left * scale * pixel_size - x + paint -> origin .x ;
986+ bounds .origin .y =
987+ tile -> bounds0 .top * scale * pixel_size - y + paint -> origin .y ;
988+ bounds .size .width = tile -> bounds0 .width * scale * pixel_size ;
989+ bounds .size .height = tile -> bounds0 .height * scale * pixel_size ;
977990
978991#ifndef HAVE_GTK_SNAPSHOT_SET_SNAP
979992 tilecache_snap_rect_to_boundary (& bounds , pixel_size );
0 commit comments