Skip to content

Commit

Permalink
HACK: Use pixel stride instead of width as gbm->map() argument
Browse files Browse the repository at this point in the history
Made by aleasto, same hack can be seen on minigbm_gbm_mesa
GloDroid/glodroid_forks@2c576ea
  • Loading branch information
hmtheboy154 committed Sep 17, 2022
1 parent b7c1953 commit e70acfc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gralloc_gbm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit e70acfc

Please sign in to comment.