summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-07 04:15:39 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-07 04:15:39 +0000
commitb36d9baa98e397fd194716a6041083ed989524c8 (patch)
tree335b3e294a41f795af59f72b1fc1cc0c6f171752 /base
parent6e41eae8b3ea421a67104fe1849d5f261a4f2b20 (diff)
downloadchromium_src-b36d9baa98e397fd194716a6041083ed989524c8.zip
chromium_src-b36d9baa98e397fd194716a6041083ed989524c8.tar.gz
chromium_src-b36d9baa98e397fd194716a6041083ed989524c8.tar.bz2
Coalesce damage rects that share an edge.
This fixes the Bloat HTTP page cycler regression, and allows me to remove the hack I checked in to disable multiple-paints due to an observed DHTML page cycler regression. I added a new histogram, RW_IntermediatePaintRectCount, that would have shown the problem clearly had it been there before. I included some cleanup in PaintAggregator: 1- rename "r" to "existing_rect" for clarity 2- check for contained (i.e., redundant) invalidates up front I also changed the opacity of the paint rects used when --show-paint-rects is specified. I find myself dogfooding with this command line option enabled, and I want it to be a little less annoying but still just as useful. R=brettw BUG=29477 TEST=none Review URL: http://codereview.chromium.org/464057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/gfx/rect.cc7
-rw-r--r--base/gfx/rect.h4
-rw-r--r--base/gfx/rect_unittest.cc34
3 files changed, 45 insertions, 0 deletions
diff --git a/base/gfx/rect.cc b/base/gfx/rect.cc
index 1e067e7..2a35575 100644
--- a/base/gfx/rect.cc
+++ b/base/gfx/rect.cc
@@ -225,6 +225,13 @@ Point Rect::CenterPoint() const {
return Point(x() + (width() + 1) / 2, y() + (height() + 1) / 2);
}
+bool Rect::SharesEdgeWith(const gfx::Rect& rect) const {
+ return (y() == rect.y() && height() == rect.height() &&
+ (x() == rect.right() || right() == rect.x())) ||
+ (x() == rect.x() && width() == rect.width() &&
+ (y() == rect.bottom() || bottom() == rect.y()));
+}
+
} // namespace gfx
std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) {
diff --git a/base/gfx/rect.h b/base/gfx/rect.h
index 2eef76c..c3c01ad 100644
--- a/base/gfx/rect.h
+++ b/base/gfx/rect.h
@@ -149,6 +149,10 @@ class Rect {
// Returns the center of this rectangle.
Point CenterPoint() const;
+ // Returns true if this rectangle shares an entire edge (i.e., same width or
+ // same height) with the given rectangle, and the rectangles do not overlap.
+ bool SharesEdgeWith(const gfx::Rect& rect) const;
+
private:
gfx::Point origin_;
gfx::Size size_;
diff --git a/base/gfx/rect_unittest.cc b/base/gfx/rect_unittest.cc
index 50c789d..3562883 100644
--- a/base/gfx/rect_unittest.cc
+++ b/base/gfx/rect_unittest.cc
@@ -278,3 +278,37 @@ TEST(RectTest, IsEmpty) {
EXPECT_FALSE(gfx::Rect(0, 0, 10, 10).IsEmpty());
EXPECT_FALSE(gfx::Rect(0, 0, 10, 10).size().IsEmpty());
}
+
+TEST(RectTest, SharesEdgeWith) {
+ gfx::Rect r(2, 3, 4, 5);
+
+ // Must be non-overlapping
+ EXPECT_FALSE(r.SharesEdgeWith(r));
+
+ gfx::Rect just_above(2, 1, 4, 2);
+ gfx::Rect just_below(2, 8, 4, 2);
+ gfx::Rect just_left(0, 3, 2, 5);
+ gfx::Rect just_right(6, 3, 2, 5);
+
+ EXPECT_TRUE(r.SharesEdgeWith(just_above));
+ EXPECT_TRUE(r.SharesEdgeWith(just_below));
+ EXPECT_TRUE(r.SharesEdgeWith(just_left));
+ EXPECT_TRUE(r.SharesEdgeWith(just_right));
+
+ // Wrong placement
+ gfx::Rect same_height_no_edge(0, 0, 1, 5);
+ gfx::Rect same_width_no_edge(0, 0, 4, 1);
+
+ EXPECT_FALSE(r.SharesEdgeWith(same_height_no_edge));
+ EXPECT_FALSE(r.SharesEdgeWith(same_width_no_edge));
+
+ gfx::Rect just_above_no_edge(2, 1, 5, 2); // too wide
+ gfx::Rect just_below_no_edge(2, 8, 3, 2); // too narrow
+ gfx::Rect just_left_no_edge(0, 3, 2, 6); // too tall
+ gfx::Rect just_right_no_edge(6, 3, 2, 4); // too short
+
+ EXPECT_FALSE(r.SharesEdgeWith(just_above_no_edge));
+ EXPECT_FALSE(r.SharesEdgeWith(just_below_no_edge));
+ EXPECT_FALSE(r.SharesEdgeWith(just_left_no_edge));
+ EXPECT_FALSE(r.SharesEdgeWith(just_right_no_edge));
+}