summaryrefslogtreecommitdiff
path: root/gsk
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2020-07-24 17:01:32 +0200
committerTimm Bäder <mail@baedert.org>2020-07-28 05:34:11 +0200
commitc6c87b97c2bd997c11a307352f9ce2b171ab97e6 (patch)
tree3626fc5bcf31c89c9f6048c31bae959c766cfc9b /gsk
parent2fa9dddea6369a1a7dea0e4770be94c006c7d0ba (diff)
downloadgtk+-c6c87b97c2bd997c11a307352f9ce2b171ab97e6.tar.gz
gl renderer: Add own graphene_rect_intersects
Diffstat (limited to 'gsk')
-rw-r--r--gsk/gl/gskglrenderer.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 1b188fddfe..62ad9f8b9f 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -191,7 +191,7 @@ dump_node (GskRenderNode *node,
cairo_surface_destroy (surface);
}
-static inline gboolean G_GNUC_PURE
+static inline bool G_GNUC_PURE __attribute__((always_inline))
node_is_invisible (const GskRenderNode *node)
{
return node->bounds.size.width == 0.0f ||
@@ -200,6 +200,22 @@ node_is_invisible (const GskRenderNode *node)
isnan (node->bounds.size.height);
}
+static inline bool G_GNUC_PURE __attribute__((always_inline))
+graphene_rect_intersects (const graphene_rect_t *r1,
+ const graphene_rect_t *r2)
+{
+ /* Assume both rects are already normalized, as they usually are */
+ if (r1->origin.x > (r2->origin.x + r2->size.width) ||
+ (r1->origin.x + r1->size.width) < r2->origin.x)
+ return false;
+
+ if (r1->origin.y > (r2->origin.y + r2->size.height) ||
+ (r1->origin.y + r1->size.height) < r2->origin.y)
+ return false;
+
+ return true;
+}
+
static inline void
sort_border_sides (const GdkRGBA *colors,
int *indices)
@@ -1152,20 +1168,20 @@ intersect_rounded_rectilinear (const graphene_rect_t *non_rounded,
/* Intersects with top left corner? */
n_corners += corners[0] = rounded_rect_has_corner (rounded, 0) &&
- graphene_rect_intersection (non_rounded,
- &rounded_rect_corner (rounded, 0), NULL);
+ graphene_rect_intersects (non_rounded,
+ &rounded_rect_corner (rounded, 0));
/* top right? */
n_corners += corners[1] = rounded_rect_has_corner (rounded, 1) &&
- graphene_rect_intersection (non_rounded,
- &rounded_rect_corner (rounded, 1), NULL);
+ graphene_rect_intersects (non_rounded,
+ &rounded_rect_corner (rounded, 1));
/* bottom right? */
n_corners += corners[2] = rounded_rect_has_corner (rounded, 2) &&
- graphene_rect_intersection (non_rounded,
- &rounded_rect_corner (rounded, 2), NULL);
+ graphene_rect_intersects (non_rounded,
+ &rounded_rect_corner (rounded, 2));
/* bottom left */
n_corners += corners[3] = rounded_rect_has_corner (rounded, 3) &&
- graphene_rect_intersection (non_rounded,
- &rounded_rect_corner (rounded, 3), NULL);
+ graphene_rect_intersects (non_rounded,
+ &rounded_rect_corner (rounded, 3));
if (corners[0] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 0)))
return false;
@@ -3171,8 +3187,8 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
&node->bounds,
&transformed_node_bounds);
- if (!graphene_rect_intersection (&builder->current_clip->bounds,
- &transformed_node_bounds, NULL))
+ if (!graphene_rect_intersects (&builder->current_clip->bounds,
+ &transformed_node_bounds))
return;
}