diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2020-08-18 08:02:20 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2020-08-18 08:02:20 -0700 |
commit | e7a6d320a5d563eac697e0bb4be96e17f91a0ecf (patch) | |
tree | 3abd905a1a5c8a8bc88040ab7107ba3a86e0ffcf /gralloc/gr_buf_mgr.cpp | |
parent | 42a9b4327125173d22b8eb2f9799b97b498f2ebe (diff) | |
parent | ec391cd81dcd0509a6b0c988f9543f198da9fdc1 (diff) |
Merge "gralloc: Add error handling to grallocToStandardPlaneLayoutComponentType" into display.lnx.5.1.r2-rel
Diffstat (limited to 'gralloc/gr_buf_mgr.cpp')
-rw-r--r-- | gralloc/gr_buf_mgr.cpp | 79 |
1 files changed, 60 insertions, 19 deletions
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp index f0b46395..dd9a0297 100644 --- a/gralloc/gr_buf_mgr.cpp +++ b/gralloc/gr_buf_mgr.cpp @@ -303,7 +303,7 @@ static Error colorMetadataToDataspace(ColorMetaData color_metadata, Dataspace *d return Error::NONE; } -static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp) { +static Error getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp) { switch (format) { case static_cast<int32_t>(HAL_PIXEL_FORMAT_RGBA_8888): case static_cast<int32_t>(HAL_PIXEL_FORMAT_RGBX_8888): @@ -315,8 +315,11 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp comp.offsetInBits = 8; } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_B.value) { comp.offsetInBits = 16; - } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value) { + } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value && + format != HAL_PIXEL_FORMAT_RGB_888) { comp.offsetInBits = 24; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_RGB_565): @@ -329,6 +332,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_B.value) { comp.offsetInBits = 11; comp.sizeInBits = 5; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_BGR_565): @@ -341,6 +346,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_B.value) { comp.offsetInBits = 0; comp.sizeInBits = 5; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_BGRA_8888): @@ -353,8 +360,11 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp comp.offsetInBits = 8; } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_B.value) { comp.offsetInBits = 0; - } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value) { + } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value && + format != HAL_PIXEL_FORMAT_BGR_888) { comp.offsetInBits = 24; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_RGBA_5551): @@ -370,6 +380,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value) { comp.sizeInBits = 1; comp.offsetInBits = 15; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_RGBA_4444): @@ -385,6 +397,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value) { comp.sizeInBits = 4; comp.offsetInBits = 12; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_R_8): @@ -392,8 +406,11 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp comp.sizeInBits = 8; if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_R.value) { comp.offsetInBits = 0; - } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_G.value) { + } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_G.value && + format != HAL_PIXEL_FORMAT_R_8) { comp.offsetInBits = 8; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_RGBA_1010102): @@ -410,6 +427,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value) { comp.sizeInBits = 2; comp.offsetInBits = 30; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_ARGB_2101010): @@ -426,6 +445,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value) { comp.sizeInBits = 2; comp.offsetInBits = 0; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_BGRA_1010102): @@ -442,6 +463,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value) { comp.sizeInBits = 2; comp.offsetInBits = 30; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_ABGR_2101010): @@ -458,6 +481,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value) { comp.sizeInBits = 2; comp.offsetInBits = 0; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_RGBA_FP16): @@ -473,6 +498,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_A.value) { comp.sizeInBits = 16; comp.offsetInBits = 48; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_YCbCr_420_SP): @@ -485,6 +512,8 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp comp.offsetInBits = 0; } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_CR.value) { comp.offsetInBits = 8; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_YCrCb_420_SP): @@ -498,12 +527,16 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp comp.offsetInBits = 0; } else if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_CB.value) { comp.offsetInBits = 8; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_Y16): if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_Y.value) { comp.offsetInBits = 0; comp.sizeInBits = 16; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_YV12): @@ -512,12 +545,16 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp comp.type.value == android::gralloc4::PlaneLayoutComponentType_CR.value) { comp.offsetInBits = 0; comp.sizeInBits = 8; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_Y8): if (comp.type.value == android::gralloc4::PlaneLayoutComponentType_Y.value) { comp.offsetInBits = 0; comp.sizeInBits = 8; + } else { + return Error::BAD_VALUE; } break; case static_cast<int32_t>(HAL_PIXEL_FORMAT_YCbCr_420_P010): @@ -526,11 +563,15 @@ static void getComponentSizeAndOffset(int32_t format, PlaneLayoutComponent &comp comp.type.value == android::gralloc4::PlaneLayoutComponentType_CR.value) { comp.offsetInBits = 0; comp.sizeInBits = 10; + } else { + return Error::BAD_VALUE; } break; default: - break; + ALOGI_IF(DEBUG, "Offset and size in bits unknown for format %d", format); + return Error::UNSUPPORTED; } + return Error::NONE; } static void grallocToStandardPlaneLayoutComponentType(uint32_t in, @@ -542,44 +583,44 @@ static void grallocToStandardPlaneLayoutComponentType(uint32_t in, if (in & PLANE_COMPONENT_Y) { comp.type = android::gralloc4::PlaneLayoutComponentType_Y; - getComponentSizeAndOffset(format, comp); - components->push_back(comp); + if (getComponentSizeAndOffset(format, comp) == Error::NONE) + components->push_back(comp); } if (in & PLANE_COMPONENT_Cb) { comp.type = android::gralloc4::PlaneLayoutComponentType_CB; - getComponentSizeAndOffset(format, comp); - components->push_back(comp); + if (getComponentSizeAndOffset(format, comp) == Error::NONE) + components->push_back(comp); } if (in & PLANE_COMPONENT_Cr) { comp.type = android::gralloc4::PlaneLayoutComponentType_CR; - getComponentSizeAndOffset(format, comp); - components->push_back(comp); + if (getComponentSizeAndOffset(format, comp) == Error::NONE) + components->push_back(comp); } if (in & PLANE_COMPONENT_R) { comp.type = android::gralloc4::PlaneLayoutComponentType_R; - getComponentSizeAndOffset(format, comp); - components->push_back(comp); + if (getComponentSizeAndOffset(format, comp) == Error::NONE) + components->push_back(comp); } if (in & PLANE_COMPONENT_G) { comp.type = android::gralloc4::PlaneLayoutComponentType_G; - getComponentSizeAndOffset(format, comp); - components->push_back(comp); + if (getComponentSizeAndOffset(format, comp) == Error::NONE) + components->push_back(comp); } if (in & PLANE_COMPONENT_B) { comp.type = android::gralloc4::PlaneLayoutComponentType_B; - getComponentSizeAndOffset(format, comp); - components->push_back(comp); + if (getComponentSizeAndOffset(format, comp) == Error::NONE) + components->push_back(comp); } if (in & PLANE_COMPONENT_A) { comp.type = android::gralloc4::PlaneLayoutComponentType_A; - getComponentSizeAndOffset(format, comp); - components->push_back(comp); + if (getComponentSizeAndOffset(format, comp) == Error::NONE) + components->push_back(comp); } if (in & PLANE_COMPONENT_RAW) { |