Loading libs/ui/Region.cpp +14 −0 Original line number Original line Diff line number Diff line Loading @@ -280,6 +280,20 @@ bool Region::isTriviallyEqual(const Region& region) const { return begin() == region.begin(); return begin() == region.begin(); } } bool Region::hasSameRects(const Region& other) const { size_t thisRectCount = 0; android::Rect const* thisRects = getArray(&thisRectCount); size_t otherRectCount = 0; android::Rect const* otherRects = other.getArray(&otherRectCount); if (thisRectCount != otherRectCount) return false; for (size_t i = 0; i < thisRectCount; i++) { if (thisRects[i] != otherRects[i]) return false; } return true; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void Region::addRectUnchecked(int l, int t, int r, int b) void Region::addRectUnchecked(int l, int t, int r, int b) Loading libs/ui/Transform.cpp +9 −0 Original line number Original line Diff line number Diff line Loading @@ -49,6 +49,15 @@ bool Transform::absIsOne(float f) { return isZero(fabs(f) - 1.0f); return isZero(fabs(f) - 1.0f); } } bool Transform::operator==(const Transform& other) const { return mMatrix[0][0] == other.mMatrix[0][0] && mMatrix[0][1] == other.mMatrix[0][1] && mMatrix[0][2] == other.mMatrix[0][2] && mMatrix[1][0] == other.mMatrix[1][0] && mMatrix[1][1] == other.mMatrix[1][1] && mMatrix[1][2] == other.mMatrix[1][2] && mMatrix[2][0] == other.mMatrix[2][0] && mMatrix[2][1] == other.mMatrix[2][1] && mMatrix[2][2] == other.mMatrix[2][2]; ; } Transform Transform::operator * (const Transform& rhs) const Transform Transform::operator * (const Transform& rhs) const { { if (CC_LIKELY(mType == IDENTITY)) if (CC_LIKELY(mType == IDENTITY)) Loading libs/ui/include/ui/FloatRect.h +7 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ #pragma once #pragma once #include <ostream> namespace android { namespace android { class FloatRect { class FloatRect { Loading Loading @@ -52,4 +54,9 @@ inline bool operator==(const FloatRect& a, const FloatRect& b) { return a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom; return a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom; } } static inline void PrintTo(const FloatRect& rect, ::std::ostream* os) { *os << "FloatRect(" << rect.left << ", " << rect.top << ", " << rect.right << ", " << rect.bottom << ")"; } } // namespace android } // namespace android libs/ui/include/ui/Rect.h +8 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,8 @@ #ifndef ANDROID_UI_RECT #ifndef ANDROID_UI_RECT #define ANDROID_UI_RECT #define ANDROID_UI_RECT #include <ostream> #include <utils/Flattenable.h> #include <utils/Flattenable.h> #include <utils/Log.h> #include <utils/Log.h> #include <utils/TypeHelpers.h> #include <utils/TypeHelpers.h> Loading Loading @@ -214,6 +216,12 @@ public: } } }; }; // Defining PrintTo helps with Google Tests. static inline void PrintTo(const Rect& rect, ::std::ostream* os) { *os << "Rect(" << rect.left << ", " << rect.top << ", " << rect.right << ", " << rect.bottom << ")"; } ANDROID_BASIC_TYPES_TRAITS(Rect) ANDROID_BASIC_TYPES_TRAITS(Rect) }; // namespace android }; // namespace android Loading libs/ui/include/ui/Region.h +18 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <stdint.h> #include <stdint.h> #include <sys/types.h> #include <sys/types.h> #include <ostream> #include <utils/Vector.h> #include <utils/Vector.h> Loading Loading @@ -119,6 +120,8 @@ public: // returns true if the regions share the same underlying storage // returns true if the regions share the same underlying storage bool isTriviallyEqual(const Region& region) const; bool isTriviallyEqual(const Region& region) const; // returns true if the regions consist of the same rectangle sequence bool hasSameRects(const Region& region) const; /* various ways to access the rectangle list */ /* various ways to access the rectangle list */ Loading Loading @@ -213,6 +216,21 @@ Region& Region::operator -= (const Region& rhs) { Region& Region::operator += (const Point& pt) { Region& Region::operator += (const Point& pt) { return translateSelf(pt.x, pt.y); return translateSelf(pt.x, pt.y); } } // Defining PrintTo helps with Google Tests. static inline void PrintTo(const Region& region, ::std::ostream* os) { Region::const_iterator head = region.begin(); Region::const_iterator const tail = region.end(); bool first = true; while (head != tail) { *os << (first ? "Region(" : ", "); PrintTo(*head, os); head++; first = false; } *os << ")"; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- }; // namespace android }; // namespace android Loading Loading
libs/ui/Region.cpp +14 −0 Original line number Original line Diff line number Diff line Loading @@ -280,6 +280,20 @@ bool Region::isTriviallyEqual(const Region& region) const { return begin() == region.begin(); return begin() == region.begin(); } } bool Region::hasSameRects(const Region& other) const { size_t thisRectCount = 0; android::Rect const* thisRects = getArray(&thisRectCount); size_t otherRectCount = 0; android::Rect const* otherRects = other.getArray(&otherRectCount); if (thisRectCount != otherRectCount) return false; for (size_t i = 0; i < thisRectCount; i++) { if (thisRects[i] != otherRects[i]) return false; } return true; } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- void Region::addRectUnchecked(int l, int t, int r, int b) void Region::addRectUnchecked(int l, int t, int r, int b) Loading
libs/ui/Transform.cpp +9 −0 Original line number Original line Diff line number Diff line Loading @@ -49,6 +49,15 @@ bool Transform::absIsOne(float f) { return isZero(fabs(f) - 1.0f); return isZero(fabs(f) - 1.0f); } } bool Transform::operator==(const Transform& other) const { return mMatrix[0][0] == other.mMatrix[0][0] && mMatrix[0][1] == other.mMatrix[0][1] && mMatrix[0][2] == other.mMatrix[0][2] && mMatrix[1][0] == other.mMatrix[1][0] && mMatrix[1][1] == other.mMatrix[1][1] && mMatrix[1][2] == other.mMatrix[1][2] && mMatrix[2][0] == other.mMatrix[2][0] && mMatrix[2][1] == other.mMatrix[2][1] && mMatrix[2][2] == other.mMatrix[2][2]; ; } Transform Transform::operator * (const Transform& rhs) const Transform Transform::operator * (const Transform& rhs) const { { if (CC_LIKELY(mType == IDENTITY)) if (CC_LIKELY(mType == IDENTITY)) Loading
libs/ui/include/ui/FloatRect.h +7 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ #pragma once #pragma once #include <ostream> namespace android { namespace android { class FloatRect { class FloatRect { Loading Loading @@ -52,4 +54,9 @@ inline bool operator==(const FloatRect& a, const FloatRect& b) { return a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom; return a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom; } } static inline void PrintTo(const FloatRect& rect, ::std::ostream* os) { *os << "FloatRect(" << rect.left << ", " << rect.top << ", " << rect.right << ", " << rect.bottom << ")"; } } // namespace android } // namespace android
libs/ui/include/ui/Rect.h +8 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,8 @@ #ifndef ANDROID_UI_RECT #ifndef ANDROID_UI_RECT #define ANDROID_UI_RECT #define ANDROID_UI_RECT #include <ostream> #include <utils/Flattenable.h> #include <utils/Flattenable.h> #include <utils/Log.h> #include <utils/Log.h> #include <utils/TypeHelpers.h> #include <utils/TypeHelpers.h> Loading Loading @@ -214,6 +216,12 @@ public: } } }; }; // Defining PrintTo helps with Google Tests. static inline void PrintTo(const Rect& rect, ::std::ostream* os) { *os << "Rect(" << rect.left << ", " << rect.top << ", " << rect.right << ", " << rect.bottom << ")"; } ANDROID_BASIC_TYPES_TRAITS(Rect) ANDROID_BASIC_TYPES_TRAITS(Rect) }; // namespace android }; // namespace android Loading
libs/ui/include/ui/Region.h +18 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <stdint.h> #include <stdint.h> #include <sys/types.h> #include <sys/types.h> #include <ostream> #include <utils/Vector.h> #include <utils/Vector.h> Loading Loading @@ -119,6 +120,8 @@ public: // returns true if the regions share the same underlying storage // returns true if the regions share the same underlying storage bool isTriviallyEqual(const Region& region) const; bool isTriviallyEqual(const Region& region) const; // returns true if the regions consist of the same rectangle sequence bool hasSameRects(const Region& region) const; /* various ways to access the rectangle list */ /* various ways to access the rectangle list */ Loading Loading @@ -213,6 +216,21 @@ Region& Region::operator -= (const Region& rhs) { Region& Region::operator += (const Point& pt) { Region& Region::operator += (const Point& pt) { return translateSelf(pt.x, pt.y); return translateSelf(pt.x, pt.y); } } // Defining PrintTo helps with Google Tests. static inline void PrintTo(const Region& region, ::std::ostream* os) { Region::const_iterator head = region.begin(); Region::const_iterator const tail = region.end(); bool first = true; while (head != tail) { *os << (first ? "Region(" : ", "); PrintTo(*head, os); head++; first = false; } *os << ")"; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- }; // namespace android }; // namespace android Loading