summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-30 22:13:32 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-30 22:13:32 +0000
commitb99603ceb9cbec4a3b1ca9ac535f6b1cbc951bb8 (patch)
tree2f9074d5ad8acf95156fc9c390646eca935d232e /ppapi/cpp
parent004f2cf5d5eb19764260b1f513738be15ae77d47 (diff)
downloadchromium_src-b99603ceb9cbec4a3b1ca9ac535f6b1cbc951bb8.zip
chromium_src-b99603ceb9cbec4a3b1ca9ac535f6b1cbc951bb8.tar.gz
chromium_src-b99603ceb9cbec4a3b1ca9ac535f6b1cbc951bb8.tar.bz2
Move some functions out of win_util and into hwnd_util, and into a new win/shell file.
This also moves two functions that were only called once from win_util and inwo window_win and download_util, respectively. TEST=it compiles BUG=none Review URL: http://codereview.chromium.org/6035011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r--ppapi/cpp/graphics_2d.cc9
-rw-r--r--ppapi/cpp/graphics_2d.h1
-rw-r--r--ppapi/cpp/image_data.cc11
-rw-r--r--ppapi/cpp/image_data.h1
-rw-r--r--ppapi/cpp/rect.cc7
-rw-r--r--ppapi/cpp/rect.h2
-rw-r--r--ppapi/cpp/resource.cc11
-rw-r--r--ppapi/cpp/resource.h1
-rw-r--r--ppapi/cpp/size.h9
9 files changed, 10 insertions, 42 deletions
diff --git a/ppapi/cpp/graphics_2d.cc b/ppapi/cpp/graphics_2d.cc
index 40a6312..edd5c33 100644
--- a/ppapi/cpp/graphics_2d.cc
+++ b/ppapi/cpp/graphics_2d.cc
@@ -50,16 +50,11 @@ Graphics2D::~Graphics2D() {
}
Graphics2D& Graphics2D::operator=(const Graphics2D& other) {
- Graphics2D copy(other);
- swap(copy);
+ Resource::operator=(other);
+ size_ = other.size_;
return *this;
}
-void Graphics2D::swap(Graphics2D& other) {
- Resource::swap(other);
- size_.swap(other.size_);
-}
-
void Graphics2D::PaintImageData(const ImageData& image,
const Point& top_left) {
if (!has_interface<PPB_Graphics2D>())
diff --git a/ppapi/cpp/graphics_2d.h b/ppapi/cpp/graphics_2d.h
index 8f4622f..39bcb5e 100644
--- a/ppapi/cpp/graphics_2d.h
+++ b/ppapi/cpp/graphics_2d.h
@@ -32,7 +32,6 @@ class Graphics2D : public Resource {
virtual ~Graphics2D();
Graphics2D& operator=(const Graphics2D& other);
- void swap(Graphics2D& other);
const Size& size() const { return size_; }
diff --git a/ppapi/cpp/image_data.cc b/ppapi/cpp/image_data.cc
index 61a291d..e43263b 100644
--- a/ppapi/cpp/image_data.cc
+++ b/ppapi/cpp/image_data.cc
@@ -58,17 +58,12 @@ ImageData::ImageData(PP_ImageDataFormat format,
}
ImageData& ImageData::operator=(const ImageData& other) {
- ImageData copy(other);
- swap(copy);
+ Resource::operator=(other);
+ desc_ = other.desc_;
+ data_ = other.data_;
return *this;
}
-void ImageData::swap(ImageData& other) {
- Resource::swap(other);
- std::swap(desc_, other.desc_);
- std::swap(data_, other.data_);
-}
-
const uint32_t* ImageData::GetAddr32(const Point& coord) const {
// Prefer evil const casts rather than evil code duplication.
return const_cast<ImageData*>(this)->GetAddr32(coord);
diff --git a/ppapi/cpp/image_data.h b/ppapi/cpp/image_data.h
index 388bbc0..25f9156 100644
--- a/ppapi/cpp/image_data.h
+++ b/ppapi/cpp/image_data.h
@@ -33,7 +33,6 @@ class ImageData : public Resource {
bool init_to_zero);
ImageData& operator=(const ImageData& other);
- void swap(ImageData& other);
// Returns the browser's preferred format for images. Using this format
// guarantees no extra conversions will occur when painting.
diff --git a/ppapi/cpp/rect.cc b/ppapi/cpp/rect.cc
index b57be2d..ef347dc 100644
--- a/ppapi/cpp/rect.cc
+++ b/ppapi/cpp/rect.cc
@@ -34,13 +34,6 @@ void Rect::Offset(int32_t horizontal, int32_t vertical) {
rect_.point.y += vertical;
}
-void Rect::swap(Rect& other) {
- std::swap(rect_.point.x, other.rect_.point.x);
- std::swap(rect_.point.y, other.rect_.point.y);
- std::swap(rect_.size.width, other.rect_.size.width);
- std::swap(rect_.size.height, other.rect_.size.height);
-}
-
bool Rect::Contains(int32_t point_x, int32_t point_y) const {
return (point_x >= x()) && (point_x < right()) &&
(point_y >= y()) && (point_y < bottom());
diff --git a/ppapi/cpp/rect.h b/ppapi/cpp/rect.h
index 7b133d2..1b07fd1 100644
--- a/ppapi/cpp/rect.h
+++ b/ppapi/cpp/rect.h
@@ -147,8 +147,6 @@ class Rect {
return rect_.size.width == 0 && rect_.size.height == 0;
}
- void swap(Rect& other);
-
// Returns true if the point identified by point_x and point_y falls inside
// this rectangle. The point (x, y) is inside the rectangle, but the
// point (x + width, y + height) is not.
diff --git a/ppapi/cpp/resource.cc b/ppapi/cpp/resource.cc
index e4a0d96..7daab4a 100644
--- a/ppapi/cpp/resource.cc
+++ b/ppapi/cpp/resource.cc
@@ -25,15 +25,14 @@ Resource::~Resource() {
}
Resource& Resource::operator=(const Resource& other) {
- Resource copy(other);
- swap(copy);
+ if (!is_null())
+ Module::Get()->core()->ReleaseResource(pp_resource_);
+ pp_resource_ = other.pp_resource_;
+ if (!is_null())
+ Module::Get()->core()->AddRefResource(pp_resource_);
return *this;
}
-void Resource::swap(Resource& other) {
- std::swap(pp_resource_, other.pp_resource_);
-}
-
PP_Resource Resource::detach() {
PP_Resource ret = pp_resource_;
pp_resource_ = 0;
diff --git a/ppapi/cpp/resource.h b/ppapi/cpp/resource.h
index 33e9982..c59b37d 100644
--- a/ppapi/cpp/resource.h
+++ b/ppapi/cpp/resource.h
@@ -18,7 +18,6 @@ class Resource {
virtual ~Resource();
Resource& operator=(const Resource& other);
- void swap(Resource& other);
// Returns true if the given resource is invalid or uninitialized.
bool is_null() const { return !pp_resource_; }
diff --git a/ppapi/cpp/size.h b/ppapi/cpp/size.h
index adcaf78..f2f9fe1 100644
--- a/ppapi/cpp/size.h
+++ b/ppapi/cpp/size.h
@@ -76,15 +76,6 @@ class Size {
set_height(height() + h);
}
- void swap(Size& other) {
- int32_t w = size_.width;
- int32_t h = size_.height;
- size_.width = other.size_.width;
- size_.height = other.size_.height;
- other.size_.width = w;
- other.size_.height = h;
- }
-
bool IsEmpty() const {
// Size doesn't allow negative dimensions, so testing for 0 is enough.
return (width() == 0) || (height() == 0);