summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/backing_store_aura.cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 16:51:47 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 16:51:47 +0000
commitd40305001bfd61bef7e118c8580895f68d36b163 (patch)
tree05a4a731233c5cb3deb56306019231e22d474deb /content/browser/renderer_host/backing_store_aura.cc
parentea75f30985b5b24627bed4c613a1ef403235aa02 (diff)
downloadchromium_src-d40305001bfd61bef7e118c8580895f68d36b163.zip
chromium_src-d40305001bfd61bef7e118c8580895f68d36b163.tar.gz
chromium_src-d40305001bfd61bef7e118c8580895f68d36b163.tar.bz2
Make gfx::Rect class operations consistently mutate the class they are called on.
Currently some methods mutate the class, and some return a new value, requiring API users to know what kind of method they are calling each time, and making inconsistent code. For example: gfx::Rect rect; rect.Inset(1, 1, 1, 1); rect = rect.Intersect(other_rect); rect.Offset(1, 1); Instead of: gfx::Rect rect; rect.Inset(1, 1, 1, 1); rect.Intersect(other_rect); rect.Offset(1, 1); We could go either way - making the class immutable or all methods return a new instance - but I believe it is better to instead make all methods mutate the class. This allows for shorter lines of code by avoiding having to repeat the object's name twice in order to change it. This patch changes gfx::Rect classes and all the callsites that uses these methods. It should make no change in behaviour, so no new tests added. R=sky BUG=147395 Review URL: https://codereview.chromium.org/11110004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163579 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/backing_store_aura.cc')
-rw-r--r--content/browser/renderer_host/backing_store_aura.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/content/browser/renderer_host/backing_store_aura.cc b/content/browser/renderer_host/backing_store_aura.cc
index 4a7adaf..5d1149a 100644
--- a/content/browser/renderer_host/backing_store_aura.cc
+++ b/content/browser/renderer_host/backing_store_aura.cc
@@ -91,8 +91,9 @@ void BackingStoreAura::PaintToBackingStore(
if (bitmap_rect.IsEmpty())
return;
- gfx::Rect pixel_bitmap_rect =
- gfx::ToEnclosedRect(bitmap_rect.Scale(scale_factor));
+ gfx::RectF scaled_bitmap_rect = bitmap_rect;
+ scaled_bitmap_rect.Scale(scale_factor);
+ gfx::Rect pixel_bitmap_rect = gfx::ToEnclosedRect(scaled_bitmap_rect);
const int width = pixel_bitmap_rect.width();
const int height = pixel_bitmap_rect.height();
@@ -112,16 +113,19 @@ void BackingStoreAura::PaintToBackingStore(
sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
sk_bitmap.setPixels(dib->memory());
for (size_t i = 0; i < copy_rects.size(); i++) {
- const gfx::Rect pixel_copy_rect =
- gfx::ToEnclosingRect(copy_rects[i].Scale(scale_factor));
+ gfx::RectF scaled_copy_rect = copy_rects[i];
+ scaled_copy_rect.Scale(scale_factor);
+ const gfx::Rect pixel_copy_rect = gfx::ToEnclosingRect(scaled_copy_rect);
int x = pixel_copy_rect.x() - pixel_bitmap_rect.x();
int y = pixel_copy_rect.y() - pixel_bitmap_rect.y();
SkIRect srcrect = SkIRect::MakeXYWH(x, y,
pixel_copy_rect.width(),
pixel_copy_rect.height());
+ gfx::RectF scaled_copy_dst_rect = copy_rects[i];
+ scaled_copy_dst_rect.Scale(device_scale_factor_);
const gfx::Rect pixel_copy_dst_rect =
- gfx::ToEnclosingRect(copy_rects[i].Scale(device_scale_factor_));
+ gfx::ToEnclosingRect(scaled_copy_dst_rect);
SkRect dstrect = SkRect::MakeXYWH(
SkIntToScalar(pixel_copy_dst_rect.x()),
SkIntToScalar(pixel_copy_dst_rect.y()),
@@ -134,8 +138,9 @@ void BackingStoreAura::PaintToBackingStore(
void BackingStoreAura::ScrollBackingStore(int dx, int dy,
const gfx::Rect& clip_rect,
const gfx::Size& view_size) {
- gfx::Rect pixel_rect =
- gfx::ToEnclosingRect(clip_rect.Scale(device_scale_factor_));
+ gfx::RectF scaled_clip_rect = clip_rect;
+ scaled_clip_rect.Scale(device_scale_factor_);
+ gfx::Rect pixel_rect = gfx::ToEnclosingRect(scaled_clip_rect);
int pixel_dx = dx * device_scale_factor_;
int pixel_dy = dy * device_scale_factor_;