Skip to content

Commit e6389f9

Browse files
committed
Remove rect_graphene_to_vips() utility
It's simpler to do these calculations ourselves.
1 parent a203e7d commit e6389f9

File tree

3 files changed

+12
-33
lines changed

3 files changed

+12
-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: 12 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,16 @@ 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+
VipsRect viewport;
909+
viewport.left = floorf(x / scale);
910+
viewport.top = floorf(y / scale);
911+
viewport.width = VIPS_MAX(1, ceilf(paint->size.width / scale));
912+
viewport.height = VIPS_MAX(1, ceilf(paint->size.height / scale));
915913

916914
/* Fetch any tiles we are missing, update any tiles we have that have
917915
* been flagged as having pixels ready for fetching.
918916
*/
919-
VipsRect bounds;
920-
tilecache_request_area(tilecache,
921-
rect_graphene_to_vips(&viewport, &bounds), z);
917+
tilecache_request_area(tilecache, &viewport, z);
922918

923919
/* Find the set of visible tiles, sorted back to front.
924920
*
@@ -987,10 +983,10 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
987983

988984
gsk_rounded_rect_init_from_rect(&outline,
989985
&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),
986+
viewport.left * scale - x + paint->origin.x,
987+
viewport.top * scale - y + paint->origin.y,
988+
viewport.width * scale,
989+
viewport.height * scale),
994990
0);
995991

996992
gtk_snapshot_append_border(snapshot,

0 commit comments

Comments
 (0)