Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: cc/trees/damage_tracker_unittest.cc

Issue 647253002: cc: Stop converting update rect from int to float to int. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: displayrectint: ccperftests Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/tiled_layer_test_common.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/damage_tracker.h" 5 #include "cc/trees/damage_tracker.h"
6 6
7 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/layers/layer_impl.h" 8 #include "cc/layers/layer_impl.h"
9 #include "cc/output/filter_operation.h" 9 #include "cc/output/filter_operation.h"
10 #include "cc/output/filter_operations.h" 10 #include "cc/output/filter_operations.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); 222 EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString());
223 } 223 }
224 224
225 TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { 225 TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) {
226 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); 226 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface();
227 LayerImpl* child = root->children()[0]; 227 LayerImpl* child = root->children()[0];
228 228
229 // CASE 1: Setting the update rect should cause the corresponding damage to 229 // CASE 1: Setting the update rect should cause the corresponding damage to
230 // the surface. 230 // the surface.
231 ClearDamageForAllSurfaces(root.get()); 231 ClearDamageForAllSurfaces(root.get());
232 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); 232 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13));
233 EmulateDrawingOneFrame(root.get()); 233 EmulateDrawingOneFrame(root.get());
234 234
235 // Damage position on the surface should be: position of update_rect (10, 11) 235 // Damage position on the surface should be: position of update_rect (10, 11)
236 // relative to the child (100, 100). 236 // relative to the child (100, 100).
237 gfx::Rect root_damage_rect = 237 gfx::Rect root_damage_rect =
238 root->render_surface()->damage_tracker()->current_damage_rect(); 238 root->render_surface()->damage_tracker()->current_damage_rect();
239 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), 239 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(),
240 root_damage_rect.ToString()); 240 root_damage_rect.ToString());
241 241
242 // CASE 2: The same update rect twice in a row still produces the same 242 // CASE 2: The same update rect twice in a row still produces the same
243 // damage. 243 // damage.
244 ClearDamageForAllSurfaces(root.get()); 244 ClearDamageForAllSurfaces(root.get());
245 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); 245 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13));
246 EmulateDrawingOneFrame(root.get()); 246 EmulateDrawingOneFrame(root.get());
247 root_damage_rect = 247 root_damage_rect =
248 root->render_surface()->damage_tracker()->current_damage_rect(); 248 root->render_surface()->damage_tracker()->current_damage_rect();
249 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), 249 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(),
250 root_damage_rect.ToString()); 250 root_damage_rect.ToString());
251 251
252 // CASE 3: Setting a different update rect should cause damage on the new 252 // CASE 3: Setting a different update rect should cause damage on the new
253 // update region, but no additional exposed old region. 253 // update region, but no additional exposed old region.
254 ClearDamageForAllSurfaces(root.get()); 254 ClearDamageForAllSurfaces(root.get());
255 child->SetUpdateRect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); 255 child->SetUpdateRect(gfx::Rect(20, 25, 1, 2));
256 EmulateDrawingOneFrame(root.get()); 256 EmulateDrawingOneFrame(root.get());
257 257
258 // Damage position on the surface should be: position of update_rect (20, 25) 258 // Damage position on the surface should be: position of update_rect (20, 25)
259 // relative to the child (100, 100). 259 // relative to the child (100, 100).
260 root_damage_rect = 260 root_damage_rect =
261 root->render_surface()->damage_tracker()->current_damage_rect(); 261 root->render_surface()->damage_tracker()->current_damage_rect();
262 EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString()); 262 EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString());
263 } 263 }
264 264
265 TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { 265 TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 315 }
316 316
317 TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) { 317 TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) {
318 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); 318 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface();
319 LayerImpl* child = root->children()[0]; 319 LayerImpl* child = root->children()[0];
320 320
321 // CASE 1: Adding the layer damage rect and update rect should cause the 321 // CASE 1: Adding the layer damage rect and update rect should cause the
322 // corresponding damage to the surface. 322 // corresponding damage to the surface.
323 ClearDamageForAllSurfaces(root.get()); 323 ClearDamageForAllSurfaces(root.get());
324 child->AddDamageRect(gfx::RectF(5.f, 6.f, 12.f, 13.f)); 324 child->AddDamageRect(gfx::RectF(5.f, 6.f, 12.f, 13.f));
325 child->SetUpdateRect(gfx::RectF(15.f, 16.f, 14.f, 10.f)); 325 child->SetUpdateRect(gfx::Rect(15, 16, 14, 10));
326 EmulateDrawingOneFrame(root.get()); 326 EmulateDrawingOneFrame(root.get());
327 327
328 // Damage position on the surface should be: position of unified layer 328 // Damage position on the surface should be: position of unified layer
329 // damage_rect and update rect (5, 6) 329 // damage_rect and update rect (5, 6)
330 // relative to the child (100, 100). 330 // relative to the child (100, 100).
331 gfx::Rect root_damage_rect = 331 gfx::Rect root_damage_rect =
332 root->render_surface()->damage_tracker()->current_damage_rect(); 332 root->render_surface()->damage_tracker()->current_damage_rect();
333 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 106, 24, 20))); 333 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 106, 24, 20)));
334 334
335 // CASE 2: The same layer damage rect and update rect twice in a row still 335 // CASE 2: The same layer damage rect and update rect twice in a row still
336 // produces the same damage. 336 // produces the same damage.
337 ClearDamageForAllSurfaces(root.get()); 337 ClearDamageForAllSurfaces(root.get());
338 child->AddDamageRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); 338 child->AddDamageRect(gfx::RectF(10.f, 11.f, 12.f, 13.f));
339 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 14.f, 15.f)); 339 child->SetUpdateRect(gfx::Rect(10, 11, 14, 15));
340 EmulateDrawingOneFrame(root.get()); 340 EmulateDrawingOneFrame(root.get());
341 root_damage_rect = 341 root_damage_rect =
342 root->render_surface()->damage_tracker()->current_damage_rect(); 342 root->render_surface()->damage_tracker()->current_damage_rect();
343 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 14, 15))); 343 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 14, 15)));
344 344
345 // CASE 3: Adding a different layer damage rect and update rect should cause 345 // CASE 3: Adding a different layer damage rect and update rect should cause
346 // damage on the new damaged region, but no additional exposed old region. 346 // damage on the new damaged region, but no additional exposed old region.
347 ClearDamageForAllSurfaces(root.get()); 347 ClearDamageForAllSurfaces(root.get());
348 child->AddDamageRect(gfx::RectF(20.f, 25.f, 2.f, 3.f)); 348 child->AddDamageRect(gfx::RectF(20.f, 25.f, 2.f, 3.f));
349 child->SetUpdateRect(gfx::RectF(5.f, 10.f, 7.f, 8.f)); 349 child->SetUpdateRect(gfx::Rect(5, 10, 7, 8));
350 EmulateDrawingOneFrame(root.get()); 350 EmulateDrawingOneFrame(root.get());
351 351
352 // Damage position on the surface should be: position of unified layer damage 352 // Damage position on the surface should be: position of unified layer damage
353 // rect and update rect (5, 10) relative to the child (100, 100). 353 // rect and update rect (5, 10) relative to the child (100, 100).
354 root_damage_rect = 354 root_damage_rect =
355 root->render_surface()->damage_tracker()->current_damage_rect(); 355 root->render_surface()->damage_tracker()->current_damage_rect();
356 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 110, 17, 18))); 356 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 110, 17, 18)));
357 } 357 }
358 358
359 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { 359 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) {
360 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); 360 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface();
361 LayerImpl* child = root->children()[0]; 361 LayerImpl* child = root->children()[0];
362 362
363 // CASE 1: The layer's property changed flag takes priority over update rect. 363 // CASE 1: The layer's property changed flag takes priority over update rect.
364 // 364 //
365 ClearDamageForAllSurfaces(root.get()); 365 ClearDamageForAllSurfaces(root.get());
366 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); 366 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13));
367 child->SetOpacity(0.5f); 367 child->SetOpacity(0.5f);
368 EmulateDrawingOneFrame(root.get()); 368 EmulateDrawingOneFrame(root.get());
369 369
370 // Sanity check - we should not have accidentally created a separate render 370 // Sanity check - we should not have accidentally created a separate render
371 // surface for the translucent layer. 371 // surface for the translucent layer.
372 ASSERT_FALSE(child->render_surface()); 372 ASSERT_FALSE(child->render_surface());
373 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); 373 ASSERT_EQ(2u, root->render_surface()->layer_list().size());
374 374
375 // Damage should be the entire child layer in target_surface space. 375 // Damage should be the entire child layer in target_surface space.
376 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); 376 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 filters.GetOutsets(&outset_top, &outset_right, &outset_bottom, &outset_left); 504 filters.GetOutsets(&outset_top, &outset_right, &outset_bottom, &outset_left);
505 505
506 // Setting the filter will damage the whole surface. 506 // Setting the filter will damage the whole surface.
507 ClearDamageForAllSurfaces(root.get()); 507 ClearDamageForAllSurfaces(root.get());
508 surface->SetFilters(filters); 508 surface->SetFilters(filters);
509 EmulateDrawingOneFrame(root.get()); 509 EmulateDrawingOneFrame(root.get());
510 510
511 // Setting the update rect should cause the corresponding damage to the 511 // Setting the update rect should cause the corresponding damage to the
512 // surface, blurred based on the size of the blur filter. 512 // surface, blurred based on the size of the blur filter.
513 ClearDamageForAllSurfaces(root.get()); 513 ClearDamageForAllSurfaces(root.get());
514 child->SetUpdateRect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); 514 child->SetUpdateRect(gfx::Rect(1, 2, 3, 4));
515 EmulateDrawingOneFrame(root.get()); 515 EmulateDrawingOneFrame(root.get());
516 516
517 // Damage position on the surface should be: position of update_rect (1, 2) 517 // Damage position on the surface should be: position of update_rect (1, 2)
518 // relative to the child (300, 300), but expanded by the blur outsets. 518 // relative to the child (300, 300), but expanded by the blur outsets.
519 gfx::Rect root_damage_rect = 519 gfx::Rect root_damage_rect =
520 root->render_surface()->damage_tracker()->current_damage_rect(); 520 root->render_surface()->damage_tracker()->current_damage_rect();
521 gfx::Rect expected_damage_rect = gfx::Rect(301, 302, 3, 4); 521 gfx::Rect expected_damage_rect = gfx::Rect(301, 302, 3, 4);
522 522
523 expected_damage_rect.Inset(-outset_left, 523 expected_damage_rect.Inset(-outset_left,
524 -outset_top, 524 -outset_top,
(...skipping 22 matching lines...) Expand all
547 root_damage_rect = 547 root_damage_rect =
548 root->render_surface()->damage_tracker()->current_damage_rect(); 548 root->render_surface()->damage_tracker()->current_damage_rect();
549 child_damage_rect = 549 child_damage_rect =
550 child->render_surface()->damage_tracker()->current_damage_rect(); 550 child->render_surface()->damage_tracker()->current_damage_rect();
551 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), 551 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(),
552 root_damage_rect.ToString()); 552 root_damage_rect.ToString());
553 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); 553 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString());
554 554
555 // CASE 1: Setting the update rect should damage the whole surface (for now) 555 // CASE 1: Setting the update rect should damage the whole surface (for now)
556 ClearDamageForAllSurfaces(root.get()); 556 ClearDamageForAllSurfaces(root.get());
557 child->SetUpdateRect(gfx::RectF(1.f, 1.f)); 557 child->SetUpdateRect(gfx::Rect(1, 1));
558 EmulateDrawingOneFrame(root.get()); 558 EmulateDrawingOneFrame(root.get());
559 559
560 root_damage_rect = 560 root_damage_rect =
561 root->render_surface()->damage_tracker()->current_damage_rect(); 561 root->render_surface()->damage_tracker()->current_damage_rect();
562 child_damage_rect = 562 child_damage_rect =
563 child->render_surface()->damage_tracker()->current_damage_rect(); 563 child->render_surface()->damage_tracker()->current_damage_rect();
564 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), 564 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(),
565 root_damage_rect.ToString()); 565 root_damage_rect.ToString());
566 EXPECT_EQ(gfx::Rect(30.f, 30.f).ToString(), child_damage_rect.ToString()); 566 EXPECT_EQ(gfx::Rect(30.f, 30.f).ToString(), child_damage_rect.ToString());
567 } 567 }
(...skipping 13 matching lines...) Expand all
581 581
582 // Setting the filter will damage the whole surface. 582 // Setting the filter will damage the whole surface.
583 ClearDamageForAllSurfaces(root.get()); 583 ClearDamageForAllSurfaces(root.get());
584 child1->SetBackgroundFilters(filters); 584 child1->SetBackgroundFilters(filters);
585 EmulateDrawingOneFrame(root.get()); 585 EmulateDrawingOneFrame(root.get());
586 586
587 // CASE 1: Setting the update rect should cause the corresponding damage to 587 // CASE 1: Setting the update rect should cause the corresponding damage to
588 // the surface, blurred based on the size of the child's background 588 // the surface, blurred based on the size of the child's background
589 // blur filter. 589 // blur filter.
590 ClearDamageForAllSurfaces(root.get()); 590 ClearDamageForAllSurfaces(root.get());
591 root->SetUpdateRect(gfx::RectF(297.f, 297.f, 2.f, 2.f)); 591 root->SetUpdateRect(gfx::Rect(297, 297, 2, 2));
592 EmulateDrawingOneFrame(root.get()); 592 EmulateDrawingOneFrame(root.get());
593 593
594 gfx::Rect root_damage_rect = 594 gfx::Rect root_damage_rect =
595 root->render_surface()->damage_tracker()->current_damage_rect(); 595 root->render_surface()->damage_tracker()->current_damage_rect();
596 // Damage position on the surface should be a composition of the damage on 596 // Damage position on the surface should be a composition of the damage on
597 // the root and on child2. Damage on the root should be: position of 597 // the root and on child2. Damage on the root should be: position of
598 // update_rect (297, 297), but expanded by the blur outsets. 598 // update_rect (297, 297), but expanded by the blur outsets.
599 gfx::Rect expected_damage_rect = gfx::Rect(297, 297, 2, 2); 599 gfx::Rect expected_damage_rect = gfx::Rect(297, 297, 2, 2);
600 600
601 expected_damage_rect.Inset(-outset_left, 601 expected_damage_rect.Inset(-outset_left,
602 -outset_top, 602 -outset_top,
603 -outset_right, 603 -outset_right,
604 -outset_bottom); 604 -outset_bottom);
605 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); 605 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString());
606 606
607 // CASE 2: Setting the update rect should cause the corresponding damage to 607 // CASE 2: Setting the update rect should cause the corresponding damage to
608 // the surface, blurred based on the size of the child's background 608 // the surface, blurred based on the size of the child's background
609 // blur filter. Since the damage extends to the right/bottom outside 609 // blur filter. Since the damage extends to the right/bottom outside
610 // of the blurred layer, only the left/top should end up expanded. 610 // of the blurred layer, only the left/top should end up expanded.
611 ClearDamageForAllSurfaces(root.get()); 611 ClearDamageForAllSurfaces(root.get());
612 root->SetUpdateRect(gfx::RectF(297.f, 297.f, 30.f, 30.f)); 612 root->SetUpdateRect(gfx::Rect(297, 297, 30, 30));
613 EmulateDrawingOneFrame(root.get()); 613 EmulateDrawingOneFrame(root.get());
614 614
615 root_damage_rect = 615 root_damage_rect =
616 root->render_surface()->damage_tracker()->current_damage_rect(); 616 root->render_surface()->damage_tracker()->current_damage_rect();
617 // Damage position on the surface should be a composition of the damage on 617 // Damage position on the surface should be a composition of the damage on
618 // the root and on child2. Damage on the root should be: position of 618 // the root and on child2. Damage on the root should be: position of
619 // update_rect (297, 297), but expanded on the left/top by the blur outsets. 619 // update_rect (297, 297), but expanded on the left/top by the blur outsets.
620 expected_damage_rect = gfx::Rect(297, 297, 30, 30); 620 expected_damage_rect = gfx::Rect(297, 297, 30, 30);
621 621
622 expected_damage_rect.Inset(-outset_left, 622 expected_damage_rect.Inset(-outset_left,
623 -outset_top, 623 -outset_top,
624 0, 624 0,
625 0); 625 0);
626 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); 626 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString());
627 627
628 // CASE 3: Setting this update rect outside the blurred content_bounds of the 628 // CASE 3: Setting this update rect outside the blurred content_bounds of the
629 // blurred child1 will not cause it to be expanded. 629 // blurred child1 will not cause it to be expanded.
630 ClearDamageForAllSurfaces(root.get()); 630 ClearDamageForAllSurfaces(root.get());
631 root->SetUpdateRect(gfx::RectF(30.f, 30.f, 2.f, 2.f)); 631 root->SetUpdateRect(gfx::Rect(30, 30, 2, 2));
632 EmulateDrawingOneFrame(root.get()); 632 EmulateDrawingOneFrame(root.get());
633 633
634 root_damage_rect = 634 root_damage_rect =
635 root->render_surface()->damage_tracker()->current_damage_rect(); 635 root->render_surface()->damage_tracker()->current_damage_rect();
636 // Damage on the root should be: position of update_rect (30, 30), not 636 // Damage on the root should be: position of update_rect (30, 30), not
637 // expanded. 637 // expanded.
638 expected_damage_rect = gfx::Rect(30, 30, 2, 2); 638 expected_damage_rect = gfx::Rect(30, 30, 2, 2);
639 639
640 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); 640 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString());
641 641
642 // CASE 4: Setting this update rect inside the blurred content_bounds but 642 // CASE 4: Setting this update rect inside the blurred content_bounds but
643 // outside the original content_bounds of the blurred child1 will 643 // outside the original content_bounds of the blurred child1 will
644 // cause it to be expanded. 644 // cause it to be expanded.
645 ClearDamageForAllSurfaces(root.get()); 645 ClearDamageForAllSurfaces(root.get());
646 root->SetUpdateRect(gfx::RectF(99.f, 99.f, 1.f, 1.f)); 646 root->SetUpdateRect(gfx::Rect(99, 99, 1, 1));
647 EmulateDrawingOneFrame(root.get()); 647 EmulateDrawingOneFrame(root.get());
648 648
649 root_damage_rect = 649 root_damage_rect =
650 root->render_surface()->damage_tracker()->current_damage_rect(); 650 root->render_surface()->damage_tracker()->current_damage_rect();
651 // Damage on the root should be: position of update_rect (99, 99), expanded by 651 // Damage on the root should be: position of update_rect (99, 99), expanded by
652 // the blurring on child1, but since it is 1 pixel outside the layer, the 652 // the blurring on child1, but since it is 1 pixel outside the layer, the
653 // expanding should be reduced by 1. 653 // expanding should be reduced by 1.
654 expected_damage_rect = gfx::Rect(99, 99, 1, 1); 654 expected_damage_rect = gfx::Rect(99, 99, 1, 1);
655 655
656 expected_damage_rect.Inset(-outset_left + 1, 656 expected_damage_rect.Inset(-outset_left + 1,
657 -outset_top + 1, 657 -outset_top + 1,
658 -outset_right, 658 -outset_right,
659 -outset_bottom); 659 -outset_bottom);
660 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); 660 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString());
661 661
662 // CASE 5: Setting the update rect on child2, which is above child1, will 662 // CASE 5: Setting the update rect on child2, which is above child1, will
663 // not get blurred by child1, so it does not need to get expanded. 663 // not get blurred by child1, so it does not need to get expanded.
664 ClearDamageForAllSurfaces(root.get()); 664 ClearDamageForAllSurfaces(root.get());
665 child2->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 1.f)); 665 child2->SetUpdateRect(gfx::Rect(1, 1));
666 EmulateDrawingOneFrame(root.get()); 666 EmulateDrawingOneFrame(root.get());
667 667
668 root_damage_rect = 668 root_damage_rect =
669 root->render_surface()->damage_tracker()->current_damage_rect(); 669 root->render_surface()->damage_tracker()->current_damage_rect();
670 // Damage on child2 should be: position of update_rect offset by the child's 670 // Damage on child2 should be: position of update_rect offset by the child's
671 // position (11, 11), and not expanded by anything. 671 // position (11, 11), and not expanded by anything.
672 expected_damage_rect = gfx::Rect(11, 11, 1, 1); 672 expected_damage_rect = gfx::Rect(11, 11, 1, 1);
673 673
674 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); 674 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString());
675 675
676 // CASE 6: Setting the update rect on child1 will also blur the damage, so 676 // CASE 6: Setting the update rect on child1 will also blur the damage, so
677 // that any pixels needed for the blur are redrawn in the current 677 // that any pixels needed for the blur are redrawn in the current
678 // frame. 678 // frame.
679 ClearDamageForAllSurfaces(root.get()); 679 ClearDamageForAllSurfaces(root.get());
680 child1->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 1.f)); 680 child1->SetUpdateRect(gfx::Rect(1, 1));
681 EmulateDrawingOneFrame(root.get()); 681 EmulateDrawingOneFrame(root.get());
682 682
683 root_damage_rect = 683 root_damage_rect =
684 root->render_surface()->damage_tracker()->current_damage_rect(); 684 root->render_surface()->damage_tracker()->current_damage_rect();
685 // Damage on child1 should be: position of update_rect offset by the child's 685 // Damage on child1 should be: position of update_rect offset by the child's
686 // position (100, 100), and expanded by the damage. 686 // position (100, 100), and expanded by the damage.
687 expected_damage_rect = gfx::Rect(100, 100, 1, 1); 687 expected_damage_rect = gfx::Rect(100, 100, 1, 1);
688 688
689 expected_damage_rect.Inset(-outset_left, 689 expected_damage_rect.Inset(-outset_left,
690 -outset_top, 690 -outset_top,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 child2->SetDrawsContent(true); 791 child2->SetDrawsContent(true);
792 root->AddChild(child2.Pass()); 792 root->AddChild(child2.Pass());
793 } 793 }
794 LayerImpl* child2 = root->children()[1]; 794 LayerImpl* child2 = root->children()[1];
795 EmulateDrawingOneFrame(root.get()); 795 EmulateDrawingOneFrame(root.get());
796 796
797 // Damaging two layers simultaneously should cause combined damage. 797 // Damaging two layers simultaneously should cause combined damage.
798 // - child1 update rect in surface space: gfx::Rect(100, 100, 1, 2); 798 // - child1 update rect in surface space: gfx::Rect(100, 100, 1, 2);
799 // - child2 update rect in surface space: gfx::Rect(400, 380, 3, 4); 799 // - child2 update rect in surface space: gfx::Rect(400, 380, 3, 4);
800 ClearDamageForAllSurfaces(root.get()); 800 ClearDamageForAllSurfaces(root.get());
801 child1->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 2.f)); 801 child1->SetUpdateRect(gfx::Rect(1, 2));
802 child2->SetUpdateRect(gfx::RectF(0.f, 0.f, 3.f, 4.f)); 802 child2->SetUpdateRect(gfx::Rect(3, 4));
803 EmulateDrawingOneFrame(root.get()); 803 EmulateDrawingOneFrame(root.get());
804 gfx::Rect root_damage_rect = 804 gfx::Rect root_damage_rect =
805 root->render_surface()->damage_tracker()->current_damage_rect(); 805 root->render_surface()->damage_tracker()->current_damage_rect();
806 EXPECT_EQ(gfx::Rect(100, 100, 303, 284).ToString(), 806 EXPECT_EQ(gfx::Rect(100, 100, 303, 284).ToString(),
807 root_damage_rect.ToString()); 807 root_damage_rect.ToString());
808 } 808 }
809 809
810 TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { 810 TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) {
811 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); 811 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces();
812 LayerImpl* child1 = root->children()[0]; 812 LayerImpl* child1 = root->children()[0];
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1003
1004 TEST_F(DamageTrackerTest, VerifyNoDamageForUpdateRectThatDoesNotDrawContent) { 1004 TEST_F(DamageTrackerTest, VerifyNoDamageForUpdateRectThatDoesNotDrawContent) {
1005 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); 1005 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces();
1006 LayerImpl* child1 = root->children()[0]; 1006 LayerImpl* child1 = root->children()[0];
1007 gfx::Rect child_damage_rect; 1007 gfx::Rect child_damage_rect;
1008 gfx::Rect root_damage_rect; 1008 gfx::Rect root_damage_rect;
1009 1009
1010 // In our specific tree, the update rect of child1 should not cause any 1010 // In our specific tree, the update rect of child1 should not cause any
1011 // damage to any surface because it does not actually draw content. 1011 // damage to any surface because it does not actually draw content.
1012 ClearDamageForAllSurfaces(root.get()); 1012 ClearDamageForAllSurfaces(root.get());
1013 child1->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 2.f)); 1013 child1->SetUpdateRect(gfx::Rect(1, 2));
1014 EmulateDrawingOneFrame(root.get()); 1014 EmulateDrawingOneFrame(root.get());
1015 child_damage_rect = 1015 child_damage_rect =
1016 child1->render_surface()->damage_tracker()->current_damage_rect(); 1016 child1->render_surface()->damage_tracker()->current_damage_rect();
1017 root_damage_rect = 1017 root_damage_rect =
1018 root->render_surface()->damage_tracker()->current_damage_rect(); 1018 root->render_surface()->damage_tracker()->current_damage_rect();
1019 EXPECT_TRUE(child_damage_rect.IsEmpty()); 1019 EXPECT_TRUE(child_damage_rect.IsEmpty());
1020 EXPECT_TRUE(root_damage_rect.IsEmpty()); 1020 EXPECT_TRUE(root_damage_rect.IsEmpty());
1021 } 1021 }
1022 1022
1023 TEST_F(DamageTrackerTest, VerifyDamageForReplica) { 1023 TEST_F(DamageTrackerTest, VerifyDamageForReplica) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 child->AddChild(grand_child.Pass()); 1156 child->AddChild(grand_child.Pass());
1157 } 1157 }
1158 EmulateDrawingOneFrame(root.get()); 1158 EmulateDrawingOneFrame(root.get());
1159 1159
1160 // Sanity check that a new surface was created for the child. 1160 // Sanity check that a new surface was created for the child.
1161 ASSERT_TRUE(child->render_surface()); 1161 ASSERT_TRUE(child->render_surface());
1162 1162
1163 // CASE 1: the update_rect on a mask layer should damage the entire target 1163 // CASE 1: the update_rect on a mask layer should damage the entire target
1164 // surface. 1164 // surface.
1165 ClearDamageForAllSurfaces(root.get()); 1165 ClearDamageForAllSurfaces(root.get());
1166 mask_layer->SetUpdateRect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); 1166 mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4));
1167 EmulateDrawingOneFrame(root.get()); 1167 EmulateDrawingOneFrame(root.get());
1168 gfx::Rect child_damage_rect = 1168 gfx::Rect child_damage_rect =
1169 child->render_surface()->damage_tracker()->current_damage_rect(); 1169 child->render_surface()->damage_tracker()->current_damage_rect();
1170 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); 1170 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString());
1171 1171
1172 // CASE 2: a property change on the mask layer should damage the entire 1172 // CASE 2: a property change on the mask layer should damage the entire
1173 // target surface. 1173 // target surface.
1174 1174
1175 // Advance one frame without damage so that we know the damage rect is not 1175 // Advance one frame without damage so that we know the damage rect is not
1176 // leftover from the previous case. 1176 // leftover from the previous case.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 } 1343 }
1344 1344
1345 TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { 1345 TEST_F(DamageTrackerTest, DamageWhenAddedExternally) {
1346 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); 1346 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface();
1347 LayerImpl* child = root->children()[0]; 1347 LayerImpl* child = root->children()[0];
1348 1348
1349 // Case 1: This test ensures that when the tracker is given damage, that 1349 // Case 1: This test ensures that when the tracker is given damage, that
1350 // it is included with any other partial damage. 1350 // it is included with any other partial damage.
1351 // 1351 //
1352 ClearDamageForAllSurfaces(root.get()); 1352 ClearDamageForAllSurfaces(root.get());
1353 child->SetUpdateRect(gfx::RectF(10, 11, 12, 13)); 1353 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13));
1354 root->render_surface()->damage_tracker()->AddDamageNextUpdate( 1354 root->render_surface()->damage_tracker()->AddDamageNextUpdate(
1355 gfx::Rect(15, 16, 32, 33)); 1355 gfx::Rect(15, 16, 32, 33));
1356 EmulateDrawingOneFrame(root.get()); 1356 EmulateDrawingOneFrame(root.get());
1357 gfx::Rect root_damage_rect = 1357 gfx::Rect root_damage_rect =
1358 root->render_surface()->damage_tracker()->current_damage_rect(); 1358 root->render_surface()->damage_tracker()->current_damage_rect();
1359 EXPECT_EQ(gfx::UnionRects(gfx::Rect(15, 16, 32, 33), 1359 EXPECT_EQ(gfx::UnionRects(gfx::Rect(15, 16, 32, 33),
1360 gfx::Rect(100 + 10, 100 + 11, 12, 13)).ToString(), 1360 gfx::Rect(100 + 10, 100 + 11, 12, 13)).ToString(),
1361 root_damage_rect.ToString()); 1361 root_damage_rect.ToString());
1362 1362
1363 // Case 2: An additional sanity check that adding damage works even when 1363 // Case 2: An additional sanity check that adding damage works even when
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 child->SetUpdateRect(gfx::Rect(10.f, 11.f, 1.f, 2.f)); 1406 child->SetUpdateRect(gfx::Rect(10.f, 11.f, 1.f, 2.f));
1407 EmulateDrawingOneFrame(root.get()); 1407 EmulateDrawingOneFrame(root.get());
1408 1408
1409 // Sanity check damage after the first frame; this isnt the actual test yet. 1409 // Sanity check damage after the first frame; this isnt the actual test yet.
1410 gfx::Rect root_damage_rect = 1410 gfx::Rect root_damage_rect =
1411 root->render_surface()->damage_tracker()->current_damage_rect(); 1411 root->render_surface()->damage_tracker()->current_damage_rect();
1412 EXPECT_EQ(gfx::Rect(110, 111, 1, 2).ToString(), root_damage_rect.ToString()); 1412 EXPECT_EQ(gfx::Rect(110, 111, 1, 2).ToString(), root_damage_rect.ToString());
1413 1413
1414 // New damage, without having cleared the previous damage, should be unioned 1414 // New damage, without having cleared the previous damage, should be unioned
1415 // to the previous one. 1415 // to the previous one.
1416 child->SetUpdateRect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); 1416 child->SetUpdateRect(gfx::Rect(20, 25, 1, 2));
1417 EmulateDrawingOneFrame(root.get()); 1417 EmulateDrawingOneFrame(root.get());
1418 root_damage_rect = 1418 root_damage_rect =
1419 root->render_surface()->damage_tracker()->current_damage_rect(); 1419 root->render_surface()->damage_tracker()->current_damage_rect();
1420 EXPECT_EQ(gfx::Rect(110, 111, 11, 16).ToString(), 1420 EXPECT_EQ(gfx::Rect(110, 111, 11, 16).ToString(),
1421 root_damage_rect.ToString()); 1421 root_damage_rect.ToString());
1422 1422
1423 // If we notify the damage tracker that we drew the damaged area, then damage 1423 // If we notify the damage tracker that we drew the damaged area, then damage
1424 // should be emptied. 1424 // should be emptied.
1425 root->render_surface()->damage_tracker()->DidDrawDamagedArea(); 1425 root->render_surface()->damage_tracker()->DidDrawDamagedArea();
1426 root_damage_rect = 1426 root_damage_rect =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 gfx::Rect root_damage_rect = 1462 gfx::Rect root_damage_rect =
1463 root->render_surface()->damage_tracker()->current_damage_rect(); 1463 root->render_surface()->damage_tracker()->current_damage_rect();
1464 gfx::Rect damage_we_care_about = gfx::Rect(i, i); 1464 gfx::Rect damage_we_care_about = gfx::Rect(i, i);
1465 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); 1465 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right());
1466 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); 1466 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom());
1467 } 1467 }
1468 } 1468 }
1469 1469
1470 } // namespace 1470 } // namespace
1471 } // namespace cc 1471 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/tiled_layer_test_common.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698