Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5208ec29 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 2502 into donut

* changes:
  minor clean-up to Rect and Point.
parents ed9e5cb3 35801cea
Loading
Loading
Loading
Loading
+10 −11
Original line number Original line Diff line number Diff line
@@ -31,12 +31,9 @@ public:
    // because we want the compiler generated versions
    // because we want the compiler generated versions


    // Default constructor doesn't initialize the Point
    // 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 {
    inline bool operator == (const Point& rhs) const {
@@ -73,11 +70,13 @@ public:
        return *this;
        return *this;
    }
    }
    
    
    Point operator + (const Point& rhs) const {
    const Point operator + (const Point& rhs) const {
        return Point(x+rhs.x, y+rhs.y);
        const Point result(x+rhs.x, y+rhs.y);
        return result;
    }
    }
    Point operator - (const Point& rhs) const {
    const Point operator - (const Point& rhs) const {
        return Point(x-rhs.x, y-rhs.y);
        const Point result(x-rhs.x, y-rhs.y);
        return result;
    }    
    }    
};
};


+17 −23
Original line number Original line Diff line number Diff line
@@ -33,23 +33,16 @@ public:
    // we don't provide copy-ctor and operator= on purpose
    // we don't provide copy-ctor and operator= on purpose
    // because we want the compiler generated versions
    // because we want the compiler generated versions


    inline Rect()
    inline Rect() {
    {
    }
    }

    inline Rect(int w, int h)
    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)
    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) 
    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();
    void makeInvalid();
@@ -78,21 +71,22 @@ public:
        return bottom-top;
        return bottom-top;
    }
    }


    // returns left-top Point non-const reference, can be assigned
    void setLeftTop(const Point& lt) {
    inline Point& leftTop() {
        left = lt.x;
        return reinterpret_cast<Point&>(left);
        top  = lt.y;
    }
    }
    // returns right bottom non-const reference, can be assigned

    inline Point& rightBottom() {
    void setRightBottom(const Point& rb) {
        return reinterpret_cast<Point&>(right);
        right = rb.x;
        bottom  = rb.y;
    }
    }
    
    
    // the following 4 functions return the 4 corners of the rect as Point
    // the following 4 functions return the 4 corners of the rect as Point
    inline const Point& leftTop() const {
    Point leftTop() const {
        return reinterpret_cast<const Point&>(left);
        return Point(left, top);
    }
    }
    inline const Point& rightBottom() const {
    Point rightBottom() const {
        return reinterpret_cast<const Point&>(right);
        return Point(right, bottom);
    }
    }
    Point rightTop() const {
    Point rightTop() const {
        return Point(right, top);
        return Point(right, top);
@@ -133,8 +127,8 @@ public:
    Rect& operator -= (const Point& rhs) {
    Rect& operator -= (const Point& rhs) {
        return offsetBy(-rhs.x, -rhs.y);
        return offsetBy(-rhs.x, -rhs.y);
    }
    }
    Rect operator + (const Point& rhs) const;
    const Rect operator + (const Point& rhs) const;
    Rect operator - (const Point& rhs) const;
    const Rect operator - (const Point& rhs) const;


    void translate(int dx, int dy) { // legacy, don't use.
    void translate(int dx, int dy) { // legacy, don't use.
        offsetBy(dx, dy);
        offsetBy(dx, dy);
+0 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ LOCAL_SRC_FILES:= \
	LayerState.cpp \
	LayerState.cpp \
	Overlay.cpp \
	Overlay.cpp \
	PixelFormat.cpp \
	PixelFormat.cpp \
	Point.cpp \
	Rect.cpp \
	Rect.cpp \
	Region.cpp \
	Region.cpp \
	Surface.cpp \
	Surface.cpp \

libs/ui/Point.cpp

deleted100644 → 0
+0 −11
Original line number Original line Diff line number Diff line
/*
 *  Point.cpp
 *  Android
 *
 *  Created on 11/16/2006.
 *  Copyright 2005 The Android Open Source Project
 *
 */

#include <ui/Point.h>
+19 −10
Original line number Original line Diff line number Diff line
/*
/*
 *  Rect.cpp
 * Copyright (C) 2009 The Android Open Source Project
 *  Android
 *
 *
 *  Created on 10/14/05.
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  Copyright 2005 The Android Open Source Project
 * 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>
#include <ui/Rect.h>


namespace android {
namespace android {


inline int min(int a, int b) {
static inline int min(int a, int b) {
    return (a<b) ? a : 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;
    return (a>b) ? a : b;
}
}


@@ -64,14 +71,16 @@ Rect& Rect::offsetBy(int x, int y)
    return *this;
    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
bool Rect::intersect(const Rect& with, Rect* result) const