| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/paint_aggregator.h" | 5 #include "content/renderer/paint_aggregator.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 namespace content { | 8 namespace content { |
| 9 | 9 |
| 10 TEST(PaintAggregator, InitialState) { | 10 TEST(PaintAggregator, InitialState) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 TEST(PaintAggregator, DoubleDisjointInvalidation) { | 31 TEST(PaintAggregator, DoubleDisjointInvalidation) { |
| 32 PaintAggregator greg; | 32 PaintAggregator greg; |
| 33 | 33 |
| 34 gfx::Rect r1(2, 4, 2, 40); | 34 gfx::Rect r1(2, 4, 2, 40); |
| 35 gfx::Rect r2(4, 2, 40, 2); | 35 gfx::Rect r2(4, 2, 40, 2); |
| 36 | 36 |
| 37 greg.InvalidateRect(r1); | 37 greg.InvalidateRect(r1); |
| 38 greg.InvalidateRect(r2); | 38 greg.InvalidateRect(r2); |
| 39 | 39 |
| 40 gfx::Rect expected_bounds = r1; | 40 gfx::Rect expected_bounds = gfx::Union(r1, r2); |
| 41 expected_bounds.Union(r2); | |
| 42 | 41 |
| 43 EXPECT_TRUE(greg.HasPendingUpdate()); | 42 EXPECT_TRUE(greg.HasPendingUpdate()); |
| 44 PaintAggregator::PendingUpdate update; | 43 PaintAggregator::PendingUpdate update; |
| 45 greg.PopPendingUpdate(&update); | 44 greg.PopPendingUpdate(&update); |
| 46 | 45 |
| 47 EXPECT_TRUE(update.scroll_rect.IsEmpty()); | 46 EXPECT_TRUE(update.scroll_rect.IsEmpty()); |
| 48 EXPECT_EQ(2U, update.paint_rects.size()); | 47 EXPECT_EQ(2U, update.paint_rects.size()); |
| 49 | 48 |
| 50 EXPECT_EQ(expected_bounds, update.GetPaintBounds()); | 49 EXPECT_EQ(expected_bounds, update.GetPaintBounds()); |
| 51 } | 50 } |
| 52 | 51 |
| 53 TEST(PaintAggregator, DisjointInvalidationsCombined) { | 52 TEST(PaintAggregator, DisjointInvalidationsCombined) { |
| 54 PaintAggregator greg; | 53 PaintAggregator greg; |
| 55 | 54 |
| 56 // Make the rectangles such that they don't overlap but cover a very large | 55 // Make the rectangles such that they don't overlap but cover a very large |
| 57 // percentage of the area of covered by their union. This is so we're not | 56 // percentage of the area of covered by their union. This is so we're not |
| 58 // very sensitive to the combining heuristic in the paint aggregator. | 57 // very sensitive to the combining heuristic in the paint aggregator. |
| 59 gfx::Rect r1(2, 4, 2, 1000); | 58 gfx::Rect r1(2, 4, 2, 1000); |
| 60 gfx::Rect r2(5, 2, 2, 1000); | 59 gfx::Rect r2(5, 2, 2, 1000); |
| 61 | 60 |
| 62 greg.InvalidateRect(r1); | 61 greg.InvalidateRect(r1); |
| 63 greg.InvalidateRect(r2); | 62 greg.InvalidateRect(r2); |
| 64 | 63 |
| 65 gfx::Rect expected_bounds = r1; | 64 gfx::Rect expected_bounds = gfx::Union(r1, r2); |
| 66 expected_bounds.Union(r2); | |
| 67 | 65 |
| 68 EXPECT_TRUE(greg.HasPendingUpdate()); | 66 EXPECT_TRUE(greg.HasPendingUpdate()); |
| 69 PaintAggregator::PendingUpdate update; | 67 PaintAggregator::PendingUpdate update; |
| 70 greg.PopPendingUpdate(&update); | 68 greg.PopPendingUpdate(&update); |
| 71 | 69 |
| 72 EXPECT_TRUE(update.scroll_rect.IsEmpty()); | 70 EXPECT_TRUE(update.scroll_rect.IsEmpty()); |
| 73 ASSERT_EQ(1U, update.paint_rects.size()); | 71 ASSERT_EQ(1U, update.paint_rects.size()); |
| 74 | 72 |
| 75 EXPECT_EQ(expected_bounds, update.paint_rects[0]); | 73 EXPECT_EQ(expected_bounds, update.paint_rects[0]); |
| 76 } | 74 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 270 |
| 273 TEST(PaintAggregator, OverlappingPaintBeforeScroll) { | 271 TEST(PaintAggregator, OverlappingPaintBeforeScroll) { |
| 274 PaintAggregator greg; | 272 PaintAggregator greg; |
| 275 | 273 |
| 276 gfx::Rect paint_rect(4, 4, 10, 2); | 274 gfx::Rect paint_rect(4, 4, 10, 2); |
| 277 greg.InvalidateRect(paint_rect); | 275 greg.InvalidateRect(paint_rect); |
| 278 | 276 |
| 279 gfx::Rect scroll_rect(0, 0, 10, 10); | 277 gfx::Rect scroll_rect(0, 0, 10, 10); |
| 280 greg.ScrollRect(2, 0, scroll_rect); | 278 greg.ScrollRect(2, 0, scroll_rect); |
| 281 | 279 |
| 282 gfx::Rect expected_paint_rect = scroll_rect; | 280 gfx::Rect expected_paint_rect = gfx::Union(scroll_rect, paint_rect); |
| 283 expected_paint_rect.Union(paint_rect); | |
| 284 | 281 |
| 285 EXPECT_TRUE(greg.HasPendingUpdate()); | 282 EXPECT_TRUE(greg.HasPendingUpdate()); |
| 286 PaintAggregator::PendingUpdate update; | 283 PaintAggregator::PendingUpdate update; |
| 287 greg.PopPendingUpdate(&update); | 284 greg.PopPendingUpdate(&update); |
| 288 | 285 |
| 289 EXPECT_TRUE(update.scroll_rect.IsEmpty()); | 286 EXPECT_TRUE(update.scroll_rect.IsEmpty()); |
| 290 EXPECT_EQ(1U, update.paint_rects.size()); | 287 EXPECT_EQ(1U, update.paint_rects.size()); |
| 291 | 288 |
| 292 EXPECT_EQ(expected_paint_rect, update.paint_rects[0]); | 289 EXPECT_EQ(expected_paint_rect, update.paint_rects[0]); |
| 293 } | 290 } |
| 294 | 291 |
| 295 TEST(PaintAggregator, OverlappingPaintAfterScroll) { | 292 TEST(PaintAggregator, OverlappingPaintAfterScroll) { |
| 296 PaintAggregator greg; | 293 PaintAggregator greg; |
| 297 | 294 |
| 298 gfx::Rect scroll_rect(0, 0, 10, 10); | 295 gfx::Rect scroll_rect(0, 0, 10, 10); |
| 299 greg.ScrollRect(2, 0, scroll_rect); | 296 greg.ScrollRect(2, 0, scroll_rect); |
| 300 | 297 |
| 301 gfx::Rect paint_rect(4, 4, 10, 2); | 298 gfx::Rect paint_rect(4, 4, 10, 2); |
| 302 greg.InvalidateRect(paint_rect); | 299 greg.InvalidateRect(paint_rect); |
| 303 | 300 |
| 304 gfx::Rect expected_paint_rect = scroll_rect; | 301 gfx::Rect expected_paint_rect = gfx::Union(scroll_rect, paint_rect); |
| 305 expected_paint_rect.Union(paint_rect); | |
| 306 | 302 |
| 307 EXPECT_TRUE(greg.HasPendingUpdate()); | 303 EXPECT_TRUE(greg.HasPendingUpdate()); |
| 308 PaintAggregator::PendingUpdate update; | 304 PaintAggregator::PendingUpdate update; |
| 309 greg.PopPendingUpdate(&update); | 305 greg.PopPendingUpdate(&update); |
| 310 | 306 |
| 311 EXPECT_TRUE(update.scroll_rect.IsEmpty()); | 307 EXPECT_TRUE(update.scroll_rect.IsEmpty()); |
| 312 EXPECT_EQ(1U, update.paint_rects.size()); | 308 EXPECT_EQ(1U, update.paint_rects.size()); |
| 313 | 309 |
| 314 EXPECT_EQ(expected_paint_rect, update.paint_rects[0]); | 310 EXPECT_EQ(expected_paint_rect, update.paint_rects[0]); |
| 315 } | 311 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 greg.PopPendingUpdate(&update); | 432 greg.PopPendingUpdate(&update); |
| 437 | 433 |
| 438 EXPECT_FALSE(update.scroll_rect.IsEmpty()); | 434 EXPECT_FALSE(update.scroll_rect.IsEmpty()); |
| 439 EXPECT_TRUE(update.paint_rects.empty()); | 435 EXPECT_TRUE(update.paint_rects.empty()); |
| 440 | 436 |
| 441 EXPECT_EQ(scroll_rect, update.scroll_rect); | 437 EXPECT_EQ(scroll_rect, update.scroll_rect); |
| 442 EXPECT_EQ(expected_scroll_damage, update.GetScrollDamage()); | 438 EXPECT_EQ(expected_scroll_damage, update.GetScrollDamage()); |
| 443 } | 439 } |
| 444 | 440 |
| 445 } // namespace content | 441 } // namespace content |
| OLD | NEW |