OSDN Git Service

minigbm: Drop drv_bo_get_stride_in_pixels() helper
authorKristian H. Kristensen <hoegsberg@chromium.org>
Wed, 4 Apr 2018 20:40:47 +0000 (13:40 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Fri, 4 May 2018 10:02:36 +0000 (03:02 -0700)
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 <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
cros_gralloc/cros_gralloc_driver.cc
drv.h
helpers.c
helpers.h

index 9e8d98f..a68023e 100644 (file)
@@ -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<uint32_t>(descriptor->use_flags >> 32);
        hnd->use_flags[1] = static_cast<uint32_t>(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 (file)
--- 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);
 
index b0db2c7..c67787f 100644 (file)
--- 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.
  */
index b292baf..4c649c2 100644 (file)
--- a/helpers.h
+++ b/helpers.h
 #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);