diff options
-rw-r--r-- | include/wlr/types/wlr_scene.h | 11 | ||||
-rw-r--r-- | types/scene/wlr_scene.c | 21 |
2 files changed, 30 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index 93be43d0..6c5194f8 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -95,6 +95,7 @@ struct wlr_scene_buffer { struct wlr_texture *texture; struct wlr_fbox src_box; + int dst_width, dst_height; }; /** A viewport for an output in the scene-graph */ @@ -222,6 +223,16 @@ void wlr_scene_buffer_set_source_box(struct wlr_scene_buffer *scene_buffer, const struct wlr_fbox *box); /** + * Set the destination size describing the region of the scene-graph the buffer + * will be painted onto. This allows scaling the buffer. + * + * If zero, the destination size will be the buffer size. By default, the + * destination size is zero. + */ +void wlr_scene_buffer_set_dest_size(struct wlr_scene_buffer *scene_buffer, + int width, int height); + +/** * Add a viewport for the specified output to the scene-graph. * * An output can only be added once to the scene-graph. diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 2d3dccde..f4aec1d8 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -283,6 +283,18 @@ void wlr_scene_buffer_set_source_box(struct wlr_scene_buffer *scene_buffer, scene_node_damage_whole(&scene_buffer->node); } +void wlr_scene_buffer_set_dest_size(struct wlr_scene_buffer *scene_buffer, + int width, int height) { + if (scene_buffer->dst_width == width && scene_buffer->dst_height == height) { + return; + } + + scene_node_damage_whole(&scene_buffer->node); + scene_buffer->dst_width = width; + scene_buffer->dst_height = height; + scene_node_damage_whole(&scene_buffer->node); +} + static struct wlr_texture *scene_buffer_get_texture( struct wlr_scene_buffer *scene_buffer, struct wlr_renderer *renderer) { struct wlr_client_buffer *client_buffer = @@ -322,8 +334,13 @@ static void scene_node_get_size(struct wlr_scene_node *node, 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; + if (scene_buffer->dst_width > 0 && scene_buffer->dst_height > 0) { + *width = scene_buffer->dst_width; + *height = scene_buffer->dst_height; + } else { + *width = scene_buffer->buffer->width; + *height = scene_buffer->buffer->height; + } break; } } |