media/omx-plugin/include/froyo/ui/Point.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/omx-plugin/include/froyo/ui/Point.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,87 @@
     1.4 +/*
     1.5 + * Copyright (C) 2006 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef ANDROID_UI_POINT
    1.21 +#define ANDROID_UI_POINT
    1.22 +
    1.23 +#include <utils/TypeHelpers.h>
    1.24 +
    1.25 +namespace android {
    1.26 +
    1.27 +class Point
    1.28 +{
    1.29 +public:
    1.30 +    int x;
    1.31 +    int y;
    1.32 +
    1.33 +    // we don't provide copy-ctor and operator= on purpose
    1.34 +    // because we want the compiler generated versions
    1.35 +
    1.36 +    // Default constructor doesn't initialize the Point
    1.37 +    inline Point() {
    1.38 +    }
    1.39 +    inline Point(int x, int y) : x(x), y(y) {
    1.40 +    }
    1.41 +
    1.42 +    inline bool operator == (const Point& rhs) const {
    1.43 +        return (x == rhs.x) && (y == rhs.y);
    1.44 +    }
    1.45 +    inline bool operator != (const Point& rhs) const {
    1.46 +        return !operator == (rhs);
    1.47 +    }
    1.48 +
    1.49 +    inline bool isOrigin() const {
    1.50 +        return !(x|y);
    1.51 +    }
    1.52 +
    1.53 +    // operator < defines an order which allows to use points in sorted
    1.54 +    // vectors.
    1.55 +    bool operator < (const Point& rhs) const {
    1.56 +        return y<rhs.y || (y==rhs.y && x<rhs.x);
    1.57 +    }
    1.58 +
    1.59 +    inline Point& operator - () {
    1.60 +        x = -x;
    1.61 +        y = -y;
    1.62 +        return *this;
    1.63 +    }
    1.64 +    
    1.65 +    inline Point& operator += (const Point& rhs) {
    1.66 +        x += rhs.x;
    1.67 +        y += rhs.y;
    1.68 +        return *this;
    1.69 +    }
    1.70 +    inline Point& operator -= (const Point& rhs) {
    1.71 +        x -= rhs.x;
    1.72 +        y -= rhs.y;
    1.73 +        return *this;
    1.74 +    }
    1.75 +    
    1.76 +    const Point operator + (const Point& rhs) const {
    1.77 +        const Point result(x+rhs.x, y+rhs.y);
    1.78 +        return result;
    1.79 +    }
    1.80 +    const Point operator - (const Point& rhs) const {
    1.81 +        const Point result(x-rhs.x, y-rhs.y);
    1.82 +        return result;
    1.83 +    }    
    1.84 +};
    1.85 +
    1.86 +ANDROID_BASIC_TYPES_TRAITS(Point)
    1.87 +
    1.88 +}; // namespace android
    1.89 +
    1.90 +#endif // ANDROID_UI_POINT

mercurial