Move FloatRect from libgfx to libui
Moves FloatRect from libgfx (which is being disintegrated) to libui
Test: Builds and sailfish boots
Change-Id: I68c1b7d86a363066fe4d6f0c038ca9d92d7ab9c7
diff --git a/include/ui/FloatRect.h b/include/ui/FloatRect.h
new file mode 100644
index 0000000..270675c
--- /dev/null
+++ b/include/ui/FloatRect.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+namespace android {
+
+class FloatRect {
+public:
+ FloatRect() = default;
+ constexpr FloatRect(float _left, float _top, float _right, float _bottom)
+ : left(_left), top(_top), right(_right), bottom(_bottom) {}
+
+ float getWidth() const { return right - left; }
+ float getHeight() const { return bottom - top; }
+
+ float left = 0.0f;
+ float top = 0.0f;
+ float right = 0.0f;
+ float bottom = 0.0f;
+};
+
+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;
+}
+
+} // namespace android
diff --git a/include/ui/Rect.h b/include/ui/Rect.h
index ce33d4e..3d600be 100644
--- a/include/ui/Rect.h
+++ b/include/ui/Rect.h
@@ -17,12 +17,12 @@
#ifndef ANDROID_UI_RECT
#define ANDROID_UI_RECT
-#include <gfx/FloatRect.h>
#include <utils/Flattenable.h>
#include <utils/Log.h>
#include <utils/TypeHelpers.h>
#include <log/log.h>
+#include <ui/FloatRect.h>
#include <ui/Point.h>
#include <android/rect.h>
@@ -185,7 +185,7 @@
inline int32_t height() const { return getHeight(); }
inline void set(const Rect& rhs) { operator = (rhs); }
- gfx::FloatRect toFloatRect() const {
+ FloatRect toFloatRect() const {
return {static_cast<float>(left), static_cast<float>(top),
static_cast<float>(right), static_cast<float>(bottom)};
}