mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-05-05 06:47:30 -04:00
util/rect_union: Take pixman_box32_t by pointer
rect_union_add takes a pixman_box32_t by value, and passes it along by value to internal helpers. render_pass_mark_box_updated which is the only caller receives the pixman_box32_t by reference, so just plumb it through that way. Results in a 13% improvement in CPU time when using the Vulkan renderer on the stacked/clip200/1024 benchmarks on my machine. Signed-off-by: Kenny Levinsen <kl@kl.wtf>
This commit is contained in:
parent
8abe53d1d2
commit
17c29268c9
3 changed files with 12 additions and 12 deletions
|
|
@ -58,7 +58,7 @@ void rect_union_finish(struct rect_union *r);
|
|||
*
|
||||
* Amortized time: O(1)
|
||||
*/
|
||||
void rect_union_add(struct rect_union *r, pixman_box32_t box);
|
||||
void rect_union_add(struct rect_union *r, const pixman_box32_t *box);
|
||||
|
||||
/**
|
||||
* Compute an exact cover of the rectangles added so far, and return
|
||||
|
|
|
|||
|
|
@ -634,7 +634,7 @@ static void render_pass_mark_box_updated(struct wlr_vk_render_pass *pass,
|
|||
if (!pass->two_pass) {
|
||||
return;
|
||||
}
|
||||
rect_union_add(&pass->updated_region, *box);
|
||||
rect_union_add(&pass->updated_region, box);
|
||||
}
|
||||
|
||||
static void render_pass_add_rect(struct wlr_render_pass *wlr_pass,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#include <limits.h>
|
||||
#include "util/rect_union.h"
|
||||
|
||||
static void box_union(pixman_box32_t *dst, pixman_box32_t box) {
|
||||
dst->x1 = dst->x1 < box.x1 ? dst->x1 : box.x1;
|
||||
dst->y1 = dst->y1 < box.y1 ? dst->y1 : box.y1;
|
||||
dst->x2 = dst->x2 > box.x2 ? dst->x2 : box.x2;
|
||||
dst->y2 = dst->y2 > box.y2 ? dst->y2 : box.y2;
|
||||
static void box_union(pixman_box32_t *dst, const pixman_box32_t *box) {
|
||||
dst->x1 = dst->x1 < box->x1 ? dst->x1 : box->x1;
|
||||
dst->y1 = dst->y1 < box->y1 ? dst->y1 : box->y1;
|
||||
dst->x2 = dst->x2 > box->x2 ? dst->x2 : box->x2;
|
||||
dst->y2 = dst->y2 > box->y2 ? dst->y2 : box->y2;
|
||||
}
|
||||
|
||||
static bool box_empty_or_invalid(pixman_box32_t box) {
|
||||
return box.x1 >= box.x2 || box.y1 >= box.y2;
|
||||
static bool box_empty_or_invalid(const pixman_box32_t *box) {
|
||||
return box->x1 >= box->x2 || box->y1 >= box->y2;
|
||||
}
|
||||
|
||||
void rect_union_init(struct rect_union *ru) {
|
||||
|
|
@ -37,7 +37,7 @@ static void handle_alloc_failure(struct rect_union *ru) {
|
|||
wl_array_init(&ru->unsorted);
|
||||
}
|
||||
|
||||
void rect_union_add(struct rect_union *ru, pixman_box32_t box) {
|
||||
void rect_union_add(struct rect_union *ru, const pixman_box32_t *box) {
|
||||
if (box_empty_or_invalid(box)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ void rect_union_add(struct rect_union *ru, pixman_box32_t box) {
|
|||
if (!ru->alloc_failure) {
|
||||
pixman_box32_t *entry = wl_array_add(&ru->unsorted, sizeof(*entry));
|
||||
if (entry) {
|
||||
*entry = box;
|
||||
*entry = *box;
|
||||
} else {
|
||||
handle_alloc_failure(ru);
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ const pixman_region32_t *rect_union_evaluate(struct rect_union *ru) {
|
|||
return &ru->region;
|
||||
bounding_box:
|
||||
pixman_region32_fini(&ru->region);
|
||||
if (box_empty_or_invalid(ru->bounding_box)) {
|
||||
if (box_empty_or_invalid(&ru->bounding_box)) {
|
||||
pixman_region32_init(&ru->region);
|
||||
} else {
|
||||
pixman_region32_init_with_extents(&ru->region, &ru->bounding_box);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue