Create libgfx, starting with FloatRect
Creates libgfx, the future home of everything currently in libui and
libgui, which will be rigorously checked with -Weverything (with a few
common-sense exceptions) and clang-tidy and formatted using the included
.clang-format file.
Starts by moving FloatRect out of services/surfaceflinger since it will
be used by other libgfx primitives later.
Test: m
Change-Id: I5045ac089020e6ee380e81e8735117c500264b37
diff --git a/include/ui/Rect.h b/include/ui/Rect.h
index a8513a9..d4eea02 100644
--- a/include/ui/Rect.h
+++ b/include/ui/Rect.h
@@ -17,6 +17,7 @@
#ifndef ANDROID_UI_RECT
#define ANDROID_UI_RECT
+#include <gfx/FloatRect.h>
#include <utils/Flattenable.h>
#include <utils/Log.h>
#include <utils/TypeHelpers.h>
@@ -177,11 +178,15 @@
// this calculates (Region(*this) - exclude).bounds() efficiently
Rect reduce(const Rect& exclude) const;
-
// for backward compatibility
inline int32_t width() const { return getWidth(); }
inline int32_t height() const { return getHeight(); }
inline void set(const Rect& rhs) { operator = (rhs); }
+
+ gfx::FloatRect toFloatRect() const {
+ return {static_cast<float>(left), static_cast<float>(top),
+ static_cast<float>(right), static_cast<float>(bottom)};
+ }
};
ANDROID_BASIC_TYPES_TRAITS(Rect)