summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-05-26 18:15:53 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-05-26 18:15:53 -0700
commit09d00f705be5dbc1766e12e47c0a743abbad360e (patch)
tree73355a7084fea382f8fd4f423d339cde5f26b191
parent602aa9748284c05ea8c7ae2679e210c23d18dcee (diff)
parent0c0ad39cd8eaa6de6b7f99cec3971bcc953461e0 (diff)
downloadframeworks_base-09d00f705be5dbc1766e12e47c0a743abbad360e.zip
frameworks_base-09d00f705be5dbc1766e12e47c0a743abbad360e.tar.gz
frameworks_base-09d00f705be5dbc1766e12e47c0a743abbad360e.tar.bz2
am 0c0ad39c: Merge change 2502 into donut
Merge commit '0c0ad39cd8eaa6de6b7f99cec3971bcc953461e0' * commit '0c0ad39cd8eaa6de6b7f99cec3971bcc953461e0': minor clean-up to Rect and Point.
-rw-r--r--include/ui/Point.h21
-rw-r--r--include/ui/Rect.h40
-rw-r--r--libs/ui/Android.mk1
-rw-r--r--libs/ui/Point.cpp11
-rw-r--r--libs/ui/Rect.cpp29
5 files changed, 46 insertions, 56 deletions
diff --git a/include/ui/Point.h b/include/ui/Point.h
index dbbad1e..1653120 100644
--- a/include/ui/Point.h
+++ b/include/ui/Point.h
@@ -31,12 +31,9 @@ public:
// because we want the compiler generated versions
// Default constructor doesn't initialize the Point
- inline Point()
- {
+ inline Point() {
}
-
- inline Point(int _x, int _y) : x(_x), y(_y)
- {
+ inline Point(int x, int y) : x(x), y(y) {
}
inline bool operator == (const Point& rhs) const {
@@ -57,8 +54,8 @@ public:
}
inline Point& operator - () {
- x=-x;
- y=-y;
+ x = -x;
+ y = -y;
return *this;
}
@@ -73,11 +70,13 @@ public:
return *this;
}
- Point operator + (const Point& rhs) const {
- return Point(x+rhs.x, y+rhs.y);
+ const Point operator + (const Point& rhs) const {
+ const Point result(x+rhs.x, y+rhs.y);
+ return result;
}
- Point operator - (const Point& rhs) const {
- return Point(x-rhs.x, y-rhs.y);
+ const Point operator - (const Point& rhs) const {
+ const Point result(x-rhs.x, y-rhs.y);
+ return result;
}
};
diff --git a/include/ui/Rect.h b/include/ui/Rect.h
index d232847..da72944 100644
--- a/include/ui/Rect.h
+++ b/include/ui/Rect.h
@@ -33,23 +33,16 @@ public:
// we don't provide copy-ctor and operator= on purpose
// because we want the compiler generated versions
- inline Rect()
- {
+ inline Rect() {
}
-
inline Rect(int w, int h)
- : left(0), top(0), right(w), bottom(h)
- {
+ : left(0), top(0), right(w), bottom(h) {
}
-
inline Rect(int l, int t, int r, int b)
- : left(l), top(t), right(r), bottom(b)
- {
+ : left(l), top(t), right(r), bottom(b) {
}
-
inline Rect(const Point& lt, const Point& rb)
- : left(lt.x), top(lt.y), right(rb.x), bottom(rb.y)
- {
+ : left(lt.x), top(lt.y), right(rb.x), bottom(rb.y) {
}
void makeInvalid();
@@ -78,21 +71,22 @@ public:
return bottom-top;
}
- // returns left-top Point non-const reference, can be assigned
- inline Point& leftTop() {
- return reinterpret_cast<Point&>(left);
+ void setLeftTop(const Point& lt) {
+ left = lt.x;
+ top = lt.y;
}
- // returns right bottom non-const reference, can be assigned
- inline Point& rightBottom() {
- return reinterpret_cast<Point&>(right);
+
+ void setRightBottom(const Point& rb) {
+ right = rb.x;
+ bottom = rb.y;
}
// the following 4 functions return the 4 corners of the rect as Point
- inline const Point& leftTop() const {
- return reinterpret_cast<const Point&>(left);
+ Point leftTop() const {
+ return Point(left, top);
}
- inline const Point& rightBottom() const {
- return reinterpret_cast<const Point&>(right);
+ Point rightBottom() const {
+ return Point(right, bottom);
}
Point rightTop() const {
return Point(right, top);
@@ -133,8 +127,8 @@ public:
Rect& operator -= (const Point& rhs) {
return offsetBy(-rhs.x, -rhs.y);
}
- Rect operator + (const Point& rhs) const;
- Rect operator - (const Point& rhs) const;
+ const Rect operator + (const Point& rhs) const;
+ const Rect operator - (const Point& rhs) const;
void translate(int dx, int dy) { // legacy, don't use.
offsetBy(dx, dy);
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
index 1ebcb54..c6fd070 100644
--- a/libs/ui/Android.mk
+++ b/libs/ui/Android.mk
@@ -20,7 +20,6 @@ LOCAL_SRC_FILES:= \
LayerState.cpp \
Overlay.cpp \
PixelFormat.cpp \
- Point.cpp \
Rect.cpp \
Region.cpp \
Surface.cpp \
diff --git a/libs/ui/Point.cpp b/libs/ui/Point.cpp
deleted file mode 100644
index 438d49f..0000000
--- a/libs/ui/Point.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Point.cpp
- * Android
- *
- * Created on 11/16/2006.
- * Copyright 2005 The Android Open Source Project
- *
- */
-
-#include <ui/Point.h>
-
diff --git a/libs/ui/Rect.cpp b/libs/ui/Rect.cpp
index 99e68bb..66b9576 100644
--- a/libs/ui/Rect.cpp
+++ b/libs/ui/Rect.cpp
@@ -1,21 +1,28 @@
/*
- * Rect.cpp
- * Android
+ * Copyright (C) 2009 The Android Open Source Project
*
- * Created on 10/14/05.
- * Copyright 2005 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.
*/
#include <ui/Rect.h>
namespace android {
-inline int min(int a, int b) {
+static inline int min(int a, int b) {
return (a<b) ? a : b;
}
-inline int max(int a, int b) {
+static inline int max(int a, int b) {
return (a>b) ? a : b;
}
@@ -64,14 +71,16 @@ Rect& Rect::offsetBy(int x, int y)
return *this;
}
-Rect Rect::operator + (const Point& rhs) const
+const Rect Rect::operator + (const Point& rhs) const
{
- return Rect(left+rhs.x, top+rhs.y, right+rhs.x, bottom+rhs.y);
+ const Rect result(left+rhs.x, top+rhs.y, right+rhs.x, bottom+rhs.y);
+ return result;
}
-Rect Rect::operator - (const Point& rhs) const
+const Rect Rect::operator - (const Point& rhs) const
{
- return Rect(left-rhs.x, top-rhs.y, right-rhs.x, bottom-rhs.y);
+ const Rect result(left-rhs.x, top-rhs.y, right-rhs.x, bottom-rhs.y);
+ return result;
}
bool Rect::intersect(const Rect& with, Rect* result) const