From e70acfc3f5acc64168a172987f34d141e55f6b54 Mon Sep 17 00:00:00 2001 From: hmtheboy154 Date: Fri, 9 Sep 2022 04:05:47 -0400 Subject: [PATCH] HACK: Use pixel stride instead of width as gbm->map() argument Made by aleasto, same hack can be seen on minigbm_gbm_mesa https://github.com/GloDroid/glodroid_forks/commit/2c576ea127a7e7fad79bf0282ba115634bcbf931 --- gralloc_gbm.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gralloc_gbm.cpp b/gralloc_gbm.cpp index d28559f..0fc4b5d 100644 --- a/gralloc_gbm.cpp +++ b/gralloc_gbm.cpp @@ -262,6 +262,8 @@ struct gbm_bo *gralloc_gbm_bo_from_handle(buffer_handle_t handle) return gbm_bo_handle_map[handle]; } +#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) + static int gbm_map(buffer_handle_t handle, int enable_write, void **addr) { int err = 0; @@ -276,7 +278,7 @@ static int gbm_map(buffer_handle_t handle, int enable_write, void **addr) if (enable_write) flags |= GBM_BO_TRANSFER_WRITE; - *addr = gbm_bo_map(bo, 0, 0, gbm_bo_get_width(bo), gbm_bo_get_height(bo), + *addr = gbm_bo_map(bo, 0, 0, DIV_ROUND_UP(gbm_bo_get_stride(bo), gbm_bo_get_bpp(bo) / 8), gbm_bo_get_height(bo), flags, &stride, &bo_data->map_data); ALOGV("mapped bo %p at %p", bo, *addr); if (*addr == NULL)