diff options
author | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-03-24 10:10:52 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-03-25 10:55:54 +0100 |
commit | 78d21fa131d746a7ae5890657654161692da63b6 (patch) | |
tree | 88d5ff5c5fbe868a331a309d9acc2b3955000251 | |
parent | 9b3f2e327f1dae047e9c5d778068a22275e8a6f8 (diff) |
render/gles2: remove depth and bpp gles2_pixel_format, use drm pixel format
-rw-r--r-- | include/render/gles2.h | 1 | ||||
-rw-r--r-- | render/gles2/pixel_format.c | 8 | ||||
-rw-r--r-- | render/gles2/renderer.c | 9 | ||||
-rw-r--r-- | render/gles2/texture.c | 19 |
4 files changed, 21 insertions, 16 deletions
diff --git a/include/render/gles2.h b/include/render/gles2.h index 8b4de5a2..7bfd6235 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -17,7 +17,6 @@ struct wlr_gles2_pixel_format { uint32_t drm_format; GLint gl_format, gl_type; - int depth, bpp; bool has_alpha; }; diff --git a/render/gles2/pixel_format.c b/render/gles2/pixel_format.c index 4ca98fe9..3f230df9 100644 --- a/render/gles2/pixel_format.c +++ b/render/gles2/pixel_format.c @@ -10,32 +10,24 @@ static const struct wlr_gles2_pixel_format formats[] = { { .drm_format = DRM_FORMAT_ARGB8888, - .depth = 32, - .bpp = 32, .gl_format = GL_BGRA_EXT, .gl_type = GL_UNSIGNED_BYTE, .has_alpha = true, }, { .drm_format = DRM_FORMAT_XRGB8888, - .depth = 24, - .bpp = 32, .gl_format = GL_BGRA_EXT, .gl_type = GL_UNSIGNED_BYTE, .has_alpha = false, }, { .drm_format = DRM_FORMAT_XBGR8888, - .depth = 24, - .bpp = 32, .gl_format = GL_RGBA, .gl_type = GL_UNSIGNED_BYTE, .has_alpha = false, }, { .drm_format = DRM_FORMAT_ABGR8888, - .depth = 32, - .bpp = 32, .gl_format = GL_RGBA, .gl_type = GL_UNSIGNED_BYTE, .has_alpha = true, diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 504af574..eb93b3b4 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -15,6 +15,7 @@ #include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/util/log.h> #include "render/gles2.h" +#include "render/pixel_format.h" static const GLfloat verts[] = { 1, 0, // top right @@ -492,6 +493,10 @@ static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer, return false; } + const struct wlr_pixel_format_info *drm_fmt = + drm_get_pixel_format_info(fmt->drm_format); + assert(drm_fmt); + push_gles2_debug(renderer); // Make sure any pending drawing is finished before we try to read it @@ -500,7 +505,7 @@ static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer, glGetError(); // Clear the error flag unsigned char *p = (unsigned char *)data + dst_y * stride; - uint32_t pack_stride = width * fmt->bpp / 8; + uint32_t pack_stride = width * drm_fmt->bpp / 8; if (pack_stride == stride && dst_x == 0) { // Under these particular conditions, we can read the pixels with only // one glReadPixels call @@ -512,7 +517,7 @@ static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer, for (size_t i = 0; i < height; ++i) { uint32_t y = src_y + i; glReadPixels(src_x, y, width, 1, fmt->gl_format, - fmt->gl_type, p + i * stride + dst_x * fmt->bpp / 8); + fmt->gl_type, p + i * stride + dst_x * drm_fmt->bpp / 8); } } diff --git a/render/gles2/texture.c b/render/gles2/texture.c index a3400eb2..94dcc022 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -12,6 +12,7 @@ #include <wlr/types/wlr_matrix.h> #include <wlr/util/log.h> #include "render/gles2.h" +#include "render/pixel_format.h" #include "util/signal.h" static const struct wlr_texture_impl texture_impl; @@ -31,7 +32,7 @@ static bool gles2_texture_is_opaque(struct wlr_texture *wlr_texture) { return !texture->has_alpha; } -static bool check_stride(const struct wlr_gles2_pixel_format *fmt, +static bool check_stride(const struct wlr_pixel_format_info *fmt, uint32_t stride, uint32_t width) { if (stride % (fmt->bpp / 8) != 0) { wlr_log(WLR_ERROR, "Invalid stride %d (incompatible with %d " @@ -61,7 +62,11 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture, get_gles2_format_from_drm(texture->drm_format); assert(fmt); - if (!check_stride(fmt, stride, width)) { + const struct wlr_pixel_format_info *drm_fmt = + drm_get_pixel_format_info(texture->drm_format); + assert(drm_fmt); + + if (!check_stride(drm_fmt, stride, width)) { return false; } @@ -73,7 +78,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture, glBindTexture(GL_TEXTURE_2D, texture->tex); - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride / (fmt->bpp / 8)); + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride / (drm_fmt->bpp / 8)); glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, src_x); glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, src_y); @@ -163,7 +168,11 @@ struct wlr_texture *gles2_texture_from_pixels(struct wlr_renderer *wlr_renderer, return NULL; } - if (!check_stride(fmt, stride, width)) { + const struct wlr_pixel_format_info *drm_fmt = + drm_get_pixel_format_info(drm_format); + assert(drm_fmt); + + if (!check_stride(drm_fmt, stride, width)) { return NULL; } @@ -190,7 +199,7 @@ struct wlr_texture *gles2_texture_from_pixels(struct wlr_renderer *wlr_renderer, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride / (fmt->bpp / 8)); + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride / (drm_fmt->bpp / 8)); glTexImage2D(GL_TEXTURE_2D, 0, fmt->gl_format, width, height, 0, fmt->gl_format, fmt->gl_type, data); glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0); |