Loading include/ui/Rect.h +9 −1 Original line number Original line Diff line number Diff line Loading @@ -140,6 +140,14 @@ public: Rect& offsetTo(int32_t x, int32_t y); Rect& offsetTo(int32_t x, int32_t y); Rect& offsetBy(int32_t x, int32_t y); Rect& offsetBy(int32_t x, int32_t y); bool intersect(const Rect& with, Rect* result) const; bool intersect(const Rect& with, Rect* result) const; // Create a new Rect by transforming this one using a graphics HAL // transform. This rectangle is defined in a coordinate space starting at // the origin and extending to (width, height). If the transform includes // a ROT90 then the output rectangle is defined in a space extending to // (height, width). Otherwise the output rectangle is in the same space as // the input. Rect transform(uint32_t xform, int32_t width, int32_t height); }; }; ANDROID_BASIC_TYPES_TRAITS(Rect) ANDROID_BASIC_TYPES_TRAITS(Rect) Loading libs/ui/Rect.cpp +21 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,7 @@ * limitations under the License. * limitations under the License. */ */ #include <system/graphics.h> #include <ui/Rect.h> #include <ui/Rect.h> namespace android { namespace android { Loading Loading @@ -92,4 +93,24 @@ bool Rect::intersect(const Rect& with, Rect* result) const return !(result->isEmpty()); return !(result->isEmpty()); } } Rect Rect::transform(uint32_t xform, int32_t width, int32_t height) { Rect result(*this); if (xform & HAL_TRANSFORM_FLIP_H) { result = Rect(width - result.right, result.top, width - result.left, result.bottom); } if (xform & HAL_TRANSFORM_FLIP_V) { result = Rect(result.left, height - result.bottom, result.right, height - result.top); } if (xform & HAL_TRANSFORM_ROT_90) { int left = height - result.bottom; int top = result.left; int right = height - result.top; int bottom = result.right; result = Rect(left, top, right, bottom); } return result; } }; // namespace android }; // namespace android Loading
include/ui/Rect.h +9 −1 Original line number Original line Diff line number Diff line Loading @@ -140,6 +140,14 @@ public: Rect& offsetTo(int32_t x, int32_t y); Rect& offsetTo(int32_t x, int32_t y); Rect& offsetBy(int32_t x, int32_t y); Rect& offsetBy(int32_t x, int32_t y); bool intersect(const Rect& with, Rect* result) const; bool intersect(const Rect& with, Rect* result) const; // Create a new Rect by transforming this one using a graphics HAL // transform. This rectangle is defined in a coordinate space starting at // the origin and extending to (width, height). If the transform includes // a ROT90 then the output rectangle is defined in a space extending to // (height, width). Otherwise the output rectangle is in the same space as // the input. Rect transform(uint32_t xform, int32_t width, int32_t height); }; }; ANDROID_BASIC_TYPES_TRAITS(Rect) ANDROID_BASIC_TYPES_TRAITS(Rect) Loading
libs/ui/Rect.cpp +21 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,7 @@ * limitations under the License. * limitations under the License. */ */ #include <system/graphics.h> #include <ui/Rect.h> #include <ui/Rect.h> namespace android { namespace android { Loading Loading @@ -92,4 +93,24 @@ bool Rect::intersect(const Rect& with, Rect* result) const return !(result->isEmpty()); return !(result->isEmpty()); } } Rect Rect::transform(uint32_t xform, int32_t width, int32_t height) { Rect result(*this); if (xform & HAL_TRANSFORM_FLIP_H) { result = Rect(width - result.right, result.top, width - result.left, result.bottom); } if (xform & HAL_TRANSFORM_FLIP_V) { result = Rect(result.left, height - result.bottom, result.right, height - result.top); } if (xform & HAL_TRANSFORM_ROT_90) { int left = height - result.bottom; int top = result.left; int right = height - result.top; int bottom = result.right; result = Rect(left, top, right, bottom); } return result; } }; // namespace android }; // namespace android