From: Kristian H. Kristensen Date: Wed, 4 Apr 2018 20:40:47 +0000 (-0700) Subject: minigbm: Drop drv_bo_get_stride_in_pixels() helper X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fexternal-minigbm.git;a=commitdiff_plain;h=222919005b758a0afe24d2c2cc4bac342b575bbd minigbm: Drop drv_bo_get_stride_in_pixels() helper Computing "stride in pixels" assumes the pixel size divides the stride, which isn't always the case. This is only used for the cros_gralloc implementation, so lets move the calculation there instead of providing a generic helper for an unhealthy concept. BUG=822346 TEST=test_that graphics_Gbm Change-Id: Iab7a363c5471e4bacef7df7095ef77723adf5e93 Reviewed-on: https://chromium-review.googlesource.com/996645 Commit-Ready: Kristian H. Kristensen Tested-by: Kristian H. Kristensen Reviewed-by: Gurchetan Singh --- diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc index 9e8d98f..a68023e 100644 --- a/cros_gralloc/cros_gralloc_driver.cc +++ b/cros_gralloc/cros_gralloc_driver.cc @@ -90,6 +90,7 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto uint64_t mod; size_t num_planes; uint32_t resolved_format; + uint32_t bytes_per_pixel; struct bo *bo; struct cros_gralloc_handle *hnd; @@ -135,7 +136,8 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto hnd->format = drv_bo_get_format(bo); hnd->use_flags[0] = static_cast(descriptor->use_flags >> 32); hnd->use_flags[1] = static_cast(descriptor->use_flags); - hnd->pixel_stride = drv_bo_get_stride_in_pixels(bo); + bytes_per_pixel = drv_bytes_per_pixel_from_format(hnd->format, 0); + hnd->pixel_stride = DIV_ROUND_UP(hnd->strides[0], bytes_per_pixel); hnd->magic = cros_gralloc_magic; hnd->droid_format = descriptor->droid_format; hnd->usage = descriptor->producer_usage; diff --git a/drv.h b/drv.h index c91382e..876f13a 100644 --- a/drv.h +++ b/drv.h @@ -155,7 +155,7 @@ uint64_t drv_bo_get_plane_format_modifier(struct bo *bo, size_t plane); uint32_t drv_bo_get_format(struct bo *bo); -uint32_t drv_bo_get_stride_in_pixels(struct bo *bo); +uint32_t drv_bytes_per_pixel_from_format(uint32_t format, size_t plane); uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane); diff --git a/helpers.c b/helpers.c index b0db2c7..c67787f 100644 --- a/helpers.c +++ b/helpers.c @@ -185,12 +185,6 @@ uint32_t drv_bytes_per_pixel_from_format(uint32_t format, size_t plane) return layout->bytes_per_pixel[plane]; } -uint32_t drv_bo_get_stride_in_pixels(struct bo *bo) -{ - uint32_t bytes_per_pixel = drv_bytes_per_pixel_from_format(bo->format, 0); - return DIV_ROUND_UP(bo->strides[0], bytes_per_pixel); -} - /* * This function returns the stride for a given format, width and plane. */ diff --git a/helpers.h b/helpers.h index b292baf..4c649c2 100644 --- a/helpers.h +++ b/helpers.h @@ -10,11 +10,9 @@ #include "drv.h" #include "helpers_array.h" -uint32_t drv_width_from_format(uint32_t format, uint32_t width, size_t plane); uint32_t drv_height_from_format(uint32_t format, uint32_t height, size_t plane); uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane); int drv_bo_from_format(struct bo *bo, uint32_t stride, uint32_t aligned_height, uint32_t format); -uint32_t drv_bytes_per_pixel_from_format(uint32_t format, size_t plane); int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format, uint64_t use_flags); int drv_dumb_bo_destroy(struct bo *bo);