aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/allocator.c3
-rw-r--r--render/drm_dumb_allocator.c11
-rw-r--r--render/pixman/renderer.c31
-rw-r--r--render/shm_allocator.c11
4 files changed, 48 insertions, 8 deletions
diff --git a/render/allocator.c b/render/allocator.c
index 4f87d95a..aade40a9 100644
--- a/render/allocator.c
+++ b/render/allocator.c
@@ -81,7 +81,8 @@ struct wlr_buffer *wlr_allocator_create_buffer(struct wlr_allocator *alloc,
return NULL;
}
if (alloc->buffer_caps & WLR_BUFFER_CAP_DATA_PTR) {
- assert(buffer->impl->get_data_ptr);
+ assert(buffer->impl->begin_data_ptr_access &&
+ buffer->impl->end_data_ptr_access);
}
if (alloc->buffer_caps & WLR_BUFFER_CAP_DMABUF) {
assert(buffer->impl->get_dmabuf);
diff --git a/render/drm_dumb_allocator.c b/render/drm_dumb_allocator.c
index 9e14e38e..9713e078 100644
--- a/render/drm_dumb_allocator.c
+++ b/render/drm_dumb_allocator.c
@@ -128,8 +128,8 @@ create_err:
return NULL;
}
-static bool drm_dumb_buffer_get_data_ptr(struct wlr_buffer *wlr_buffer, void **data,
- uint32_t *format, size_t *stride) {
+static bool drm_dumb_buffer_begin_data_ptr_access(struct wlr_buffer *wlr_buffer,
+ void **data, uint32_t *format, size_t *stride) {
struct wlr_drm_dumb_buffer *buf = drm_dumb_buffer_from_buffer(wlr_buffer);
*data = buf->data;
*stride = buf->stride;
@@ -137,6 +137,10 @@ static bool drm_dumb_buffer_get_data_ptr(struct wlr_buffer *wlr_buffer, void **d
return true;
}
+static void drm_dumb_buffer_end_data_ptr_access(struct wlr_buffer *wlr_buffer) {
+ // This space is intentionally left blank
+}
+
static bool buffer_get_dmabuf(struct wlr_buffer *wlr_buffer,
struct wlr_dmabuf_attributes *attribs) {
struct wlr_drm_dumb_buffer *buf = drm_dumb_buffer_from_buffer(wlr_buffer);
@@ -153,7 +157,8 @@ static void buffer_destroy(struct wlr_buffer *wlr_buffer) {
static const struct wlr_buffer_impl buffer_impl = {
.destroy = buffer_destroy,
.get_dmabuf = buffer_get_dmabuf,
- .get_data_ptr = drm_dumb_buffer_get_data_ptr,
+ .begin_data_ptr_access = drm_dumb_buffer_begin_data_ptr_access,
+ .end_data_ptr_access = drm_dumb_buffer_end_data_ptr_access,
};
static const struct wlr_allocator_interface allocator_impl;
diff --git a/render/pixman/renderer.c b/render/pixman/renderer.c
index a5a402f2..ff9375ee 100644
--- a/render/pixman/renderer.c
+++ b/render/pixman/renderer.c
@@ -86,10 +86,11 @@ static struct wlr_pixman_buffer *create_buffer(
void *data = NULL;
uint32_t drm_format;
size_t stride;
- if (!buffer_get_data_ptr(wlr_buffer, &data, &drm_format, &stride)) {
+ if (!buffer_begin_data_ptr_access(wlr_buffer, &data, &drm_format, &stride)) {
wlr_log(WLR_ERROR, "Failed to get buffer data");
goto error_buffer;
}
+ buffer_end_data_ptr_access(wlr_buffer);
pixman_format_code_t format = get_pixman_format_from_drm(drm_format);
if (format == 0) {
@@ -125,6 +126,33 @@ static void pixman_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer);
renderer->width = width;
renderer->height = height;
+
+ struct wlr_pixman_buffer *buffer = renderer->current_buffer;
+ assert(buffer != NULL);
+
+ void *data = NULL;
+ uint32_t drm_format;
+ size_t stride;
+ buffer_begin_data_ptr_access(buffer->buffer, &data, &drm_format, &stride);
+
+ // If the data pointer has changed, re-create the Pixman image. This can
+ // happen if it's a client buffer and the wl_shm_pool has been resized.
+ if (data != pixman_image_get_data(buffer->image)) {
+ pixman_format_code_t format = get_pixman_format_from_drm(drm_format);
+ assert(format != 0);
+
+ pixman_image_unref(buffer->image);
+ buffer->image = pixman_image_create_bits_no_clear(format,
+ buffer->buffer->width, buffer->buffer->height, data, stride);
+ }
+}
+
+static void pixman_end(struct wlr_renderer *wlr_renderer) {
+ struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer);
+
+ assert(renderer->current_buffer != NULL);
+
+ buffer_end_data_ptr_access(renderer->current_buffer->buffer);
}
static void pixman_clear(struct wlr_renderer *wlr_renderer,
@@ -413,6 +441,7 @@ static uint32_t pixman_get_render_buffer_caps(void) {
static const struct wlr_renderer_impl renderer_impl = {
.begin = pixman_begin,
+ .end = pixman_end,
.clear = pixman_clear,
.scissor = pixman_scissor,
.render_subtexture_with_matrix = pixman_render_subtexture_with_matrix,
diff --git a/render/shm_allocator.c b/render/shm_allocator.c
index e1a3d9e5..2066b125 100644
--- a/render/shm_allocator.c
+++ b/render/shm_allocator.c
@@ -31,8 +31,8 @@ static bool buffer_get_shm(struct wlr_buffer *wlr_buffer,
return true;
}
-static bool shm_buffer_get_data_ptr(struct wlr_buffer *wlr_buffer, void **data,
- uint32_t *format, size_t *stride) {
+static bool shm_buffer_begin_data_ptr_access(struct wlr_buffer *wlr_buffer,
+ void **data, uint32_t *format, size_t *stride) {
struct wlr_shm_buffer *buffer = shm_buffer_from_buffer(wlr_buffer);
*data = buffer->data;
*format = buffer->shm.format;
@@ -40,10 +40,15 @@ static bool shm_buffer_get_data_ptr(struct wlr_buffer *wlr_buffer, void **data,
return true;
}
+static void shm_buffer_end_data_ptr_access(struct wlr_buffer *wlr_buffer) {
+ // This space is intentionally left blank
+}
+
static const struct wlr_buffer_impl buffer_impl = {
.destroy = buffer_destroy,
.get_shm = buffer_get_shm,
- .get_data_ptr = shm_buffer_get_data_ptr,
+ .begin_data_ptr_access = shm_buffer_begin_data_ptr_access,
+ .end_data_ptr_access = shm_buffer_end_data_ptr_access,
};
static struct wlr_buffer *allocator_create_buffer(