scene: add wlr_scene_buffer_set_buffer_with_options()

This is an extensible version of wlr_scene_buffer_set_buffer().
master
Simon Ser 4 months ago
parent edb867bc05
commit 48f0902a36

@ -404,6 +404,24 @@ void wlr_scene_buffer_set_buffer(struct wlr_scene_buffer *scene_buffer,
void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buffer, void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buffer,
struct wlr_buffer *buffer, const pixman_region32_t *region); struct wlr_buffer *buffer, const pixman_region32_t *region);
/**
* Options for wlr_scene_buffer_set_buffer_with_options().
*/
struct wlr_scene_buffer_set_buffer_options {
// The damage region is in buffer-local coordinates. If the region is NULL,
// the whole buffer node will be damaged.
const pixman_region32_t *damage;
};
/**
* Sets the buffer's backing buffer.
*
* If the buffer is NULL, the buffer node will not be displayed. If options is
* NULL, empty options are used.
*/
void wlr_scene_buffer_set_buffer_with_options(struct wlr_scene_buffer *scene_buffer,
struct wlr_buffer *buffer, const struct wlr_scene_buffer_set_buffer_options *options);
/** /**
* Sets the buffer's opaque region. This is an optimization hint used to * Sets the buffer's opaque region. This is an optimization hint used to
* determine if buffers which reside under this one need to be rendered or not. * determine if buffers which reside under this one need to be rendered or not.

@ -686,12 +686,17 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
return scene_buffer; return scene_buffer;
} }
void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buffer, void wlr_scene_buffer_set_buffer_with_options(struct wlr_scene_buffer *scene_buffer,
struct wlr_buffer *buffer, const pixman_region32_t *damage) { struct wlr_buffer *buffer, const struct wlr_scene_buffer_set_buffer_options *options) {
const struct wlr_scene_buffer_set_buffer_options default_options = {0};
if (options == NULL) {
options = &default_options;
}
// specifying a region for a NULL buffer doesn't make sense. We need to know // specifying a region for a NULL buffer doesn't make sense. We need to know
// about the buffer to scale the buffer local coordinates down to scene // about the buffer to scale the buffer local coordinates down to scene
// coordinates. // coordinates.
assert(buffer || !damage); assert(buffer || !options->damage);
bool mapped = buffer != NULL; bool mapped = buffer != NULL;
bool prev_mapped = scene_buffer->buffer != NULL || scene_buffer->texture != NULL; bool prev_mapped = scene_buffer->buffer != NULL || scene_buffer->texture != NULL;
@ -727,6 +732,7 @@ void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buff
pixman_region32_t fallback_damage; pixman_region32_t fallback_damage;
pixman_region32_init_rect(&fallback_damage, 0, 0, buffer->width, buffer->height); pixman_region32_init_rect(&fallback_damage, 0, 0, buffer->width, buffer->height);
const pixman_region32_t *damage = options->damage;
if (!damage) { if (!damage) {
damage = &fallback_damage; damage = &fallback_damage;
} }
@ -810,9 +816,17 @@ void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buff
pixman_region32_fini(&fallback_damage); pixman_region32_fini(&fallback_damage);
} }
void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buffer,
struct wlr_buffer *buffer, const pixman_region32_t *damage) {
const struct wlr_scene_buffer_set_buffer_options options = {
.damage = damage,
};
wlr_scene_buffer_set_buffer_with_options(scene_buffer, buffer, &options);
}
void wlr_scene_buffer_set_buffer(struct wlr_scene_buffer *scene_buffer, void wlr_scene_buffer_set_buffer(struct wlr_scene_buffer *scene_buffer,
struct wlr_buffer *buffer) { struct wlr_buffer *buffer) {
wlr_scene_buffer_set_buffer_with_damage(scene_buffer, buffer, NULL); wlr_scene_buffer_set_buffer_with_options(scene_buffer, buffer, NULL);
} }
void wlr_scene_buffer_set_opaque_region(struct wlr_scene_buffer *scene_buffer, void wlr_scene_buffer_set_opaque_region(struct wlr_scene_buffer *scene_buffer,

Loading…
Cancel
Save