Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
surface: make wlr_surface.buffer a wlr_buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Apr 13, 2021
1 parent ed57b2d commit a7215c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/wlr/types/wlr_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct wlr_surface {
* have a buffer if it has never committed one, has committed a null buffer,
* or something went wrong with uploading the buffer.
*/
struct wlr_client_buffer *buffer;
struct wlr_buffer *buffer;
/**
* The buffer position, in surface-local units.
*/
Expand Down
27 changes: 13 additions & 14 deletions types/wlr_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,19 @@ static void surface_apply_damage(struct wlr_surface *surface) {
struct wl_resource *resource = surface->current.buffer_resource;
if (resource == NULL) {
// NULL commit
if (surface->buffer != NULL) {
wlr_buffer_unlock(&surface->buffer->base);
}
wlr_buffer_unlock(surface->buffer);
surface->buffer = NULL;
return;
}

if (surface->buffer != NULL && surface->buffer->resource_released) {
struct wlr_client_buffer *client_buffer = surface->buffer != NULL ?
wlr_client_buffer_get(surface->buffer) : NULL;
if (client_buffer != NULL && client_buffer->resource_released) {
struct wlr_client_buffer *updated_buffer =
wlr_client_buffer_apply_damage(surface->buffer, resource,
wlr_client_buffer_apply_damage(client_buffer, resource,
&surface->buffer_damage);
if (updated_buffer != NULL) {
surface->buffer = updated_buffer;
surface->buffer = &updated_buffer->base;
return;
}
}
Expand All @@ -374,10 +374,8 @@ static void surface_apply_damage(struct wlr_surface *surface) {
return;
}

if (surface->buffer != NULL) {
wlr_buffer_unlock(&surface->buffer->base);
}
surface->buffer = buffer;
wlr_buffer_unlock(surface->buffer);
surface->buffer = &buffer->base;
}

static void surface_update_opaque_region(struct wlr_surface *surface) {
Expand Down Expand Up @@ -688,9 +686,7 @@ static void surface_handle_resource_destroy(struct wl_resource *resource) {
pixman_region32_fini(&surface->buffer_damage);
pixman_region32_fini(&surface->opaque_region);
pixman_region32_fini(&surface->input_region);
if (surface->buffer != NULL) {
wlr_buffer_unlock(&surface->buffer->base);
}
wlr_buffer_unlock(surface->buffer);
free(surface);
}

Expand Down Expand Up @@ -750,7 +746,10 @@ struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface) {
if (surface->buffer == NULL) {
return NULL;
}
return surface->buffer->texture;
struct wlr_client_buffer *client_buffer =
wlr_client_buffer_get(surface->buffer);
assert(client_buffer);
return client_buffer->texture;
}

bool wlr_surface_has_buffer(struct wlr_surface *surface) {
Expand Down

0 comments on commit a7215c8

Please sign in to comment.