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

Side by Side Diff: cc/occlusion_tracker_unittest.cc

Issue 11366094: cc: Create a Region class that wraps SkRegion, to replace use of WebCore::Region. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « cc/occlusion_tracker.cc ('k') | cc/quad_culler.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/occlusion_tracker.h" 7 #include "cc/occlusion_tracker.h"
8 8
9 #include "Region.h"
10 #include "cc/layer.h" 9 #include "cc/layer.h"
11 #include "cc/layer_animation_controller.h" 10 #include "cc/layer_animation_controller.h"
12 #include "cc/layer_impl.h" 11 #include "cc/layer_impl.h"
13 #include "cc/layer_tree_host_common.h" 12 #include "cc/layer_tree_host_common.h"
14 #include "cc/math_util.h" 13 #include "cc/math_util.h"
15 #include "cc/overdraw_metrics.h" 14 #include "cc/overdraw_metrics.h"
16 #include "cc/single_thread_proxy.h" 15 #include "cc/single_thread_proxy.h"
17 #include "cc/test/animation_test_common.h" 16 #include "cc/test/animation_test_common.h"
18 #include "cc/test/geometry_test_utils.h" 17 #include "cc/test/geometry_test_utils.h"
19 #include "cc/test/occlusion_tracker_test_common.h" 18 #include "cc/test/occlusion_tracker_test_common.h"
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); 463 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
465 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, this->identityMatrix, gfx::PointF(30, 30), gfx::Size(500, 500), true); 464 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, this->identityMatrix, gfx::PointF(30, 30), gfx::Size(500, 500), true);
466 this->calcDrawEtc(parent); 465 this->calcDrawEtc(parent);
467 466
468 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 467 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
469 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 468 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
470 469
471 this->visitLayer(layer, occlusion); 470 this->visitLayer(layer, occlusion);
472 this->enterLayer(parent, occlusion); 471 this->enterLayer(parent, occlusion);
473 472
474 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpa ce().bounds()); 473 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScr eenSpace().ToString());
475 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 474 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInTar getSurface().ToString());
476 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSur face().bounds());
477 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
478 475
479 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70))); 476 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
480 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70))) ; 477 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70))) ;
481 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 29, 70, 70))) ; 478 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 29, 70, 70))) ;
482 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(31, 30, 70, 70))) ; 479 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(31, 30, 70, 70))) ;
483 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 31, 70, 70))) ; 480 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 31, 70, 70))) ;
484 481
485 occlusion.useDefaultLayerClipRect(); 482 occlusion.useDefaultLayerClipRect();
486 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70))); 483 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
487 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70))) ; 484 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70))) ;
(...skipping 28 matching lines...) Expand all
516 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::Point(0, 0), gfx::Size(100, 100)); 513 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::Point(0, 0), gfx::Size(100, 100));
517 typename Types::ContentLayerType* layer1 = this->createDrawingLayer(pare nt, layerTransform, gfx::PointF(0, 0), gfx::Size(90, 90), true); 514 typename Types::ContentLayerType* layer1 = this->createDrawingLayer(pare nt, layerTransform, gfx::PointF(0, 0), gfx::Size(90, 90), true);
518 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(laye r1, layerTransform, gfx::PointF(0, 0), gfx::Size(50, 50), true); 515 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(laye r1, layerTransform, gfx::PointF(0, 0), gfx::Size(50, 50), true);
519 this->calcDrawEtc(parent); 516 this->calcDrawEtc(parent);
520 517
521 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 518 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
522 519
523 this->visitLayer(layer2, occlusion); 520 this->visitLayer(layer2, occlusion);
524 this->enterLayer(layer1, occlusion); 521 this->enterLayer(layer1, occlusion);
525 522
526 EXPECT_RECT_EQ(gfx::Rect(20, 20, 50, 50), occlusion.occlusionInScreenSpa ce().bounds()); 523 EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(), occlusion.occlusionInScr eenSpace().ToString());
527 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 524 EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(), occlusion.occlusionInTar getSurface().ToString());
528 EXPECT_RECT_EQ(gfx::Rect(20, 20, 50, 50), occlusion.occlusionInTargetSur face().bounds());
529 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
530 525
531 // This checks cases where the quads don't match their "containing" 526 // This checks cases where the quads don't match their "containing"
532 // layers, e.g. in terms of transforms or clip rect. This is typical for 527 // layers, e.g. in terms of transforms or clip rect. This is typical for
533 // DelegatedRendererLayer. 528 // DelegatedRendererLayer.
534 529
535 WebTransformationMatrix quadTransform; 530 WebTransformationMatrix quadTransform;
536 quadTransform.translate(30, 30); 531 quadTransform.translate(30, 30);
537 gfx::Rect clipRectInTarget(0, 0, 100, 100); 532 gfx::Rect clipRectInTarget(0, 0, 100, 100);
538 533
539 EXPECT_TRUE(occlusion.unoccludedContentRect(parent, gfx::Rect(0, 0, 10, 10), quadTransform, false, clipRectInTarget).IsEmpty()); 534 EXPECT_TRUE(occlusion.unoccludedContentRect(parent, gfx::Rect(0, 0, 10, 10), quadTransform, false, clipRectInTarget).IsEmpty());
(...skipping 20 matching lines...) Expand all
560 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); 555 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
561 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, layerTransform, gfx::PointF(30, 30), gfx::Size(500, 500), true); 556 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, layerTransform, gfx::PointF(30, 30), gfx::Size(500, 500), true);
562 this->calcDrawEtc(parent); 557 this->calcDrawEtc(parent);
563 558
564 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 559 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
565 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 560 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
566 561
567 this->visitLayer(layer, occlusion); 562 this->visitLayer(layer, occlusion);
568 this->enterLayer(parent, occlusion); 563 this->enterLayer(parent, occlusion);
569 564
570 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpa ce().bounds()); 565 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScr eenSpace().ToString());
571 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 566 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInTar getSurface().ToString());
572 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSur face().bounds());
573 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
574 567
575 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70))); 568 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
576 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70))) ; 569 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70))) ;
577 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 29, 70, 70))) ; 570 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 29, 70, 70))) ;
578 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(31, 30, 70, 70))) ; 571 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(31, 30, 70, 70))) ;
579 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 31, 70, 70))) ; 572 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 31, 70, 70))) ;
580 573
581 occlusion.useDefaultLayerClipRect(); 574 occlusion.useDefaultLayerClipRect();
582 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70))); 575 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
583 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70))) ; 576 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 70, 70))) ;
(...skipping 28 matching lines...) Expand all
612 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 100)); 605 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 100));
613 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, layerTransform, gfx::PointF(30, 30), gfx::Size(500, 500), true); 606 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, layerTransform, gfx::PointF(30, 30), gfx::Size(500, 500), true);
614 this->calcDrawEtc(parent); 607 this->calcDrawEtc(parent);
615 608
616 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 609 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
617 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 610 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
618 611
619 this->visitLayer(layer, occlusion); 612 this->visitLayer(layer, occlusion);
620 this->enterLayer(parent, occlusion); 613 this->enterLayer(parent, occlusion);
621 614
622 EXPECT_RECT_EQ(gfx::Rect(50, 50, 50, 50), occlusion.occlusionInScreenSpa ce().bounds()); 615 EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), occlusion.occlusionInScr eenSpace().ToString());
623 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 616 EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), occlusion.occlusionInTar getSurface().ToString());
624 EXPECT_RECT_EQ(gfx::Rect(50, 50, 50, 50), occlusion.occlusionInTargetSur face().bounds());
625 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
626 617
627 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(50, 50, 50, 50))); 618 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(50, 50, 50, 50)));
628 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(49, 50, 50, 50))) ; 619 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(49, 50, 50, 50))) ;
629 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(50, 49, 50, 50))) ; 620 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(50, 49, 50, 50))) ;
630 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(51, 50, 50, 50))) ; 621 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(51, 50, 50, 50))) ;
631 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(50, 51, 50, 50))) ; 622 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(50, 51, 50, 50))) ;
632 623
633 occlusion.useDefaultLayerClipRect(); 624 occlusion.useDefaultLayerClipRect();
634 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(50, 50, 50, 50))); 625 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(50, 50, 50, 50)));
635 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(49, 50, 50, 50))) ; 626 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(49, 50, 50, 50))) ;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 child->setMasksToBounds(true); 672 child->setMasksToBounds(true);
682 typename Types::ContentLayerType* layer = this->createDrawingLayer(child , this->identityMatrix, gfx::PointF(10, 10), gfx::Size(500, 500), true); 673 typename Types::ContentLayerType* layer = this->createDrawingLayer(child , this->identityMatrix, gfx::PointF(10, 10), gfx::Size(500, 500), true);
683 this->calcDrawEtc(parent); 674 this->calcDrawEtc(parent);
684 675
685 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 676 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
686 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 677 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
687 678
688 this->visitLayer(layer, occlusion); 679 this->visitLayer(layer, occlusion);
689 this->enterContributingSurface(child, occlusion); 680 this->enterContributingSurface(child, occlusion);
690 681
691 EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInScreenSpa ce().bounds()); 682 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInScr eenSpace().ToString());
692 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 683 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), occlusion.occlusionInTa rgetSurface().ToString());
693 EXPECT_RECT_EQ(gfx::Rect(10, 430, 60, 70), occlusion.occlusionInTargetSu rface().bounds());
694 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
695 684
696 this->leaveContributingSurface(child, occlusion); 685 this->leaveContributingSurface(child, occlusion);
697 this->enterLayer(parent, occlusion); 686 this->enterLayer(parent, occlusion);
698 687
699 EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInScreenSpa ce().bounds()); 688 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInScr eenSpace().ToString());
700 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 689 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInTar getSurface().ToString());
701 EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInTargetSur face().bounds());
702 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
703 690
704 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 40, 70, 60))); 691 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 40, 70, 60)));
705 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 40, 70, 60))) ; 692 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 40, 70, 60))) ;
706 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 39, 70, 60))) ; 693 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 39, 70, 60))) ;
707 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(31, 40, 70, 60))) ; 694 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(31, 40, 70, 60))) ;
708 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 41, 70, 60))) ; 695 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 41, 70, 60))) ;
709 696
710 occlusion.useDefaultLayerClipRect(); 697 occlusion.useDefaultLayerClipRect();
711 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 40, 70, 60))); 698 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 40, 70, 60)));
712 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 40, 70, 60))) ; 699 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 40, 70, 60))) ;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 layer2Matrix.translate(25, 25); 750 layer2Matrix.translate(25, 25);
764 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(laye r1, layer2Matrix, gfx::PointF(0, 0), gfx::Size(50, 50), true); 751 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(laye r1, layer2Matrix, gfx::PointF(0, 0), gfx::Size(50, 50), true);
765 typename Types::ContentLayerType* occluder = this->createDrawingLayer(pa rent, this->identityMatrix, gfx::PointF(100, 100), gfx::Size(500, 500), true); 752 typename Types::ContentLayerType* occluder = this->createDrawingLayer(pa rent, this->identityMatrix, gfx::PointF(100, 100), gfx::Size(500, 500), true);
766 this->calcDrawEtc(parent); 753 this->calcDrawEtc(parent);
767 754
768 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 755 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
769 756
770 this->visitLayer(occluder, occlusion); 757 this->visitLayer(occluder, occlusion);
771 this->enterLayer(layer2, occlusion); 758 this->enterLayer(layer2, occlusion);
772 759
773 EXPECT_RECT_EQ(gfx::Rect(100, 100, 100, 100), occlusion.occlusionInScree nSpace().bounds()); 760 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), occlusion.occlusionI nScreenSpace().ToString());
774 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 761 EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().T oString());
775 EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty());
776 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
777 762
778 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), occlusion.unoccludedLayerContent Rect(layer2, gfx::Rect(0, 0, 25, 25))); 763 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), occlusion.unoccludedLayerContent Rect(layer2, gfx::Rect(0, 0, 25, 25)));
779 EXPECT_RECT_EQ(gfx::Rect(10, 25, 15, 25), occlusion.unoccludedLayerConte ntRect(layer2, gfx::Rect(10, 25, 25, 25))); 764 EXPECT_RECT_EQ(gfx::Rect(10, 25, 15, 25), occlusion.unoccludedLayerConte ntRect(layer2, gfx::Rect(10, 25, 25, 25)));
780 EXPECT_RECT_EQ(gfx::Rect(25, 10, 25, 15), occlusion.unoccludedLayerConte ntRect(layer2, gfx::Rect(25, 10, 25, 25))); 765 EXPECT_RECT_EQ(gfx::Rect(25, 10, 25, 15), occlusion.unoccludedLayerConte ntRect(layer2, gfx::Rect(25, 10, 25, 25)));
781 EXPECT_TRUE(occlusion.unoccludedLayerContentRect(layer2, gfx::Rect(25, 2 5, 25, 25)).IsEmpty()); 766 EXPECT_TRUE(occlusion.unoccludedLayerContentRect(layer2, gfx::Rect(25, 2 5, 25, 25)).IsEmpty());
782 } 767 }
783 }; 768 };
784 769
785 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledRenderSurface); 770 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledRenderSurface);
786 771
(...skipping 16 matching lines...) Expand all
803 // |child2| makes |parent|'s surface get considered by OcclusionTracker first, instead of |child|'s. This exercises different code in 788 // |child2| makes |parent|'s surface get considered by OcclusionTracker first, instead of |child|'s. This exercises different code in
804 // leaveToTargetRenderSurface, as the target surface has already been se en. 789 // leaveToTargetRenderSurface, as the target surface has already been se en.
805 typename Types::ContentLayerType* child2 = this->createDrawingLayer(pare nt, this->identityMatrix, gfx::PointF(30, 30), gfx::Size(60, 20), true); 790 typename Types::ContentLayerType* child2 = this->createDrawingLayer(pare nt, this->identityMatrix, gfx::PointF(30, 30), gfx::Size(60, 20), true);
806 this->calcDrawEtc(parent); 791 this->calcDrawEtc(parent);
807 792
808 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 793 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
809 occlusion.setLayerClipRect(gfx::Rect(-10, -10, 1000, 1000)); 794 occlusion.setLayerClipRect(gfx::Rect(-10, -10, 1000, 1000));
810 795
811 this->visitLayer(child2, occlusion); 796 this->visitLayer(child2, occlusion);
812 797
813 EXPECT_RECT_EQ(gfx::Rect(30, 30, 60, 20), occlusion.occlusionInScreenSpa ce().bounds()); 798 EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(), occlusion.occlusionInScr eenSpace().ToString());
814 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 799 EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(), occlusion.occlusionInTar getSurface().ToString());
815 EXPECT_RECT_EQ(gfx::Rect(30, 30, 60, 20), occlusion.occlusionInTargetSur face().bounds());
816 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
817 800
818 this->visitLayer(layer, occlusion); 801 this->visitLayer(layer, occlusion);
819 802
820 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpa ce().bounds()); 803 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)).ToString(), occlusion.occlusionInScreenSpace().ToString());
821 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 804 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), occlusion.occlusionInTa rgetSurface().ToString());
822 EXPECT_RECT_EQ(gfx::Rect(10, 430, 60, 70), occlusion.occlusionInTargetSu rface().bounds());
823 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
824 805
825 this->enterContributingSurface(child, occlusion); 806 this->enterContributingSurface(child, occlusion);
826 807
827 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpa ce().bounds()); 808 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)).ToString(), occlusion.occlusionInScreenSpace().ToString());
828 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 809 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), occlusion.occlusionInTa rgetSurface().ToString());
829 EXPECT_RECT_EQ(gfx::Rect(10, 430, 60, 70), occlusion.occlusionInTargetSu rface().bounds());
830 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
831 810
832 // Occlusion in |child2| should get merged with the |child| surface we a re leaving now. 811 // Occlusion in |child2| should get merged with the |child| surface we a re leaving now.
833 this->leaveContributingSurface(child, occlusion); 812 this->leaveContributingSurface(child, occlusion);
834 this->enterLayer(parent, occlusion); 813 this->enterLayer(parent, occlusion);
835 814
836 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpa ce().bounds()); 815 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)).ToString(), occlusion.occlusionInScreenSpace().ToString());
837 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 816 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)).ToString(), occlusion.occlusionInTargetSurface().ToString());
838 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSur face().bounds());
839 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
840 817
841 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70))) ; 818 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 70, 70))) ;
842 EXPECT_RECT_EQ(gfx::Rect(90, 30, 10, 10), occlusion.unoccludedLayerConte ntRect(parent, gfx::Rect(30, 30, 70, 70))); 819 EXPECT_RECT_EQ(gfx::Rect(90, 30, 10, 10), occlusion.unoccludedLayerConte ntRect(parent, gfx::Rect(30, 30, 70, 70)));
843 820
844 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 60, 10))); 821 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 30, 60, 10)));
845 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 60, 10))) ; 822 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 30, 60, 10))) ;
846 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 29, 60, 10))) ; 823 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 29, 60, 10))) ;
847 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(31, 30, 60, 10))) ; 824 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(31, 30, 60, 10))) ;
848 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 31, 60, 10))); 825 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 31, 60, 10)));
849 826
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 this->calcDrawEtc(parent); 895 this->calcDrawEtc(parent);
919 896
920 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 897 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
921 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 898 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
922 899
923 gfx::Rect clippedLayerInChild = MathUtil::mapClippedRect(layerTransform, layer->visibleContentRect()); 900 gfx::Rect clippedLayerInChild = MathUtil::mapClippedRect(layerTransform, layer->visibleContentRect());
924 901
925 this->visitLayer(layer, occlusion); 902 this->visitLayer(layer, occlusion);
926 this->enterContributingSurface(child, occlusion); 903 this->enterContributingSurface(child, occlusion);
927 904
928 EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInScreenSpace().bounds()) ; 905 EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInScreenSpace().ToS tring());
929 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 906 EXPECT_EQ(clippedLayerInChild.ToString(), occlusion.occlusionInTargetSur face().ToString());
930 EXPECT_RECT_EQ(clippedLayerInChild, occlusion.occlusionInTargetSurface() .bounds());
931 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
932 907
933 EXPECT_TRUE(occlusion.occludedLayer(child, clippedLayerInChild)); 908 EXPECT_TRUE(occlusion.occludedLayer(child, clippedLayerInChild));
934 EXPECT_TRUE(occlusion.unoccludedLayerContentRect(child, clippedLayerInCh ild).IsEmpty()); 909 EXPECT_TRUE(occlusion.unoccludedLayerContentRect(child, clippedLayerInCh ild).IsEmpty());
935 clippedLayerInChild.Offset(-1, 0); 910 clippedLayerInChild.Offset(-1, 0);
936 EXPECT_FALSE(occlusion.occludedLayer(child, clippedLayerInChild)); 911 EXPECT_FALSE(occlusion.occludedLayer(child, clippedLayerInChild));
937 EXPECT_FALSE(occlusion.unoccludedLayerContentRect(child, clippedLayerInC hild).IsEmpty()); 912 EXPECT_FALSE(occlusion.unoccludedLayerContentRect(child, clippedLayerInC hild).IsEmpty());
938 clippedLayerInChild.Offset(1, 0); 913 clippedLayerInChild.Offset(1, 0);
939 clippedLayerInChild.Offset(1, 0); 914 clippedLayerInChild.Offset(1, 0);
940 EXPECT_FALSE(occlusion.occludedLayer(child, clippedLayerInChild)); 915 EXPECT_FALSE(occlusion.occludedLayer(child, clippedLayerInChild));
941 EXPECT_FALSE(occlusion.unoccludedLayerContentRect(child, clippedLayerInC hild).IsEmpty()); 916 EXPECT_FALSE(occlusion.unoccludedLayerContentRect(child, clippedLayerInC hild).IsEmpty());
942 clippedLayerInChild.Offset(-1, 0); 917 clippedLayerInChild.Offset(-1, 0);
943 clippedLayerInChild.Offset(0, -1); 918 clippedLayerInChild.Offset(0, -1);
944 EXPECT_FALSE(occlusion.occludedLayer(child, clippedLayerInChild)); 919 EXPECT_FALSE(occlusion.occludedLayer(child, clippedLayerInChild));
945 EXPECT_FALSE(occlusion.unoccludedLayerContentRect(child, clippedLayerInC hild).IsEmpty()); 920 EXPECT_FALSE(occlusion.unoccludedLayerContentRect(child, clippedLayerInC hild).IsEmpty());
946 clippedLayerInChild.Offset(0, 1); 921 clippedLayerInChild.Offset(0, 1);
947 clippedLayerInChild.Offset(0, 1); 922 clippedLayerInChild.Offset(0, 1);
948 EXPECT_FALSE(occlusion.occludedLayer(child, clippedLayerInChild)); 923 EXPECT_FALSE(occlusion.occludedLayer(child, clippedLayerInChild));
949 EXPECT_FALSE(occlusion.unoccludedLayerContentRect(child, clippedLayerInC hild).IsEmpty()); 924 EXPECT_FALSE(occlusion.unoccludedLayerContentRect(child, clippedLayerInC hild).IsEmpty());
950 clippedLayerInChild.Offset(0, -1); 925 clippedLayerInChild.Offset(0, -1);
951 926
952 this->leaveContributingSurface(child, occlusion); 927 this->leaveContributingSurface(child, occlusion);
953 this->enterLayer(parent, occlusion); 928 this->enterLayer(parent, occlusion);
954 929
955 EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInScreenSpace().bounds()) ; 930 EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInScreenSpace().ToS tring());
956 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 931 EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().T oString());
957 EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInTargetSurface().bounds( ));
958 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
959 932
960 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(75, 55, 1, 1))); 933 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(75, 55, 1, 1)));
961 EXPECT_RECT_EQ(gfx::Rect(75, 55, 1, 1), occlusion.unoccludedLayerContent Rect(parent, gfx::Rect(75, 55, 1, 1))); 934 EXPECT_RECT_EQ(gfx::Rect(75, 55, 1, 1), occlusion.unoccludedLayerContent Rect(parent, gfx::Rect(75, 55, 1, 1)));
962 } 935 }
963 }; 936 };
964 937
965 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceRotatedOffAxis); 938 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceRotatedOffAxis);
966 939
967 template<class Types> 940 template<class Types>
968 class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren : public OcclusionTracker Test<Types> { 941 class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren : public OcclusionTracker Test<Types> {
(...skipping 14 matching lines...) Expand all
983 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(chil d, this->identityMatrix, gfx::PointF(10, 450), gfx::Size(500, 60), true); 956 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(chil d, this->identityMatrix, gfx::PointF(10, 450), gfx::Size(500, 60), true);
984 this->calcDrawEtc(parent); 957 this->calcDrawEtc(parent);
985 958
986 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 959 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
987 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 960 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
988 961
989 this->visitLayer(layer2, occlusion); 962 this->visitLayer(layer2, occlusion);
990 this->visitLayer(layer1, occlusion); 963 this->visitLayer(layer1, occlusion);
991 this->enterContributingSurface(child, occlusion); 964 this->enterContributingSurface(child, occlusion);
992 965
993 EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInScreenSpa ce().bounds()); 966 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInScr eenSpace().ToString());
994 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 967 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), occlusion.occlusionInTa rgetSurface().ToString());
995 EXPECT_RECT_EQ(gfx::Rect(10, 430, 60, 70), occlusion.occlusionInTargetSu rface().bounds());
996 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
997 968
998 EXPECT_TRUE(occlusion.occludedLayer(child, gfx::Rect(10, 430, 60, 70))); 969 EXPECT_TRUE(occlusion.occludedLayer(child, gfx::Rect(10, 430, 60, 70)));
999 EXPECT_FALSE(occlusion.occludedLayer(child, gfx::Rect(9, 430, 60, 70))); 970 EXPECT_FALSE(occlusion.occludedLayer(child, gfx::Rect(9, 430, 60, 70)));
1000 EXPECT_FALSE(occlusion.occludedLayer(child, gfx::Rect(10, 429, 60, 70))) ; 971 EXPECT_FALSE(occlusion.occludedLayer(child, gfx::Rect(10, 429, 60, 70))) ;
1001 EXPECT_FALSE(occlusion.occludedLayer(child, gfx::Rect(11, 430, 60, 70))) ; 972 EXPECT_FALSE(occlusion.occludedLayer(child, gfx::Rect(11, 430, 60, 70))) ;
1002 EXPECT_FALSE(occlusion.occludedLayer(child, gfx::Rect(10, 431, 60, 70))) ; 973 EXPECT_FALSE(occlusion.occludedLayer(child, gfx::Rect(10, 431, 60, 70))) ;
1003 974
1004 EXPECT_TRUE(occlusion.unoccludedLayerContentRect(child, gfx::Rect(10, 43 0, 60, 70)).IsEmpty()); 975 EXPECT_TRUE(occlusion.unoccludedLayerContentRect(child, gfx::Rect(10, 43 0, 60, 70)).IsEmpty());
1005 EXPECT_RECT_EQ(gfx::Rect(9, 430, 1, 70), occlusion.unoccludedLayerConten tRect(child, gfx::Rect(9, 430, 60, 70))); 976 EXPECT_RECT_EQ(gfx::Rect(9, 430, 1, 70), occlusion.unoccludedLayerConten tRect(child, gfx::Rect(9, 430, 60, 70)));
1006 EXPECT_RECT_EQ(gfx::Rect(10, 429, 60, 1), occlusion.unoccludedLayerConte ntRect(child, gfx::Rect(10, 429, 60, 70))); 977 EXPECT_RECT_EQ(gfx::Rect(10, 429, 60, 1), occlusion.unoccludedLayerConte ntRect(child, gfx::Rect(10, 429, 60, 70)));
1007 EXPECT_RECT_EQ(gfx::Rect(70, 430, 1, 70), occlusion.unoccludedLayerConte ntRect(child, gfx::Rect(11, 430, 60, 70))); 978 EXPECT_RECT_EQ(gfx::Rect(70, 430, 1, 70), occlusion.unoccludedLayerConte ntRect(child, gfx::Rect(11, 430, 60, 70)));
1008 EXPECT_RECT_EQ(gfx::Rect(10, 500, 60, 1), occlusion.unoccludedLayerConte ntRect(child, gfx::Rect(10, 431, 60, 70))); 979 EXPECT_RECT_EQ(gfx::Rect(10, 500, 60, 1), occlusion.unoccludedLayerConte ntRect(child, gfx::Rect(10, 431, 60, 70)));
1009 980
1010 this->leaveContributingSurface(child, occlusion); 981 this->leaveContributingSurface(child, occlusion);
1011 this->enterLayer(parent, occlusion); 982 this->enterLayer(parent, occlusion);
1012 983
1013 EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInScreenSpa ce().bounds()); 984 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1014 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 985 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), occlusion.occlusionInTar getSurface().ToString());
1015 EXPECT_RECT_EQ(gfx::Rect(30, 40, 70, 60), occlusion.occlusionInTargetSur face().bounds());
1016 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1017 986
1018 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 40, 70, 60))); 987 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 40, 70, 60)));
1019 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 40, 70, 60))) ; 988 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 40, 70, 60))) ;
1020 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 39, 70, 60))) ; 989 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 39, 70, 60))) ;
1021 990
1022 EXPECT_TRUE(occlusion.unoccludedLayerContentRect(parent, gfx::Rect(30, 4 0, 70, 60)).IsEmpty()); 991 EXPECT_TRUE(occlusion.unoccludedLayerContentRect(parent, gfx::Rect(30, 4 0, 70, 60)).IsEmpty());
1023 EXPECT_RECT_EQ(gfx::Rect(29, 40, 1, 60), occlusion.unoccludedLayerConten tRect(parent, gfx::Rect(29, 40, 70, 60))); 992 EXPECT_RECT_EQ(gfx::Rect(29, 40, 1, 60), occlusion.unoccludedLayerConten tRect(parent, gfx::Rect(29, 40, 70, 60)));
1024 EXPECT_RECT_EQ(gfx::Rect(30, 39, 70, 1), occlusion.unoccludedLayerConten tRect(parent, gfx::Rect(30, 39, 70, 60))); 993 EXPECT_RECT_EQ(gfx::Rect(30, 39, 70, 1), occlusion.unoccludedLayerConten tRect(parent, gfx::Rect(30, 39, 70, 60)));
1025 EXPECT_RECT_EQ(gfx::Rect(100, 40, 1, 60), occlusion.unoccludedLayerConte ntRect(parent, gfx::Rect(31, 40, 70, 60))); 994 EXPECT_RECT_EQ(gfx::Rect(100, 40, 1, 60), occlusion.unoccludedLayerConte ntRect(parent, gfx::Rect(31, 40, 70, 60)));
1026 EXPECT_RECT_EQ(gfx::Rect(30, 100, 70, 1), occlusion.unoccludedLayerConte ntRect(parent, gfx::Rect(30, 41, 70, 60))); 995 EXPECT_RECT_EQ(gfx::Rect(30, 100, 70, 1), occlusion.unoccludedLayerConte ntRect(parent, gfx::Rect(30, 41, 70, 60)));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 typename Types::ContentLayerType* layer1 = this->createDrawingLayer(chil d1, this->identityMatrix, gfx::PointF(-10, -10), gfx::Size(510, 510), true); 1041 typename Types::ContentLayerType* layer1 = this->createDrawingLayer(chil d1, this->identityMatrix, gfx::PointF(-10, -10), gfx::Size(510, 510), true);
1073 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(chil d2, this->identityMatrix, gfx::PointF(-10, -10), gfx::Size(510, 510), true); 1042 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(chil d2, this->identityMatrix, gfx::PointF(-10, -10), gfx::Size(510, 510), true);
1074 this->calcDrawEtc(parent); 1043 this->calcDrawEtc(parent);
1075 1044
1076 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 1045 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
1077 occlusion.setLayerClipRect(gfx::Rect(-20, -20, 1000, 1000)); 1046 occlusion.setLayerClipRect(gfx::Rect(-20, -20, 1000, 1000));
1078 1047
1079 this->visitLayer(layer2, occlusion); 1048 this->visitLayer(layer2, occlusion);
1080 this->enterContributingSurface(child2, occlusion); 1049 this->enterContributingSurface(child2, occlusion);
1081 1050
1082 EXPECT_RECT_EQ(gfx::Rect(20, 30, 80, 70), occlusion.occlusionInScreenSpa ce().bounds()); 1051 EXPECT_EQ(gfx::Rect(20, 30, 80, 70).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1083 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1052 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), occlusion.occlusionInT argetSurface().ToString());
1084 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), occlusion.occlusionInTargetS urface().bounds());
1085 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1086 1053
1087 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 80)) ); 1054 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 80)) );
1088 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-11, 420, 70, 80) )); 1055 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-11, 420, 70, 80) ));
1089 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 419, 70, 80) )); 1056 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 419, 70, 80) ));
1090 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 71, 80) )); 1057 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 71, 80) ));
1091 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 81) )); 1058 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 81) ));
1092 1059
1093 occlusion.useDefaultLayerClipRect(); 1060 occlusion.useDefaultLayerClipRect();
1094 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 80)) ); 1061 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 80)) );
1095 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-11, 420, 70, 80)) ); 1062 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-11, 420, 70, 80)) );
1096 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 419, 70, 80)) ); 1063 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 419, 70, 80)) );
1097 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 71, 80)) ); 1064 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 71, 80)) );
1098 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 81)) ); 1065 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 81)) );
1099 occlusion.setLayerClipRect(gfx::Rect(-20, -20, 1000, 1000)); 1066 occlusion.setLayerClipRect(gfx::Rect(-20, -20, 1000, 1000));
1100 1067
1101 // There is nothing above child2's surface in the z-order. 1068 // There is nothing above child2's surface in the z-order.
1102 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), occlusion.unoccludedContribu tingSurfaceContentRect(child2, false, gfx::Rect(-10, 420, 70, 80))); 1069 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), occlusion.unoccludedContribu tingSurfaceContentRect(child2, false, gfx::Rect(-10, 420, 70, 80)));
1103 1070
1104 this->leaveContributingSurface(child2, occlusion); 1071 this->leaveContributingSurface(child2, occlusion);
1105 this->visitLayer(layer1, occlusion); 1072 this->visitLayer(layer1, occlusion);
1106 this->enterContributingSurface(child1, occlusion); 1073 this->enterContributingSurface(child1, occlusion);
1107 1074
1108 EXPECT_RECT_EQ(gfx::Rect(20, 20, 80, 80), occlusion.occlusionInScreenSpa ce().bounds()); 1075 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)).ToString(), occlusion.occlusionInScreenSpace().ToString());
1109 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1076 EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(), occlusion.occlusionInT argetSurface().ToString());
1110 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 80, 70), occlusion.occlusionInTargetS urface().bounds());
1111 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1112 1077
1113 EXPECT_TRUE(occlusion.occludedLayer(child1, gfx::Rect(-10, 430, 80, 70)) ); 1078 EXPECT_TRUE(occlusion.occludedLayer(child1, gfx::Rect(-10, 430, 80, 70)) );
1114 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(-11, 430, 80, 70) )); 1079 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(-11, 430, 80, 70) ));
1115 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(-10, 429, 80, 70) )); 1080 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(-10, 429, 80, 70) ));
1116 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(-10, 430, 81, 70) )); 1081 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(-10, 430, 81, 70) ));
1117 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(-10, 430, 80, 71) )); 1082 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(-10, 430, 80, 71) ));
1118 1083
1119 // child2's contents will occlude child1 below it. 1084 // child2's contents will occlude child1 below it.
1120 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70), occlusion.unoccludedContribu tingSurfaceContentRect(child1, false, gfx::Rect(-10, 430, 80, 70))); 1085 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70), occlusion.unoccludedContribu tingSurfaceContentRect(child1, false, gfx::Rect(-10, 430, 80, 70)));
1121 1086
1122 this->leaveContributingSurface(child1, occlusion); 1087 this->leaveContributingSurface(child1, occlusion);
1123 this->enterLayer(parent, occlusion); 1088 this->enterLayer(parent, occlusion);
1124 1089
1125 EXPECT_RECT_EQ(gfx::Rect(20, 20, 80, 80), occlusion.occlusionInScreenSpa ce().bounds()); 1090 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)).ToString(), occlusion.occlusionInScreenSpace().ToString());
1126 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1091 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)).ToString(), occlusion.occlusionInTargetSurface().ToString());
1127 EXPECT_RECT_EQ(gfx::Rect(20, 20, 80, 80), occlusion.occlusionInTargetSur face().bounds());
1128 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1129 1092
1130 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(20, 20, 80, 80))) ; 1093 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(20, 20, 80, 80))) ;
1131 1094
1132 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 20, 70, 80))); 1095 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(30, 20, 70, 80)));
1133 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 20, 70, 80))) ; 1096 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(29, 20, 70, 80))) ;
1134 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 19, 70, 80))) ; 1097 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(30, 19, 70, 80))) ;
1135 1098
1136 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(20, 30, 80, 70))); 1099 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(20, 30, 80, 70)));
1137 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(19, 30, 80, 70))) ; 1100 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(19, 30, 80, 70))) ;
1138 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(20, 29, 80, 70))) ; 1101 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(20, 29, 80, 70))) ;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 typename Types::ContentLayerType* layer1 = this->createDrawingLayer(chil d1, this->identityMatrix, gfx::PointF(-10, -20), gfx::Size(510, 510), true); 1151 typename Types::ContentLayerType* layer1 = this->createDrawingLayer(chil d1, this->identityMatrix, gfx::PointF(-10, -20), gfx::Size(510, 510), true);
1189 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(chil d2, this->identityMatrix, gfx::PointF(-10, -10), gfx::Size(510, 510), true); 1152 typename Types::ContentLayerType* layer2 = this->createDrawingLayer(chil d2, this->identityMatrix, gfx::PointF(-10, -10), gfx::Size(510, 510), true);
1190 this->calcDrawEtc(parent); 1153 this->calcDrawEtc(parent);
1191 1154
1192 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 1155 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
1193 occlusion.setLayerClipRect(gfx::Rect(-30, -30, 1000, 1000)); 1156 occlusion.setLayerClipRect(gfx::Rect(-30, -30, 1000, 1000));
1194 1157
1195 this->visitLayer(layer2, occlusion); 1158 this->visitLayer(layer2, occlusion);
1196 this->enterLayer(child2, occlusion); 1159 this->enterLayer(child2, occlusion);
1197 1160
1198 EXPECT_RECT_EQ(gfx::Rect(20, 30, 80, 70), occlusion.occlusionInScreenSpa ce().bounds()); 1161 EXPECT_EQ(gfx::Rect(20, 30, 80, 70).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1199 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1162 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), occlusion.occlusionInT argetSurface().ToString());
1200 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), occlusion.occlusionInTargetS urface().bounds());
1201 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1202 1163
1203 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 80)) ); 1164 EXPECT_TRUE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 80)) );
1204 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-11, 420, 70, 80) )); 1165 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-11, 420, 70, 80) ));
1205 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 419, 70, 80) )); 1166 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 419, 70, 80) ));
1206 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 71, 80) )); 1167 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 71, 80) ));
1207 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 81) )); 1168 EXPECT_FALSE(occlusion.occludedLayer(child2, gfx::Rect(-10, 420, 70, 81) ));
1208 1169
1209 this->leaveLayer(child2, occlusion); 1170 this->leaveLayer(child2, occlusion);
1210 this->enterContributingSurface(child2, occlusion); 1171 this->enterContributingSurface(child2, occlusion);
1211 1172
1212 // There is nothing above child2's surface in the z-order. 1173 // There is nothing above child2's surface in the z-order.
1213 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), occlusion.unoccludedContribu tingSurfaceContentRect(child2, false, gfx::Rect(-10, 420, 70, 80))); 1174 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), occlusion.unoccludedContribu tingSurfaceContentRect(child2, false, gfx::Rect(-10, 420, 70, 80)));
1214 1175
1215 this->leaveContributingSurface(child2, occlusion); 1176 this->leaveContributingSurface(child2, occlusion);
1216 this->visitLayer(layer1, occlusion); 1177 this->visitLayer(layer1, occlusion);
1217 this->enterContributingSurface(child1, occlusion); 1178 this->enterContributingSurface(child1, occlusion);
1218 1179
1219 EXPECT_RECT_EQ(gfx::Rect(10, 20, 90, 80), occlusion.occlusionInScreenSpa ce().bounds()); 1180 EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1220 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1181 EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), occlusion.occlusionInT argetSurface().ToString());
1221 EXPECT_RECT_EQ(gfx::Rect(420, -20, 80, 90), occlusion.occlusionInTargetS urface().bounds());
1222 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1223 1182
1224 EXPECT_TRUE(occlusion.occludedLayer(child1, gfx::Rect(420, -20, 80, 90)) ); 1183 EXPECT_TRUE(occlusion.occludedLayer(child1, gfx::Rect(420, -20, 80, 90)) );
1225 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(419, -20, 80, 90) )); 1184 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(419, -20, 80, 90) ));
1226 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(420, -21, 80, 90) )); 1185 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(420, -21, 80, 90) ));
1227 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(420, -19, 80, 90) )); 1186 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(420, -19, 80, 90) ));
1228 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(421, -20, 80, 90) )); 1187 EXPECT_FALSE(occlusion.occludedLayer(child1, gfx::Rect(421, -20, 80, 90) ));
1229 1188
1230 // child2's contents will occlude child1 below it. 1189 // child2's contents will occlude child1 below it.
1231 EXPECT_RECT_EQ(gfx::Rect(420, -20, 80, 90), occlusion.unoccludedContribu tingSurfaceContentRect(child1, false, gfx::Rect(420, -20, 80, 90))); 1190 EXPECT_RECT_EQ(gfx::Rect(420, -20, 80, 90), occlusion.unoccludedContribu tingSurfaceContentRect(child1, false, gfx::Rect(420, -20, 80, 90)));
1232 EXPECT_RECT_EQ(gfx::Rect(490, -10, 10, 80), occlusion.unoccludedContribu tingSurfaceContentRect(child1, false, gfx::Rect(420, -10, 80, 90))); 1191 EXPECT_RECT_EQ(gfx::Rect(490, -10, 10, 80), occlusion.unoccludedContribu tingSurfaceContentRect(child1, false, gfx::Rect(420, -10, 80, 90)));
1233 EXPECT_RECT_EQ(gfx::Rect(420, -20, 70, 10), occlusion.unoccludedContribu tingSurfaceContentRect(child1, false, gfx::Rect(420, -20, 70, 90))); 1192 EXPECT_RECT_EQ(gfx::Rect(420, -20, 70, 10), occlusion.unoccludedContribu tingSurfaceContentRect(child1, false, gfx::Rect(420, -20, 70, 90)));
1234 1193
1235 this->leaveContributingSurface(child1, occlusion); 1194 this->leaveContributingSurface(child1, occlusion);
1236 this->enterLayer(parent, occlusion); 1195 this->enterLayer(parent, occlusion);
1237 1196
1238 EXPECT_RECT_EQ(gfx::Rect(10, 20, 90, 80), occlusion.occlusionInScreenSpa ce().bounds()); 1197 EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1239 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1198 EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), occlusion.occlusionInTar getSurface().ToString());
1240 EXPECT_RECT_EQ(gfx::Rect(10, 20, 90, 80), occlusion.occlusionInTargetSur face().bounds());
1241 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1242 1199
1243 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(10, 20, 90, 80))); 1200 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(10, 20, 90, 80)));
1244 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(9, 20, 90, 80))); 1201 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(9, 20, 90, 80)));
1245 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(10, 19, 90, 80))) ; 1202 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(10, 19, 90, 80))) ;
1246 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(11, 20, 90, 80))) ; 1203 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(11, 20, 90, 80))) ;
1247 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(10, 21, 90, 80))) ; 1204 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(10, 21, 90, 80))) ;
1248 1205
1249 /* Justification for the above occlusion: 1206 /* Justification for the above occlusion:
1250 100 1207 100
1251 +---------------------+ 1208 +---------------------+
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 1274
1318 // And has nothing to contribute to its parent surface. 1275 // And has nothing to contribute to its parent surface.
1319 this->leaveContributingSurface(opacityLayer, occlusion); 1276 this->leaveContributingSurface(opacityLayer, occlusion);
1320 EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty()); 1277 EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty());
1321 EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty()); 1278 EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty());
1322 1279
1323 // Opaque layer will contribute to occlusion. 1280 // Opaque layer will contribute to occlusion.
1324 this->visitLayer(opaqueLayer, occlusion); 1281 this->visitLayer(opaqueLayer, occlusion);
1325 this->enterContributingSurface(opaqueLayer, occlusion); 1282 this->enterContributingSurface(opaqueLayer, occlusion);
1326 1283
1327 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpa ce().bounds()); 1284 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1328 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1285 EXPECT_EQ(gfx::Rect(0, 430, 70, 70).ToString(), occlusion.occlusionInTar getSurface().ToString());
1329 EXPECT_RECT_EQ(gfx::Rect(0, 430, 70, 70), occlusion.occlusionInTargetSur face().bounds());
1330 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1331 1286
1332 // And it gets translated to the parent surface. 1287 // And it gets translated to the parent surface.
1333 this->leaveContributingSurface(opaqueLayer, occlusion); 1288 this->leaveContributingSurface(opaqueLayer, occlusion);
1334 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpa ce().bounds()); 1289 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1335 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1290 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInTar getSurface().ToString());
1336 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSur face().bounds());
1337 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1338 1291
1339 // The blur layer needs to throw away any occlusion from outside its sub tree. 1292 // The blur layer needs to throw away any occlusion from outside its sub tree.
1340 this->enterLayer(blurLayer, occlusion); 1293 this->enterLayer(blurLayer, occlusion);
1341 EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty()); 1294 EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty());
1342 EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty()); 1295 EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty());
1343 1296
1344 // And it won't contribute to occlusion. 1297 // And it won't contribute to occlusion.
1345 this->leaveLayer(blurLayer, occlusion); 1298 this->leaveLayer(blurLayer, occlusion);
1346 this->enterContributingSurface(blurLayer, occlusion); 1299 this->enterContributingSurface(blurLayer, occlusion);
1347 EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty()); 1300 EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty());
1348 EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty()); 1301 EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty());
1349 1302
1350 // But the opaque layer's occlusion is preserved on the parent. 1303 // But the opaque layer's occlusion is preserved on the parent.
1351 this->leaveContributingSurface(blurLayer, occlusion); 1304 this->leaveContributingSurface(blurLayer, occlusion);
1352 this->enterLayer(parent, occlusion); 1305 this->enterLayer(parent, occlusion);
1353 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInScreenSpa ce().bounds()); 1306 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1354 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1307 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), occlusion.occlusionInTar getSurface().ToString());
1355 EXPECT_RECT_EQ(gfx::Rect(30, 30, 70, 70), occlusion.occlusionInTargetSur face().bounds());
1356 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1357 } 1308 }
1358 }; 1309 };
1359 1310
1360 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters); 1311 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters);
1361 1312
1362 template<class Types> 1313 template<class Types>
1363 class OcclusionTrackerTestReplicaDoesOcclude : public OcclusionTrackerTest<Types > { 1314 class OcclusionTrackerTestReplicaDoesOcclude : public OcclusionTrackerTest<Types > {
1364 protected: 1315 protected:
1365 OcclusionTrackerTestReplicaDoesOcclude(bool opaqueLayers) : OcclusionTracker Test<Types>(opaqueLayers) {} 1316 OcclusionTrackerTestReplicaDoesOcclude(bool opaqueLayers) : OcclusionTracker Test<Types>(opaqueLayers) {}
1366 void runMyTest() 1317 void runMyTest()
1367 { 1318 {
1368 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 200)); 1319 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 200));
1369 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 100), gfx::Size(50, 50), true); 1320 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 100), gfx::Size(50, 50), true);
1370 this->createReplicaLayer(surface, this->identityMatrix, gfx::PointF(50, 50), gfx::Size()); 1321 this->createReplicaLayer(surface, this->identityMatrix, gfx::PointF(50, 50), gfx::Size());
1371 this->calcDrawEtc(parent); 1322 this->calcDrawEtc(parent);
1372 1323
1373 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 1324 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
1374 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 1325 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
1375 1326
1376 this->visitLayer(surface, occlusion); 1327 this->visitLayer(surface, occlusion);
1377 1328
1378 EXPECT_RECT_EQ(gfx::Rect(0, 100, 50, 50), occlusion.occlusionInScreenSpa ce().bounds()); 1329 EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1379 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1330 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), occlusion.occlusionInTarge tSurface().ToString());
1380 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), occlusion.occlusionInTargetSurfa ce().bounds());
1381 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1382 1331
1383 this->visitContributingSurface(surface, occlusion); 1332 this->visitContributingSurface(surface, occlusion);
1384 this->enterLayer(parent, occlusion); 1333 this->enterLayer(parent, occlusion);
1385 1334
1386 // The surface and replica should both be occluding the parent. 1335 // The surface and replica should both be occluding the parent.
1387 EXPECT_RECT_EQ(gfx::Rect(0, 100, 100, 100), occlusion.occlusionInTargetS urface().bounds()); 1336 EXPECT_EQ(UnionRegions(gfx::Rect(0, 100, 50, 50), gfx::Rect(50, 150, 50, 50)).ToString(), occlusion.occlusionInTargetSurface().ToString());
1388 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1389 } 1337 }
1390 }; 1338 };
1391 1339
1392 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude); 1340 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude);
1393 1341
1394 template<class Types> 1342 template<class Types>
1395 class OcclusionTrackerTestReplicaWithClipping : public OcclusionTrackerTest<Type s> { 1343 class OcclusionTrackerTestReplicaWithClipping : public OcclusionTrackerTest<Type s> {
1396 protected: 1344 protected:
1397 OcclusionTrackerTestReplicaWithClipping(bool opaqueLayers) : OcclusionTracke rTest<Types>(opaqueLayers) {} 1345 OcclusionTrackerTestReplicaWithClipping(bool opaqueLayers) : OcclusionTracke rTest<Types>(opaqueLayers) {}
1398 void runMyTest() 1346 void runMyTest()
1399 { 1347 {
1400 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 170)); 1348 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 170));
1401 parent->setMasksToBounds(true); 1349 parent->setMasksToBounds(true);
1402 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 100), gfx::Size(50, 50), true); 1350 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 100), gfx::Size(50, 50), true);
1403 this->createReplicaLayer(surface, this->identityMatrix, gfx::PointF(50, 50), gfx::Size()); 1351 this->createReplicaLayer(surface, this->identityMatrix, gfx::PointF(50, 50), gfx::Size());
1404 this->calcDrawEtc(parent); 1352 this->calcDrawEtc(parent);
1405 1353
1406 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 1354 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
1407 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 1355 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
1408 1356
1409 this->visitLayer(surface, occlusion); 1357 this->visitLayer(surface, occlusion);
1410 1358
1411 EXPECT_RECT_EQ(gfx::Rect(0, 100, 50, 50), occlusion.occlusionInScreenSpa ce().bounds()); 1359 EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1412 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1360 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), occlusion.occlusionInTarge tSurface().ToString());
1413 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), occlusion.occlusionInTargetSurfa ce().bounds());
1414 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1415 1361
1416 this->visitContributingSurface(surface, occlusion); 1362 this->visitContributingSurface(surface, occlusion);
1417 this->enterLayer(parent, occlusion); 1363 this->enterLayer(parent, occlusion);
1418 1364
1419 // The surface and replica should both be occluding the parent. 1365 // The surface and replica should both be occluding the parent.
1420 EXPECT_RECT_EQ(gfx::Rect(0, 100, 100, 70), occlusion.occlusionInTargetSu rface().bounds()); 1366 EXPECT_EQ(UnionRegions(gfx::Rect(0, 100, 50, 50), gfx::Rect(50, 150, 50, 20)).ToString(), occlusion.occlusionInTargetSurface().ToString());
1421 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1422 } 1367 }
1423 }; 1368 };
1424 1369
1425 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping); 1370 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping);
1426 1371
1427 template<class Types> 1372 template<class Types>
1428 class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest<Types> { 1373 class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest<Types> {
1429 protected: 1374 protected:
1430 OcclusionTrackerTestReplicaWithMask(bool opaqueLayers) : OcclusionTrackerTes t<Types>(opaqueLayers) {} 1375 OcclusionTrackerTestReplicaWithMask(bool opaqueLayers) : OcclusionTrackerTes t<Types>(opaqueLayers) {}
1431 void runMyTest() 1376 void runMyTest()
1432 { 1377 {
1433 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 200)); 1378 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 200));
1434 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 100), gfx::Size(50, 50), true); 1379 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 100), gfx::Size(50, 50), true);
1435 typename Types::LayerType* replica = this->createReplicaLayer(surface, t his->identityMatrix, gfx::PointF(50, 50), gfx::Size()); 1380 typename Types::LayerType* replica = this->createReplicaLayer(surface, t his->identityMatrix, gfx::PointF(50, 50), gfx::Size());
1436 this->createMaskLayer(replica, gfx::Size(10, 10)); 1381 this->createMaskLayer(replica, gfx::Size(10, 10));
1437 this->calcDrawEtc(parent); 1382 this->calcDrawEtc(parent);
1438 1383
1439 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 1384 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
1440 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 1385 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
1441 1386
1442 this->visitLayer(surface, occlusion); 1387 this->visitLayer(surface, occlusion);
1443 1388
1444 EXPECT_RECT_EQ(gfx::Rect(0, 100, 50, 50), occlusion.occlusionInScreenSpa ce().bounds()); 1389 EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), occlusion.occlusionInScr eenSpace().ToString());
1445 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 1390 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), occlusion.occlusionInTarge tSurface().ToString());
1446 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), occlusion.occlusionInTargetSurfa ce().bounds());
1447 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1448 1391
1449 this->visitContributingSurface(surface, occlusion); 1392 this->visitContributingSurface(surface, occlusion);
1450 this->enterLayer(parent, occlusion); 1393 this->enterLayer(parent, occlusion);
1451 1394
1452 // The replica should not be occluding the parent, since it has a mask a pplied to it. 1395 // The replica should not be occluding the parent, since it has a mask a pplied to it.
1453 EXPECT_RECT_EQ(gfx::Rect(0, 100, 50, 50), occlusion.occlusionInTargetSur face().bounds()); 1396 EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), occlusion.occlusionInTar getSurface().ToString());
1454 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
1455 } 1397 }
1456 }; 1398 };
1457 1399
1458 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithMask); 1400 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithMask);
1459 1401
1460 template<class Types> 1402 template<class Types>
1461 class OcclusionTrackerTestLayerClipRectOutsideChild : public OcclusionTrackerTes t<Types> { 1403 class OcclusionTrackerTestLayerClipRectOutsideChild : public OcclusionTrackerTes t<Types> {
1462 protected: 1404 protected:
1463 OcclusionTrackerTestLayerClipRectOutsideChild(bool opaqueLayers) : Occlusion TrackerTest<Types>(opaqueLayers) {} 1405 OcclusionTrackerTestLayerClipRectOutsideChild(bool opaqueLayers) : Occlusion TrackerTest<Types>(opaqueLayers) {}
1464 void runMyTest() 1406 void runMyTest()
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 1793
1852 // Test without any clip rect. 1794 // Test without any clip rect.
1853 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 1795 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
1854 EXPECT_FALSE(occlusion.occludedLayer(layer, gfx::Rect(200, 100, 100, 100 ))); 1796 EXPECT_FALSE(occlusion.occludedLayer(layer, gfx::Rect(200, 100, 100, 100 )));
1855 occlusion.useDefaultLayerClipRect(); 1797 occlusion.useDefaultLayerClipRect();
1856 1798
1857 this->leaveLayer(layer, occlusion); 1799 this->leaveLayer(layer, occlusion);
1858 this->visitContributingSurface(layer, occlusion); 1800 this->visitContributingSurface(layer, occlusion);
1859 this->enterLayer(parent, occlusion); 1801 this->enterLayer(parent, occlusion);
1860 1802
1861 EXPECT_TRUE(occlusion.occlusionInScreenSpace().bounds().IsEmpty()); 1803 EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty());
1862 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( ));
1863 } 1804 }
1864 }; 1805 };
1865 1806
1866 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty); 1807 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty);
1867 1808
1868 template<class Types> 1809 template<class Types>
1869 class OcclusionTrackerTestOpaqueContentsRegionNonEmpty : public OcclusionTracker Test<Types> { 1810 class OcclusionTrackerTestOpaqueContentsRegionNonEmpty : public OcclusionTracker Test<Types> {
1870 protected: 1811 protected:
1871 OcclusionTrackerTestOpaqueContentsRegionNonEmpty(bool opaqueLayers) : Occlus ionTrackerTest<Types>(opaqueLayers) {} 1812 OcclusionTrackerTestOpaqueContentsRegionNonEmpty(bool opaqueLayers) : Occlus ionTrackerTest<Types>(opaqueLayers) {}
1872 void runMyTest() 1813 void runMyTest()
1873 { 1814 {
1874 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(300, 300)); 1815 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
1875 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, this->identityMatrix, gfx::PointF(100, 100), gfx::Size(200, 200), false); 1816 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, this->identityMatrix, gfx::PointF(100, 100), gfx::Size(200, 200), false);
1876 this->calcDrawEtc(parent); 1817 this->calcDrawEtc(parent);
1877 1818
1878 { 1819 {
1879 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Typ es::RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 1820 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Typ es::RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
1880 layer->setOpaqueContentsRect(gfx::Rect(0, 0, 100, 100)); 1821 layer->setOpaqueContentsRect(gfx::Rect(0, 0, 100, 100));
1881 1822
1882 this->resetLayerIterator(); 1823 this->resetLayerIterator();
1883 this->visitLayer(layer, occlusion); 1824 this->visitLayer(layer, occlusion);
1884 this->enterLayer(parent, occlusion); 1825 this->enterLayer(parent, occlusion);
1885 1826
1886 EXPECT_RECT_EQ(gfx::Rect(100, 100, 100, 100), occlusion.occlusionInS creenSpace().bounds()); 1827 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), occlusion.occlus ionInScreenSpace().ToString());
1887 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).s ize());
1888 1828
1889 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 1829 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
1890 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(100, 100, 100, 100))); 1830 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
1891 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(200, 200, 100 , 100))); 1831 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(200, 200, 100 , 100)));
1892 } 1832 }
1893 1833
1894 { 1834 {
1895 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Typ es::RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 1835 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Typ es::RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
1896 layer->setOpaqueContentsRect(gfx::Rect(20, 20, 180, 180)); 1836 layer->setOpaqueContentsRect(gfx::Rect(20, 20, 180, 180));
1897 1837
1898 this->resetLayerIterator(); 1838 this->resetLayerIterator();
1899 this->visitLayer(layer, occlusion); 1839 this->visitLayer(layer, occlusion);
1900 this->enterLayer(parent, occlusion); 1840 this->enterLayer(parent, occlusion);
1901 1841
1902 EXPECT_RECT_EQ(gfx::Rect(120, 120, 180, 180), occlusion.occlusionInS creenSpace().bounds()); 1842 EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), occlusion.occlus ionInScreenSpace().ToString());
1903 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).s ize());
1904 1843
1905 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 1844 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
1906 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(100, 100, 100 , 100))); 1845 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(100, 100, 100 , 100)));
1907 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(200, 200, 100, 100))); 1846 EXPECT_TRUE(occlusion.occludedLayer(parent, gfx::Rect(200, 200, 100, 100)));
1908 } 1847 }
1909 1848
1910 { 1849 {
1911 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Typ es::RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 1850 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Typ es::RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
1912 layer->setOpaqueContentsRect(gfx::Rect(150, 150, 100, 100)); 1851 layer->setOpaqueContentsRect(gfx::Rect(150, 150, 100, 100));
1913 1852
1914 this->resetLayerIterator(); 1853 this->resetLayerIterator();
1915 this->visitLayer(layer, occlusion); 1854 this->visitLayer(layer, occlusion);
1916 this->enterLayer(parent, occlusion); 1855 this->enterLayer(parent, occlusion);
1917 1856
1918 EXPECT_RECT_EQ(gfx::Rect(250, 250, 50, 50), occlusion.occlusionInScr eenSpace().bounds()); 1857 EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), occlusion.occlusio nInScreenSpace().ToString());
1919 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).s ize());
1920 1858
1921 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 1859 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
1922 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(100, 100, 100 , 100))); 1860 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(100, 100, 100 , 100)));
1923 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(200, 200, 100 , 100))); 1861 EXPECT_FALSE(occlusion.occludedLayer(parent, gfx::Rect(200, 200, 100 , 100)));
1924 } 1862 }
1925 } 1863 }
1926 }; 1864 };
1927 1865
1928 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty); 1866 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty);
1929 1867
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, transform, gfx::PointF(0, 0), gfx::Size(100, 100), true); 2007 typename Types::ContentLayerType* layer = this->createDrawingLayer(paren t, transform, gfx::PointF(0, 0), gfx::Size(100, 100), true);
2070 parent->setPreserves3D(true); 2008 parent->setPreserves3D(true);
2071 layer->setPreserves3D(true); 2009 layer->setPreserves3D(true);
2072 this->calcDrawEtc(parent); 2010 this->calcDrawEtc(parent);
2073 2011
2074 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2012 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2075 2013
2076 // The |layer| is entirely behind the camera and should not occlude. 2014 // The |layer| is entirely behind the camera and should not occlude.
2077 this->visitLayer(layer, occlusion); 2015 this->visitLayer(layer, occlusion);
2078 this->enterLayer(parent, occlusion); 2016 this->enterLayer(parent, occlusion);
2079 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e()); 2017 EXPECT_TRUE(occlusion.occlusionInTargetSurface().IsEmpty());
2080 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2018 EXPECT_TRUE(occlusion.occlusionInScreenSpace().IsEmpty());
2081 } 2019 }
2082 }; 2020 };
2083 2021
2084 // This test requires accumulating occlusion of 3d layers, which are skipped by the occlusion tracker on the main thread. So this test should run on the impl th read. 2022 // This test requires accumulating occlusion of 3d layers, which are skipped by the occlusion tracker on the main thread. So this test should run on the impl th read.
2085 IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude); 2023 IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude);
2086 2024
2087 template<class Types> 2025 template<class Types>
2088 class OcclusionTrackerTestLargePixelsOccludeInsideClipRect : public OcclusionTra ckerTest<Types> { 2026 class OcclusionTrackerTestLargePixelsOccludeInsideClipRect : public OcclusionTra ckerTest<Types> {
2089 protected: 2027 protected:
2090 OcclusionTrackerTestLargePixelsOccludeInsideClipRect(bool opaqueLayers) : Oc clusionTrackerTest<Types>(opaqueLayers) {} 2028 OcclusionTrackerTestLargePixelsOccludeInsideClipRect(bool opaqueLayers) : Oc clusionTrackerTest<Types>(opaqueLayers) {}
(...skipping 11 matching lines...) Expand all
2102 parent->setPreserves3D(true); 2040 parent->setPreserves3D(true);
2103 layer->setPreserves3D(true); 2041 layer->setPreserves3D(true);
2104 this->calcDrawEtc(parent); 2042 this->calcDrawEtc(parent);
2105 2043
2106 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2044 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2107 2045
2108 // This is very close to the camera, so pixels in its visibleContentRect will actually go outside of the layer's clipRect. 2046 // This is very close to the camera, so pixels in its visibleContentRect will actually go outside of the layer's clipRect.
2109 // Ensure that those pixels don't occlude things outside the clipRect. 2047 // Ensure that those pixels don't occlude things outside the clipRect.
2110 this->visitLayer(layer, occlusion); 2048 this->visitLayer(layer, occlusion);
2111 this->enterLayer(parent, occlusion); 2049 this->enterLayer(parent, occlusion);
2112 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInTargetSur face().bounds()); 2050 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInTar getSurface().ToString());
2113 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e()); 2051 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInScr eenSpace().ToString());
2114 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInScreenSpa ce().bounds());
2115 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( ));
2116 } 2052 }
2117 }; 2053 };
2118 2054
2119 // This test requires accumulating occlusion of 3d layers, which are skipped by the occlusion tracker on the main thread. So this test should run on the impl th read. 2055 // This test requires accumulating occlusion of 3d layers, which are skipped by the occlusion tracker on the main thread. So this test should run on the impl th read.
2120 IMPL_THREAD_TEST(OcclusionTrackerTestLargePixelsOccludeInsideClipRect); 2056 IMPL_THREAD_TEST(OcclusionTrackerTestLargePixelsOccludeInsideClipRect);
2121 2057
2122 template<class Types> 2058 template<class Types>
2123 class OcclusionTrackerTestAnimationOpacity1OnMainThread : public OcclusionTracke rTest<Types> { 2059 class OcclusionTrackerTestAnimationOpacity1OnMainThread : public OcclusionTracke rTest<Types> {
2124 protected: 2060 protected:
2125 OcclusionTrackerTestAnimationOpacity1OnMainThread(bool opaqueLayers) : Occlu sionTrackerTest<Types>(opaqueLayers) {} 2061 OcclusionTrackerTestAnimationOpacity1OnMainThread(bool opaqueLayers) : Occlu sionTrackerTest<Types>(opaqueLayers) {}
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 EXPECT_FALSE(surface->drawTransformIsAnimating()); 2187 EXPECT_FALSE(surface->drawTransformIsAnimating());
2252 EXPECT_TRUE(surface->screenSpaceTransformIsAnimating()); 2188 EXPECT_TRUE(surface->screenSpaceTransformIsAnimating());
2253 EXPECT_TRUE(surfaceChild->drawTransformIsAnimating()); 2189 EXPECT_TRUE(surfaceChild->drawTransformIsAnimating());
2254 EXPECT_TRUE(surfaceChild->screenSpaceTransformIsAnimating()); 2190 EXPECT_TRUE(surfaceChild->screenSpaceTransformIsAnimating());
2255 2191
2256 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2192 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2257 2193
2258 this->visitLayer(surface2, occlusion); 2194 this->visitLayer(surface2, occlusion);
2259 this->enterContributingSurface(surface2, occlusion); 2195 this->enterContributingSurface(surface2, occlusion);
2260 2196
2261 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 300), occlusion.occlusionInScreenSpac e().bounds()); 2197 EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), occlusion.occlusionInScre enSpace().ToString());
2262 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( ));
2263 2198
2264 this->leaveContributingSurface(surface2, occlusion); 2199 this->leaveContributingSurface(surface2, occlusion);
2265 this->enterLayer(surfaceChild2, occlusion); 2200 this->enterLayer(surfaceChild2, occlusion);
2266 2201
2267 // surfaceChild2 is moving in screen space but not relative to its targe t, so occlusion should happen in its target space only. 2202 // surfaceChild2 is moving in screen space but not relative to its targe t, so occlusion should happen in its target space only.
2268 // It also means that things occluding in screen space (e.g. surface2) c annot occlude this layer. 2203 // It also means that things occluding in screen space (e.g. surface2) c annot occlude this layer.
2269 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300), occlusion.unoccludedLayerConte ntRect(surfaceChild2, gfx::Rect(0, 0, 100, 300))); 2204 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300), occlusion.unoccludedLayerConte ntRect(surfaceChild2, gfx::Rect(0, 0, 100, 300)));
2270 EXPECT_FALSE(occlusion.occludedLayer(surfaceChild, gfx::Rect(0, 0, 50, 3 00))); 2205 EXPECT_FALSE(occlusion.occludedLayer(surfaceChild, gfx::Rect(0, 0, 50, 3 00)));
2271 2206
2272 this->leaveLayer(surfaceChild2, occlusion); 2207 this->leaveLayer(surfaceChild2, occlusion);
2273 this->enterLayer(surfaceChild, occlusion); 2208 this->enterLayer(surfaceChild, occlusion);
2274 EXPECT_FALSE(occlusion.occludedLayer(surfaceChild, gfx::Rect(0, 0, 100, 300))); 2209 EXPECT_FALSE(occlusion.occludedLayer(surfaceChild, gfx::Rect(0, 0, 100, 300)));
2275 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 300), occlusion.occlusionInScreenSpac e().bounds()); 2210 EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), occlusion.occlusionInScre enSpace().ToString());
2276 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2211 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), occlusion.occlusionInTar getSurface().ToString());
2277 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300), occlusion.occlusionInTargetSur face().bounds());
2278 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2279 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), occlusion.unoccludedLayerCon tentRect(surface, gfx::Rect(0, 0, 300, 300))); 2212 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), occlusion.unoccludedLayerCon tentRect(surface, gfx::Rect(0, 0, 300, 300)));
2280 2213
2281 // The surfaceChild is occluded by the surfaceChild2, but is moving rela tive its target and the screen, so it 2214 // The surfaceChild is occluded by the surfaceChild2, but is moving rela tive its target and the screen, so it
2282 // can't be occluded. 2215 // can't be occluded.
2283 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 300), occlusion.unoccludedLayerConte ntRect(surfaceChild, gfx::Rect(0, 0, 200, 300))); 2216 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 300), occlusion.unoccludedLayerConte ntRect(surfaceChild, gfx::Rect(0, 0, 200, 300)));
2284 EXPECT_FALSE(occlusion.occludedLayer(surfaceChild, gfx::Rect(0, 0, 50, 3 00))); 2217 EXPECT_FALSE(occlusion.occludedLayer(surfaceChild, gfx::Rect(0, 0, 50, 3 00)));
2285 2218
2286 this->leaveLayer(surfaceChild, occlusion); 2219 this->leaveLayer(surfaceChild, occlusion);
2287 this->enterLayer(surface, occlusion); 2220 this->enterLayer(surface, occlusion);
2288 // The surfaceChild is moving in screen space but not relative to its ta rget, so occlusion should happen in its target space only. 2221 // The surfaceChild is moving in screen space but not relative to its ta rget, so occlusion should happen in its target space only.
2289 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 300), occlusion.occlusionInScreenSpac e().bounds()); 2222 EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), occlusion.occlusionInScre enSpace().ToString());
2290 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2223 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), occlusion.occlusionInTar getSurface().ToString());
2291 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300), occlusion.occlusionInTargetSur face().bounds());
2292 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2293 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), occlusion.unoccludedLayerCon tentRect(surface, gfx::Rect(0, 0, 300, 300))); 2224 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), occlusion.unoccludedLayerCon tentRect(surface, gfx::Rect(0, 0, 300, 300)));
2294 2225
2295 this->leaveLayer(surface, occlusion); 2226 this->leaveLayer(surface, occlusion);
2296 // The surface's owning layer is moving in screen space but not relative to its target, so occlusion should happen in its target space only. 2227 // The surface's owning layer is moving in screen space but not relative to its target, so occlusion should happen in its target space only.
2297 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 300), occlusion.occlusionInScreenSpac e().bounds()); 2228 EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), occlusion.occlusionInScre enSpace().ToString());
2298 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2229 EXPECT_EQ(gfx::Rect(0, 0, 300, 300).ToString(), occlusion.occlusionInTar getSurface().ToString());
2299 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 300), occlusion.occlusionInTargetSur face().bounds());
2300 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2301 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.unoccludedLayerContentRe ct(surface, gfx::Rect(0, 0, 300, 300))); 2230 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.unoccludedLayerContentRe ct(surface, gfx::Rect(0, 0, 300, 300)));
2302 2231
2303 this->enterContributingSurface(surface, occlusion); 2232 this->enterContributingSurface(surface, occlusion);
2304 // The contributing |surface| is animating so it can't be occluded. 2233 // The contributing |surface| is animating so it can't be occluded.
2305 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 300), occlusion.unoccludedContributi ngSurfaceContentRect(surface, false, gfx::Rect(0, 0, 300, 300))); 2234 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 300), occlusion.unoccludedContributi ngSurfaceContentRect(surface, false, gfx::Rect(0, 0, 300, 300)));
2306 this->leaveContributingSurface(surface, occlusion); 2235 this->leaveContributingSurface(surface, occlusion);
2307 2236
2308 this->enterLayer(layer, occlusion); 2237 this->enterLayer(layer, occlusion);
2309 // The |surface| is moving in the screen and in its target, so all occlu sion within the surface is lost when leaving it. 2238 // The |surface| is moving in the screen and in its target, so all occlu sion within the surface is lost when leaving it.
2310 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300), occlusion.unoccludedLayerCont entRect(parent, gfx::Rect(0, 0, 300, 300))); 2239 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300), occlusion.unoccludedLayerCont entRect(parent, gfx::Rect(0, 0, 300, 300)));
(...skipping 23 matching lines...) Expand all
2334 typename Types::ContentLayerType* surface2 = this->createDrawingSurface( parent, this->identityMatrix, gfx::PointF(50, 50), gfx::Size(300, 300), false); 2263 typename Types::ContentLayerType* surface2 = this->createDrawingSurface( parent, this->identityMatrix, gfx::PointF(50, 50), gfx::Size(300, 300), false);
2335 surface->setOpaqueContentsRect(gfx::Rect(0, 0, 200, 200)); 2264 surface->setOpaqueContentsRect(gfx::Rect(0, 0, 200, 200));
2336 surface2->setOpaqueContentsRect(gfx::Rect(0, 0, 200, 200)); 2265 surface2->setOpaqueContentsRect(gfx::Rect(0, 0, 200, 200));
2337 this->calcDrawEtc(parent); 2266 this->calcDrawEtc(parent);
2338 2267
2339 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2268 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2340 2269
2341 this->visitLayer(surface2, occlusion); 2270 this->visitLayer(surface2, occlusion);
2342 this->visitContributingSurface(surface2, occlusion); 2271 this->visitContributingSurface(surface2, occlusion);
2343 2272
2344 EXPECT_RECT_EQ(gfx::Rect(50, 50, 200, 200), occlusion.occlusionInScreenS pace().bounds()); 2273 EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(), occlusion.occlusionInS creenSpace().ToString());
2345 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2274 EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(), occlusion.occlusionInT argetSurface().ToString());
2346 EXPECT_RECT_EQ(gfx::Rect(50, 50, 200, 200), occlusion.occlusionInTargetS urface().bounds());
2347 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2348 2275
2349 // Clear any stored occlusion. 2276 // Clear any stored occlusion.
2350 occlusion.setOcclusionInScreenSpace(Region()); 2277 occlusion.setOcclusionInScreenSpace(Region());
2351 occlusion.setOcclusionInTargetSurface(Region()); 2278 occlusion.setOcclusionInTargetSurface(Region());
2352 2279
2353 this->visitLayer(surface, occlusion); 2280 this->visitLayer(surface, occlusion);
2354 this->visitContributingSurface(surface, occlusion); 2281 this->visitContributingSurface(surface, occlusion);
2355 2282
2356 EXPECT_RECT_EQ(gfx::Rect(0, 0, 400, 400), occlusion.occlusionInScreenSpa ce().bounds()); 2283 EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(), occlusion.occlusionInScr eenSpace().ToString());
2357 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2284 EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(), occlusion.occlusionInTar getSurface().ToString());
2358 EXPECT_RECT_EQ(gfx::Rect(0, 0, 400, 400), occlusion.occlusionInTargetSur face().bounds());
2359 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2360 } 2285 }
2361 }; 2286 };
2362 2287
2363 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestSurfaceOcclusionTranslatesToParent ); 2288 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestSurfaceOcclusionTranslatesToParent );
2364 2289
2365 template<class Types> 2290 template<class Types>
2366 class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping : public Occlus ionTrackerTest<Types> { 2291 class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping : public Occlus ionTrackerTest<Types> {
2367 protected: 2292 protected:
2368 OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping(bool opaqueLayers ) : OcclusionTrackerTest<Types>(opaqueLayers) {} 2293 OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping(bool opaqueLayers ) : OcclusionTrackerTest<Types>(opaqueLayers) {}
2369 void runMyTest() 2294 void runMyTest()
2370 { 2295 {
2371 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(300, 300)); 2296 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(300, 300));
2372 parent->setMasksToBounds(true); 2297 parent->setMasksToBounds(true);
2373 typename Types::ContentLayerType* surface = this->createDrawingSurface(p arent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 300), false); 2298 typename Types::ContentLayerType* surface = this->createDrawingSurface(p arent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(500, 300), false);
2374 surface->setOpaqueContentsRect(gfx::Rect(0, 0, 400, 200)); 2299 surface->setOpaqueContentsRect(gfx::Rect(0, 0, 400, 200));
2375 this->calcDrawEtc(parent); 2300 this->calcDrawEtc(parent);
2376 2301
2377 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2302 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2378 2303
2379 this->visitLayer(surface, occlusion); 2304 this->visitLayer(surface, occlusion);
2380 this->visitContributingSurface(surface, occlusion); 2305 this->visitContributingSurface(surface, occlusion);
2381 2306
2382 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 200), occlusion.occlusionInScreenSpa ce().bounds()); 2307 EXPECT_EQ(gfx::Rect(0, 0, 300, 200).ToString(), occlusion.occlusionInScr eenSpace().ToString());
2383 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2308 EXPECT_EQ(gfx::Rect(0, 0, 300, 200).ToString(), occlusion.occlusionInTar getSurface().ToString());
2384 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 200), occlusion.occlusionInTargetSur face().bounds());
2385 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2386 } 2309 }
2387 }; 2310 };
2388 2311
2389 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestSurfaceOcclusionTranslatesWithClip ping); 2312 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestSurfaceOcclusionTranslatesWithClip ping);
2390 2313
2391 template<class Types> 2314 template<class Types>
2392 class OcclusionTrackerTestReplicaOccluded : public OcclusionTrackerTest<Types> { 2315 class OcclusionTrackerTestReplicaOccluded : public OcclusionTrackerTest<Types> {
2393 protected: 2316 protected:
2394 OcclusionTrackerTestReplicaOccluded(bool opaqueLayers) : OcclusionTrackerTes t<Types>(opaqueLayers) {} 2317 OcclusionTrackerTestReplicaOccluded(bool opaqueLayers) : OcclusionTrackerTes t<Types>(opaqueLayers) {}
2395 void runMyTest() 2318 void runMyTest()
2396 { 2319 {
2397 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 200)); 2320 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 200));
2398 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100), true); 2321 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100), true);
2399 this->createReplicaLayer(surface, this->identityMatrix, gfx::PointF(0, 1 00), gfx::Size(100, 100)); 2322 this->createReplicaLayer(surface, this->identityMatrix, gfx::PointF(0, 1 00), gfx::Size(100, 100));
2400 typename Types::LayerType* topmost = this->createDrawingLayer(parent, th is->identityMatrix, gfx::PointF(0, 100), gfx::Size(100, 100), true); 2323 typename Types::LayerType* topmost = this->createDrawingLayer(parent, th is->identityMatrix, gfx::PointF(0, 100), gfx::Size(100, 100), true);
2401 this->calcDrawEtc(parent); 2324 this->calcDrawEtc(parent);
2402 2325
2403 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2326 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2404 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 2327 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
2405 2328
2406 // |topmost| occludes the replica, but not the surface itself. 2329 // |topmost| occludes the replica, but not the surface itself.
2407 this->visitLayer(topmost, occlusion); 2330 this->visitLayer(topmost, occlusion);
2408 2331
2409 EXPECT_RECT_EQ(gfx::Rect(0, 100, 100, 100), occlusion.occlusionInScreenS pace().bounds()); 2332 EXPECT_EQ(gfx::Rect(0, 100, 100, 100).ToString(), occlusion.occlusionInS creenSpace().ToString());
2410 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2333 EXPECT_EQ(gfx::Rect(0, 100, 100, 100).ToString(), occlusion.occlusionInT argetSurface().ToString());
2411 EXPECT_RECT_EQ(gfx::Rect(0, 100, 100, 100), occlusion.occlusionInTargetS urface().bounds());
2412 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2413 2334
2414 this->visitLayer(surface, occlusion); 2335 this->visitLayer(surface, occlusion);
2415 2336
2416 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 200), occlusion.occlusionInScreenSpa ce().bounds()); 2337 EXPECT_EQ(gfx::Rect(0, 0, 100, 200).ToString(), occlusion.occlusionInScr eenSpace().ToString());
2417 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2338 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInTar getSurface().ToString());
2418 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInTargetSur face().bounds());
2419 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2420 2339
2421 this->enterContributingSurface(surface, occlusion); 2340 this->enterContributingSurface(surface, occlusion);
2422 2341
2423 // Surface is not occluded so it shouldn't think it is. 2342 // Surface is not occluded so it shouldn't think it is.
2424 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.unoccludedContributi ngSurfaceContentRect(surface, false, gfx::Rect(0, 0, 100, 100))); 2343 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.unoccludedContributi ngSurfaceContentRect(surface, false, gfx::Rect(0, 0, 100, 100)));
2425 } 2344 }
2426 }; 2345 };
2427 2346
2428 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded); 2347 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded);
2429 2348
2430 template<class Types> 2349 template<class Types>
2431 class OcclusionTrackerTestSurfaceWithReplicaUnoccluded : public OcclusionTracker Test<Types> { 2350 class OcclusionTrackerTestSurfaceWithReplicaUnoccluded : public OcclusionTracker Test<Types> {
2432 protected: 2351 protected:
2433 OcclusionTrackerTestSurfaceWithReplicaUnoccluded(bool opaqueLayers) : Occlus ionTrackerTest<Types>(opaqueLayers) {} 2352 OcclusionTrackerTestSurfaceWithReplicaUnoccluded(bool opaqueLayers) : Occlus ionTrackerTest<Types>(opaqueLayers) {}
2434 void runMyTest() 2353 void runMyTest()
2435 { 2354 {
2436 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 200)); 2355 typename Types::ContentLayerType* parent = this->createRoot(this->identi tyMatrix, gfx::PointF(0, 0), gfx::Size(100, 200));
2437 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100), true); 2356 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100), true);
2438 this->createReplicaLayer(surface, this->identityMatrix, gfx::PointF(0, 1 00), gfx::Size(100, 100)); 2357 this->createReplicaLayer(surface, this->identityMatrix, gfx::PointF(0, 1 00), gfx::Size(100, 100));
2439 typename Types::LayerType* topmost = this->createDrawingLayer(parent, th is->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 110), true); 2358 typename Types::LayerType* topmost = this->createDrawingLayer(parent, th is->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 110), true);
2440 this->calcDrawEtc(parent); 2359 this->calcDrawEtc(parent);
2441 2360
2442 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2361 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2443 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 2362 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
2444 2363
2445 // |topmost| occludes the surface, but not the entire surface's replica. 2364 // |topmost| occludes the surface, but not the entire surface's replica.
2446 this->visitLayer(topmost, occlusion); 2365 this->visitLayer(topmost, occlusion);
2447 2366
2448 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 110), occlusion.occlusionInScreenSpa ce().bounds()); 2367 EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(), occlusion.occlusionInScr eenSpace().ToString());
2449 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2368 EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(), occlusion.occlusionInTar getSurface().ToString());
2450 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 110), occlusion.occlusionInTargetSur face().bounds());
2451 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2452 2369
2453 this->visitLayer(surface, occlusion); 2370 this->visitLayer(surface, occlusion);
2454 2371
2455 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 110), occlusion.occlusionInScreenSpa ce().bounds()); 2372 EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(), occlusion.occlusionInScr eenSpace().ToString());
2456 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2373 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInTar getSurface().ToString());
2457 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInTargetSur face().bounds());
2458 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2459 2374
2460 this->enterContributingSurface(surface, occlusion); 2375 this->enterContributingSurface(surface, occlusion);
2461 2376
2462 // Surface is occluded, but only the top 10px of the replica. 2377 // Surface is occluded, but only the top 10px of the replica.
2463 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.unoccludedContributingSu rfaceContentRect(surface, false, gfx::Rect(0, 0, 100, 100))); 2378 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.unoccludedContributingSu rfaceContentRect(surface, false, gfx::Rect(0, 0, 100, 100)));
2464 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90), occlusion.unoccludedContributi ngSurfaceContentRect(surface, true, gfx::Rect(0, 0, 100, 100))); 2379 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90), occlusion.unoccludedContributi ngSurfaceContentRect(surface, true, gfx::Rect(0, 0, 100, 100)));
2465 } 2380 }
2466 }; 2381 };
2467 2382
2468 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithReplicaUnoccluded); 2383 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithReplicaUnoccluded);
(...skipping 11 matching lines...) Expand all
2480 typename Types::LayerType* overReplica = this->createDrawingLayer(parent , this->identityMatrix, gfx::PointF(0, 100), gfx::Size(50, 100), true); 2395 typename Types::LayerType* overReplica = this->createDrawingLayer(parent , this->identityMatrix, gfx::PointF(0, 100), gfx::Size(50, 100), true);
2481 this->calcDrawEtc(parent); 2396 this->calcDrawEtc(parent);
2482 2397
2483 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2398 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2484 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 2399 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
2485 2400
2486 // These occlude the surface and replica differently, so we can test eac h one. 2401 // These occlude the surface and replica differently, so we can test eac h one.
2487 this->visitLayer(overReplica, occlusion); 2402 this->visitLayer(overReplica, occlusion);
2488 this->visitLayer(overSurface, occlusion); 2403 this->visitLayer(overSurface, occlusion);
2489 2404
2490 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 200), occlusion.occlusionInScreenSpac e().bounds()); 2405 EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 1 00)).ToString(), occlusion.occlusionInScreenSpace().ToString());
2491 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2406 EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 1 00)).ToString(), occlusion.occlusionInTargetSurface().ToString());
2492 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 200), occlusion.occlusionInTargetSurf ace().bounds());
2493 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2494 2407
2495 this->visitLayer(surface, occlusion); 2408 this->visitLayer(surface, occlusion);
2496 2409
2497 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 200), occlusion.occlusionInScreenSpa ce().bounds()); 2410 EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 100, 50, 100)).ToString(), occlusion.occlusionInScreenSpace().ToString());
2498 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2411 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), occlusion.occlusionInTar getSurface().ToString());
2499 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), occlusion.occlusionInTargetSur face().bounds());
2500 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2501 2412
2502 this->enterContributingSurface(surface, occlusion); 2413 this->enterContributingSurface(surface, occlusion);
2503 2414
2504 // Surface and replica are occluded different amounts. 2415 // Surface and replica are occluded different amounts.
2505 EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100), occlusion.unoccludedContributi ngSurfaceContentRect(surface, false, gfx::Rect(0, 0, 100, 100))); 2416 EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100), occlusion.unoccludedContributi ngSurfaceContentRect(surface, false, gfx::Rect(0, 0, 100, 100)));
2506 EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100), occlusion.unoccludedContributi ngSurfaceContentRect(surface, true, gfx::Rect(0, 0, 100, 100))); 2417 EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100), occlusion.unoccludedContributi ngSurfaceContentRect(surface, true, gfx::Rect(0, 0, 100, 100)));
2507 } 2418 }
2508 }; 2419 };
2509 2420
2510 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceAndReplicaOccludedDifferent ly); 2421 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceAndReplicaOccludedDifferent ly);
(...skipping 10 matching lines...) Expand all
2521 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100), true); 2432 typename Types::LayerType* surface = this->createDrawingSurface(parent, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100), true);
2522 typename Types::LayerType* surfaceChild = this->createDrawingSurface(sur face, this->identityMatrix, gfx::PointF(0, 10), gfx::Size(100, 50), true); 2433 typename Types::LayerType* surfaceChild = this->createDrawingSurface(sur face, this->identityMatrix, gfx::PointF(0, 10), gfx::Size(100, 50), true);
2523 typename Types::LayerType* topmost = this->createDrawingLayer(parent, th is->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 50), true); 2434 typename Types::LayerType* topmost = this->createDrawingLayer(parent, th is->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 50), true);
2524 this->calcDrawEtc(parent); 2435 this->calcDrawEtc(parent);
2525 2436
2526 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(-100, -100, 1000, 1000)); 2437 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(-100, -100, 1000, 1000));
2527 2438
2528 // |topmost| occludes everything partially so we know occlusion is happe ning at all. 2439 // |topmost| occludes everything partially so we know occlusion is happe ning at all.
2529 this->visitLayer(topmost, occlusion); 2440 this->visitLayer(topmost, occlusion);
2530 2441
2531 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 50), occlusion.occlusionInScreenSpac e().bounds()); 2442 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), occlusion.occlusionInScre enSpace().ToString());
2532 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2443 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), occlusion.occlusionInTarg etSurface().ToString());
2533 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 50), occlusion.occlusionInTargetSurf ace().bounds());
2534 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2535 2444
2536 this->visitLayer(surfaceChild, occlusion); 2445 this->visitLayer(surfaceChild, occlusion);
2537 2446
2538 // surfaceChild increases the occlusion in the screen by a narrow sliver . 2447 // surfaceChild increases the occlusion in the screen by a narrow sliver .
2539 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 60), occlusion.occlusionInScreenSpac e().bounds()); 2448 EXPECT_EQ(gfx::Rect(0, 0, 100, 60).ToString(), occlusion.occlusionInScre enSpace().ToString());
2540 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( ));
2541 // In its own surface, surfaceChild is at 0,0 as is its occlusion. 2449 // In its own surface, surfaceChild is at 0,0 as is its occlusion.
2542 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 50), occlusion.occlusionInTargetSurf ace().bounds()); 2450 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), occlusion.occlusionInTarg etSurface().ToString());
2543 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2544 2451
2545 // The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not 2452 // The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not
2546 // mask to bounds, so it doesn't have a clipRect of its own. Thus the pa rent of |surfaceChild| exercises different code paths 2453 // mask to bounds, so it doesn't have a clipRect of its own. Thus the pa rent of |surfaceChild| exercises different code paths
2547 // as its parent does not have a clipRect. 2454 // as its parent does not have a clipRect.
2548 2455
2549 this->enterContributingSurface(surfaceChild, occlusion); 2456 this->enterContributingSurface(surfaceChild, occlusion);
2550 // The surfaceChild's parent does not have a clipRect as it owns a rende r surface. Make sure the unoccluded rect 2457 // The surfaceChild's parent does not have a clipRect as it owns a rende r surface. Make sure the unoccluded rect
2551 // does not get clipped away inappropriately. 2458 // does not get clipped away inappropriately.
2552 EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10), occlusion.unoccludedContributi ngSurfaceContentRect(surfaceChild, false, gfx::Rect(0, 0, 100, 50))); 2459 EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10), occlusion.unoccludedContributi ngSurfaceContentRect(surfaceChild, false, gfx::Rect(0, 0, 100, 50)));
2553 this->leaveContributingSurface(surfaceChild, occlusion); 2460 this->leaveContributingSurface(surfaceChild, occlusion);
2554 2461
2555 // When the surfaceChild's occlusion is transformed up to its parent, ma ke sure it is not clipped away inappropriately also. 2462 // When the surfaceChild's occlusion is transformed up to its parent, ma ke sure it is not clipped away inappropriately also.
2556 this->enterLayer(surface, occlusion); 2463 this->enterLayer(surface, occlusion);
2557 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 60), occlusion.occlusionInScreenSpac e().bounds()); 2464 EXPECT_EQ(gfx::Rect(0, 0, 100, 60).ToString(), occlusion.occlusionInScre enSpace().ToString());
2558 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2465 EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), occlusion.occlusionInTar getSurface().ToString());
2559 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 50), occlusion.occlusionInTargetSur face().bounds());
2560 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2561 this->leaveLayer(surface, occlusion); 2466 this->leaveLayer(surface, occlusion);
2562 2467
2563 this->enterContributingSurface(surface, occlusion); 2468 this->enterContributingSurface(surface, occlusion);
2564 // The surface's parent does have a clipRect as it is the root layer. 2469 // The surface's parent does have a clipRect as it is the root layer.
2565 EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50), occlusion.unoccludedContributi ngSurfaceContentRect(surface, false, gfx::Rect(0, 0, 100, 100))); 2470 EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50), occlusion.unoccludedContributi ngSurfaceContentRect(surface, false, gfx::Rect(0, 0, 100, 100)));
2566 } 2471 }
2567 }; 2472 };
2568 2473
2569 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); 2474 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface);
2570 2475
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 typename Types::LayerType* surfaceChild = this->createDrawingSurface(sur face, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100), false); 2527 typename Types::LayerType* surfaceChild = this->createDrawingSurface(sur face, this->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 100), false);
2623 typename Types::LayerType* topmost = this->createDrawingLayer(parent, th is->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 50), true); 2528 typename Types::LayerType* topmost = this->createDrawingLayer(parent, th is->identityMatrix, gfx::PointF(0, 0), gfx::Size(100, 50), true);
2624 this->calcDrawEtc(parent); 2529 this->calcDrawEtc(parent);
2625 2530
2626 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2531 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2627 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 2532 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
2628 2533
2629 // |topmost| occludes everything partially so we know occlusion is happe ning at all. 2534 // |topmost| occludes everything partially so we know occlusion is happe ning at all.
2630 this->visitLayer(topmost, occlusion); 2535 this->visitLayer(topmost, occlusion);
2631 2536
2632 EXPECT_RECT_EQ(gfx::Rect(0, 0, 80, 50), occlusion.occlusionInScreenSpace ().bounds()); 2537 EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(), occlusion.occlusionInScree nSpace().ToString());
2633 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2538 EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(), occlusion.occlusionInTarge tSurface().ToString());
2634 EXPECT_RECT_EQ(gfx::Rect(0, 0, 80, 50), occlusion.occlusionInTargetSurfa ce().bounds());
2635 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2636 2539
2637 // surfaceChild is not opaque and does not occlude, so we have a non-emp ty unoccluded area on surface. 2540 // surfaceChild is not opaque and does not occlude, so we have a non-emp ty unoccluded area on surface.
2638 this->visitLayer(surfaceChild, occlusion); 2541 this->visitLayer(surfaceChild, occlusion);
2639 2542
2640 EXPECT_RECT_EQ(gfx::Rect(0, 0, 80, 50), occlusion.occlusionInScreenSpace ().bounds()); 2543 EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(), occlusion.occlusionInScree nSpace().ToString());
2641 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2544 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), occlusion.occlusionInTargetS urface().ToString());
2642 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.occlusionInTargetSurface ().bounds());
2643 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2644 2545
2645 // The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not 2546 // The root layer always has a clipRect. So the parent of |surface| has a clipRect. However, the owning layer for |surface| does not
2646 // mask to bounds, so it doesn't have a clipRect of its own. Thus the pa rent of |surfaceChild| exercises different code paths 2547 // mask to bounds, so it doesn't have a clipRect of its own. Thus the pa rent of |surfaceChild| exercises different code paths
2647 // as its parent does not have a clipRect. 2548 // as its parent does not have a clipRect.
2648 2549
2649 this->enterContributingSurface(surfaceChild, occlusion); 2550 this->enterContributingSurface(surfaceChild, occlusion);
2650 // The surfaceChild's parent does not have a clipRect as it owns a rende r surface. 2551 // The surfaceChild's parent does not have a clipRect as it owns a rende r surface.
2651 EXPECT_RECT_EQ(gfx::Rect(0, 50, 80, 50), occlusion.unoccludedContributin gSurfaceContentRect(surfaceChild, false, gfx::Rect(0, 0, 100, 100))); 2552 EXPECT_RECT_EQ(gfx::Rect(0, 50, 80, 50), occlusion.unoccludedContributin gSurfaceContentRect(surfaceChild, false, gfx::Rect(0, 0, 100, 100)));
2652 this->leaveContributingSurface(surfaceChild, occlusion); 2553 this->leaveContributingSurface(surfaceChild, occlusion);
2653 2554
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 2597 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
2697 2598
2698 // These layers occlude pixels directly beside the filteredSurface. Beca use filtered surface blends pixels in a radius, it will 2599 // These layers occlude pixels directly beside the filteredSurface. Beca use filtered surface blends pixels in a radius, it will
2699 // need to see some of the pixels (up to radius far) underneath the occl udingLayers. 2600 // need to see some of the pixels (up to radius far) underneath the occl udingLayers.
2700 this->visitLayer(occludingLayer5, occlusion); 2601 this->visitLayer(occludingLayer5, occlusion);
2701 this->visitLayer(occludingLayer4, occlusion); 2602 this->visitLayer(occludingLayer4, occlusion);
2702 this->visitLayer(occludingLayer3, occlusion); 2603 this->visitLayer(occludingLayer3, occlusion);
2703 this->visitLayer(occludingLayer2, occlusion); 2604 this->visitLayer(occludingLayer2, occlusion);
2704 this->visitLayer(occludingLayer1, occlusion); 2605 this->visitLayer(occludingLayer1, occlusion);
2705 2606
2706 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpa ce().bounds()); 2607 Region expectedOcclusion;
2707 EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2608 expectedOcclusion.Union(gfx::Rect(0, 0, 300, 50));
2708 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInTargetSur face().bounds()); 2609 expectedOcclusion.Union(gfx::Rect(0, 50, 50, 50));
2709 EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e()); 2610 expectedOcclusion.Union(gfx::Rect(100, 50, 100, 50));
2611 expectedOcclusion.Union(gfx::Rect(250, 50, 50, 50));
2612 expectedOcclusion.Union(gfx::Rect(0, 100, 300, 50));
2613
2614 EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace ().ToString());
2615 EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInTargetSurfa ce().ToString());
2710 2616
2711 // Everything outside the surface/replica is occluded but the surface/re plica itself is not. 2617 // Everything outside the surface/replica is occluded but the surface/re plica itself is not.
2712 this->enterLayer(filteredSurface, occlusion); 2618 this->enterLayer(filteredSurface, occlusion);
2713 EXPECT_RECT_EQ(gfx::Rect(1, 0, 99, 100), occlusion.unoccludedLayerConten tRect(filteredSurface, gfx::Rect(1, 0, 100, 100))); 2619 EXPECT_RECT_EQ(gfx::Rect(1, 0, 99, 100), occlusion.unoccludedLayerConten tRect(filteredSurface, gfx::Rect(1, 0, 100, 100)));
2714 EXPECT_RECT_EQ(gfx::Rect(0, 1, 100, 99), occlusion.unoccludedLayerConten tRect(filteredSurface, gfx::Rect(0, 1, 100, 100))); 2620 EXPECT_RECT_EQ(gfx::Rect(0, 1, 100, 99), occlusion.unoccludedLayerConten tRect(filteredSurface, gfx::Rect(0, 1, 100, 100)));
2715 EXPECT_RECT_EQ(gfx::Rect(0, 0, 99, 100), occlusion.unoccludedLayerConten tRect(filteredSurface, gfx::Rect(-1, 0, 100, 100))); 2621 EXPECT_RECT_EQ(gfx::Rect(0, 0, 99, 100), occlusion.unoccludedLayerConten tRect(filteredSurface, gfx::Rect(-1, 0, 100, 100)));
2716 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 99), occlusion.unoccludedLayerConten tRect(filteredSurface, gfx::Rect(0, -1, 100, 100))); 2622 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 99), occlusion.unoccludedLayerConten tRect(filteredSurface, gfx::Rect(0, -1, 100, 100)));
2717 2623
2718 EXPECT_RECT_EQ(gfx::Rect(300 + 1, 0, 99, 100), occlusion.unoccludedLayer ContentRect(filteredSurface, gfx::Rect(300 + 1, 0, 100, 100))); 2624 EXPECT_RECT_EQ(gfx::Rect(300 + 1, 0, 99, 100), occlusion.unoccludedLayer ContentRect(filteredSurface, gfx::Rect(300 + 1, 0, 100, 100)));
2719 EXPECT_RECT_EQ(gfx::Rect(300 + 0, 1, 100, 99), occlusion.unoccludedLayer ContentRect(filteredSurface, gfx::Rect(300 + 0, 1, 100, 100))); 2625 EXPECT_RECT_EQ(gfx::Rect(300 + 0, 1, 100, 99), occlusion.unoccludedLayer ContentRect(filteredSurface, gfx::Rect(300 + 0, 1, 100, 100)));
2720 EXPECT_RECT_EQ(gfx::Rect(300 + 0, 0, 99, 100), occlusion.unoccludedLayer ContentRect(filteredSurface, gfx::Rect(300 - 1, 0, 100, 100))); 2626 EXPECT_RECT_EQ(gfx::Rect(300 + 0, 0, 99, 100), occlusion.unoccludedLayer ContentRect(filteredSurface, gfx::Rect(300 - 1, 0, 100, 100)));
2721 EXPECT_RECT_EQ(gfx::Rect(300 + 0, 0, 100, 99), occlusion.unoccludedLayer ContentRect(filteredSurface, gfx::Rect(300 + 0, -1, 100, 100))); 2627 EXPECT_RECT_EQ(gfx::Rect(300 + 0, 0, 100, 99), occlusion.unoccludedLayer ContentRect(filteredSurface, gfx::Rect(300 + 0, -1, 100, 100)));
2722 this->leaveLayer(filteredSurface, occlusion); 2628 this->leaveLayer(filteredSurface, occlusion);
2723 2629
2724 // The filtered layer/replica does not occlude. 2630 // The filtered layer/replica does not occlude.
2725 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpa ce().bounds()); 2631 EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace ().ToString());
2726 EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2632 EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().T oString());
2727 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.occlusionInTargetSurface ().bounds());
2728 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2729 2633
2730 // The surface has a background blur, so it needs pixels that are curren tly considered occluded in order to be drawn. So the pixels 2634 // The surface has a background blur, so it needs pixels that are curren tly considered occluded in order to be drawn. So the pixels
2731 // it needs should be removed some the occluded area so that when we get to the parent they are drawn. 2635 // it needs should be removed some the occluded area so that when we get to the parent they are drawn.
2732 this->visitContributingSurface(filteredSurface, occlusion); 2636 this->visitContributingSurface(filteredSurface, occlusion);
2733 2637
2734 this->enterLayer(parent, occlusion); 2638 this->enterLayer(parent, occlusion);
2735 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpa ce().bounds()); 2639
2736 EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2640 Region expectedBlurredOcclusion;
2737 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInTargetSur face().bounds()); 2641 expectedBlurredOcclusion.Union(gfx::Rect(0, 0, 300, 50 - outsetTop));
2738 EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e()); 2642 expectedBlurredOcclusion.Union(gfx::Rect(0, 50 - outsetTop, 50 - outsetL eft, 50 + outsetTop + outsetBottom));
2643 expectedBlurredOcclusion.Union(gfx::Rect(100 + outsetRight, 50 - outsetT op, 100 - outsetRight - outsetLeft, 50 + outsetTop + outsetBottom));
2644 expectedBlurredOcclusion.Union(gfx::Rect(250 + outsetRight, 50 - outsetT op, 50 - outsetRight, 50 + outsetTop + outsetBottom));
2645 expectedBlurredOcclusion.Union(gfx::Rect(0, 100 + outsetBottom, 300, 50 - outsetBottom));
2646
2647 EXPECT_EQ(expectedBlurredOcclusion.ToString(), occlusion.occlusionInScre enSpace().ToString());
2648 EXPECT_EQ(expectedBlurredOcclusion.ToString(), occlusion.occlusionInTarg etSurface().ToString());
2739 2649
2740 gfx::Rect outsetRect; 2650 gfx::Rect outsetRect;
2741 gfx::Rect testRect; 2651 gfx::Rect testRect;
2742 2652
2743 // Nothing in the blur outsets for the filteredSurface is occluded. 2653 // Nothing in the blur outsets for the filteredSurface is occluded.
2744 outsetRect = gfx::Rect(50 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom); 2654 outsetRect = gfx::Rect(50 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom);
2745 testRect = outsetRect; 2655 testRect = outsetRect;
2746 EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedLayerContentRect(parent, testRect)); 2656 EXPECT_RECT_EQ(outsetRect, occlusion.unoccludedLayerContentRect(parent, testRect));
2747 2657
2748 // Stuff outside the blur outsets is still occluded though. 2658 // Stuff outside the blur outsets is still occluded though.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 // Save the distance of influence for the blur effect. 2718 // Save the distance of influence for the blur effect.
2809 int outsetTop, outsetRight, outsetBottom, outsetLeft; 2719 int outsetTop, outsetRight, outsetBottom, outsetLeft;
2810 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); 2720 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft);
2811 2721
2812 this->calcDrawEtc(root); 2722 this->calcDrawEtc(root);
2813 2723
2814 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 2724 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
2815 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 2725 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
2816 2726
2817 this->visitLayer(occludingLayerAbove, occlusion); 2727 this->visitLayer(occludingLayerAbove, occlusion);
2818 EXPECT_RECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.oc clusionInScreenSpace().bounds()); 2728 EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(), occlus ion.occlusionInScreenSpace().ToString());
2819 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2729 EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(), occlus ion.occlusionInTargetSurface().ToString());
2820 EXPECT_RECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2), occlusion.oc clusionInTargetSurface().bounds());
2821 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2822 2730
2823 this->visitLayer(filteredSurface2, occlusion); 2731 this->visitLayer(filteredSurface2, occlusion);
2824 this->visitContributingSurface(filteredSurface2, occlusion); 2732 this->visitContributingSurface(filteredSurface2, occlusion);
2825 this->visitLayer(filteredSurface1, occlusion); 2733 this->visitLayer(filteredSurface1, occlusion);
2826 this->visitContributingSurface(filteredSurface1, occlusion); 2734 this->visitContributingSurface(filteredSurface1, occlusion);
2827 2735
2828 ASSERT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( ));
2829 ASSERT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2830
2831 // Test expectations in the target. 2736 // Test expectations in the target.
2832 gfx::Rect expectedOcclusion = gfx::Rect(100 / 2 + outsetRight * 2, 100 / 2 + outsetBottom * 2, 50 / 2 - (outsetLeft + outsetRight) * 2, 50 / 2 - (outset Top + outsetBottom) * 2); 2737 gfx::Rect expectedOcclusion = gfx::Rect(100 / 2 + outsetRight * 2, 100 / 2 + outsetBottom * 2, 50 / 2 - (outsetLeft + outsetRight) * 2, 50 / 2 - (outset Top + outsetBottom) * 2);
2833 EXPECT_RECT_EQ(expectedOcclusion, Region::Iterator(occlusion.occlusionIn TargetSurface()).rect()); 2738 EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInTargetSurfa ce().ToString());
2834 2739
2835 // Test expectations in the screen are the same as in the target, as the render surface is 1:1 with the screen. 2740 // Test expectations in the screen are the same as in the target, as the render surface is 1:1 with the screen.
2836 EXPECT_RECT_EQ(expectedOcclusion, Region::Iterator(occlusion.occlusionIn ScreenSpace()).rect()); 2741 EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace ().ToString());
2837 } 2742 }
2838 }; 2743 };
2839 2744
2840 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusio nTwice); 2745 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusio nTwice);
2841 2746
2842 template<class Types> 2747 template<class Types>
2843 class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip : p ublic OcclusionTrackerTest<Types> { 2748 class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip : p ublic OcclusionTrackerTest<Types> {
2844 protected: 2749 protected:
2845 OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} 2750 OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilterWithClip(bool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
2846 void runMyTest() 2751 void runMyTest()
(...skipping 27 matching lines...) Expand all
2874 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 2779 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
2875 2780
2876 // These layers occlude pixels directly beside the filteredSurface. Beca use filtered surface blends pixels in a radius, it will 2781 // These layers occlude pixels directly beside the filteredSurface. Beca use filtered surface blends pixels in a radius, it will
2877 // need to see some of the pixels (up to radius far) underneath the occl udingLayers. 2782 // need to see some of the pixels (up to radius far) underneath the occl udingLayers.
2878 this->visitLayer(occludingLayer5, occlusion); 2783 this->visitLayer(occludingLayer5, occlusion);
2879 this->visitLayer(occludingLayer4, occlusion); 2784 this->visitLayer(occludingLayer4, occlusion);
2880 this->visitLayer(occludingLayer3, occlusion); 2785 this->visitLayer(occludingLayer3, occlusion);
2881 this->visitLayer(occludingLayer2, occlusion); 2786 this->visitLayer(occludingLayer2, occlusion);
2882 this->visitLayer(occludingLayer1, occlusion); 2787 this->visitLayer(occludingLayer1, occlusion);
2883 2788
2884 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpa ce().bounds()); 2789 Region expectedOcclusion;
2885 EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2790 expectedOcclusion.Union(gfx::Rect(0, 0, 300, 50));
2886 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInTargetSur face().bounds()); 2791 expectedOcclusion.Union(gfx::Rect(0, 50, 50, 50));
2887 EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e()); 2792 expectedOcclusion.Union(gfx::Rect(100, 50, 100, 50));
2793 expectedOcclusion.Union(gfx::Rect(250, 50, 50, 50));
2794 expectedOcclusion.Union(gfx::Rect(0, 100, 300, 50));
2795
2796 EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace ().ToString());
2797 EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInTargetSurfa ce().ToString());
2888 2798
2889 // Everything outside the surface/replica is occluded but the surface/re plica itself is not. 2799 // Everything outside the surface/replica is occluded but the surface/re plica itself is not.
2890 this->enterLayer(filteredSurface, occlusion); 2800 this->enterLayer(filteredSurface, occlusion);
2891 EXPECT_RECT_EQ(gfx::Rect(1, 0, 49, 50), occlusion.unoccludedLayerContent Rect(filteredSurface, gfx::Rect(1, 0, 50, 50))); 2801 EXPECT_RECT_EQ(gfx::Rect(1, 0, 49, 50), occlusion.unoccludedLayerContent Rect(filteredSurface, gfx::Rect(1, 0, 50, 50)));
2892 EXPECT_RECT_EQ(gfx::Rect(0, 1, 50, 49), occlusion.unoccludedLayerContent Rect(filteredSurface, gfx::Rect(0, 1, 50, 50))); 2802 EXPECT_RECT_EQ(gfx::Rect(0, 1, 50, 49), occlusion.unoccludedLayerContent Rect(filteredSurface, gfx::Rect(0, 1, 50, 50)));
2893 EXPECT_RECT_EQ(gfx::Rect(0, 0, 49, 50), occlusion.unoccludedLayerContent Rect(filteredSurface, gfx::Rect(-1, 0, 50, 50))); 2803 EXPECT_RECT_EQ(gfx::Rect(0, 0, 49, 50), occlusion.unoccludedLayerContent Rect(filteredSurface, gfx::Rect(-1, 0, 50, 50)));
2894 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 49), occlusion.unoccludedLayerContent Rect(filteredSurface, gfx::Rect(0, -1, 50, 50))); 2804 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 49), occlusion.unoccludedLayerContent Rect(filteredSurface, gfx::Rect(0, -1, 50, 50)));
2895 2805
2896 EXPECT_RECT_EQ(gfx::Rect(150 + 1, 0, 49, 50), occlusion.unoccludedLayerC ontentRect(filteredSurface, gfx::Rect(150 + 1, 0, 50, 50))); 2806 EXPECT_RECT_EQ(gfx::Rect(150 + 1, 0, 49, 50), occlusion.unoccludedLayerC ontentRect(filteredSurface, gfx::Rect(150 + 1, 0, 50, 50)));
2897 EXPECT_RECT_EQ(gfx::Rect(150 + 0, 1, 50, 49), occlusion.unoccludedLayerC ontentRect(filteredSurface, gfx::Rect(150 + 0, 1, 50, 50))); 2807 EXPECT_RECT_EQ(gfx::Rect(150 + 0, 1, 50, 49), occlusion.unoccludedLayerC ontentRect(filteredSurface, gfx::Rect(150 + 0, 1, 50, 50)));
2898 EXPECT_RECT_EQ(gfx::Rect(150 + 0, 0, 49, 50), occlusion.unoccludedLayerC ontentRect(filteredSurface, gfx::Rect(150 - 1, 0, 50, 50))); 2808 EXPECT_RECT_EQ(gfx::Rect(150 + 0, 0, 49, 50), occlusion.unoccludedLayerC ontentRect(filteredSurface, gfx::Rect(150 - 1, 0, 50, 50)));
2899 EXPECT_RECT_EQ(gfx::Rect(150 + 0, 0, 50, 49), occlusion.unoccludedLayerC ontentRect(filteredSurface, gfx::Rect(150 + 0, -1, 50, 50))); 2809 EXPECT_RECT_EQ(gfx::Rect(150 + 0, 0, 50, 49), occlusion.unoccludedLayerC ontentRect(filteredSurface, gfx::Rect(150 + 0, -1, 50, 50)));
2900 this->leaveLayer(filteredSurface, occlusion); 2810 this->leaveLayer(filteredSurface, occlusion);
2901 2811
2902 // The filtered layer/replica does not occlude. 2812 // The filtered layer/replica does not occlude.
2903 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpa ce().bounds()); 2813 EXPECT_EQ(expectedOcclusion.ToString(), occlusion.occlusionInScreenSpace ().ToString());
2904 EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2814 EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().T oString());
2905 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), occlusion.occlusionInTargetSurface ().bounds());
2906 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
2907 2815
2908 // The surface has a background blur, so it needs pixels that are curren tly considered occluded in order to be drawn. So the pixels 2816 // The surface has a background blur, so it needs pixels that are curren tly considered occluded in order to be drawn. So the pixels
2909 // it needs should be removed some the occluded area so that when we get to the parent they are drawn. 2817 // it needs should be removed some the occluded area so that when we get to the parent they are drawn.
2910 this->visitContributingSurface(filteredSurface, occlusion); 2818 this->visitContributingSurface(filteredSurface, occlusion);
2911 2819
2912 this->enterContributingSurface(clippingSurface, occlusion); 2820 this->enterContributingSurface(clippingSurface, occlusion);
2913 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 150), occlusion.occlusionInScreenSpa ce().bounds()); 2821
2914 EXPECT_EQ(5u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2822 Region expectedBlurredOcclusion;
2823 expectedBlurredOcclusion.Union(gfx::Rect(0, 0, 300, 50 - outsetTop));
2824 expectedBlurredOcclusion.Union(gfx::Rect(0, 50 - outsetTop, 50 - outsetL eft, 20 + outsetTop + outsetBottom));
2825 expectedBlurredOcclusion.Union(gfx::Rect(100 + outsetRight, 50 - outsetT op, 100 - outsetRight - outsetLeft, 20 + outsetTop + outsetBottom));
2826 expectedBlurredOcclusion.Union(gfx::Rect(250 + outsetRight, 50 - outsetT op, 50 - outsetRight, 20 + outsetTop + outsetBottom));
2827 expectedBlurredOcclusion.Union(gfx::Rect(0, 100 + 5, 300, 50 - 5));
2828
2829 EXPECT_EQ(expectedBlurredOcclusion.ToString(), occlusion.occlusionInScre enSpace().ToString());
2830 EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().T oString());
2915 2831
2916 gfx::Rect outsetRect; 2832 gfx::Rect outsetRect;
2917 gfx::Rect clippedOutsetRect; 2833 gfx::Rect clippedOutsetRect;
2918 gfx::Rect testRect; 2834 gfx::Rect testRect;
2919 2835
2920 // Nothing in the (clipped) blur outsets for the filteredSurface is occl uded. 2836 // Nothing in the (clipped) blur outsets for the filteredSurface is occl uded.
2921 outsetRect = gfx::Rect(50 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom); 2837 outsetRect = gfx::Rect(50 - outsetLeft, 50 - outsetTop, 50 + outsetLeft + outsetRight, 50 + outsetTop + outsetBottom);
2922 clippedOutsetRect = gfx::IntersectRects(outsetRect, gfx::Rect(0 - outset Left, 0 - outsetTop, 300 + outsetLeft + outsetRight, 70 + outsetTop + outsetBott om)); 2838 clippedOutsetRect = gfx::IntersectRects(outsetRect, gfx::Rect(0 - outset Left, 0 - outsetTop, 300 + outsetLeft + outsetRight, 70 + outsetTop + outsetBott om));
2923 testRect = outsetRect; 2839 testRect = outsetRect;
2924 EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedLayerContentRect(c lippingSurface, testRect)); 2840 EXPECT_RECT_EQ(clippedOutsetRect, occlusion.unoccludedLayerContentRect(c lippingSurface, testRect));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 this->visitContributingSurface(filteredSurface, occlusion); 2910 this->visitContributingSurface(filteredSurface, occlusion);
2995 2911
2996 this->visitLayer(behindReplicaLayer, occlusion); 2912 this->visitLayer(behindReplicaLayer, occlusion);
2997 this->visitLayer(behindSurfaceLayer, occlusion); 2913 this->visitLayer(behindSurfaceLayer, occlusion);
2998 2914
2999 // The layers behind the surface are not blurred, and their occlusion do es not change, until we leave the surface. 2915 // The layers behind the surface are not blurred, and their occlusion do es not change, until we leave the surface.
3000 // So it should not be modified by the filter here. 2916 // So it should not be modified by the filter here.
3001 gfx::Rect occlusionBehindSurface = gfx::Rect(60, 60, 30, 30); 2917 gfx::Rect occlusionBehindSurface = gfx::Rect(60, 60, 30, 30);
3002 gfx::Rect occlusionBehindReplica = gfx::Rect(210, 60, 30, 30); 2918 gfx::Rect occlusionBehindReplica = gfx::Rect(210, 60, 30, 30);
3003 2919
3004 gfx::Rect expectedOpaqueBounds = gfx::UnionRects(occlusionBehindSurface, occlusionBehindReplica); 2920 Region expectedOpaqueBounds = UnionRegions(occlusionBehindSurface, occlu sionBehindReplica);
3005 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace(). bounds()); 2921 EXPECT_EQ(expectedOpaqueBounds.ToString(), occlusion.occlusionInScreenSp ace().ToString());
3006 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2922 EXPECT_EQ(expectedOpaqueBounds.ToString(), occlusion.occlusionInTargetSu rface().ToString());
3007 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface( ).bounds());
3008 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
3009 } 2923 }
3010 }; 2924 };
3011 2925
3012 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestDontReduceOcclusionBelowBackground Filter); 2926 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestDontReduceOcclusionBelowBackground Filter);
3013 2927
3014 template<class Types> 2928 template<class Types>
3015 class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded : publ ic OcclusionTrackerTest<Types> { 2929 class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded : publ ic OcclusionTrackerTest<Types> {
3016 protected: 2930 protected:
3017 OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded(bool opa queLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} 2931 OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded(bool opa queLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
3018 void runMyTest() 2932 void runMyTest()
(...skipping 24 matching lines...) Expand all
3043 this->visitLayer(aboveSurfaceLayer, occlusion); 2957 this->visitLayer(aboveSurfaceLayer, occlusion);
3044 2958
3045 // The surface has a background blur, so it blurs non-opaque pixels belo w it. 2959 // The surface has a background blur, so it blurs non-opaque pixels belo w it.
3046 this->visitLayer(filteredSurface, occlusion); 2960 this->visitLayer(filteredSurface, occlusion);
3047 this->visitContributingSurface(filteredSurface, occlusion); 2961 this->visitContributingSurface(filteredSurface, occlusion);
3048 2962
3049 // The filter is completely occluded, so it should not blur anything and reduce any occlusion. 2963 // The filter is completely occluded, so it should not blur anything and reduce any occlusion.
3050 gfx::Rect occlusionAboveSurface = gfx::Rect(50, 50, 50, 50); 2964 gfx::Rect occlusionAboveSurface = gfx::Rect(50, 50, 50, 50);
3051 gfx::Rect occlusionAboveReplica = gfx::Rect(200, 50, 50, 50); 2965 gfx::Rect occlusionAboveReplica = gfx::Rect(200, 50, 50, 50);
3052 2966
3053 gfx::Rect expectedOpaqueBounds = gfx::UnionRects(occlusionAboveSurface, occlusionAboveReplica); 2967 Region expectedOpaqueRegion = UnionRegions(occlusionAboveSurface, occlus ionAboveReplica);
3054 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInScreenSpace(). bounds()); 2968 EXPECT_EQ(expectedOpaqueRegion, occlusion.occlusionInScreenSpace());
3055 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 2969 EXPECT_EQ(expectedOpaqueRegion, occlusion.occlusionInTargetSurface());
3056 EXPECT_RECT_EQ(expectedOpaqueBounds, occlusion.occlusionInTargetSurface( ).bounds());
3057 EXPECT_EQ(2u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
3058 } 2970 }
3059 }; 2971 };
3060 2972
3061 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestDontReduceOcclusionIfBackgroundFil terIsOccluded); 2973 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestDontReduceOcclusionIfBackgroundFil terIsOccluded);
3062 2974
3063 template<class Types> 2975 template<class Types>
3064 class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded : public OcclusionTrackerTest<Types> { 2976 class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded : public OcclusionTrackerTest<Types> {
3065 protected: 2977 protected:
3066 OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded(b ool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {} 2978 OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded(b ool opaqueLayers) : OcclusionTrackerTest<Types>(opaqueLayers) {}
3067 void runMyTest() 2979 void runMyTest()
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 gfx::Rect occlusionAboveReplica = gfx::Rect(200, 50, 30 - outsetLeft, 50 ); 3023 gfx::Rect occlusionAboveReplica = gfx::Rect(200, 50, 30 - outsetLeft, 50 );
3112 gfx::Rect occlusionBesideSurface = gfx::Rect(90, 40, 10, 10); 3024 gfx::Rect occlusionBesideSurface = gfx::Rect(90, 40, 10, 10);
3113 gfx::Rect occlusionBesideReplica = gfx::Rect(200, 40, 10, 10); 3025 gfx::Rect occlusionBesideReplica = gfx::Rect(200, 40, 10, 10);
3114 3026
3115 Region expectedOcclusion; 3027 Region expectedOcclusion;
3116 expectedOcclusion.Union(occlusionAboveSurface); 3028 expectedOcclusion.Union(occlusionAboveSurface);
3117 expectedOcclusion.Union(occlusionAboveReplica); 3029 expectedOcclusion.Union(occlusionAboveReplica);
3118 expectedOcclusion.Union(occlusionBesideSurface); 3030 expectedOcclusion.Union(occlusionBesideSurface);
3119 expectedOcclusion.Union(occlusionBesideReplica); 3031 expectedOcclusion.Union(occlusionBesideReplica);
3120 3032
3121 ASSERT_EQ(Region::Iterator(expectedOcclusion).size(), Region::Iterator(o cclusion.occlusionInTargetSurface()).size()); 3033 ASSERT_EQ(expectedOcclusion, occlusion.occlusionInTargetSurface());
3122 ASSERT_EQ(Region::Iterator(expectedOcclusion).size(), Region::Iterator(o cclusion.occlusionInScreenSpace()).size()); 3034 ASSERT_EQ(expectedOcclusion, occlusion.occlusionInScreenSpace());
3123 3035
3124 Region::Iterator expectedRects(expectedOcclusion); 3036 Region::Iterator expectedRects(expectedOcclusion);
3125 Region::Iterator screenSpaceRects(occlusion.occlusionInScreenSpace()); 3037 Region::Iterator screenSpaceRects(occlusion.occlusionInScreenSpace());
3126 Region::Iterator targetSurfaceRects(occlusion.occlusionInTargetSurface() ); 3038 Region::Iterator targetSurfaceRects(occlusion.occlusionInTargetSurface() );
3127 for (; expectedRects.has_rect(); expectedRects.next(), screenSpaceRects. next(), targetSurfaceRects.next()) { 3039 for (; expectedRects.has_rect(); expectedRects.next(), screenSpaceRects. next(), targetSurfaceRects.next()) {
3128 ASSERT_TRUE(screenSpaceRects.has_rect()); 3040 ASSERT_TRUE(screenSpaceRects.has_rect());
3129 ASSERT_TRUE(targetSurfaceRects.has_rect()); 3041 ASSERT_TRUE(targetSurfaceRects.has_rect());
3130 EXPECT_EQ(expectedRects.rect(), screenSpaceRects.rect()); 3042 EXPECT_EQ(expectedRects.rect(), screenSpaceRects.rect());
3131 EXPECT_EQ(expectedRects.rect(), targetSurfaceRects.rect()); 3043 EXPECT_EQ(expectedRects.rect(), targetSurfaceRects.rect());
3132 } 3044 }
(...skipping 16 matching lines...) Expand all
3149 typename Types::LayerType* small = this->createDrawingLayer(parent, this ->identityMatrix, gfx::PointF(0, 0), belowTrackingSize, true); 3061 typename Types::LayerType* small = this->createDrawingLayer(parent, this ->identityMatrix, gfx::PointF(0, 0), belowTrackingSize, true);
3150 this->calcDrawEtc(parent); 3062 this->calcDrawEtc(parent);
3151 3063
3152 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000)); 3064 TestOcclusionTrackerWithClip<typename Types::LayerType, typename Types:: RenderSurfaceType> occlusion(gfx::Rect(0, 0, 1000, 1000));
3153 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000)); 3065 occlusion.setLayerClipRect(gfx::Rect(0, 0, 1000, 1000));
3154 occlusion.setMinimumTrackingSize(trackingSize); 3066 occlusion.setMinimumTrackingSize(trackingSize);
3155 3067
3156 // The small layer is not tracked because it is too small. 3068 // The small layer is not tracked because it is too small.
3157 this->visitLayer(small, occlusion); 3069 this->visitLayer(small, occlusion);
3158 3070
3159 EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInScreenSpace().bounds()) ; 3071 EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInScreenSpace().ToS tring());
3160 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 3072 EXPECT_EQ(gfx::Rect().ToString(), occlusion.occlusionInTargetSurface().T oString());
3161 EXPECT_RECT_EQ(gfx::Rect(), occlusion.occlusionInTargetSurface().bounds( ));
3162 EXPECT_EQ(0u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
3163 3073
3164 // The large layer is tracked as it is large enough. 3074 // The large layer is tracked as it is large enough.
3165 this->visitLayer(large, occlusion); 3075 this->visitLayer(large, occlusion);
3166 3076
3167 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), trackingSize), occlusion.occlusio nInScreenSpace().bounds()); 3077 EXPECT_EQ(gfx::Rect(gfx::Point(), trackingSize).ToString(), occlusion.oc clusionInScreenSpace().ToString());
3168 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInScreenSpace()).size( )); 3078 EXPECT_EQ(gfx::Rect(gfx::Point(), trackingSize).ToString(), occlusion.oc clusionInTargetSurface().ToString());
3169 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), trackingSize), occlusion.occlusio nInTargetSurface().bounds());
3170 EXPECT_EQ(1u, Region::Iterator(occlusion.occlusionInTargetSurface()).siz e());
3171 } 3079 }
3172 }; 3080 };
3173 3081
3174 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize); 3082 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize);
3175 3083
3176 } // anonymous namespace 3084 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/occlusion_tracker.cc ('k') | cc/quad_culler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698