Skip to content

Commit 632ea3c

Browse files
committed
Sync with vipsdisp
Incorporates: libvips/vipsdisp#53.
1 parent 5423df7 commit 632ea3c

File tree

3 files changed

+26
-42
lines changed

3 files changed

+26
-42
lines changed

src/gtkutil.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -621,18 +621,3 @@ weakref_set(GObject **pointer, GObject *object)
621621

622622
#define WEAKREF_SET(A, B) weakref_set((GObject **) &(A), (GObject *) (B));
623623

624-
VipsRect *
625-
rect_graphene_to_vips(graphene_rect_t *graphene, VipsRect *vips)
626-
{
627-
// round out to enclosing int area
628-
graphene_rect_t bounds;
629-
graphene_rect_round_extents(graphene, &bounds);
630-
631-
vips->left = bounds.origin.x;
632-
vips->top = bounds.origin.y;
633-
vips->width = bounds.size.width;
634-
vips->height = bounds.size.height;
635-
636-
return vips;
637-
}
638-

src/gtkutil.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,3 @@ gboolean value_to_filename(const GValue *value,
116116

117117
void weakref_set(GObject **pointer, GObject *object);
118118
#define WEAKREF_SET(A, B) weakref_set((GObject **) &(A), (GObject *) (B));
119-
120-
VipsRect *rect_graphene_to_vips(graphene_rect_t *graphene, VipsRect *vips);

src/tilecache.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ tilecache_print(Tilecache *tilecache)
709709

710710
static void
711711
tilecache_compute_visibility(Tilecache *tilecache,
712-
graphene_rect_t *grect, int z)
712+
VipsRect *viewport, int z)
713713
{
714714
int size0 = TILE_SIZE << z;
715715
int start_time = tile_get_time();
@@ -727,10 +727,8 @@ tilecache_compute_visibility(Tilecache *tilecache,
727727

728728
/* The rect of tiles touched by the viewport.
729729
*/
730-
VipsRect viewport;
731-
rect_graphene_to_vips(grect, &viewport);
732730
VipsRect touches;
733-
tilecache_tiles_for_rect(tilecache, &viewport, z, &touches);
731+
tilecache_tiles_for_rect(tilecache, viewport, z, &touches);
734732

735733
#ifdef DEBUG_VERBOSE
736734
printf("viewport in level0 coordinates: left = %d, top = %d, "
@@ -839,15 +837,15 @@ tilecache_draw_bounds(GtkSnapshot *snapshot,
839837
static void
840838
tilecache_snap_rect(graphene_rect_t *bounds)
841839
{
842-
double left = rint(bounds->origin.x);
843-
double top = rint(bounds->origin.y);
844-
double right = rint(bounds->origin.x + bounds->size.width);
845-
double bottom = rint(bounds->origin.y + bounds->size.height);
846-
847-
bounds->origin.x = left;
848-
bounds->origin.y = top;
849-
bounds->size.width = right - left;
850-
bounds->size.height = bottom - top;
840+
double left = rint(bounds->origin.x);
841+
double top = rint(bounds->origin.y);
842+
double right = rint(bounds->origin.x + bounds->size.width);
843+
double bottom = rint(bounds->origin.y + bounds->size.height);
844+
845+
bounds->origin.x = left;
846+
bounds->origin.y = top;
847+
bounds->size.width = right - left;
848+
bounds->size.height = bottom - top;
851849
}
852850
#endif /*!HAVE_GTK_SNAPSHOT_SET_SNAP*/
853851

@@ -907,18 +905,21 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
907905

908906
/* paint_rect in level0 coordinates.
909907
*/
910-
graphene_rect_t viewport;
911-
viewport.origin.x = x / scale;
912-
viewport.origin.y = y / scale;
913-
viewport.size.width = VIPS_MAX(1, paint->size.width / scale);
914-
viewport.size.height = VIPS_MAX(1, paint->size.height / scale);
908+
double left = floor(x / scale);
909+
double top = floor(y / scale);
910+
double right = ceil((x + paint->size.width) / scale);
911+
double bottom = ceil((y + paint->size.height) / scale);
912+
913+
VipsRect viewport;
914+
viewport.left = left;
915+
viewport.top = top;
916+
viewport.width = VIPS_MAX(1, right - left);
917+
viewport.height = VIPS_MAX(1, bottom - top);
915918

916919
/* Fetch any tiles we are missing, update any tiles we have that have
917920
* been flagged as having pixels ready for fetching.
918921
*/
919-
VipsRect bounds;
920-
tilecache_request_area(tilecache,
921-
rect_graphene_to_vips(&viewport, &bounds), z);
922+
tilecache_request_area(tilecache, &viewport, z);
922923

923924
/* Find the set of visible tiles, sorted back to front.
924925
*
@@ -987,10 +988,10 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
987988

988989
gsk_rounded_rect_init_from_rect(&outline,
989990
&GRAPHENE_RECT_INIT(
990-
viewport.origin.x * scale - x + paint->origin.x,
991-
viewport.origin.y * scale - y + paint->origin.y,
992-
viewport.size.width * scale,
993-
viewport.size.height * scale),
991+
viewport.left * scale - x + paint->origin.x,
992+
viewport.top * scale - y + paint->origin.y,
993+
viewport.width * scale,
994+
viewport.height * scale),
994995
0);
995996

996997
gtk_snapshot_append_border(snapshot,

0 commit comments

Comments
 (0)