aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_buffer.h9
-rw-r--r--types/wlr_buffer.c19
-rw-r--r--types/wlr_surface.c7
3 files changed, 14 insertions, 21 deletions
diff --git a/include/wlr/types/wlr_buffer.h b/include/wlr/types/wlr_buffer.h
index 4d9640d8..c714ddb6 100644
--- a/include/wlr/types/wlr_buffer.h
+++ b/include/wlr/types/wlr_buffer.h
@@ -178,15 +178,12 @@ struct wlr_client_buffer *wlr_client_buffer_get(struct wlr_buffer *buffer);
*/
bool wlr_resource_is_buffer(struct wl_resource *resource);
/**
- * Try to update the buffer's content. On success, returns the updated buffer
- * and destroys the provided `buffer`. On error, `buffer` is intact and NULL is
- * returned.
+ * Try to update the buffer's content.
*
* Fails if there's more than one reference to the buffer or if the texture
* isn't mutable.
*/
-struct wlr_client_buffer *wlr_client_buffer_apply_damage(
- struct wlr_client_buffer *buffer, struct wlr_buffer *next,
- pixman_region32_t *damage);
+bool wlr_client_buffer_apply_damage(struct wlr_client_buffer *client_buffer,
+ struct wlr_buffer *next, pixman_region32_t *damage);
#endif
diff --git a/types/wlr_buffer.c b/types/wlr_buffer.c
index 86b138d9..fce20a71 100644
--- a/types/wlr_buffer.c
+++ b/types/wlr_buffer.c
@@ -271,36 +271,35 @@ struct wlr_client_buffer *wlr_client_buffer_create(struct wlr_buffer *buffer,
return client_buffer;
}
-struct wlr_client_buffer *wlr_client_buffer_apply_damage(
- struct wlr_client_buffer *client_buffer, struct wlr_buffer *next,
- pixman_region32_t *damage) {
+bool wlr_client_buffer_apply_damage(struct wlr_client_buffer *client_buffer,
+ struct wlr_buffer *next, pixman_region32_t *damage) {
if (client_buffer->base.n_locks > 1) {
// Someone else still has a reference to the buffer
- return NULL;
+ return false;
}
if ((uint32_t)next->width != client_buffer->texture->width ||
(uint32_t)next->height != client_buffer->texture->height) {
- return NULL;
+ return false;
}
if (client_buffer->shm_source_format == DRM_FORMAT_INVALID) {
// Uploading only damaged regions only works for wl_shm buffers and
// mutable textures (created from wl_shm buffer)
- return NULL;
+ return false;
}
void *data;
uint32_t format;
size_t stride;
if (!buffer_begin_data_ptr_access(next, &data, &format, &stride)) {
- return NULL;
+ return false;
}
if (format != client_buffer->shm_source_format) {
// Uploading to textures can't change the format
buffer_end_data_ptr_access(next);
- return NULL;
+ return false;
}
int n;
@@ -311,13 +310,13 @@ struct wlr_client_buffer *wlr_client_buffer_apply_damage(
r->x2 - r->x1, r->y2 - r->y1, r->x1, r->y1,
r->x1, r->y1, data)) {
buffer_end_data_ptr_access(next);
- return NULL;
+ return false;
}
}
buffer_end_data_ptr_access(next);
- return client_buffer;
+ return true;
}
static const struct wlr_buffer_impl shm_client_buffer_impl;
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index a82fc5bf..2058e21a 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -364,13 +364,10 @@ static void surface_apply_damage(struct wlr_surface *surface) {
}
if (surface->buffer != NULL) {
- struct wlr_client_buffer *updated_buffer =
- wlr_client_buffer_apply_damage(surface->buffer,
- surface->current.buffer, &surface->buffer_damage);
- if (updated_buffer != NULL) {
+ if (wlr_client_buffer_apply_damage(surface->buffer,
+ surface->current.buffer, &surface->buffer_damage)) {
wlr_buffer_unlock(surface->current.buffer);
surface->current.buffer = NULL;
- surface->buffer = updated_buffer;
return;
}
}