From 563cce5530c1e0d3163b7d500d1a6637c6d2d48e Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 11 Aug 2024 20:59:23 +0200 Subject: [PATCH] gsk: Use gsk_rect_init_offset() everywhere ... and make it use a graphene_point_t as argument, because that's what the callers want. --- gsk/gpu/gskgpunodeprocessor.c | 23 +++++++---------------- gsk/gskrectprivate.h | 9 ++++----- gsk/gskroundedrect.c | 2 +- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 77cb5fb552..6ab7c120fb 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -501,10 +501,7 @@ gsk_gpu_node_processor_rect_to_device_shrink (GskGpuNodeProcessor *self, { graphene_rect_t tmp; - graphene_rect_offset_r (rect, - self->offset.x, - self->offset.y, - &tmp); + gsk_rect_init_offset (&tmp, rect, &self->offset); if (!gsk_gpu_node_processor_rect_clip_to_device (self, &tmp, &tmp)) return FALSE; @@ -990,9 +987,7 @@ gsk_gpu_node_processor_add_node_clipped (GskGpuNodeProcessor *self, return; } - graphene_rect_offset_r (clip_bounds, - self->offset.x, self->offset.y, - &clip); + gsk_rect_init_offset (&clip, clip_bounds, &self->offset); gsk_gpu_clip_init_copy (&old_clip, &self->clip); @@ -1731,9 +1726,7 @@ gsk_gpu_node_processor_add_color_node (GskGpuNodeProcessor *self, graphene_rect_t rect, clipped; float clear_color[4]; - graphene_rect_offset_r (&node->bounds, - self->offset.x, self->offset.y, - &rect); + gsk_rect_init_offset (&rect, &node->bounds, &self->offset); gsk_rect_intersection (&self->clip.rect.bounds, &rect, &clipped); if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_CLEAR) && @@ -2406,7 +2399,7 @@ gsk_gpu_node_processor_add_outset_shadow_node (GskGpuNodeProcessor *self, gsk_rounded_rect_init_copy (&outline, gsk_outset_shadow_node_get_outline (node)); gsk_rounded_rect_shrink (&outline, -spread, -spread, -spread, -spread); - graphene_rect_offset (&outline.bounds, offset->x, offset->y); + gsk_rect_init_offset (&outline.bounds, &outline.bounds, offset); for (int i = 0; i < 4; i++) gdk_color_init_copy (&colors[i], color); @@ -3172,8 +3165,8 @@ gsk_gpu_node_processor_repeat_tile (GskGpuNodeProcessor *self, gsk_rect_init_offset (&offset_rect, rect, - - x * child_bounds->size.width, - - y * child_bounds->size.height); + &GRAPHENE_POINT_INIT (- x * child_bounds->size.width, + - y * child_bounds->size.height)); if (!gsk_rect_intersection (&offset_rect, child_bounds, &clipped_child_bounds)) { /* The math has gone wrong probably, someone should look at this. */ @@ -3561,9 +3554,7 @@ gsk_gpu_node_processor_add_subsurface_node (GskGpuNodeProcessor *self, cairo_rectangle_int_t int_clipped; graphene_rect_t rect, clipped; - graphene_rect_offset_r (&node->bounds, - self->offset.x, self->offset.y, - &rect); + gsk_rect_init_offset (&rect, &node->bounds, &self->offset); gsk_rect_intersection (&self->clip.rect.bounds, &rect, &clipped); if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_CLEAR) && diff --git a/gsk/gskrectprivate.h b/gsk/gskrectprivate.h index aad5e8812b..1c07b2a63d 100644 --- a/gsk/gskrectprivate.h +++ b/gsk/gskrectprivate.h @@ -28,12 +28,11 @@ gsk_rect_init_from_rect (graphene_rect_t *r, } static inline void -gsk_rect_init_offset (graphene_rect_t *r, - const graphene_rect_t *src, - float dx, - float dy) +gsk_rect_init_offset (graphene_rect_t *r, + const graphene_rect_t *src, + const graphene_point_t *offset) { - gsk_rect_init (r, src->origin.x + dx, src->origin.y + dy, src->size.width, src->size.height); + gsk_rect_init (r, src->origin.x + offset->x, src->origin.y + offset->y, src->size.width, src->size.height); } static inline gboolean G_GNUC_PURE diff --git a/gsk/gskroundedrect.c b/gsk/gskroundedrect.c index df2b1af370..5adbddb73d 100644 --- a/gsk/gskroundedrect.c +++ b/gsk/gskroundedrect.c @@ -309,7 +309,7 @@ gsk_rounded_rect_scale_affine (GskRoundedRect *dest, g_assert (dest != src); gsk_rect_scale (&src->bounds, scale_x, scale_y, &dest->bounds); - graphene_rect_offset (&dest->bounds, dx, dy); + gsk_rect_init_offset (&dest->bounds, &dest->bounds, &GRAPHENE_POINT_INIT (dx, dy)); scale_x = fabsf (scale_x); scale_y = fabsf (scale_y);