diff options
author | Mathias Agopian <mathias@google.com> | 2010-02-16 14:04:00 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-02-16 14:04:00 -0800 |
commit | 9da751bbf7cc6db4a0156b92bb1d3ae585bcdf32 (patch) | |
tree | 80fac98919cf3f0ceebce49318726b7aa144c351 /modules/gralloc | |
parent | c212d9d76fdb5f24e50f4d3e1f463f739335e8a7 (diff) | |
download | hardware_libhardware-9da751bbf7cc6db4a0156b92bb1d3ae585bcdf32.zip hardware_libhardware-9da751bbf7cc6db4a0156b92bb1d3ae585bcdf32.tar.gz hardware_libhardware-9da751bbf7cc6db4a0156b92bb1d3ae585bcdf32.tar.bz2 |
fix [2444483] gralloc size for YUV formats
Diffstat (limited to 'modules/gralloc')
-rw-r--r-- | modules/gralloc/gralloc.cpp | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/modules/gralloc/gralloc.cpp b/modules/gralloc/gralloc.cpp index a9ae784..dcd2e2b 100644 --- a/modules/gralloc/gralloc.cpp +++ b/modules/gralloc/gralloc.cpp @@ -204,47 +204,29 @@ static int gralloc_alloc(alloc_device_t* dev, return -EINVAL; size_t size, stride; - if (format == HAL_PIXEL_FORMAT_YCbCr_420_SP || - format == HAL_PIXEL_FORMAT_YCbCr_422_SP) - { - // FIXME: there is no way to return the vstride - int vstride; - stride = (w + 1) & ~1; - switch (format) { - case HAL_PIXEL_FORMAT_YCbCr_420_SP: - size = stride * h * 2; - break; - case HAL_PIXEL_FORMAT_YCbCr_422_SP: - vstride = (h+1) & ~1; - size = (stride * vstride) + (w/2 * h/2) * 2; - break; - default: - return -EINVAL; - } - } else { - int align = 4; - int bpp = 0; - switch (format) { - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_BGRA_8888: - bpp = 4; - break; - case HAL_PIXEL_FORMAT_RGB_888: - bpp = 3; - break; - case HAL_PIXEL_FORMAT_RGB_565: - case HAL_PIXEL_FORMAT_RGBA_5551: - case HAL_PIXEL_FORMAT_RGBA_4444: - bpp = 2; - break; - default: - return -EINVAL; - } - size_t bpr = (w*bpp + (align-1)) & ~(align-1); - size = bpr * h; - stride = bpr / bpp; + + int align = 4; + int bpp = 0; + switch (format) { + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_BGRA_8888: + bpp = 4; + break; + case HAL_PIXEL_FORMAT_RGB_888: + bpp = 3; + break; + case HAL_PIXEL_FORMAT_RGB_565: + case HAL_PIXEL_FORMAT_RGBA_5551: + case HAL_PIXEL_FORMAT_RGBA_4444: + bpp = 2; + break; + default: + return -EINVAL; } + size_t bpr = (w*bpp + (align-1)) & ~(align-1); + size = bpr * h; + stride = bpr / bpp; int err; if (usage & GRALLOC_USAGE_HW_FB) { |