From 29c8df7e0a3e6ac1720cd843ba6f523de6b71c0a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 29 Jun 2021 20:11:53 +0200 Subject: render: use wlr_readonly_data_buffer in wlr_texture_from_pixels --- render/wlr_texture.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/render/wlr_texture.c b/render/wlr_texture.c index b2acfcb4..73c1d8f3 100644 --- a/render/wlr_texture.c +++ b/render/wlr_texture.c @@ -3,6 +3,7 @@ #include #include #include +#include "types/wlr_buffer.h" #include "render/wlr_texture.h" void wlr_texture_init(struct wlr_texture *texture, @@ -27,8 +28,21 @@ struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer, assert(height > 0); assert(stride > 0); assert(data); - return renderer->impl->texture_from_pixels(renderer, fmt, stride, width, - height, data); + + struct wlr_readonly_data_buffer *buffer = + readonly_data_buffer_create(fmt, stride, width, height, data); + if (buffer == NULL) { + return NULL; + } + + struct wlr_texture *texture = + wlr_texture_from_buffer(renderer, &buffer->base); + + // By this point, the renderer should have locked the buffer if it still + // needs to access it in the future. + readonly_data_buffer_drop(buffer); + + return texture; } struct wlr_texture *wlr_texture_from_wl_drm(struct wlr_renderer *renderer, -- cgit v1.2.3