mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-03-10 05:34:08 -04:00
Adopt wlr_box_intersects where useful
This makes wlr_scene_node_at roughly 50% faster, and gives a minor boost to node modification as well. Before: create test tree: 7030 nodes, 473.510 s, 15 nodes/ms wlr_scene_node_at: 10000 iters, 894.945 s, 78552 nodes/ms (hits: 10/10000) wlr_scene_node_for_each_buffer: 10000 iters, 330.597 s, 212646 nodes/ms (hits: 0/10000) After: create test tree: 7030 nodes, 385.930 s, 18 nodes/ms wlr_scene_node_at: 10000 iters, 586.013 s, 119963 nodes/ms (hits: 10/10000) wlr_scene_node_for_each_buffer: 10000 iters, 334.559 s, 210127 nodes/ms (hits: 0/10000)
This commit is contained in:
parent
2938c10cd3
commit
7ccef7d9eb
4 changed files with 6 additions and 10 deletions
|
|
@ -159,9 +159,8 @@ static void output_cursor_update_visible(struct wlr_output_cursor *cursor) {
|
|||
struct wlr_box cursor_box;
|
||||
output_cursor_get_box(cursor, &cursor_box);
|
||||
|
||||
struct wlr_box intersection;
|
||||
cursor->visible =
|
||||
wlr_box_intersection(&intersection, &output_box, &cursor_box);
|
||||
wlr_box_intersects(&output_box, &cursor_box);
|
||||
}
|
||||
|
||||
static bool output_pick_cursor_format(struct wlr_output *output,
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ static bool output_basic_test(struct wlr_output *output,
|
|||
};
|
||||
struct wlr_box dst_box;
|
||||
output_state_get_buffer_dst_box(state, &dst_box);
|
||||
if (!wlr_box_intersection(&output_box, &output_box, &dst_box)) {
|
||||
if (!wlr_box_intersects(&output_box, &dst_box)) {
|
||||
wlr_log(WLR_ERROR, "Primary buffer is entirely off-screen or 0-sized");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ static bool _scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box
|
|||
struct wlr_box node_box = { .x = lx, .y = ly };
|
||||
scene_node_get_size(node, &node_box.width, &node_box.height);
|
||||
|
||||
if (wlr_box_intersection(&node_box, &node_box, box) &&
|
||||
if (wlr_box_intersects(&node_box, box) &&
|
||||
iterator(node, lx, ly, user_data)) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2673,8 +2673,7 @@ static void scene_output_for_each_scene_buffer(const struct wlr_box *output_box,
|
|||
struct wlr_box node_box = { .x = lx, .y = ly };
|
||||
scene_node_get_size(node, &node_box.width, &node_box.height);
|
||||
|
||||
struct wlr_box intersection;
|
||||
if (wlr_box_intersection(&intersection, output_box, &node_box)) {
|
||||
if (wlr_box_intersects(output_box, &node_box)) {
|
||||
struct wlr_scene_buffer *scene_buffer =
|
||||
wlr_scene_buffer_from_node(node);
|
||||
user_iterator(scene_buffer, lx, ly, user_data);
|
||||
|
|
|
|||
|
|
@ -260,14 +260,12 @@ bool wlr_output_layout_contains_point(struct wlr_output_layout *layout,
|
|||
|
||||
bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
|
||||
struct wlr_output *reference, const struct wlr_box *target_lbox) {
|
||||
struct wlr_box out_box;
|
||||
|
||||
if (reference == NULL) {
|
||||
struct wlr_output_layout_output *l_output;
|
||||
wl_list_for_each(l_output, &layout->outputs, link) {
|
||||
struct wlr_box output_box;
|
||||
output_layout_output_get_box(l_output, &output_box);
|
||||
if (wlr_box_intersection(&out_box, &output_box, target_lbox)) {
|
||||
if (wlr_box_intersects(&output_box, target_lbox)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -281,7 +279,7 @@ bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
|
|||
|
||||
struct wlr_box output_box;
|
||||
output_layout_output_get_box(l_output, &output_box);
|
||||
return wlr_box_intersection(&out_box, &output_box, target_lbox);
|
||||
return wlr_box_intersects(&output_box, target_lbox);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue