gsk: Use gsk_rect_init_offset() everywhere

... and make it use a graphene_point_t as argument, because that's what
the callers want.
This commit is contained in:
Benjamin Otte 2024-08-11 20:59:23 +02:00
parent b0e4be7fda
commit 563cce5530
3 changed files with 12 additions and 22 deletions

View File

@ -501,10 +501,7 @@ gsk_gpu_node_processor_rect_to_device_shrink (GskGpuNodeProcessor *self,
{ {
graphene_rect_t tmp; graphene_rect_t tmp;
graphene_rect_offset_r (rect, gsk_rect_init_offset (&tmp, rect, &self->offset);
self->offset.x,
self->offset.y,
&tmp);
if (!gsk_gpu_node_processor_rect_clip_to_device (self, &tmp, &tmp)) if (!gsk_gpu_node_processor_rect_clip_to_device (self, &tmp, &tmp))
return FALSE; return FALSE;
@ -990,9 +987,7 @@ gsk_gpu_node_processor_add_node_clipped (GskGpuNodeProcessor *self,
return; return;
} }
graphene_rect_offset_r (clip_bounds, gsk_rect_init_offset (&clip, clip_bounds, &self->offset);
self->offset.x, self->offset.y,
&clip);
gsk_gpu_clip_init_copy (&old_clip, &self->clip); 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; graphene_rect_t rect, clipped;
float clear_color[4]; float clear_color[4];
graphene_rect_offset_r (&node->bounds, gsk_rect_init_offset (&rect, &node->bounds, &self->offset);
self->offset.x, self->offset.y,
&rect);
gsk_rect_intersection (&self->clip.rect.bounds, &rect, &clipped); gsk_rect_intersection (&self->clip.rect.bounds, &rect, &clipped);
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_CLEAR) && 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_init_copy (&outline, gsk_outset_shadow_node_get_outline (node));
gsk_rounded_rect_shrink (&outline, -spread, -spread, -spread, -spread); 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++) for (int i = 0; i < 4; i++)
gdk_color_init_copy (&colors[i], color); 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, gsk_rect_init_offset (&offset_rect,
rect, rect,
- x * child_bounds->size.width, &GRAPHENE_POINT_INIT (- x * child_bounds->size.width,
- y * child_bounds->size.height); - y * child_bounds->size.height));
if (!gsk_rect_intersection (&offset_rect, child_bounds, &clipped_child_bounds)) if (!gsk_rect_intersection (&offset_rect, child_bounds, &clipped_child_bounds))
{ {
/* The math has gone wrong probably, someone should look at this. */ /* 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; cairo_rectangle_int_t int_clipped;
graphene_rect_t rect, clipped; graphene_rect_t rect, clipped;
graphene_rect_offset_r (&node->bounds, gsk_rect_init_offset (&rect, &node->bounds, &self->offset);
self->offset.x, self->offset.y,
&rect);
gsk_rect_intersection (&self->clip.rect.bounds, &rect, &clipped); gsk_rect_intersection (&self->clip.rect.bounds, &rect, &clipped);
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_CLEAR) && if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_CLEAR) &&

View File

@ -28,12 +28,11 @@ gsk_rect_init_from_rect (graphene_rect_t *r,
} }
static inline void static inline void
gsk_rect_init_offset (graphene_rect_t *r, gsk_rect_init_offset (graphene_rect_t *r,
const graphene_rect_t *src, const graphene_rect_t *src,
float dx, const graphene_point_t *offset)
float dy)
{ {
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 static inline gboolean G_GNUC_PURE

View File

@ -309,7 +309,7 @@ gsk_rounded_rect_scale_affine (GskRoundedRect *dest,
g_assert (dest != src); g_assert (dest != src);
gsk_rect_scale (&src->bounds, scale_x, scale_y, &dest->bounds); 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_x = fabsf (scale_x);
scale_y = fabsf (scale_y); scale_y = fabsf (scale_y);