diff options
author | Mathias Agopian <mathias@google.com> | 2009-05-26 17:44:57 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-05-26 17:47:39 -0700 |
commit | 35801cea5f301c0e1d7a93b15a8f73f98e6b1033 (patch) | |
tree | 2cad208ad6212d912b6f3476c98c0873f8d56fd4 /libs | |
parent | 7419ebc96fa5ae665dd4426dc5a4277c9ae1f325 (diff) | |
download | frameworks_native-35801cea5f301c0e1d7a93b15a8f73f98e6b1033.zip frameworks_native-35801cea5f301c0e1d7a93b15a8f73f98e6b1033.tar.gz frameworks_native-35801cea5f301c0e1d7a93b15a8f73f98e6b1033.tar.bz2 |
minor clean-up to Rect and Point.
- return "const" objects for overloaded operators to disallow constructs like: (a+b) = c;
- don't return references to non-static members, it's not always safe.
- Point.cpp was empty, so get rid of it
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ui/Android.mk | 1 | ||||
-rw-r--r-- | libs/ui/Point.cpp | 11 | ||||
-rw-r--r-- | libs/ui/Rect.cpp | 29 |
3 files changed, 19 insertions, 22 deletions
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk index f944357..b3b2104 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 |