diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-01 16:16:50 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-01 16:16:50 +0000 |
commit | 1758e88fd909ea0ffd49621e8066ffad5627ffdf (patch) | |
tree | c304a5eed047cae5665f5af1739d84655fb5815d /ppapi/cpp/point.h | |
parent | e7d8b51953b7d3b2b8a0aba46132305b32f3efce (diff) | |
download | chromium_src-1758e88fd909ea0ffd49621e8066ffad5627ffdf.zip chromium_src-1758e88fd909ea0ffd49621e8066ffad5627ffdf.tar.gz chromium_src-1758e88fd909ea0ffd49621e8066ffad5627ffdf.tar.bz2 |
Move PPAPI into the Chrome repo. The old repo was
http://ppapi.googlecode.com/
TEST=none
BUG=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp/point.h')
-rw-r--r-- | ppapi/cpp/point.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/ppapi/cpp/point.h b/ppapi/cpp/point.h new file mode 100644 index 0000000..ce1c5a4 --- /dev/null +++ b/ppapi/cpp/point.h @@ -0,0 +1,93 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_POINT_H_ +#define PPAPI_CPP_POINT_H_ + +#include "ppapi/c/pp_point.h" + +namespace pp { + +// A point has an x and y coordinate. +class Point { + public: + Point() { + point_.x = 0; + point_.y = 0; + } + Point(int32_t in_x, int32_t in_y) { + point_.x = in_x; + point_.y = in_y; + } + Point(const PP_Point& point) { // Implicit. + point_.x = point.x; + point_.y = point.y; + } + + ~Point() { + } + + operator PP_Point() const { + return point_; + } + const PP_Point& pp_point() const { + return point_; + } + PP_Point& pp_point() { + return point_; + } + + int32_t x() const { return point_.x; } + void set_x(int32_t in_x) { + point_.x = in_x; + } + + int32_t y() const { return point_.y; } + void set_y(int32_t in_y) { + point_.y = in_y; + } + + Point operator+(const Point& other) const { + return Point(x() + other.x(), y() + other.y()); + } + Point operator-(const Point& other) const { + return Point(x() - other.x(), y() - other.y()); + } + + Point& operator+=(const Point& other) { + point_.x += other.x(); + point_.y += other.y(); + return *this; + } + Point& operator-=(const Point& other) { + point_.x -= other.x(); + point_.y -= other.y(); + return *this; + } + + void swap(Point& other) { + int32_t x = point_.x; + int32_t y = point_.y; + point_.x = other.point_.x; + point_.y = other.point_.y; + other.point_.x = x; + other.point_.y = y; + } + + private: + PP_Point point_; +}; + +} // namespace pp + +inline bool operator==(const pp::Point& lhs, const pp::Point& rhs) { + return lhs.x() == rhs.x() && lhs.y() == rhs.y(); +} + +inline bool operator!=(const pp::Point& lhs, const pp::Point& rhs) { + return !(lhs == rhs); +} + +#endif // PPAPI_CPP_POINT_H_ + |