From 549435aee52164b925716283ce38597de85bc2bf Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 16 Feb 2021 19:17:18 +0100 Subject: render/gles2: replace wlr_gles2_texture.wl_format with drm_format --- include/render/gles2.h | 5 ++--- render/gles2/pixel_format.c | 5 ++--- render/gles2/renderer.c | 3 ++- render/gles2/texture.c | 12 +++++++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/render/gles2.h b/include/render/gles2.h index 00ee34fb..067bdd31 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -107,11 +107,10 @@ struct wlr_gles2_texture { bool has_alpha; // Only affects target == GL_TEXTURE_2D - enum wl_shm_format wl_format; // used to interpret upload data + uint32_t drm_format; // used to interpret upload data }; -const struct wlr_gles2_pixel_format *get_gles2_format_from_wl( - enum wl_shm_format fmt); +const struct wlr_gles2_pixel_format *get_gles2_format_from_drm(uint32_t fmt); const struct wlr_gles2_pixel_format *get_gles2_format_from_gl( GLint gl_format, GLint gl_type, bool alpha); const enum wl_shm_format *get_gles2_wl_formats(size_t *len); diff --git a/render/gles2/pixel_format.c b/render/gles2/pixel_format.c index c3eaa8e6..d7711caa 100644 --- a/render/gles2/pixel_format.c +++ b/render/gles2/pixel_format.c @@ -45,10 +45,9 @@ static const struct wlr_gles2_pixel_format formats[] = { // TODO: more pixel formats -const struct wlr_gles2_pixel_format *get_gles2_format_from_wl( - enum wl_shm_format fmt) { +const struct wlr_gles2_pixel_format *get_gles2_format_from_drm(uint32_t fmt) { for (size_t i = 0; i < sizeof(formats) / sizeof(*formats); ++i) { - if (convert_drm_format_to_wl_shm(formats[i].drm_format) == fmt) { + if (formats[i].drm_format == fmt) { return &formats[i]; } } diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index cdf2c8b2..fa7bc6c7 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -472,7 +472,8 @@ static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer, struct wlr_gles2_renderer *renderer = gles2_get_renderer_in_context(wlr_renderer); - const struct wlr_gles2_pixel_format *fmt = get_gles2_format_from_wl(wl_fmt); + const struct wlr_gles2_pixel_format *fmt = + get_gles2_format_from_drm(convert_wl_shm_format_to_drm(wl_fmt)); if (fmt == NULL) { wlr_log(WLR_ERROR, "Cannot read pixels: unsupported pixel format"); return false; diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 000333ce..e2d492f5 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -58,7 +59,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture, } const struct wlr_gles2_pixel_format *fmt = - get_gles2_format_from_wl(texture->wl_format); + get_gles2_format_from_drm(texture->drm_format); assert(fmt); if (!check_stride(fmt, stride, width)) { @@ -156,7 +157,8 @@ struct wlr_texture *gles2_texture_from_pixels(struct wlr_renderer *wlr_renderer, uint32_t height, const void *data) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); - const struct wlr_gles2_pixel_format *fmt = get_gles2_format_from_wl(wl_fmt); + const struct wlr_gles2_pixel_format *fmt = + get_gles2_format_from_drm(convert_wl_shm_format_to_drm(wl_fmt)); if (fmt == NULL) { wlr_log(WLR_ERROR, "Unsupported pixel format %"PRIu32, wl_fmt); return NULL; @@ -176,7 +178,7 @@ struct wlr_texture *gles2_texture_from_pixels(struct wlr_renderer *wlr_renderer, texture->renderer = renderer; texture->target = GL_TEXTURE_2D; texture->has_alpha = fmt->has_alpha; - texture->wl_format = convert_drm_format_to_wl_shm(fmt->drm_format); + texture->drm_format = fmt->drm_format; struct wlr_egl_context prev_ctx; wlr_egl_save_context(&prev_ctx); @@ -234,7 +236,7 @@ struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer, wlr_texture_init(&texture->wlr_texture, &texture_impl, width, height); texture->renderer = renderer; - texture->wl_format = 0xFFFFFFFF; // texture can't be written anyways + texture->drm_format = DRM_FORMAT_INVALID; // texture can't be written anyways texture->image = image; texture->inverted_y = inverted_y; @@ -302,7 +304,7 @@ struct wlr_texture *gles2_texture_from_dmabuf(struct wlr_renderer *wlr_renderer, attribs->width, attribs->height); texture->renderer = renderer; texture->has_alpha = true; - texture->wl_format = 0xFFFFFFFF; // texture can't be written anyways + texture->drm_format = DRM_FORMAT_INVALID; // texture can't be written anyways texture->inverted_y = (attribs->flags & WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT) != 0; -- cgit v1.2.3