3232/*
3333#define DEBUG_RENDER_TIME
3434#define DEBUG_VERBOSE
35- */
3635#define DEBUG
36+ */
3737
3838enum {
3939 /* Properties.
@@ -860,9 +860,8 @@ 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_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.
863+ * @pixel_scale is gdk_surface_get_scale() for the surface this snapshot will
864+ * be rendered to.
866865 *
867866 * @paint is the pixel area in gtk coordinates that we paint in the widget.
868867 *
@@ -894,12 +893,12 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
894893 tilecache , scale , x , y );
895894#endif /*DEBUG*/
896895
897- #ifdef DEBUG
896+ #ifdef DEBUG_VERBOSE
898897 printf (" paint x = %g, y = %g, "
899898 "width = %g, height = %g\n" ,
900899 paint -> origin .x , paint -> origin .y ,
901900 paint -> size .width , paint -> size .height );
902- #endif /*DEBUG */
901+ #endif /*DEBUG_VERBOSE */
903902
904903#ifdef DEBUG_VERBOSE
905904 printf ("tilecache_snapshot: %p tiles are:\n" , tilecache );
@@ -916,23 +915,13 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
916915 else
917916 z = VIPS_CLIP (0 , log (1.0 / scale ) / log (2.0 ), tilecache -> n_levels - 1 );
918917
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.
918+ /* paint_rect in level0 coordinates.
921919 */
922920 graphene_rect_t viewport ;
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*/
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 );
936925
937926 /* Fetch any tiles we are missing, update any tiles we have that have
938927 * been flagged as having pixels ready for fetching.
@@ -975,18 +964,16 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
975964 /* If we are zooming in beyond 1:1, we want nearest so we don't
976965 * blur the image. For zooming out, we want trilinear to get
977966 * mipmaps and antialiasing.
967+ */
978968 GskScalingFilter filter = scale > 1.0 ?
979969 GSK_SCALING_FILTER_NEAREST : GSK_SCALING_FILTER_TRILINEAR ;
980- */
981- GskScalingFilter filter = GSK_SCALING_FILTER_NEAREST ;
982970
983971 graphene_rect_t bounds ;
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 ;
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 ;
990977
991978#ifndef HAVE_GTK_SNAPSHOT_SET_SNAP
992979 tilecache_snap_rect_to_boundary (& bounds , pixel_size );
0 commit comments