diff options
author | Simon Ser <contact@emersion.fr> | 2021-09-20 18:14:50 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-09-22 10:45:39 -0600 |
commit | 27b529f8a0a594a9933dbbaa81bd1167f791e4f9 (patch) | |
tree | 8811749c6ccaef17dd1e2b8403f3b7b54939ef6d | |
parent | 63040d67448ad710fb3536b86d0e417b06783079 (diff) |
scene: add scene_node_get_size helper
-rw-r--r-- | types/scene/wlr_scene.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 108f18f8..4004b500 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -300,6 +300,34 @@ static struct wlr_texture *scene_buffer_get_texture( return scene_buffer->texture; } +static void scene_node_get_size(struct wlr_scene_node *node, + int *width, int *height) { + *width = 0; + *height = 0; + + switch (node->type) { + case WLR_SCENE_NODE_ROOT: + case WLR_SCENE_NODE_TREE: + return; + case WLR_SCENE_NODE_SURFACE:; + struct wlr_scene_surface *scene_surface = + wlr_scene_surface_from_node(node); + *width = scene_surface->surface->current.width; + *height = scene_surface->surface->current.height; + break; + case WLR_SCENE_NODE_RECT:; + struct wlr_scene_rect *scene_rect = scene_rect_from_node(node); + *width = scene_rect->width; + *height = scene_rect->height; + break; + case WLR_SCENE_NODE_BUFFER:; + struct wlr_scene_buffer *scene_buffer = scene_buffer_from_node(node); + *width = scene_buffer->buffer->width; + *height = scene_buffer->buffer->height; + break; + } +} + static int scale_length(int length, int offset, float scale) { return round((offset + length) * scale) - round(offset * scale); } @@ -323,28 +351,8 @@ static void _scene_node_damage_whole(struct wlr_scene_node *node, lx + child->state.x, ly + child->state.y); } - int width = 0, height = 0; - switch (node->type) { - case WLR_SCENE_NODE_ROOT: - case WLR_SCENE_NODE_TREE: - return; - case WLR_SCENE_NODE_SURFACE:; - struct wlr_scene_surface *scene_surface = - wlr_scene_surface_from_node(node); - width = scene_surface->surface->current.width; - height = scene_surface->surface->current.height; - break; - case WLR_SCENE_NODE_RECT:; - struct wlr_scene_rect *scene_rect = scene_rect_from_node(node); - width = scene_rect->width; - height = scene_rect->height; - break; - case WLR_SCENE_NODE_BUFFER:; - struct wlr_scene_buffer *scene_buffer = scene_buffer_from_node(node); - width = scene_buffer->buffer->width; - height = scene_buffer->buffer->height; - break; - } + int width, height; + scene_node_get_size(node, &width, &height); struct wlr_scene_output *scene_output; wl_list_for_each(scene_output, &scene->outputs, link) { @@ -626,10 +634,13 @@ static void render_node_iterator(struct wlr_scene_node *node, struct render_data *data = _data; struct wlr_output *output = data->output; pixman_region32_t *output_damage = data->damage; + struct wlr_box dst_box = { .x = x, .y = y, }; + scene_node_get_size(node, &dst_box.width, &dst_box.height); + scale_box(&dst_box, output->scale); struct wlr_texture *texture; float matrix[9]; @@ -647,10 +658,6 @@ static void render_node_iterator(struct wlr_scene_node *node, return; } - dst_box.width = surface->current.width; - dst_box.height = surface->current.height; - scale_box(&dst_box, output->scale); - enum wl_output_transform transform = wlr_output_transform_invert(surface->current.transform); wlr_matrix_project_box(matrix, &dst_box, transform, 0.0, @@ -661,10 +668,6 @@ static void render_node_iterator(struct wlr_scene_node *node, case WLR_SCENE_NODE_RECT:; struct wlr_scene_rect *scene_rect = scene_rect_from_node(node); - dst_box.width = scene_rect->width; - dst_box.height = scene_rect->height; - scale_box(&dst_box, data->output->scale); - render_rect(output, output_damage, scene_rect->color, &dst_box, output->transform_matrix); break; @@ -677,10 +680,6 @@ static void render_node_iterator(struct wlr_scene_node *node, return; } - dst_box.width = scene_buffer->buffer->width; - dst_box.height = scene_buffer->buffer->height; - scale_box(&dst_box, data->output->scale); - wlr_matrix_project_box(matrix, &dst_box, WL_OUTPUT_TRANSFORM_NORMAL, 0.0, output->transform_matrix); |