Skip to content

Commit 0a0bfd0

Browse files
authored
Merge pull request #19 from kleisauke/sync-with-vipsdisp
Sync with vipsdisp
2 parents 5423df7 + 83db047 commit 0a0bfd0

File tree

4 files changed

+29
-45
lines changed

4 files changed

+29
-45
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/kplot/reallocarray.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
* distribute, sublicense, and/or sell copies of the Software, and to
1010
* permit persons to whom the Software is furnished to do so, subject to
1111
* the following conditions:
12-
*
12+
*
1313
* The above copyright notice and this permission notice shall be
1414
* included in all copies or substantial portions of the Software.
15-
*
15+
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1717
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1818
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -21,7 +21,7 @@
2121
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2222
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323
*/
24-
24+
2525
#ifdef HAVE_CONFIG_H
2626
#include <config.h>
2727
#endif /*HAVE_CONFIG_H*/

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)