diff options
author | Alexander Larsson <alexl@redhat.com> | 2017-01-11 16:14:03 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2017-01-11 16:14:03 +0100 |
commit | c00f8dce9f8076e3e914210dda62e7fd2207d1e4 (patch) | |
tree | 016ec44ab7b6eea3a595c8f2cdebe3ddb7d1196a /gtk/gtksnapshot.c | |
parent | 275185d4157f40def0ec34c98058a98c4b98382f (diff) | |
download | gtk+-c00f8dce9f8076e3e914210dda62e7fd2207d1e4.tar.gz |
GtkSnapshot: Always use int for the translationwip/alexl/snapshot-int-translate
We already take ints when setting the translation, so it can't
currently take any other values. Additionally, I was seeing large
costs in int -> double -> int for the rects in
gtk_snapshot_clips_rect(), as all callers really are ints (widget
allocations) and the clip region is int-based.
This change completely cleared a 2% rectangle_init_from_graphene from
the profile and is likely to have nice performance effects elsewhere
too.
Diffstat (limited to 'gtk/gtksnapshot.c')
-rw-r--r-- | gtk/gtksnapshot.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 72f1b1586f..08db8c5b63 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -78,8 +78,8 @@ static GtkSnapshotState * gtk_snapshot_state_new (GtkSnapshotState *parent, char *name, cairo_region_t *clip, - double translate_x, - double translate_y, + int translate_x, + int translate_y, GtkSnapshotCollectFunc collect_func) { GtkSnapshotState *state; @@ -797,8 +797,8 @@ gtk_snapshot_translate_2d (GtkSnapshot *snapshot, **/ void gtk_snapshot_get_offset (GtkSnapshot *snapshot, - double *x, - double *y) + int *x, + int *y) { if (x) *x = snapshot->state->translate_x; @@ -996,18 +996,19 @@ gtk_snapshot_append_color_node (GtkSnapshot *snapshot, */ gboolean gtk_snapshot_clips_rect (GtkSnapshot *snapshot, - const graphene_rect_t *bounds) + const cairo_rectangle_int_t *rect) { - graphene_rect_t offset_bounds; - cairo_rectangle_int_t rect; + cairo_rectangle_int_t offset_rect; if (snapshot->state->clip_region == NULL) return FALSE; - graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y, &offset_bounds); - rectangle_init_from_graphene (&rect, &offset_bounds); + offset_rect.x = rect->x + snapshot->state->translate_x; + offset_rect.y = rect->y + snapshot->state->translate_y; + offset_rect.width = rect->width; + offset_rect.height = rect->height; - return cairo_region_contains_rectangle (snapshot->state->clip_region, &rect) == CAIRO_REGION_OVERLAP_OUT; + return cairo_region_contains_rectangle (snapshot->state->clip_region, &offset_rect) == CAIRO_REGION_OVERLAP_OUT; } /** |