From c6a3d6060ed7858fb435a0f0f02eaacd5b5c2e42 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Fri, 2 Jul 2021 13:06:09 -0700 Subject: Add an utility function to convert RotationFlags to Rotation Test: presubmit Bug: 191841127 Change-Id: I9193f24eb91fc2f9f8e13abb7b21101575ee0663 --- libs/ui/include/ui/Transform.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libs/ui/include/ui/Transform.h b/libs/ui/include/ui/Transform.h index a197b3b20e..33fbe05035 100644 --- a/libs/ui/include/ui/Transform.h +++ b/libs/ui/include/ui/Transform.h @@ -112,6 +112,7 @@ public: void dump(const char* name, const char* prefix = "") const; static constexpr RotationFlags toRotationFlags(Rotation); + static constexpr Rotation toRotation(RotationFlags); private: struct mat33 { @@ -151,5 +152,20 @@ inline constexpr Transform::RotationFlags Transform::toRotationFlags(Rotation ro } } +inline constexpr Rotation Transform::toRotation(Transform::RotationFlags rotationFlags) { + switch (rotationFlags) { + case ROT_0: + return ROTATION_0; + case ROT_90: + return ROTATION_90; + case ROT_180: + return ROTATION_180; + case ROT_270: + return ROTATION_270; + default: + return ROTATION_0; + } +} + } // namespace ui } // namespace android -- cgit v1.2.3-59-g8ed1b