Loading libs/gralloc/types/Gralloc4.cpp +53 −12 Original line number Diff line number Diff line Loading @@ -734,12 +734,7 @@ status_t encodePlaneLayout(const PlaneLayout& input, OutputHidlVec* output) { if (err) { return err; } err = encodeInteger<int64_t>(static_cast<int32_t>(input.verticalSubsampling), output); if (err) { return err; } return encodeRect(input.crop, output); return encodeInteger<int64_t>(static_cast<int32_t>(input.verticalSubsampling), output); } status_t decodePlaneLayout(InputHidlVec* input, PlaneLayout* output) { Loading Loading @@ -780,12 +775,7 @@ status_t decodePlaneLayout(InputHidlVec* input, PlaneLayout* output) { if (err) { return err; } err = decodeInteger<int64_t>(input, &output->verticalSubsampling); if (err) { return err; } return decodeRect(input, &output->crop); return decodeInteger<int64_t>(input, &output->verticalSubsampling); } status_t encodePlaneLayoutsHelper(const std::vector<PlaneLayout>& planeLayouts, OutputHidlVec* outOutputHidlVec) { Loading Loading @@ -831,6 +821,49 @@ void clearPlaneLayouts(std::vector<PlaneLayout>* output) { output->clear(); } status_t encodeCropHelper(const std::vector<Rect>& crops, OutputHidlVec* outOutputHidlVec) { status_t err = encodeInteger<int64_t>(static_cast<int64_t>(crops.size()), outOutputHidlVec); if (err) { return err; } for (const auto& crop : crops) { err = encodeRect(crop, outOutputHidlVec); if (err) { return err; } } return NO_ERROR; } status_t decodeCropHelper(InputHidlVec* inputHidlVec, std::vector<Rect>* outCrops) { int64_t size = 0; status_t err = decodeInteger<int64_t>(inputHidlVec, &size); if (err) { return err; } if (size < 0) { return BAD_VALUE; } for (size_t i = 0; i < size; i++) { outCrops->emplace_back(); err = decodeRect(inputHidlVec, &outCrops->back()); if (err) { return err; } } return NO_ERROR; } void clearCrop(std::vector<Rect>* output) { if (!output) { return; } output->clear(); } status_t encodeSmpte2086Helper(const Smpte2086& smpte2086, OutputHidlVec* outOutputHidlVec) { status_t err = encodeXyColor(smpte2086.primaryRed, outOutputHidlVec); if (err) { Loading Loading @@ -1043,6 +1076,14 @@ status_t decodePlaneLayouts(const hidl_vec<uint8_t>& planeLayouts, std::vector<P decodePlaneLayoutsHelper, clearPlaneLayouts); } status_t encodeCrop(const std::vector<Rect>& crop, hidl_vec<uint8_t>* outCrop) { return encodeMetadata(MetadataType_Crop, crop, outCrop, encodeCropHelper); } status_t decodeCrop(const hidl_vec<uint8_t>& crop, std::vector<Rect>* outCrop) { return decodeMetadata(MetadataType_Crop, crop, outCrop, decodeCropHelper, clearCrop); } status_t encodeDataspace(const Dataspace& dataspace, hidl_vec<uint8_t>* outDataspace) { return encodeMetadata(MetadataType_Dataspace, static_cast<int32_t>(dataspace), outDataspace, encodeInteger); Loading libs/gralloc/types/fuzzer/gralloctypes.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ std::vector<GrallocTypesDecode> GRALLOCTYPES_DECODE_FUNCTIONS { GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::ExtendableType, ::android::gralloc4::decodeInterlaced), GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::ExtendableType, ::android::gralloc4::decodeChromaSiting), GRALLOCTYPES_DECODE(std::vector<aidl::android::hardware::graphics::common::PlaneLayout>, ::android::gralloc4::decodePlaneLayouts), GRALLOCTYPES_DECODE(std::vector<aidl::android::hardware::graphics::common::Rect>, ::android::gralloc4::decodeCrop), GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::Dataspace, ::android::gralloc4::decodeDataspace), GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::BlendMode, ::android::gralloc4::decodeBlendMode), GRALLOCTYPES_DECODE(std::optional<aidl::android::hardware::graphics::common::Smpte2086>, ::android::gralloc4::decodeSmpte2086), Loading libs/gralloc/types/include/gralloctypes/Gralloc4.h +25 −3 Original line number Diff line number Diff line Loading @@ -89,6 +89,24 @@ inline bool operator!=(const aidl::android::hardware::graphics::common::Rect& lh return !(lhs == rhs); } inline bool operator==(const std::vector<aidl::android::hardware::graphics::common::Rect>& lhs, const std::vector<aidl::android::hardware::graphics::common::Rect>& rhs) { if (lhs.size() != rhs.size()) { return false; } for (size_t i = 0; i < lhs.size(); i++) { if (lhs[i] != rhs[i]) { return false; } } return true; } inline bool operator!=(const std::vector<aidl::android::hardware::graphics::common::Rect>& lhs, const std::vector<aidl::android::hardware::graphics::common::Rect>& rhs) { return !(lhs == rhs); } inline bool operator==(const aidl::android::hardware::graphics::common::PlaneLayout& lhs, const aidl::android::hardware::graphics::common::PlaneLayout& rhs) { if (lhs.offsetInBytes != rhs.offsetInBytes) { Loading @@ -115,9 +133,6 @@ inline bool operator==(const aidl::android::hardware::graphics::common::PlaneLay if (lhs.verticalSubsampling != rhs.verticalSubsampling) { return false; } if (lhs.crop != rhs.crop) { return false; } if (lhs.components.size() != rhs.components.size()) { return false; } Loading Loading @@ -286,6 +301,10 @@ static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType Me GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::PLANE_LAYOUTS) }; static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Crop = { GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::CROP) }; static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Dataspace = { GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::DATASPACE) }; Loading Loading @@ -469,6 +488,9 @@ status_t decodeChromaSiting(const android::hardware::hidl_vec<uint8_t>& chromaSi status_t encodePlaneLayouts(const std::vector<aidl::android::hardware::graphics::common::PlaneLayout>& planeLayouts, android::hardware::hidl_vec<uint8_t>* outPlaneLayouts); status_t decodePlaneLayouts(const android::hardware::hidl_vec<uint8_t>& planeLayouts, std::vector<aidl::android::hardware::graphics::common::PlaneLayout>* outPlaneLayouts); status_t encodeCrop(const std::vector<aidl::android::hardware::graphics::common::Rect>& crop, android::hardware::hidl_vec<uint8_t>* outCrop); status_t decodeCrop(const android::hardware::hidl_vec<uint8_t>& crop, std::vector<aidl::android::hardware::graphics::common::Rect>* outCrop); status_t encodeDataspace(const aidl::android::hardware::graphics::common::Dataspace& dataspace, android::hardware::hidl_vec<uint8_t>* outDataspace); status_t decodeDataspace(const android::hardware::hidl_vec<uint8_t>& dataspace, aidl::android::hardware::graphics::common::Dataspace* outDataspace); Loading libs/gralloc/types/tests/Gralloc4_test.cpp +27 −9 Original line number Diff line number Diff line Loading @@ -321,10 +321,6 @@ TEST_F(Gralloc4TestPlaneLayouts, PlaneLayouts) { planeLayoutA.totalSizeInBytes = planeLayoutA.strideInBytes * height; planeLayoutA.horizontalSubsampling = 1; planeLayoutA.verticalSubsampling = 1; planeLayoutA.crop.left = 0; planeLayoutA.crop.top = 0; planeLayoutA.crop.right = width; planeLayoutA.crop.bottom = height; component.type = gralloc4::PlaneLayoutComponentType_A; component.offsetInBits = 0; Loading @@ -341,11 +337,6 @@ TEST_F(Gralloc4TestPlaneLayouts, PlaneLayouts) { planeLayoutRGB.totalSizeInBytes = planeLayoutRGB.strideInBytes * height; planeLayoutRGB.horizontalSubsampling = 1; planeLayoutRGB.verticalSubsampling = 1; planeLayoutRGB.crop.left = 0; planeLayoutRGB.crop.top = 0; planeLayoutRGB.crop.right = width; planeLayoutRGB.crop.bottom = height; component.type = gralloc4::PlaneLayoutComponentType_R; planeLayoutRGB.components.push_back(component); component.type = gralloc4::PlaneLayoutComponentType_G; Loading @@ -358,6 +349,33 @@ TEST_F(Gralloc4TestPlaneLayouts, PlaneLayouts) { ASSERT_NO_FATAL_FAILURE(testHelperStableAidlType(planeLayouts, gralloc4::encodePlaneLayouts, gralloc4::decodePlaneLayouts)); } class Gralloc4TestCrop : public testing::Test { }; TEST_F(Gralloc4TestCrop, Crop) { std::vector<Rect> crops; Rect crop1, crop2, crop3; crop1.left = 0; crop1.top = 0; crop1.right = 64; crop1.bottom = 64; crops.push_back(crop1); crop2.left = std::numeric_limits<int32_t>::min(); crop2.top = 0xFF; crop2.right = std::numeric_limits<int32_t>::max(); crop2.bottom = 0xFFFF; crops.push_back(crop2); crop3.left = 0; crop3.top = 0; crop3.right = -1; crop3.bottom = -1; crops.push_back(crop3); ASSERT_NO_FATAL_FAILURE(testHelperStableAidlType(crops, gralloc4::encodeCrop, gralloc4::decodeCrop)); } class Gralloc4TestDataspace : public testing::TestWithParam<Dataspace> { }; INSTANTIATE_TEST_CASE_P( Loading Loading
libs/gralloc/types/Gralloc4.cpp +53 −12 Original line number Diff line number Diff line Loading @@ -734,12 +734,7 @@ status_t encodePlaneLayout(const PlaneLayout& input, OutputHidlVec* output) { if (err) { return err; } err = encodeInteger<int64_t>(static_cast<int32_t>(input.verticalSubsampling), output); if (err) { return err; } return encodeRect(input.crop, output); return encodeInteger<int64_t>(static_cast<int32_t>(input.verticalSubsampling), output); } status_t decodePlaneLayout(InputHidlVec* input, PlaneLayout* output) { Loading Loading @@ -780,12 +775,7 @@ status_t decodePlaneLayout(InputHidlVec* input, PlaneLayout* output) { if (err) { return err; } err = decodeInteger<int64_t>(input, &output->verticalSubsampling); if (err) { return err; } return decodeRect(input, &output->crop); return decodeInteger<int64_t>(input, &output->verticalSubsampling); } status_t encodePlaneLayoutsHelper(const std::vector<PlaneLayout>& planeLayouts, OutputHidlVec* outOutputHidlVec) { Loading Loading @@ -831,6 +821,49 @@ void clearPlaneLayouts(std::vector<PlaneLayout>* output) { output->clear(); } status_t encodeCropHelper(const std::vector<Rect>& crops, OutputHidlVec* outOutputHidlVec) { status_t err = encodeInteger<int64_t>(static_cast<int64_t>(crops.size()), outOutputHidlVec); if (err) { return err; } for (const auto& crop : crops) { err = encodeRect(crop, outOutputHidlVec); if (err) { return err; } } return NO_ERROR; } status_t decodeCropHelper(InputHidlVec* inputHidlVec, std::vector<Rect>* outCrops) { int64_t size = 0; status_t err = decodeInteger<int64_t>(inputHidlVec, &size); if (err) { return err; } if (size < 0) { return BAD_VALUE; } for (size_t i = 0; i < size; i++) { outCrops->emplace_back(); err = decodeRect(inputHidlVec, &outCrops->back()); if (err) { return err; } } return NO_ERROR; } void clearCrop(std::vector<Rect>* output) { if (!output) { return; } output->clear(); } status_t encodeSmpte2086Helper(const Smpte2086& smpte2086, OutputHidlVec* outOutputHidlVec) { status_t err = encodeXyColor(smpte2086.primaryRed, outOutputHidlVec); if (err) { Loading Loading @@ -1043,6 +1076,14 @@ status_t decodePlaneLayouts(const hidl_vec<uint8_t>& planeLayouts, std::vector<P decodePlaneLayoutsHelper, clearPlaneLayouts); } status_t encodeCrop(const std::vector<Rect>& crop, hidl_vec<uint8_t>* outCrop) { return encodeMetadata(MetadataType_Crop, crop, outCrop, encodeCropHelper); } status_t decodeCrop(const hidl_vec<uint8_t>& crop, std::vector<Rect>* outCrop) { return decodeMetadata(MetadataType_Crop, crop, outCrop, decodeCropHelper, clearCrop); } status_t encodeDataspace(const Dataspace& dataspace, hidl_vec<uint8_t>* outDataspace) { return encodeMetadata(MetadataType_Dataspace, static_cast<int32_t>(dataspace), outDataspace, encodeInteger); Loading
libs/gralloc/types/fuzzer/gralloctypes.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ std::vector<GrallocTypesDecode> GRALLOCTYPES_DECODE_FUNCTIONS { GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::ExtendableType, ::android::gralloc4::decodeInterlaced), GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::ExtendableType, ::android::gralloc4::decodeChromaSiting), GRALLOCTYPES_DECODE(std::vector<aidl::android::hardware::graphics::common::PlaneLayout>, ::android::gralloc4::decodePlaneLayouts), GRALLOCTYPES_DECODE(std::vector<aidl::android::hardware::graphics::common::Rect>, ::android::gralloc4::decodeCrop), GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::Dataspace, ::android::gralloc4::decodeDataspace), GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::BlendMode, ::android::gralloc4::decodeBlendMode), GRALLOCTYPES_DECODE(std::optional<aidl::android::hardware::graphics::common::Smpte2086>, ::android::gralloc4::decodeSmpte2086), Loading
libs/gralloc/types/include/gralloctypes/Gralloc4.h +25 −3 Original line number Diff line number Diff line Loading @@ -89,6 +89,24 @@ inline bool operator!=(const aidl::android::hardware::graphics::common::Rect& lh return !(lhs == rhs); } inline bool operator==(const std::vector<aidl::android::hardware::graphics::common::Rect>& lhs, const std::vector<aidl::android::hardware::graphics::common::Rect>& rhs) { if (lhs.size() != rhs.size()) { return false; } for (size_t i = 0; i < lhs.size(); i++) { if (lhs[i] != rhs[i]) { return false; } } return true; } inline bool operator!=(const std::vector<aidl::android::hardware::graphics::common::Rect>& lhs, const std::vector<aidl::android::hardware::graphics::common::Rect>& rhs) { return !(lhs == rhs); } inline bool operator==(const aidl::android::hardware::graphics::common::PlaneLayout& lhs, const aidl::android::hardware::graphics::common::PlaneLayout& rhs) { if (lhs.offsetInBytes != rhs.offsetInBytes) { Loading @@ -115,9 +133,6 @@ inline bool operator==(const aidl::android::hardware::graphics::common::PlaneLay if (lhs.verticalSubsampling != rhs.verticalSubsampling) { return false; } if (lhs.crop != rhs.crop) { return false; } if (lhs.components.size() != rhs.components.size()) { return false; } Loading Loading @@ -286,6 +301,10 @@ static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType Me GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::PLANE_LAYOUTS) }; static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Crop = { GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::CROP) }; static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Dataspace = { GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::DATASPACE) }; Loading Loading @@ -469,6 +488,9 @@ status_t decodeChromaSiting(const android::hardware::hidl_vec<uint8_t>& chromaSi status_t encodePlaneLayouts(const std::vector<aidl::android::hardware::graphics::common::PlaneLayout>& planeLayouts, android::hardware::hidl_vec<uint8_t>* outPlaneLayouts); status_t decodePlaneLayouts(const android::hardware::hidl_vec<uint8_t>& planeLayouts, std::vector<aidl::android::hardware::graphics::common::PlaneLayout>* outPlaneLayouts); status_t encodeCrop(const std::vector<aidl::android::hardware::graphics::common::Rect>& crop, android::hardware::hidl_vec<uint8_t>* outCrop); status_t decodeCrop(const android::hardware::hidl_vec<uint8_t>& crop, std::vector<aidl::android::hardware::graphics::common::Rect>* outCrop); status_t encodeDataspace(const aidl::android::hardware::graphics::common::Dataspace& dataspace, android::hardware::hidl_vec<uint8_t>* outDataspace); status_t decodeDataspace(const android::hardware::hidl_vec<uint8_t>& dataspace, aidl::android::hardware::graphics::common::Dataspace* outDataspace); Loading
libs/gralloc/types/tests/Gralloc4_test.cpp +27 −9 Original line number Diff line number Diff line Loading @@ -321,10 +321,6 @@ TEST_F(Gralloc4TestPlaneLayouts, PlaneLayouts) { planeLayoutA.totalSizeInBytes = planeLayoutA.strideInBytes * height; planeLayoutA.horizontalSubsampling = 1; planeLayoutA.verticalSubsampling = 1; planeLayoutA.crop.left = 0; planeLayoutA.crop.top = 0; planeLayoutA.crop.right = width; planeLayoutA.crop.bottom = height; component.type = gralloc4::PlaneLayoutComponentType_A; component.offsetInBits = 0; Loading @@ -341,11 +337,6 @@ TEST_F(Gralloc4TestPlaneLayouts, PlaneLayouts) { planeLayoutRGB.totalSizeInBytes = planeLayoutRGB.strideInBytes * height; planeLayoutRGB.horizontalSubsampling = 1; planeLayoutRGB.verticalSubsampling = 1; planeLayoutRGB.crop.left = 0; planeLayoutRGB.crop.top = 0; planeLayoutRGB.crop.right = width; planeLayoutRGB.crop.bottom = height; component.type = gralloc4::PlaneLayoutComponentType_R; planeLayoutRGB.components.push_back(component); component.type = gralloc4::PlaneLayoutComponentType_G; Loading @@ -358,6 +349,33 @@ TEST_F(Gralloc4TestPlaneLayouts, PlaneLayouts) { ASSERT_NO_FATAL_FAILURE(testHelperStableAidlType(planeLayouts, gralloc4::encodePlaneLayouts, gralloc4::decodePlaneLayouts)); } class Gralloc4TestCrop : public testing::Test { }; TEST_F(Gralloc4TestCrop, Crop) { std::vector<Rect> crops; Rect crop1, crop2, crop3; crop1.left = 0; crop1.top = 0; crop1.right = 64; crop1.bottom = 64; crops.push_back(crop1); crop2.left = std::numeric_limits<int32_t>::min(); crop2.top = 0xFF; crop2.right = std::numeric_limits<int32_t>::max(); crop2.bottom = 0xFFFF; crops.push_back(crop2); crop3.left = 0; crop3.top = 0; crop3.right = -1; crop3.bottom = -1; crops.push_back(crop3); ASSERT_NO_FATAL_FAILURE(testHelperStableAidlType(crops, gralloc4::encodeCrop, gralloc4::decodeCrop)); } class Gralloc4TestDataspace : public testing::TestWithParam<Dataspace> { }; INSTANTIATE_TEST_CASE_P( Loading