mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
d30a9e7fa9
Add a bunch of inline functions for graphene_rectangle_t. We use those quite extensively in tight loops so making them as fast as possible via inlining has massive benefits. The current render-heavy benchmark I am playing (th paris-30k in node-editor) went from 49fps to 85fps on my AMD.
29 lines
895 B
C
29 lines
895 B
C
#pragma once
|
|
|
|
#include <graphene.h>
|
|
|
|
static inline gboolean G_GNUC_PURE
|
|
gsk_rect_contains_rect (const graphene_rect_t *r1,
|
|
const graphene_rect_t *r2)
|
|
{
|
|
return r2->origin.x >= r1->origin.x &&
|
|
(r2->origin.x + r2->size.width) <= (r1->origin.x + r1->size.width) &&
|
|
r2->origin.y >= r1->origin.y &&
|
|
(r2->origin.y + r2->size.height) <= (r1->origin.y + r1->size.height);
|
|
}
|
|
|
|
static inline gboolean G_GNUC_PURE
|
|
gsk_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 ||
|
|
r1->origin.y >= (r2->origin.y + r2->size.height) ||
|
|
(r1->origin.y + r1->size.height) <= r2->origin.y)
|
|
return FALSE;
|
|
else
|
|
return TRUE;
|
|
}
|
|
|