Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 672222b3 authored by Steven Moreland's avatar Steven Moreland Committed by Android Build Cherrypicker Worker
Browse files

GraphicsBuffer: comparison operators

All AIDL structures are comparable. It makes it possible to use them as keys in a map. We can define an order for any type on the computer, since we can always take the address. Though - this may not always be the most useful meaning.

We didn't discover this earlier, because this was only ever used in an argument. Regardless, it seems like a useful thing to have.

Also - we shouldn't add complexity to AIDL to make this optional. It has deep consequences, since any element, even 4-5 structures deep could cause a struct to not be comparable. If someone adds a non-comparable type to a structure in a later version, AIDL packages depending on it might find it impossible to upgrade without making their structures non-comparable, which could break client code.

Bug: N/A
Test: N/A
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2d4660083c7eb0ea56040745830abcb148d8de54)
Merged-In: I627adbd110d037246ce307f4984739008fe91c33
Change-Id: I627adbd110d037246ce307f4984739008fe91c33
parent 97d06963
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -123,6 +123,13 @@ public:
    inline AHardwareBuffer* _Nullable get() const { return mBuffer; }
    inline AHardwareBuffer* _Nullable get() const { return mBuffer; }
    inline explicit operator bool () const { return mBuffer != nullptr; }
    inline explicit operator bool () const { return mBuffer != nullptr; }


    inline bool operator!=(const HardwareBuffer& rhs) const { return get() != rhs.get(); }
    inline bool operator<(const HardwareBuffer& rhs) const { return get() < rhs.get(); }
    inline bool operator<=(const HardwareBuffer& rhs) const { return get() <= rhs.get(); }
    inline bool operator==(const HardwareBuffer& rhs) const { return get() == rhs.get(); }
    inline bool operator>(const HardwareBuffer& rhs) const { return get() > rhs.get(); }
    inline bool operator>=(const HardwareBuffer& rhs) const { return get() >= rhs.get(); }

    HardwareBuffer& operator=(HardwareBuffer&& other) noexcept {
    HardwareBuffer& operator=(HardwareBuffer&& other) noexcept {
        reset(other.release());
        reset(other.release());
        return *this;
        return *this;