surface: add wlr_surface.opaque_region
This commit is contained in:
parent
c4915d1492
commit
5bb272d7f3
|
@ -66,6 +66,12 @@ struct wlr_surface {
|
||||||
* just like the buffer's texture.
|
* just like the buffer's texture.
|
||||||
*/
|
*/
|
||||||
pixman_region32_t buffer_damage;
|
pixman_region32_t buffer_damage;
|
||||||
|
/**
|
||||||
|
* The current opaque region, in surface-local coordinates. It is clipped to
|
||||||
|
* the surface bounds. If the surface's buffer is using a fully opaque
|
||||||
|
* format, this is set to the whole surface.
|
||||||
|
*/
|
||||||
|
pixman_region32_t opaque_region;
|
||||||
/**
|
/**
|
||||||
* `current` contains the current, committed surface state. `pending`
|
* `current` contains the current, committed surface state. `pending`
|
||||||
* accumulates state changes from the client between commits and shouldn't
|
* accumulates state changes from the client between commits and shouldn't
|
||||||
|
|
|
@ -340,6 +340,25 @@ static void surface_apply_damage(struct wlr_surface *surface) {
|
||||||
surface->buffer = buffer;
|
surface->buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void surface_update_opaque_region(struct wlr_surface *surface) {
|
||||||
|
struct wlr_texture *texture = wlr_surface_get_texture(surface);
|
||||||
|
if (texture == NULL) {
|
||||||
|
pixman_region32_clear(&surface->opaque_region);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wlr_texture_is_opaque(texture)) {
|
||||||
|
pixman_region32_init_rect(&surface->opaque_region,
|
||||||
|
0, 0, surface->current.width, surface->current.height);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixman_region32_copy(&surface->opaque_region, &surface->current.opaque);
|
||||||
|
pixman_region32_intersect_rect(&surface->opaque_region,
|
||||||
|
&surface->opaque_region,
|
||||||
|
0, 0, surface->current.width, surface->current.height);
|
||||||
|
}
|
||||||
|
|
||||||
static void surface_commit_pending(struct wlr_surface *surface) {
|
static void surface_commit_pending(struct wlr_surface *surface) {
|
||||||
bool invalid_buffer = surface->pending.committed & WLR_SURFACE_STATE_BUFFER;
|
bool invalid_buffer = surface->pending.committed & WLR_SURFACE_STATE_BUFFER;
|
||||||
|
|
||||||
|
@ -356,6 +375,7 @@ static void surface_commit_pending(struct wlr_surface *surface) {
|
||||||
if (invalid_buffer) {
|
if (invalid_buffer) {
|
||||||
surface_apply_damage(surface);
|
surface_apply_damage(surface);
|
||||||
}
|
}
|
||||||
|
surface_update_opaque_region(surface);
|
||||||
|
|
||||||
// commit subsurface order
|
// commit subsurface order
|
||||||
struct wlr_subsurface *subsurface;
|
struct wlr_subsurface *subsurface;
|
||||||
|
@ -562,6 +582,7 @@ static void surface_handle_resource_destroy(struct wl_resource *resource) {
|
||||||
surface_state_finish(&surface->current);
|
surface_state_finish(&surface->current);
|
||||||
surface_state_finish(&surface->previous);
|
surface_state_finish(&surface->previous);
|
||||||
pixman_region32_fini(&surface->buffer_damage);
|
pixman_region32_fini(&surface->buffer_damage);
|
||||||
|
pixman_region32_fini(&surface->opaque_region);
|
||||||
wlr_buffer_unref(surface->buffer);
|
wlr_buffer_unref(surface->buffer);
|
||||||
free(surface);
|
free(surface);
|
||||||
}
|
}
|
||||||
|
@ -607,6 +628,7 @@ struct wlr_surface *wlr_surface_create(struct wl_client *client,
|
||||||
wl_list_init(&surface->subsurfaces);
|
wl_list_init(&surface->subsurfaces);
|
||||||
wl_list_init(&surface->subsurface_pending_list);
|
wl_list_init(&surface->subsurface_pending_list);
|
||||||
pixman_region32_init(&surface->buffer_damage);
|
pixman_region32_init(&surface->buffer_damage);
|
||||||
|
pixman_region32_init(&surface->opaque_region);
|
||||||
|
|
||||||
wl_signal_add(&renderer->events.destroy, &surface->renderer_destroy);
|
wl_signal_add(&renderer->events.destroy, &surface->renderer_destroy);
|
||||||
surface->renderer_destroy.notify = surface_handle_renderer_destroy;
|
surface->renderer_destroy.notify = surface_handle_renderer_destroy;
|
||||||
|
|
Loading…
Reference in New Issue