OSDN Git Service

minigbm: cros_gralloc: remove constexpr functions
authorGurchetan Singh <gurchetansingh@chromium.org>
Mon, 20 Mar 2017 21:45:39 +0000 (14:45 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Fri, 31 Mar 2017 17:40:28 +0000 (10:40 -0700)
There's no reason to have these as functions. Also eliminate
sw_write() and sw_read(), the only reason I added them because
I was hitting the 80 column limit (we're 100 columns wide now).

BUG=chromium:616275
TEST=compiles

Change-Id: If0d406df64dc760f2c007eeecf79874c1deb3ec7
Reviewed-on: https://chromium-review.googlesource.com/457288
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
cros_gralloc/cros_alloc_device.cc
cros_gralloc/cros_gralloc_helpers.cc
cros_gralloc/cros_gralloc_helpers.h
cros_gralloc/cros_gralloc_module.cc

index 63b455c..dbb409c 100644 (file)
@@ -70,7 +70,7 @@ static struct cros_gralloc_handle *cros_gralloc_handle_from_bo(struct bo *bo)
 
        hnd->base.version = sizeof(hnd->base);
        hnd->base.numFds = num_planes;
-       hnd->base.numInts = num_ints_handle() - num_planes;
+       hnd->base.numInts = num_ints_handle - num_planes;
 
        for (size_t p = 0; p < num_planes; p++) {
                hnd->fds[p] = drv_bo_get_plane_fd(bo, p);
@@ -88,7 +88,7 @@ static struct cros_gralloc_handle *cros_gralloc_handle_from_bo(struct bo *bo)
        hnd->format = drv_bo_get_format(bo);
        hnd->pixel_stride = drv_bo_get_stride_in_pixels(bo);
 
-       hnd->magic = cros_gralloc_magic();
+       hnd->magic = cros_gralloc_magic;
 
        return hnd;
 }
index ed0a25a..366ca75 100644 (file)
@@ -17,13 +17,13 @@ uint64_t cros_gralloc_convert_flags(int flags)
 
        if (flags & GRALLOC_USAGE_CURSOR)
                usage |= BO_USE_NONE;
-       if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_RARELY)
+       if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_RARELY)
                usage |= BO_USE_SW_READ_RARELY;
-       if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_OFTEN)
+       if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)
                usage |= BO_USE_SW_READ_OFTEN;
-       if ((flags & sw_write()) == GRALLOC_USAGE_SW_WRITE_RARELY)
+       if ((flags & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_RARELY)
                usage |= BO_USE_SW_WRITE_RARELY;
-       if ((flags & sw_write()) == GRALLOC_USAGE_SW_WRITE_OFTEN)
+       if ((flags & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_OFTEN)
                usage |= BO_USE_SW_WRITE_OFTEN;
        if (flags & GRALLOC_USAGE_HW_TEXTURE)
                usage |= BO_USE_TEXTURE;
@@ -147,7 +147,7 @@ int32_t cros_gralloc_rendernode_open(struct driver **drv)
 
 int32_t cros_gralloc_validate_handle(struct cros_gralloc_handle *hnd)
 {
-       if (!hnd || hnd->magic != cros_gralloc_magic())
+       if (!hnd || hnd->magic != cros_gralloc_magic)
                return CROS_GRALLOC_ERROR_BAD_HANDLE;
 
        return CROS_GRALLOC_ERROR_NONE;
index 0d79f92..026d92a 100644 (file)
@@ -42,30 +42,11 @@ enum {
 };
 // clang-format on
 
-constexpr uint32_t cros_gralloc_magic(void)
-{
-       return 0xABCDDCBA;
-}
+constexpr uint32_t cros_gralloc_magic = 0xABCDDCBA;
 
-constexpr uint32_t num_ints_handle()
-{
-       return ((sizeof(struct cros_gralloc_handle)) / sizeof(int));
-}
+constexpr uint32_t num_ints_handle = ((sizeof(struct cros_gralloc_handle)) / sizeof(int));
 
-constexpr uint32_t sw_access(void)
-{
-       return GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK;
-}
-
-constexpr uint32_t sw_read(void)
-{
-       return GRALLOC_USAGE_SW_READ_MASK;
-}
-
-constexpr uint32_t sw_write(void)
-{
-       return GRALLOC_USAGE_SW_WRITE_MASK;
-}
+constexpr uint32_t sw_access = GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK;
 
 uint64_t cros_gralloc_convert_flags(int flags);
 
index c3d0e65..eef3614 100644 (file)
@@ -169,7 +169,7 @@ static int cros_gralloc_lock(struct gralloc_module_t const *module, buffer_handl
                return CROS_GRALLOC_ERROR_BAD_HANDLE;
        }
 
-       if (sw_access() & usage) {
+       if (sw_access & usage) {
                if (bo->map_data) {
                        *vaddr = bo->map_data->addr;
                } else {
@@ -303,7 +303,7 @@ static int cros_gralloc_lock_ycbcr(struct gralloc_module_t const *module, buffer
                return CROS_GRALLOC_ERROR_BAD_HANDLE;
        }
 
-       if (sw_access() & usage) {
+       if (sw_access & usage) {
                void *vaddr;
                if (bo->map_data) {
                        vaddr = bo->map_data->addr;