wlr_scene: Make scene_rect_from_node public

This is in an effort to be more consistent with both already public
getters: wlr_scene_buffer_from_node and wlr_scene_tree_from_node
This commit is contained in:
Alexander Orzechowski 2023-05-27 04:20:07 -04:00 committed by Simon Ser
parent 88f80c4a7c
commit 2346b90a9f
2 changed files with 12 additions and 7 deletions

View File

@ -329,6 +329,12 @@ struct wlr_scene_buffer *wlr_scene_buffer_from_node(struct wlr_scene_node *node)
*/ */
struct wlr_scene_tree *wlr_scene_tree_from_node(struct wlr_scene_node *node); struct wlr_scene_tree *wlr_scene_tree_from_node(struct wlr_scene_node *node);
/**
* If this node represents a wlr_scene_rect, that rect will be returned. It
* is not legal to feed a node that does not represent a wlr_scene_rect.
*/
struct wlr_scene_rect *wlr_scene_rect_from_node(struct wlr_scene_node *node);
/** /**
* If this buffer is backed by a surface, then the struct wlr_scene_surface is * If this buffer is backed by a surface, then the struct wlr_scene_surface is
* returned. If not, NULL will be returned. * returned. If not, NULL will be returned.

View File

@ -27,8 +27,7 @@ struct wlr_scene_tree *wlr_scene_tree_from_node(struct wlr_scene_node *node) {
return tree; return tree;
} }
static struct wlr_scene_rect *scene_rect_from_node( struct wlr_scene_rect *wlr_scene_rect_from_node(struct wlr_scene_node *node) {
struct wlr_scene_node *node) {
assert(node->type == WLR_SCENE_NODE_RECT); assert(node->type == WLR_SCENE_NODE_RECT);
struct wlr_scene_rect *rect = wl_container_of(node, rect, node); struct wlr_scene_rect *rect = wl_container_of(node, rect, node);
return rect; return rect;
@ -231,7 +230,7 @@ static bool scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box,
static void scene_node_opaque_region(struct wlr_scene_node *node, int x, int y, static void scene_node_opaque_region(struct wlr_scene_node *node, int x, int y,
pixman_region32_t *opaque) { pixman_region32_t *opaque) {
if (node->type == WLR_SCENE_NODE_RECT) { if (node->type == WLR_SCENE_NODE_RECT) {
struct wlr_scene_rect *scene_rect = scene_rect_from_node(node); struct wlr_scene_rect *scene_rect = wlr_scene_rect_from_node(node);
if (scene_rect->color[3] != 1) { if (scene_rect->color[3] != 1) {
return; return;
} }
@ -821,7 +820,7 @@ static void scene_node_get_size(struct wlr_scene_node *node,
case WLR_SCENE_NODE_TREE: case WLR_SCENE_NODE_TREE:
return; return;
case WLR_SCENE_NODE_RECT:; case WLR_SCENE_NODE_RECT:;
struct wlr_scene_rect *scene_rect = scene_rect_from_node(node); struct wlr_scene_rect *scene_rect = wlr_scene_rect_from_node(node);
*width = scene_rect->width; *width = scene_rect->width;
*height = scene_rect->height; *height = scene_rect->height;
break; break;
@ -1096,7 +1095,7 @@ static void scene_node_render(struct wlr_scene_node *node,
assert(false); assert(false);
break; break;
case WLR_SCENE_NODE_RECT:; case WLR_SCENE_NODE_RECT:;
struct wlr_scene_rect *scene_rect = scene_rect_from_node(node); struct wlr_scene_rect *scene_rect = wlr_scene_rect_from_node(node);
wlr_render_pass_add_rect(render_pass, &(struct wlr_render_rect_options){ wlr_render_pass_add_rect(render_pass, &(struct wlr_render_rect_options){
.box = dst_box, .box = dst_box,
@ -1341,7 +1340,7 @@ static bool scene_node_invisible(struct wlr_scene_node *node) {
if (node->type == WLR_SCENE_NODE_TREE) { if (node->type == WLR_SCENE_NODE_TREE) {
return true; return true;
} else if (node->type == WLR_SCENE_NODE_RECT) { } else if (node->type == WLR_SCENE_NODE_RECT) {
struct wlr_scene_rect *rect = scene_rect_from_node(node); struct wlr_scene_rect *rect = wlr_scene_rect_from_node(node);
return rect->color[3] == 0.f; return rect->color[3] == 0.f;
} else if (node->type == WLR_SCENE_NODE_BUFFER) { } else if (node->type == WLR_SCENE_NODE_BUFFER) {
@ -1371,7 +1370,7 @@ static bool construct_render_list_iterator(struct wlr_scene_node *node,
// If we see a black rect, we can ignore rendering everything under the rect // If we see a black rect, we can ignore rendering everything under the rect
// and even the rect itself. // and even the rect itself.
if (node->type == WLR_SCENE_NODE_RECT && data->calculate_visibility) { if (node->type == WLR_SCENE_NODE_RECT && data->calculate_visibility) {
struct wlr_scene_rect *rect = scene_rect_from_node(node); struct wlr_scene_rect *rect = wlr_scene_rect_from_node(node);
float *black = (float[4]){ 0.f, 0.f, 0.f, 1.f }; float *black = (float[4]){ 0.f, 0.f, 0.f, 1.f };
if (memcmp(rect->color, black, sizeof(float) * 4) == 0) { if (memcmp(rect->color, black, sizeof(float) * 4) == 0) {