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

Commit 8d1afba6 authored by Jamie Gennis's avatar Jamie Gennis Committed by Android Git Automerger
Browse files

am 59df82f3: Merge "libui: add the Rect::transform method" into jb-dev

* commit '59df82f3':
  libui: add the Rect::transform method
parents dad60f2a 59df82f3
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -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)
+21 −0
Original line number Original line Diff line number Diff line
@@ -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 {
@@ -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