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

Side by Side Diff: cc/damage_tracker_unittest.cc

Issue 11316171: Don't create render passes for transparent images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing code reviews. Created 8 years 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 | « no previous file | cc/delegated_renderer_layer_impl.h » ('j') | cc/delegated_renderer_layer_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/damage_tracker.h" 5 #include "cc/damage_tracker.h"
6 6
7 #include "cc/layer_impl.h" 7 #include "cc/layer_impl.h"
8 #include "cc/layer_sorter.h" 8 #include "cc/layer_sorter.h"
9 #include "cc/layer_tree_host_common.h" 9 #include "cc/layer_tree_host_common.h"
10 #include "cc/math_util.h" 10 #include "cc/math_util.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 root->setDrawsContent(true); 106 root->setDrawsContent(true);
107 root->createRenderSurface(); 107 root->createRenderSurface();
108 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(500, 500))); 108 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(500, 500)));
109 109
110 child1->setPosition(gfx::PointF(100, 100)); 110 child1->setPosition(gfx::PointF(100, 100));
111 child1->setAnchorPoint(gfx::PointF()); 111 child1->setAnchorPoint(gfx::PointF());
112 child1->setBounds(gfx::Size(30, 30)); 112 child1->setBounds(gfx::Size(30, 30));
113 child1->setContentBounds(gfx::Size(30, 30)); 113 child1->setContentBounds(gfx::Size(30, 30));
114 child1->setOpacity(0.5); // with a child that drawsContent, this will cause the layer to create its own renderSurface. 114 child1->setOpacity(0.5); // with a child that drawsContent, this will cause the layer to create its own renderSurface.
115 child1->setDrawsContent(false); // this layer does not draw, but is intended to create its own renderSurface. 115 child1->setDrawsContent(false); // this layer does not draw, but is intended to create its own renderSurface.
116 child1->setForceRenderSurface(true);
116 117
117 child2->setPosition(gfx::PointF(11, 11)); 118 child2->setPosition(gfx::PointF(11, 11));
118 child2->setAnchorPoint(gfx::PointF()); 119 child2->setAnchorPoint(gfx::PointF());
119 child2->setBounds(gfx::Size(18, 18)); 120 child2->setBounds(gfx::Size(18, 18));
120 child2->setContentBounds(gfx::Size(18, 18)); 121 child2->setContentBounds(gfx::Size(18, 18));
121 child2->setDrawsContent(true); 122 child2->setDrawsContent(true);
122 123
123 grandChild1->setPosition(gfx::PointF(200, 200)); 124 grandChild1->setPosition(gfx::PointF(200, 200));
124 grandChild1->setAnchorPoint(gfx::PointF()); 125 grandChild1->setAnchorPoint(gfx::PointF());
125 grandChild1->setBounds(gfx::Size(6, 8)); 126 grandChild1->setBounds(gfx::Size(6, 8));
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 { 717 {
717 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 718 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
718 LayerImpl* child1 = root->children()[0]; 719 LayerImpl* child1 = root->children()[0];
719 gfx::RectF childDamageRect; 720 gfx::RectF childDamageRect;
720 gfx::RectF rootDamageRect; 721 gfx::RectF rootDamageRect;
721 722
722 // CASE 1: If a descendant surface disappears, its entire old area becomes e xposed. 723 // CASE 1: If a descendant surface disappears, its entire old area becomes e xposed.
723 // 724 //
724 clearDamageForAllSurfaces(root.get()); 725 clearDamageForAllSurfaces(root.get());
725 child1->setOpacity(1); 726 child1->setOpacity(1);
727 child1->setForceRenderSurface(false);
726 emulateDrawingOneFrame(root.get()); 728 emulateDrawingOneFrame(root.get());
727 729
728 // Sanity check that there is only one surface now. 730 // Sanity check that there is only one surface now.
729 ASSERT_FALSE(child1->renderSurface()); 731 ASSERT_FALSE(child1->renderSurface());
730 ASSERT_EQ(4u, root->renderSurface()->layerList().size()); 732 ASSERT_EQ(4u, root->renderSurface()->layerList().size());
731 733
732 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 734 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
733 EXPECT_FLOAT_RECT_EQ(gfx::RectF(290, 290, 16, 18), rootDamageRect); 735 EXPECT_FLOAT_RECT_EQ(gfx::RectF(290, 290, 16, 18), rootDamageRect);
734 736
735 // CASE 2: If a descendant surface appears, its entire old area becomes expo sed. 737 // CASE 2: If a descendant surface appears, its entire old area becomes expo sed.
736 738
737 // Cycle one frame of no change, just to sanity check that the next rect is not because of the old damage state. 739 // Cycle one frame of no change, just to sanity check that the next rect is not because of the old damage state.
738 clearDamageForAllSurfaces(root.get()); 740 clearDamageForAllSurfaces(root.get());
739 emulateDrawingOneFrame(root.get()); 741 emulateDrawingOneFrame(root.get());
740 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 742 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
741 EXPECT_TRUE(rootDamageRect.IsEmpty()); 743 EXPECT_TRUE(rootDamageRect.IsEmpty());
742 744
743 // Then change the tree so that the render surface is added back. 745 // Then change the tree so that the render surface is added back.
744 clearDamageForAllSurfaces(root.get()); 746 clearDamageForAllSurfaces(root.get());
745 child1->setOpacity(0.5); 747 child1->setOpacity(0.5);
748 child1->setForceRenderSurface(true);
746 emulateDrawingOneFrame(root.get()); 749 emulateDrawingOneFrame(root.get());
747 750
748 // Sanity check that there is a new surface now. 751 // Sanity check that there is a new surface now.
749 ASSERT_TRUE(child1->renderSurface()); 752 ASSERT_TRUE(child1->renderSurface());
750 EXPECT_EQ(3u, root->renderSurface()->layerList().size()); 753 EXPECT_EQ(3u, root->renderSurface()->layerList().size());
751 EXPECT_EQ(2u, child1->renderSurface()->layerList().size()); 754 EXPECT_EQ(2u, child1->renderSurface()->layerList().size());
752 755
753 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec t(); 756 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec t();
754 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 757 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
755 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 16, 18), childDamageRect); 758 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 16, 18), childDamageRect);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1153 EXPECT_TRUE(rootDamageRect.IsEmpty());
1151 1154
1152 // Damage should remain empty even after one frame, since there's yet no new damage 1155 // Damage should remain empty even after one frame, since there's yet no new damage
1153 emulateDrawingOneFrame(root.get()); 1156 emulateDrawingOneFrame(root.get());
1154 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 1157 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
1155 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1158 EXPECT_TRUE(rootDamageRect.IsEmpty());
1156 } 1159 }
1157 1160
1158 } // namespace 1161 } // namespace
1159 } // namespace cc 1162 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/delegated_renderer_layer_impl.h » ('j') | cc/delegated_renderer_layer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698