From f62698cbeb289db7609d8511d35c0e3d4a46be5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 17 Apr 2026 14:51:10 +0200 Subject: [PATCH] renderer/gles2: Allow to import textures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to manipulate textures before feeding them to the render pass e.g. to greyscale them for a11y reasons or to blur them. Signed-off-by: Guido Günther --- include/wlr/render/gles2.h | 2 ++ render/gles2/texture.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h index 87a57fa54..796474550 100644 --- a/include/wlr/render/gles2.h +++ b/include/wlr/render/gles2.h @@ -47,5 +47,7 @@ bool wlr_render_timer_is_gles2(const struct wlr_render_timer *timer); bool wlr_texture_is_gles2(const struct wlr_texture *texture); void wlr_gles2_texture_get_attribs(struct wlr_texture *texture, struct wlr_gles2_texture_attribs *attribs); +struct wlr_texture *wlr_gles2_texture_from_attribs(struct wlr_renderer *wlr_renderer, + struct wlr_gles2_texture_attribs *attribs, int width, int height); #endif diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 575a11fca..a3cf18af8 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -461,3 +461,25 @@ void wlr_gles2_texture_get_attribs(struct wlr_texture *wlr_texture, .has_alpha = texture->has_alpha, }; } + +struct wlr_texture *wlr_gles2_texture_from_attribs(struct wlr_renderer *wlr_renderer, + struct wlr_gles2_texture_attribs *attribs, int width, int height) { + struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); + + if (attribs->target != GL_TEXTURE_2D) { + return NULL; + } + + struct wlr_gles2_texture *texture = + gles2_texture_create(renderer, width, height); + + if (texture == NULL) { + return NULL; + } + + texture->target = attribs->target; + texture->tex = attribs->tex; + texture->has_alpha = attribs->has_alpha; + + return &texture->wlr_texture; +}