aboutsummaryrefslogtreecommitdiff
path: root/render/gles2
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-09-17 14:37:52 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-11-15 16:30:00 +0000
commit6e88eeadebe5bed0210158124a3c498a8f8a47cb (patch)
tree83edd18ab44ea8fb34a4e8ad3a6c09d9c488a17f /render/gles2
parent8cfd44980baae8fdc3eb64461378cadd3362878b (diff)
render/pixel_format: import pixel_format_info_check_stride()
We'll use this function from wlr_shm too. Add some assertions, use int32_t (since the wire protocol uses that, and we don't want to use 16-bit integers on exotic systems) and switch the stride check to be overflow-safe.
Diffstat (limited to 'render/gles2')
-rw-r--r--render/gles2/texture.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index f304df93..9dccc526 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -28,21 +28,6 @@ struct wlr_gles2_texture *gles2_get_texture(
return (struct wlr_gles2_texture *)wlr_texture;
}
-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 "
- "bytes-per-pixel)", stride, fmt->bpp / 8);
- return false;
- }
- if (stride < width * (fmt->bpp / 8)) {
- wlr_log(WLR_ERROR, "Invalid stride %d (too small for %d "
- "bytes-per-pixel and width %d)", stride, fmt->bpp / 8, width);
- return false;
- }
- return true;
-}
-
static bool gles2_texture_update_from_buffer(struct wlr_texture *wlr_texture,
struct wlr_buffer *buffer, const pixman_region32_t *damage) {
struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture);
@@ -72,7 +57,7 @@ static bool gles2_texture_update_from_buffer(struct wlr_texture *wlr_texture,
drm_get_pixel_format_info(texture->drm_format);
assert(drm_fmt);
- if (!check_stride(drm_fmt, stride, buffer->width)) {
+ if (!pixel_format_info_check_stride(drm_fmt, stride, buffer->width)) {
wlr_buffer_end_data_ptr_access(buffer);
return false;
}
@@ -212,7 +197,7 @@ static struct wlr_texture *gles2_texture_from_pixels(
drm_get_pixel_format_info(drm_format);
assert(drm_fmt);
- if (!check_stride(drm_fmt, stride, width)) {
+ if (!pixel_format_info_check_stride(drm_fmt, stride, width)) {
return NULL;
}