scene: add wlr_scene_buffer_set_dest_size
This commit is contained in:
parent
3d4afbe945
commit
43833fba64
|
@ -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 */
|
||||
|
@ -221,6 +222,16 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_node *parent,
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue