Skip to content

Commit 85f3568

Browse files
committed
Remove rect_graphene_to_vips() utility
It's simpler to do these calculations ourselves. Non-functional change.
1 parent a203e7d commit 85f3568

File tree

3 files changed

+17
-33
lines changed

3 files changed

+17
-33
lines changed

src/gtkutil.c

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

539539
#define WEAKREF_SET(A, B) weakref_set((GObject **) &(A), (GObject *) (B));
540540

541-
VipsRect *
542-
rect_graphene_to_vips(graphene_rect_t *graphene, VipsRect *vips)
543-
{
544-
// round out to enclosing int area
545-
graphene_rect_t bounds;
546-
graphene_rect_round_extents(graphene, &bounds);
547-
548-
vips->left = bounds.origin.x;
549-
vips->top = bounds.origin.y;
550-
vips->width = bounds.size.width;
551-
vips->height = bounds.size.height;
552-
553-
return vips;
554-
}
555-

src/gtkutil.h

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

110110
void weakref_set(GObject **pointer, GObject *object);
111111
#define WEAKREF_SET(A, B) weakref_set((GObject **) &(A), (GObject *) (B));
112-
113-
VipsRect *rect_graphene_to_vips(graphene_rect_t *graphene, VipsRect *vips);

src/tilecache.c

Lines changed: 17 additions & 16 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, "
@@ -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)