From 1e22dc10fc89092cf88488a8c3d1223f32a313a6 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Mon, 7 Dec 2020 17:28:35 +0000 Subject: libgralloctypes: remove AIDL comparison operators These are now auto-generated, and these were creating ambiguous resolution errors. Bug: 175018841 Test: GrallocTypes_test Change-Id: Iff87bf9c10f82c1f90367d640fc6367f92e285da Merged-In: Iff87bf9c10f82c1f90367d640fc6367f92e285da --- libs/gralloc/types/include/gralloctypes/Gralloc4.h | 196 --------------------- 1 file changed, 196 deletions(-) diff --git a/libs/gralloc/types/include/gralloctypes/Gralloc4.h b/libs/gralloc/types/include/gralloctypes/Gralloc4.h index 1a7c2c946a..2f418acca5 100644 --- a/libs/gralloc/types/include/gralloctypes/Gralloc4.h +++ b/libs/gralloc/types/include/gralloctypes/Gralloc4.h @@ -32,202 +32,6 @@ #include namespace android { - -/** - * Define equality operators for Stable AIDL types. - */ -inline bool operator==(const aidl::android::hardware::graphics::common::ExtendableType& lhs, - const aidl::android::hardware::graphics::common::ExtendableType& rhs) { - return !std::strcmp(lhs.name.c_str(), rhs.name.c_str()) && lhs.value == rhs.value; -} - -inline bool operator!=(const aidl::android::hardware::graphics::common::ExtendableType& lhs, - const aidl::android::hardware::graphics::common::ExtendableType& rhs) { - return !(lhs == rhs); -} - -inline bool operator==(const aidl::android::hardware::graphics::common::PlaneLayoutComponent& lhs, - const aidl::android::hardware::graphics::common::PlaneLayoutComponent& rhs) { - if (lhs.type.name != rhs.type.name) { - return false; - } - if (lhs.type.value != rhs.type.value) { - return false; - } - if (lhs.sizeInBits != rhs.sizeInBits) { - return false; - } - if (lhs.offsetInBits != rhs.offsetInBits) { - return false; - } - return true; -} - -inline bool operator!=(const aidl::android::hardware::graphics::common::PlaneLayoutComponent& lhs, - const aidl::android::hardware::graphics::common::PlaneLayoutComponent& rhs) { - return !(lhs == rhs); -} - -inline bool operator==(const aidl::android::hardware::graphics::common::Rect& lhs, - const aidl::android::hardware::graphics::common::Rect& rhs) { - if (lhs.left != rhs.left) { - return false; - } - if (lhs.top != rhs.top) { - return false; - } - if (lhs.right != rhs.right) { - return false; - } - if (lhs.bottom != rhs.bottom) { - return false; - } - return true; -} - -inline bool operator!=(const aidl::android::hardware::graphics::common::Rect& lhs, - const aidl::android::hardware::graphics::common::Rect& rhs) { - return !(lhs == rhs); -} - -inline bool operator==(const std::vector& lhs, - const std::vector& 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& lhs, - const std::vector& 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) { - return false; - } - if (lhs.sampleIncrementInBits != rhs.sampleIncrementInBits) { - return false; - } - if (lhs.strideInBytes != rhs.strideInBytes) { - return false; - } - if (lhs.widthInSamples != rhs.widthInSamples) { - return false; - } - if (lhs.heightInSamples != rhs.heightInSamples) { - return false; - } - if (lhs.totalSizeInBytes != rhs.totalSizeInBytes) { - return false; - } - if (lhs.horizontalSubsampling != rhs.horizontalSubsampling) { - return false; - } - if (lhs.verticalSubsampling != rhs.verticalSubsampling) { - return false; - } - if (lhs.components.size() != rhs.components.size()) { - return false; - } - for (size_t i = 0; i < lhs.components.size(); i++) { - if (lhs.components[i] != rhs.components[i]) { - return false; - } - } - return true; -} - -inline bool operator!=(const aidl::android::hardware::graphics::common::PlaneLayout& lhs, - const aidl::android::hardware::graphics::common::PlaneLayout& rhs) { - return !(lhs == rhs); -} - -inline bool operator==(const std::vector& lhs, - const std::vector& 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& lhs, - const std::vector& rhs) { - return !(lhs == rhs); -} - -inline bool operator==(const aidl::android::hardware::graphics::common::XyColor& lhs, - const aidl::android::hardware::graphics::common::XyColor& rhs) { - if (lhs.x != rhs.x) { - return false; - } - if (lhs.y != rhs.y) { - return false; - } - return true; -} - -inline bool operator!=(const aidl::android::hardware::graphics::common::XyColor& lhs, - const aidl::android::hardware::graphics::common::XyColor& rhs) { - return !(lhs == rhs); -} - -inline bool operator==(const aidl::android::hardware::graphics::common::Smpte2086& lhs, - const aidl::android::hardware::graphics::common::Smpte2086& rhs) { - if (lhs.primaryRed != rhs.primaryRed) { - return false; - } - if (lhs.primaryGreen != rhs.primaryGreen) { - return false; - } - if (lhs.primaryBlue != rhs.primaryBlue) { - return false; - } - if (lhs.whitePoint != rhs.whitePoint) { - return false; - } - if (lhs.maxLuminance != rhs.maxLuminance) { - return false; - } - if (lhs.minLuminance != rhs.minLuminance) { - return false; - } - return true; -} - -inline bool operator!=(const aidl::android::hardware::graphics::common::Smpte2086& lhs, - const aidl::android::hardware::graphics::common::Smpte2086& rhs) { - return !(lhs == rhs); -} - -inline bool operator==(const aidl::android::hardware::graphics::common::Cta861_3& lhs, - const aidl::android::hardware::graphics::common::Cta861_3& rhs) { - if (lhs.maxContentLightLevel != rhs.maxContentLightLevel) { - return false; - } - if (lhs.maxFrameAverageLightLevel != rhs.maxFrameAverageLightLevel) { - return false; - } - return true; -} - -inline bool operator!=(const aidl::android::hardware::graphics::common::Cta861_3& lhs, - const aidl::android::hardware::graphics::common::Cta861_3& rhs) { - return !(lhs == rhs); -} - namespace gralloc4 { #define GRALLOC4_STANDARD_METADATA_TYPE "android.hardware.graphics.common.StandardMetadataType" -- cgit v1.2.3-59-g8ed1b From 36c3736482aacb722f3cfee8a43b1bab9be296a8 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Mon, 7 Dec 2020 17:25:35 +0000 Subject: libbinder_ndk: core object type comparison Comparison operators for core types which are missing these, in order to support comparison of arbitrary NDK backend types. Bug: 175018841 Test: atest CtsNdkBinderTestCases Change-Id: I3c112d0883c4d51fd5376709f3db4d72b6883697 Merged-In: I3c112d0883c4d51fd5376709f3db4d72b6883697 --- .../ndk/include_cpp/android/binder_auto_utils.h | 21 +++++++++++++++++++++ .../include_cpp/android/binder_parcelable_utils.h | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/libs/binder/ndk/include_cpp/android/binder_auto_utils.h b/libs/binder/ndk/include_cpp/android/binder_auto_utils.h index 2d85f90968..04167f7a82 100644 --- a/libs/binder/ndk/include_cpp/android/binder_auto_utils.h +++ b/libs/binder/ndk/include_cpp/android/binder_auto_utils.h @@ -114,6 +114,13 @@ class SpAIBinder { */ AIBinder** getR() { return &mBinder; } + bool operator!=(const SpAIBinder& rhs) const { return get() != rhs.get(); } + bool operator<(const SpAIBinder& rhs) const { return get() < rhs.get(); } + bool operator<=(const SpAIBinder& rhs) const { return get() <= rhs.get(); } + bool operator==(const SpAIBinder& rhs) const { return get() == rhs.get(); } + bool operator>(const SpAIBinder& rhs) const { return get() > rhs.get(); } + bool operator>=(const SpAIBinder& rhs) const { return get() >= rhs.get(); } + private: AIBinder* mBinder = nullptr; }; @@ -200,6 +207,13 @@ class ScopedAParcel : public impl::ScopedAResource(const ScopedAParcel& rhs) const { return get() > rhs.get(); } + bool operator>=(const ScopedAParcel& rhs) const { return get() >= rhs.get(); } }; /** @@ -323,6 +337,13 @@ class ScopedFileDescriptor : public impl::ScopedAResource { ~ScopedFileDescriptor() {} ScopedFileDescriptor(ScopedFileDescriptor&&) = default; ScopedFileDescriptor& operator=(ScopedFileDescriptor&&) = default; + + bool operator!=(const ScopedFileDescriptor& rhs) const { return get() != rhs.get(); } + bool operator<(const ScopedFileDescriptor& rhs) const { return get() < rhs.get(); } + bool operator<=(const ScopedFileDescriptor& rhs) const { return get() <= rhs.get(); } + bool operator==(const ScopedFileDescriptor& rhs) const { return get() == rhs.get(); } + bool operator>(const ScopedFileDescriptor& rhs) const { return get() > rhs.get(); } + bool operator>=(const ScopedFileDescriptor& rhs) const { return get() >= rhs.get(); } }; } // namespace ndk diff --git a/libs/binder/ndk/include_cpp/android/binder_parcelable_utils.h b/libs/binder/ndk/include_cpp/android/binder_parcelable_utils.h index 4858514164..cf2b9e9745 100644 --- a/libs/binder/ndk/include_cpp/android/binder_parcelable_utils.h +++ b/libs/binder/ndk/include_cpp/android/binder_parcelable_utils.h @@ -114,6 +114,25 @@ class AParcelableHolder { void reset() { AParcel_reset(mParcel.get()); } + inline bool operator!=(const AParcelableHolder& rhs) const { + return std::tie(mParcel, mStability) != std::tie(rhs.mParcel, rhs.mStability); + } + inline bool operator<(const AParcelableHolder& rhs) const { + return std::tie(mParcel, mStability) < std::tie(rhs.mParcel, rhs.mStability); + } + inline bool operator<=(const AParcelableHolder& rhs) const { + return std::tie(mParcel, mStability) <= std::tie(rhs.mParcel, rhs.mStability); + } + inline bool operator==(const AParcelableHolder& rhs) const { + return std::tie(mParcel, mStability) == std::tie(rhs.mParcel, rhs.mStability); + } + inline bool operator>(const AParcelableHolder& rhs) const { + return std::tie(mParcel, mStability) > std::tie(rhs.mParcel, rhs.mStability); + } + inline bool operator>=(const AParcelableHolder& rhs) const { + return std::tie(mParcel, mStability) >= std::tie(rhs.mParcel, rhs.mStability); + } + private: mutable ndk::ScopedAParcel mParcel; parcelable_stability_t mStability; -- cgit v1.2.3-59-g8ed1b