| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/damage_tracker.h" | 5 #include "cc/trees/damage_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 root->layer_tree_impl()->ResetAllChangeTracking(); | 82 root->layer_tree_impl()->ResetAllChangeTracking(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 class DamageTrackerTest : public testing::Test { | 85 class DamageTrackerTest : public testing::Test { |
| 86 public: | 86 public: |
| 87 DamageTrackerTest() | 87 DamageTrackerTest() |
| 88 : host_impl_(&task_runner_provider_, &task_graph_runner_) {} | 88 : host_impl_(&task_runner_provider_, &task_graph_runner_) {} |
| 89 | 89 |
| 90 LayerImpl* CreateTestTreeWithOneSurface() { | 90 LayerImpl* CreateTestTreeWithOneSurface(int number_of_children) { |
| 91 host_impl_.active_tree()->DetachLayers(); | 91 host_impl_.active_tree()->DetachLayers(); |
| 92 std::unique_ptr<LayerImpl> root = | 92 std::unique_ptr<LayerImpl> root = |
| 93 LayerImpl::Create(host_impl_.active_tree(), 1); | 93 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 94 std::unique_ptr<LayerImpl> child = | |
| 95 LayerImpl::Create(host_impl_.active_tree(), 2); | |
| 96 | 94 |
| 97 root->SetPosition(gfx::PointF()); | 95 root->SetPosition(gfx::PointF()); |
| 98 root->SetBounds(gfx::Size(500, 500)); | 96 root->SetBounds(gfx::Size(500, 500)); |
| 99 root->SetDrawsContent(true); | 97 root->SetDrawsContent(true); |
| 100 root->test_properties()->force_render_surface = true; | 98 root->test_properties()->force_render_surface = true; |
| 101 | 99 |
| 102 child->SetPosition(gfx::PointF(100.f, 100.f)); | 100 for (int i = 0; i < number_of_children; ++i) { |
| 103 child->SetBounds(gfx::Size(30, 30)); | 101 std::unique_ptr<LayerImpl> child = |
| 104 child->SetDrawsContent(true); | 102 LayerImpl::Create(host_impl_.active_tree(), 2 + i); |
| 105 root->test_properties()->AddChild(std::move(child)); | 103 child->SetPosition(gfx::PointF(100.f, 100.f)); |
| 104 child->SetBounds(gfx::Size(30, 30)); |
| 105 child->SetDrawsContent(true); |
| 106 root->test_properties()->AddChild(std::move(child)); |
| 107 } |
| 106 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); | 108 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 107 | 109 |
| 108 return host_impl_.active_tree()->root_layer_for_testing(); | 110 return host_impl_.active_tree()->root_layer_for_testing(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 LayerImpl* CreateTestTreeWithTwoSurfaces() { | 113 LayerImpl* CreateTestTreeWithTwoSurfaces() { |
| 112 // This test tree has two render surfaces: one for the root, and one for | 114 // This test tree has two render surfaces: one for the root, and one for |
| 113 // child1. Additionally, the root has a second child layer, and child1 has | 115 // child1. Additionally, the root has a second child layer, and child1 has |
| 114 // two children of its own. | 116 // two children of its own. |
| 115 | 117 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 154 |
| 153 child1->test_properties()->AddChild(std::move(grand_child1)); | 155 child1->test_properties()->AddChild(std::move(grand_child1)); |
| 154 child1->test_properties()->AddChild(std::move(grand_child2)); | 156 child1->test_properties()->AddChild(std::move(grand_child2)); |
| 155 root->test_properties()->AddChild(std::move(child1)); | 157 root->test_properties()->AddChild(std::move(child1)); |
| 156 root->test_properties()->AddChild(std::move(child2)); | 158 root->test_properties()->AddChild(std::move(child2)); |
| 157 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); | 159 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 158 | 160 |
| 159 return host_impl_.active_tree()->root_layer_for_testing(); | 161 return host_impl_.active_tree()->root_layer_for_testing(); |
| 160 } | 162 } |
| 161 | 163 |
| 162 LayerImpl* CreateAndSetUpTestTreeWithOneSurface() { | 164 LayerImpl* CreateAndSetUpTestTreeWithOneSurface(int number_of_children = 1) { |
| 163 LayerImpl* root = CreateTestTreeWithOneSurface(); | 165 LayerImpl* root = CreateTestTreeWithOneSurface(number_of_children); |
| 164 | 166 |
| 165 // Setup includes going past the first frame which always damages | 167 // Setup includes going past the first frame which always damages |
| 166 // everything, so that we can actually perform specific tests. | 168 // everything, so that we can actually perform specific tests. |
| 167 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 169 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 168 EmulateDrawingOneFrame(root); | 170 EmulateDrawingOneFrame(root); |
| 169 | 171 |
| 170 return root; | 172 return root; |
| 171 } | 173 } |
| 172 | 174 |
| 173 LayerImpl* CreateAndSetUpTestTreeWithTwoSurfaces() { | 175 LayerImpl* CreateAndSetUpTestTreeWithTwoSurfaces() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 190 TEST_F(DamageTrackerTest, SanityCheckTestTreeWithOneSurface) { | 192 TEST_F(DamageTrackerTest, SanityCheckTestTreeWithOneSurface) { |
| 191 // Sanity check that the simple test tree will actually produce the expected | 193 // Sanity check that the simple test tree will actually produce the expected |
| 192 // render surfaces and layer lists. | 194 // render surfaces and layer lists. |
| 193 | 195 |
| 194 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 196 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 195 | 197 |
| 196 EXPECT_EQ(2u, root->render_surface()->layer_list().size()); | 198 EXPECT_EQ(2u, root->render_surface()->layer_list().size()); |
| 197 EXPECT_EQ(1, root->render_surface()->layer_list()[0]->id()); | 199 EXPECT_EQ(1, root->render_surface()->layer_list()[0]->id()); |
| 198 EXPECT_EQ(2, root->render_surface()->layer_list()[1]->id()); | 200 EXPECT_EQ(2, root->render_surface()->layer_list()[1]->id()); |
| 199 | 201 |
| 200 gfx::Rect root_damage_rect = | 202 gfx::Rect root_damage_rect; |
| 201 root->render_surface()->damage_tracker()->current_damage_rect(); | 203 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 204 &root_damage_rect)); |
| 202 | 205 |
| 203 EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); | 206 EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); |
| 204 } | 207 } |
| 205 | 208 |
| 206 TEST_F(DamageTrackerTest, SanityCheckTestTreeWithTwoSurfaces) { | 209 TEST_F(DamageTrackerTest, SanityCheckTestTreeWithTwoSurfaces) { |
| 207 // Sanity check that the complex test tree will actually produce the expected | 210 // Sanity check that the complex test tree will actually produce the expected |
| 208 // render surfaces and layer lists. | 211 // render surfaces and layer lists. |
| 209 | 212 |
| 210 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 213 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 211 | 214 |
| 212 LayerImpl* child1 = root->test_properties()->children[0]; | 215 LayerImpl* child1 = root->test_properties()->children[0]; |
| 213 LayerImpl* child2 = root->test_properties()->children[1]; | 216 LayerImpl* child2 = root->test_properties()->children[1]; |
| 214 gfx::Rect child_damage_rect = | 217 |
| 215 child1->render_surface()->damage_tracker()->current_damage_rect(); | 218 gfx::Rect child_damage_rect; |
| 216 gfx::Rect root_damage_rect = | 219 EXPECT_TRUE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 217 root->render_surface()->damage_tracker()->current_damage_rect(); | 220 &child_damage_rect)); |
| 221 gfx::Rect root_damage_rect; |
| 222 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 223 &root_damage_rect)); |
| 218 | 224 |
| 219 ASSERT_TRUE(child1->render_surface()); | 225 ASSERT_TRUE(child1->render_surface()); |
| 220 EXPECT_FALSE(child2->render_surface()); | 226 EXPECT_FALSE(child2->render_surface()); |
| 221 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); | 227 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); |
| 222 EXPECT_EQ(2u, child1->render_surface()->layer_list().size()); | 228 EXPECT_EQ(2u, child1->render_surface()->layer_list().size()); |
| 223 | 229 |
| 224 // The render surface for child1 only has a content_rect that encloses | 230 // The render surface for child1 only has a content_rect that encloses |
| 225 // grand_child1 and grand_child2, because child1 does not draw content. | 231 // grand_child1 and grand_child2, because child1 does not draw content. |
| 226 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), | 232 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), |
| 227 child_damage_rect.ToString()); | 233 child_damage_rect.ToString()); |
| 228 EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); | 234 EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); |
| 229 } | 235 } |
| 230 | 236 |
| 231 TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { | 237 TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { |
| 232 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 238 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 233 LayerImpl* child = root->test_properties()->children[0]; | 239 LayerImpl* child = root->test_properties()->children[0]; |
| 234 | 240 |
| 235 // CASE 1: Setting the update rect should cause the corresponding damage to | 241 // CASE 1: Setting the update rect should cause the corresponding damage to |
| 236 // the surface. | 242 // the surface. |
| 237 ClearDamageForAllSurfaces(root); | 243 ClearDamageForAllSurfaces(root); |
| 238 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); | 244 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
| 239 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 245 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 240 EmulateDrawingOneFrame(root); | 246 EmulateDrawingOneFrame(root); |
| 241 | 247 |
| 242 // Damage position on the surface should be: position of update_rect (10, 11) | 248 // Damage position on the surface should be: position of update_rect (10, 11) |
| 243 // relative to the child (100, 100). | 249 // relative to the child (100, 100). |
| 244 gfx::Rect root_damage_rect = | 250 gfx::Rect root_damage_rect; |
| 245 root->render_surface()->damage_tracker()->current_damage_rect(); | 251 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 252 &root_damage_rect)); |
| 246 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), | 253 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), |
| 247 root_damage_rect.ToString()); | 254 root_damage_rect.ToString()); |
| 248 | 255 |
| 249 // CASE 2: The same update rect twice in a row still produces the same | 256 // CASE 2: The same update rect twice in a row still produces the same |
| 250 // damage. | 257 // damage. |
| 251 ClearDamageForAllSurfaces(root); | 258 ClearDamageForAllSurfaces(root); |
| 252 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); | 259 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
| 253 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 260 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 254 EmulateDrawingOneFrame(root); | 261 EmulateDrawingOneFrame(root); |
| 255 root_damage_rect = | 262 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 256 root->render_surface()->damage_tracker()->current_damage_rect(); | 263 &root_damage_rect)); |
| 257 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), | 264 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), |
| 258 root_damage_rect.ToString()); | 265 root_damage_rect.ToString()); |
| 259 | 266 |
| 260 // CASE 3: Setting a different update rect should cause damage on the new | 267 // CASE 3: Setting a different update rect should cause damage on the new |
| 261 // update region, but no additional exposed old region. | 268 // update region, but no additional exposed old region. |
| 262 ClearDamageForAllSurfaces(root); | 269 ClearDamageForAllSurfaces(root); |
| 263 child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); | 270 child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); |
| 264 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 271 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 265 EmulateDrawingOneFrame(root); | 272 EmulateDrawingOneFrame(root); |
| 266 | 273 |
| 267 // Damage position on the surface should be: position of update_rect (20, 25) | 274 // Damage position on the surface should be: position of update_rect (20, 25) |
| 268 // relative to the child (100, 100). | 275 // relative to the child (100, 100). |
| 269 root_damage_rect = | 276 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 270 root->render_surface()->damage_tracker()->current_damage_rect(); | 277 &root_damage_rect)); |
| 271 EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString()); | 278 EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString()); |
| 272 } | 279 } |
| 273 | 280 |
| 274 TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { | 281 TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { |
| 275 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 282 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 276 LayerImpl* child = root->test_properties()->children[0]; | 283 LayerImpl* child = root->test_properties()->children[0]; |
| 277 | 284 |
| 278 // CASE 1: Adding the layer damage rect should cause the corresponding damage | 285 // CASE 1: Adding the layer damage rect should cause the corresponding damage |
| 279 // to the surface. | 286 // to the surface. |
| 280 ClearDamageForAllSurfaces(root); | 287 ClearDamageForAllSurfaces(root); |
| 281 child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); | 288 child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); |
| 282 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 289 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 283 EmulateDrawingOneFrame(root); | 290 EmulateDrawingOneFrame(root); |
| 284 | 291 |
| 285 // Damage position on the surface should be: position of layer damage_rect | 292 // Damage position on the surface should be: position of layer damage_rect |
| 286 // (10, 11) relative to the child (100, 100). | 293 // (10, 11) relative to the child (100, 100). |
| 287 gfx::Rect root_damage_rect = | 294 gfx::Rect root_damage_rect; |
| 288 root->render_surface()->damage_tracker()->current_damage_rect(); | 295 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 296 &root_damage_rect)); |
| 289 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 12, 13))); | 297 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 12, 13))); |
| 290 | 298 |
| 291 // CASE 2: The same layer damage rect twice in a row still produces the same | 299 // CASE 2: The same layer damage rect twice in a row still produces the same |
| 292 // damage. | 300 // damage. |
| 293 ClearDamageForAllSurfaces(root); | 301 ClearDamageForAllSurfaces(root); |
| 294 child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); | 302 child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); |
| 295 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 303 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 296 EmulateDrawingOneFrame(root); | 304 EmulateDrawingOneFrame(root); |
| 297 root_damage_rect = | 305 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 298 root->render_surface()->damage_tracker()->current_damage_rect(); | 306 &root_damage_rect)); |
| 299 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 12, 13))); | 307 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 12, 13))); |
| 300 | 308 |
| 301 // CASE 3: Adding a different layer damage rect should cause damage on the | 309 // CASE 3: Adding a different layer damage rect should cause damage on the |
| 302 // new damaged region, but no additional exposed old region. | 310 // new damaged region, but no additional exposed old region. |
| 303 ClearDamageForAllSurfaces(root); | 311 ClearDamageForAllSurfaces(root); |
| 304 child->AddDamageRect(gfx::Rect(20, 25, 1, 2)); | 312 child->AddDamageRect(gfx::Rect(20, 25, 1, 2)); |
| 305 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 313 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 306 EmulateDrawingOneFrame(root); | 314 EmulateDrawingOneFrame(root); |
| 307 | 315 |
| 308 // Damage position on the surface should be: position of layer damage_rect | 316 // Damage position on the surface should be: position of layer damage_rect |
| 309 // (20, 25) relative to the child (100, 100). | 317 // (20, 25) relative to the child (100, 100). |
| 310 root_damage_rect = | 318 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 311 root->render_surface()->damage_tracker()->current_damage_rect(); | 319 &root_damage_rect)); |
| 312 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(120, 125, 1, 2))); | 320 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(120, 125, 1, 2))); |
| 313 | 321 |
| 314 // CASE 4: Adding multiple layer damage rects should cause a unified | 322 // CASE 4: Adding multiple layer damage rects should cause a unified |
| 315 // damage on root damage rect. | 323 // damage on root damage rect. |
| 316 ClearDamageForAllSurfaces(root); | 324 ClearDamageForAllSurfaces(root); |
| 317 child->AddDamageRect(gfx::Rect(20, 25, 1, 2)); | 325 child->AddDamageRect(gfx::Rect(20, 25, 1, 2)); |
| 318 child->AddDamageRect(gfx::Rect(10, 15, 3, 4)); | 326 child->AddDamageRect(gfx::Rect(10, 15, 3, 4)); |
| 319 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 327 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 320 EmulateDrawingOneFrame(root); | 328 EmulateDrawingOneFrame(root); |
| 321 | 329 |
| 322 // Damage position on the surface should be: position of layer damage_rect | 330 // Damage position on the surface should be: position of layer damage_rect |
| 323 // (20, 25) relative to the child (100, 100). | 331 // (20, 25) relative to the child (100, 100). |
| 324 root_damage_rect = | 332 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 325 root->render_surface()->damage_tracker()->current_damage_rect(); | 333 &root_damage_rect)); |
| 326 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(120, 125, 1, 2))); | 334 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(120, 125, 1, 2))); |
| 327 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 115, 3, 4))); | 335 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 115, 3, 4))); |
| 328 } | 336 } |
| 329 | 337 |
| 330 TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) { | 338 TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) { |
| 331 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 339 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 332 LayerImpl* child = root->test_properties()->children[0]; | 340 LayerImpl* child = root->test_properties()->children[0]; |
| 333 | 341 |
| 334 // CASE 1: Adding the layer damage rect and update rect should cause the | 342 // CASE 1: Adding the layer damage rect and update rect should cause the |
| 335 // corresponding damage to the surface. | 343 // corresponding damage to the surface. |
| 336 ClearDamageForAllSurfaces(root); | 344 ClearDamageForAllSurfaces(root); |
| 337 child->AddDamageRect(gfx::Rect(5, 6, 12, 13)); | 345 child->AddDamageRect(gfx::Rect(5, 6, 12, 13)); |
| 338 child->SetUpdateRect(gfx::Rect(15, 16, 14, 10)); | 346 child->SetUpdateRect(gfx::Rect(15, 16, 14, 10)); |
| 339 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 347 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 340 EmulateDrawingOneFrame(root); | 348 EmulateDrawingOneFrame(root); |
| 341 | 349 |
| 342 // Damage position on the surface should be: position of unified layer | 350 // Damage position on the surface should be: position of unified layer |
| 343 // damage_rect and update rect (5, 6) | 351 // damage_rect and update rect (5, 6) |
| 344 // relative to the child (100, 100). | 352 // relative to the child (100, 100). |
| 345 gfx::Rect root_damage_rect = | 353 gfx::Rect root_damage_rect; |
| 346 root->render_surface()->damage_tracker()->current_damage_rect(); | 354 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 355 &root_damage_rect)); |
| 347 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 106, 24, 20))); | 356 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 106, 24, 20))); |
| 348 | 357 |
| 349 // CASE 2: The same layer damage rect and update rect twice in a row still | 358 // CASE 2: The same layer damage rect and update rect twice in a row still |
| 350 // produces the same damage. | 359 // produces the same damage. |
| 351 ClearDamageForAllSurfaces(root); | 360 ClearDamageForAllSurfaces(root); |
| 352 child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); | 361 child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); |
| 353 child->SetUpdateRect(gfx::Rect(10, 11, 14, 15)); | 362 child->SetUpdateRect(gfx::Rect(10, 11, 14, 15)); |
| 354 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 363 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 355 EmulateDrawingOneFrame(root); | 364 EmulateDrawingOneFrame(root); |
| 356 root_damage_rect = | 365 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 357 root->render_surface()->damage_tracker()->current_damage_rect(); | 366 &root_damage_rect)); |
| 358 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 14, 15))); | 367 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(110, 111, 14, 15))); |
| 359 | 368 |
| 360 // CASE 3: Adding a different layer damage rect and update rect should cause | 369 // CASE 3: Adding a different layer damage rect and update rect should cause |
| 361 // damage on the new damaged region, but no additional exposed old region. | 370 // damage on the new damaged region, but no additional exposed old region. |
| 362 ClearDamageForAllSurfaces(root); | 371 ClearDamageForAllSurfaces(root); |
| 363 child->AddDamageRect(gfx::Rect(20, 25, 2, 3)); | 372 child->AddDamageRect(gfx::Rect(20, 25, 2, 3)); |
| 364 child->SetUpdateRect(gfx::Rect(5, 10, 7, 8)); | 373 child->SetUpdateRect(gfx::Rect(5, 10, 7, 8)); |
| 365 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 374 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 366 EmulateDrawingOneFrame(root); | 375 EmulateDrawingOneFrame(root); |
| 367 | 376 |
| 368 // Damage position on the surface should be: position of unified layer damage | 377 // Damage position on the surface should be: position of unified layer damage |
| 369 // rect and update rect (5, 10) relative to the child (100, 100). | 378 // rect and update rect (5, 10) relative to the child (100, 100). |
| 370 root_damage_rect = | 379 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 371 root->render_surface()->damage_tracker()->current_damage_rect(); | 380 &root_damage_rect)); |
| 372 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 110, 17, 18))); | 381 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 110, 17, 18))); |
| 373 } | 382 } |
| 374 | 383 |
| 375 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { | 384 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { |
| 376 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 385 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 377 LayerImpl* child = root->test_properties()->children[0]; | 386 LayerImpl* child = root->test_properties()->children[0]; |
| 378 | 387 |
| 379 // CASE 1: The layer's property changed flag takes priority over update rect. | 388 // CASE 1: The layer's property changed flag takes priority over update rect. |
| 380 // | 389 // |
| 381 child->test_properties()->force_render_surface = true; | 390 child->test_properties()->force_render_surface = true; |
| 382 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 391 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 383 EmulateDrawingOneFrame(root); | 392 EmulateDrawingOneFrame(root); |
| 384 ClearDamageForAllSurfaces(root); | 393 ClearDamageForAllSurfaces(root); |
| 385 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); | 394 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
| 386 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 395 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( |
| 387 0.5f, child->effect_tree_index(), root->layer_tree_impl()); | 396 0.5f, child->effect_tree_index(), root->layer_tree_impl()); |
| 388 EmulateDrawingOneFrame(root); | 397 EmulateDrawingOneFrame(root); |
| 389 | 398 |
| 390 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 399 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 391 | 400 |
| 392 // Damage should be the entire child layer in target_surface space. | 401 // Damage should be the entire child layer in target_surface space. |
| 393 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); | 402 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); |
| 394 gfx::Rect root_damage_rect = | 403 gfx::Rect root_damage_rect; |
| 395 root->render_surface()->damage_tracker()->current_damage_rect(); | 404 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 405 &root_damage_rect)); |
| 396 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); | 406 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); |
| 397 | 407 |
| 398 // CASE 2: If a layer moves due to property change, it damages both the new | 408 // CASE 2: If a layer moves due to property change, it damages both the new |
| 399 // location and the old (exposed) location. The old location is the | 409 // location and the old (exposed) location. The old location is the |
| 400 // entire old layer, not just the update_rect. | 410 // entire old layer, not just the update_rect. |
| 401 | 411 |
| 402 // Cycle one frame of no change, just to sanity check that the next rect is | 412 // Cycle one frame of no change, just to sanity check that the next rect is |
| 403 // not because of the old damage state. | 413 // not because of the old damage state. |
| 404 ClearDamageForAllSurfaces(root); | 414 ClearDamageForAllSurfaces(root); |
| 405 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 415 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 406 EmulateDrawingOneFrame(root); | 416 EmulateDrawingOneFrame(root); |
| 407 root_damage_rect = | 417 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 408 root->render_surface()->damage_tracker()->current_damage_rect(); | 418 &root_damage_rect)); |
| 409 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 419 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 410 | 420 |
| 411 // Then, test the actual layer movement. | 421 // Then, test the actual layer movement. |
| 412 ClearDamageForAllSurfaces(root); | 422 ClearDamageForAllSurfaces(root); |
| 413 gfx::Transform translation; | 423 gfx::Transform translation; |
| 414 translation.Translate(100.f, 130.f); | 424 translation.Translate(100.f, 130.f); |
| 415 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 425 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( |
| 416 translation, child->transform_tree_index(), root->layer_tree_impl()); | 426 translation, child->transform_tree_index(), root->layer_tree_impl()); |
| 417 EmulateDrawingOneFrame(root); | 427 EmulateDrawingOneFrame(root); |
| 418 | 428 |
| 419 // Expect damage to be the combination of the previous one and the new one. | 429 // Expect damage to be the combination of the previous one and the new one. |
| 420 expected_rect.Union(gfx::Rect(200, 230, 30, 30)); | 430 expected_rect.Union(gfx::Rect(200, 230, 30, 30)); |
| 421 root_damage_rect = | 431 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 422 root->render_surface()->damage_tracker()->current_damage_rect(); | 432 &root_damage_rect)); |
| 423 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); | 433 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); |
| 424 } | 434 } |
| 425 | 435 |
| 426 TEST_F(DamageTrackerTest, VerifyDamageWhenSurfaceRemoved) { | 436 TEST_F(DamageTrackerTest, VerifyDamageWhenSurfaceRemoved) { |
| 427 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 437 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 428 LayerImpl* surface = root->test_properties()->children[0]; | 438 LayerImpl* surface = root->test_properties()->children[0]; |
| 429 LayerImpl* child = surface->test_properties()->children[0]; | 439 LayerImpl* child = surface->test_properties()->children[0]; |
| 430 child->SetDrawsContent(true); | 440 child->SetDrawsContent(true); |
| 431 EmulateDrawingOneFrame(root); | 441 EmulateDrawingOneFrame(root); |
| 432 ClearDamageForAllSurfaces(root); | 442 ClearDamageForAllSurfaces(root); |
| 433 | 443 |
| 434 surface->test_properties()->force_render_surface = false; | 444 surface->test_properties()->force_render_surface = false; |
| 435 child->SetDrawsContent(false); | 445 child->SetDrawsContent(false); |
| 436 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 446 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 437 EmulateDrawingOneFrame(root); | 447 EmulateDrawingOneFrame(root); |
| 438 gfx::Rect root_damage_rect = | 448 gfx::Rect root_damage_rect; |
| 439 root->render_surface()->damage_tracker()->current_damage_rect(); | 449 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 450 &root_damage_rect)); |
| 440 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), | 451 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), |
| 441 root_damage_rect.ToString()); | 452 root_damage_rect.ToString()); |
| 442 } | 453 } |
| 443 | 454 |
| 444 TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { | 455 TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { |
| 445 // If a layer is transformed, the damage rect should still enclose the entire | 456 // If a layer is transformed, the damage rect should still enclose the entire |
| 446 // transformed layer. | 457 // transformed layer. |
| 447 | 458 |
| 448 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 459 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 449 LayerImpl* child = root->test_properties()->children[0]; | 460 LayerImpl* child = root->test_properties()->children[0]; |
| 450 child->test_properties()->force_render_surface = true; | 461 child->test_properties()->force_render_surface = true; |
| 451 | 462 |
| 452 gfx::Transform rotation; | 463 gfx::Transform rotation; |
| 453 rotation.Rotate(45.0); | 464 rotation.Rotate(45.0); |
| 454 | 465 |
| 455 ClearDamageForAllSurfaces(root); | 466 ClearDamageForAllSurfaces(root); |
| 456 child->test_properties()->transform_origin = gfx::Point3F( | 467 child->test_properties()->transform_origin = gfx::Point3F( |
| 457 child->bounds().width() * 0.5f, child->bounds().height() * 0.5f, 0.f); | 468 child->bounds().width() * 0.5f, child->bounds().height() * 0.5f, 0.f); |
| 458 child->SetPosition(gfx::PointF(85.f, 85.f)); | 469 child->SetPosition(gfx::PointF(85.f, 85.f)); |
| 459 child->NoteLayerPropertyChanged(); | 470 child->NoteLayerPropertyChanged(); |
| 460 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 471 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 461 EmulateDrawingOneFrame(root); | 472 EmulateDrawingOneFrame(root); |
| 462 | 473 |
| 463 // Sanity check that the layer actually moved to (85, 85), damaging its old | 474 // Sanity check that the layer actually moved to (85, 85), damaging its old |
| 464 // location and new location. | 475 // location and new location. |
| 465 gfx::Rect root_damage_rect = | 476 gfx::Rect root_damage_rect; |
| 466 root->render_surface()->damage_tracker()->current_damage_rect(); | 477 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 478 &root_damage_rect)); |
| 467 EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString()); | 479 EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString()); |
| 468 | 480 |
| 469 // With the anchor on the layer's center, now we can test the rotation more | 481 // With the anchor on the layer's center, now we can test the rotation more |
| 470 // intuitively, since it applies about the layer's anchor. | 482 // intuitively, since it applies about the layer's anchor. |
| 471 ClearDamageForAllSurfaces(root); | 483 ClearDamageForAllSurfaces(root); |
| 472 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 484 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( |
| 473 rotation, child->transform_tree_index(), root->layer_tree_impl()); | 485 rotation, child->transform_tree_index(), root->layer_tree_impl()); |
| 474 EmulateDrawingOneFrame(root); | 486 EmulateDrawingOneFrame(root); |
| 475 | 487 |
| 476 // Since the child layer is square, rotation by 45 degrees about the center | 488 // Since the child layer is square, rotation by 45 degrees about the center |
| 477 // should increase the size of the expected rect by sqrt(2), centered around | 489 // should increase the size of the expected rect by sqrt(2), centered around |
| 478 // (100, 100). The old exposed region should be fully contained in the new | 490 // (100, 100). The old exposed region should be fully contained in the new |
| 479 // region. | 491 // region. |
| 480 float expected_width = 30.f * sqrt(2.f); | 492 float expected_width = 30.f * sqrt(2.f); |
| 481 float expected_position = 100.f - 0.5f * expected_width; | 493 float expected_position = 100.f - 0.5f * expected_width; |
| 482 gfx::Rect expected_rect = gfx::ToEnclosingRect(gfx::RectF( | 494 gfx::Rect expected_rect = gfx::ToEnclosingRect(gfx::RectF( |
| 483 expected_position, expected_position, expected_width, expected_width)); | 495 expected_position, expected_position, expected_width, expected_width)); |
| 484 root_damage_rect = | 496 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 485 root->render_surface()->damage_tracker()->current_damage_rect(); | 497 &root_damage_rect)); |
| 486 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); | 498 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); |
| 487 } | 499 } |
| 488 | 500 |
| 489 TEST_F(DamageTrackerTest, VerifyDamageForPerspectiveClippedLayer) { | 501 TEST_F(DamageTrackerTest, VerifyDamageForPerspectiveClippedLayer) { |
| 490 // If a layer has a perspective transform that causes w < 0, then not | 502 // If a layer has a perspective transform that causes w < 0, then not |
| 491 // clipping the layer can cause an invalid damage rect. This test checks that | 503 // clipping the layer can cause an invalid damage rect. This test checks that |
| 492 // the w < 0 case is tracked properly. | 504 // the w < 0 case is tracked properly. |
| 493 // | 505 // |
| 494 // The transform is constructed so that if w < 0 clipping is not performed, | 506 // The transform is constructed so that if w < 0 clipping is not performed, |
| 495 // the incorrect rect will be very small, specifically: position (500.972504, | 507 // the incorrect rect will be very small, specifically: position (500.972504, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 539 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 528 EmulateDrawingOneFrame(root); | 540 EmulateDrawingOneFrame(root); |
| 529 ClearDamageForAllSurfaces(root); | 541 ClearDamageForAllSurfaces(root); |
| 530 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 542 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( |
| 531 0.5f, child->effect_tree_index(), root->layer_tree_impl()); | 543 0.5f, child->effect_tree_index(), root->layer_tree_impl()); |
| 532 EmulateDrawingOneFrame(root); | 544 EmulateDrawingOneFrame(root); |
| 533 | 545 |
| 534 // The expected damage should cover the entire root surface (500x500), but we | 546 // The expected damage should cover the entire root surface (500x500), but we |
| 535 // don't care whether the damage rect was clamped or is larger than the | 547 // don't care whether the damage rect was clamped or is larger than the |
| 536 // surface for this test. | 548 // surface for this test. |
| 537 gfx::Rect root_damage_rect = | 549 gfx::Rect root_damage_rect; |
| 538 root->render_surface()->damage_tracker()->current_damage_rect(); | 550 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 551 &root_damage_rect)); |
| 539 gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500)); | 552 gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500)); |
| 540 EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); | 553 EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); |
| 541 } | 554 } |
| 542 | 555 |
| 543 TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { | 556 TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { |
| 544 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 557 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 545 LayerImpl* surface = root->test_properties()->children[0]; | 558 LayerImpl* surface = root->test_properties()->children[0]; |
| 546 LayerImpl* child = surface->test_properties()->children[0]; | 559 LayerImpl* child = surface->test_properties()->children[0]; |
| 547 | 560 |
| 548 FilterOperations filters; | 561 FilterOperations filters; |
| 549 filters.Append(FilterOperation::CreateBlurFilter(5.f)); | 562 filters.Append(FilterOperation::CreateBlurFilter(5.f)); |
| 550 | 563 |
| 551 // Setting the filter will damage the whole surface. | 564 // Setting the filter will damage the whole surface. |
| 552 ClearDamageForAllSurfaces(root); | 565 ClearDamageForAllSurfaces(root); |
| 553 surface->test_properties()->filters = filters; | 566 surface->test_properties()->filters = filters; |
| 554 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 567 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 555 EmulateDrawingOneFrame(root); | 568 EmulateDrawingOneFrame(root); |
| 556 | 569 |
| 557 // Setting the update rect should cause the corresponding damage to the | 570 // Setting the update rect should cause the corresponding damage to the |
| 558 // surface, blurred based on the size of the blur filter. | 571 // surface, blurred based on the size of the blur filter. |
| 559 ClearDamageForAllSurfaces(root); | 572 ClearDamageForAllSurfaces(root); |
| 560 child->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); | 573 child->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); |
| 561 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 574 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 562 EmulateDrawingOneFrame(root); | 575 EmulateDrawingOneFrame(root); |
| 563 | 576 |
| 564 // Damage position on the surface should be: position of update_rect (1, 2) | 577 // Damage position on the surface should be: position of update_rect (1, 2) |
| 565 // relative to the child (300, 300), but expanded by the blur outsets | 578 // relative to the child (300, 300), but expanded by the blur outsets |
| 566 // (15, since the blur radius is 5). | 579 // (15, since the blur radius is 5). |
| 567 gfx::Rect root_damage_rect = | 580 gfx::Rect root_damage_rect; |
| 568 root->render_surface()->damage_tracker()->current_damage_rect(); | 581 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 582 &root_damage_rect)); |
| 569 EXPECT_EQ(gfx::Rect(286, 287, 33, 34), root_damage_rect); | 583 EXPECT_EQ(gfx::Rect(286, 287, 33, 34), root_damage_rect); |
| 570 } | 584 } |
| 571 | 585 |
| 572 TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { | 586 TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { |
| 573 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 587 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 574 LayerImpl* child = root->test_properties()->children[0]; | 588 LayerImpl* child = root->test_properties()->children[0]; |
| 575 gfx::Rect root_damage_rect, child_damage_rect; | 589 gfx::Rect root_damage_rect, child_damage_rect; |
| 576 | 590 |
| 577 // Allow us to set damage on child too. | 591 // Allow us to set damage on child too. |
| 578 child->SetDrawsContent(true); | 592 child->SetDrawsContent(true); |
| 579 | 593 |
| 580 FilterOperations filters; | 594 FilterOperations filters; |
| 581 filters.Append(FilterOperation::CreateReferenceFilter( | 595 filters.Append(FilterOperation::CreateReferenceFilter( |
| 582 SkBlurImageFilter::Make(2, 2, nullptr))); | 596 SkBlurImageFilter::Make(2, 2, nullptr))); |
| 583 | 597 |
| 584 // Setting the filter will damage the whole surface. | 598 // Setting the filter will damage the whole surface. |
| 585 ClearDamageForAllSurfaces(root); | 599 ClearDamageForAllSurfaces(root); |
| 586 child->test_properties()->force_render_surface = true; | 600 child->test_properties()->force_render_surface = true; |
| 587 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 601 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 588 EmulateDrawingOneFrame(root); | 602 EmulateDrawingOneFrame(root); |
| 589 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( | 603 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( |
| 590 filters, child->effect_tree_index(), child->layer_tree_impl()); | 604 filters, child->effect_tree_index(), child->layer_tree_impl()); |
| 591 EmulateDrawingOneFrame(root); | 605 EmulateDrawingOneFrame(root); |
| 592 root_damage_rect = | 606 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 593 root->render_surface()->damage_tracker()->current_damage_rect(); | 607 &root_damage_rect)); |
| 594 child_damage_rect = | 608 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 595 child->render_surface()->damage_tracker()->current_damage_rect(); | 609 &child_damage_rect)); |
| 596 | 610 |
| 597 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. | 611 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. |
| 598 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); | 612 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); |
| 599 | 613 |
| 600 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. | 614 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. |
| 601 EXPECT_EQ(gfx::Rect(-6, -6, 42, 42), child_damage_rect); | 615 EXPECT_EQ(gfx::Rect(-6, -6, 42, 42), child_damage_rect); |
| 602 | 616 |
| 603 // CASE 1: Setting the update rect should damage the whole surface (for now) | 617 // CASE 1: Setting the update rect should damage the whole surface (for now) |
| 604 ClearDamageForAllSurfaces(root); | 618 ClearDamageForAllSurfaces(root); |
| 605 child->SetUpdateRect(gfx::Rect(1, 1)); | 619 child->SetUpdateRect(gfx::Rect(1, 1)); |
| 606 EmulateDrawingOneFrame(root); | 620 EmulateDrawingOneFrame(root); |
| 607 | 621 |
| 608 root_damage_rect = | 622 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 609 root->render_surface()->damage_tracker()->current_damage_rect(); | 623 &root_damage_rect)); |
| 610 child_damage_rect = | 624 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 611 child->render_surface()->damage_tracker()->current_damage_rect(); | 625 &child_damage_rect)); |
| 612 | 626 |
| 613 // gfx::Rect(100, 100, 1, 1), expanded by 6px for the 2px blur filter. | 627 // gfx::Rect(100, 100, 1, 1), expanded by 6px for the 2px blur filter. |
| 614 EXPECT_EQ(gfx::Rect(94, 94, 13, 13), root_damage_rect); | 628 EXPECT_EQ(gfx::Rect(94, 94, 13, 13), root_damage_rect); |
| 615 | 629 |
| 616 // gfx::Rect(0, 0, 1, 1), expanded by 6px for the 2px blur filter. | 630 // gfx::Rect(0, 0, 1, 1), expanded by 6px for the 2px blur filter. |
| 617 EXPECT_EQ(gfx::Rect(-6, -6, 13, 13), child_damage_rect); | 631 EXPECT_EQ(gfx::Rect(-6, -6, 13, 13), child_damage_rect); |
| 618 } | 632 } |
| 619 | 633 |
| 620 TEST_F(DamageTrackerTest, VerifyDamageForTransformedImageFilter) { | 634 TEST_F(DamageTrackerTest, VerifyDamageForTransformedImageFilter) { |
| 621 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 635 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 633 gfx::Transform transform; | 647 gfx::Transform transform; |
| 634 transform.RotateAboutYAxis(60); | 648 transform.RotateAboutYAxis(60); |
| 635 ClearDamageForAllSurfaces(root); | 649 ClearDamageForAllSurfaces(root); |
| 636 child->test_properties()->force_render_surface = true; | 650 child->test_properties()->force_render_surface = true; |
| 637 child->test_properties()->transform = transform; | 651 child->test_properties()->transform = transform; |
| 638 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 652 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 639 EmulateDrawingOneFrame(root); | 653 EmulateDrawingOneFrame(root); |
| 640 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( | 654 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( |
| 641 filters, child->effect_tree_index(), child->layer_tree_impl()); | 655 filters, child->effect_tree_index(), child->layer_tree_impl()); |
| 642 EmulateDrawingOneFrame(root); | 656 EmulateDrawingOneFrame(root); |
| 643 root_damage_rect = | 657 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 644 root->render_surface()->damage_tracker()->current_damage_rect(); | 658 &root_damage_rect)); |
| 645 child_damage_rect = | 659 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 646 child->render_surface()->damage_tracker()->current_damage_rect(); | 660 &child_damage_rect)); |
| 647 | 661 |
| 648 // Blur outset is 6px for a 2px blur. | 662 // Blur outset is 6px for a 2px blur. |
| 649 int blur_outset = 6; | 663 int blur_outset = 6; |
| 650 int rotated_outset_left = blur_outset / 2; | 664 int rotated_outset_left = blur_outset / 2; |
| 651 int expected_rotated_width = (30 + 2 * blur_outset) / 2; | 665 int expected_rotated_width = (30 + 2 * blur_outset) / 2; |
| 652 gfx::Rect expected_root_damage(100 - rotated_outset_left, 100 - blur_outset, | 666 gfx::Rect expected_root_damage(100 - rotated_outset_left, 100 - blur_outset, |
| 653 expected_rotated_width, 30 + 2 * blur_outset); | 667 expected_rotated_width, 30 + 2 * blur_outset); |
| 654 expected_root_damage.Union(gfx::Rect(100, 100, 30, 30)); | 668 expected_root_damage.Union(gfx::Rect(100, 100, 30, 30)); |
| 655 EXPECT_EQ(expected_root_damage, root_damage_rect); | 669 EXPECT_EQ(expected_root_damage, root_damage_rect); |
| 656 EXPECT_EQ(gfx::Rect(-blur_outset, -blur_outset, 30 + 2 * blur_outset, | 670 EXPECT_EQ(gfx::Rect(-blur_outset, -blur_outset, 30 + 2 * blur_outset, |
| 657 30 + 2 * blur_outset), | 671 30 + 2 * blur_outset), |
| 658 child_damage_rect); | 672 child_damage_rect); |
| 659 | 673 |
| 660 // Setting the update rect should damage the whole surface (for now) | 674 // Setting the update rect should damage the whole surface (for now) |
| 661 ClearDamageForAllSurfaces(root); | 675 ClearDamageForAllSurfaces(root); |
| 662 child->SetUpdateRect(gfx::Rect(30, 30)); | 676 child->SetUpdateRect(gfx::Rect(30, 30)); |
| 663 EmulateDrawingOneFrame(root); | 677 EmulateDrawingOneFrame(root); |
| 664 | 678 |
| 665 root_damage_rect = | 679 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 666 root->render_surface()->damage_tracker()->current_damage_rect(); | 680 &root_damage_rect)); |
| 667 child_damage_rect = | 681 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 668 child->render_surface()->damage_tracker()->current_damage_rect(); | 682 &child_damage_rect)); |
| 669 | 683 |
| 670 int expect_width = 30 + 2 * blur_outset; | 684 int expect_width = 30 + 2 * blur_outset; |
| 671 int expect_height = 30 + 2 * blur_outset; | 685 int expect_height = 30 + 2 * blur_outset; |
| 672 EXPECT_EQ(gfx::Rect(100 - blur_outset / 2, 100 - blur_outset, | 686 EXPECT_EQ(gfx::Rect(100 - blur_outset / 2, 100 - blur_outset, |
| 673 expect_width / 2, expect_height), | 687 expect_width / 2, expect_height), |
| 674 root_damage_rect); | 688 root_damage_rect); |
| 675 EXPECT_EQ(gfx::Rect(-blur_outset, -blur_outset, expect_width, expect_height), | 689 EXPECT_EQ(gfx::Rect(-blur_outset, -blur_outset, expect_width, expect_height), |
| 676 child_damage_rect); | 690 child_damage_rect); |
| 677 } | 691 } |
| 678 | 692 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 689 | 703 |
| 690 // Setting the filter will damage the whole surface. | 704 // Setting the filter will damage the whole surface. |
| 691 ClearDamageForAllSurfaces(root); | 705 ClearDamageForAllSurfaces(root); |
| 692 child->test_properties()->force_render_surface = true; | 706 child->test_properties()->force_render_surface = true; |
| 693 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 707 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 694 int device_scale_factor = 2; | 708 int device_scale_factor = 2; |
| 695 EmulateDrawingOneFrame(root, device_scale_factor); | 709 EmulateDrawingOneFrame(root, device_scale_factor); |
| 696 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( | 710 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( |
| 697 filters, child->effect_tree_index(), child->layer_tree_impl()); | 711 filters, child->effect_tree_index(), child->layer_tree_impl()); |
| 698 EmulateDrawingOneFrame(root, device_scale_factor); | 712 EmulateDrawingOneFrame(root, device_scale_factor); |
| 699 root_damage_rect = | 713 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 700 root->render_surface()->damage_tracker()->current_damage_rect(); | 714 &root_damage_rect)); |
| 701 child_damage_rect = | 715 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 702 child->render_surface()->damage_tracker()->current_damage_rect(); | 716 &child_damage_rect)); |
| 703 | 717 |
| 704 // Blur outset is 9px for a 3px blur, scaled up by DSF. | 718 // Blur outset is 9px for a 3px blur, scaled up by DSF. |
| 705 int blur_outset = 9 * device_scale_factor; | 719 int blur_outset = 9 * device_scale_factor; |
| 706 gfx::Rect original_rect(100, 100, 100, 100); | 720 gfx::Rect original_rect(100, 100, 100, 100); |
| 707 gfx::Rect expected_child_damage_rect(60, 60); | 721 gfx::Rect expected_child_damage_rect(60, 60); |
| 708 expected_child_damage_rect.Inset(-blur_outset, -blur_outset); | 722 expected_child_damage_rect.Inset(-blur_outset, -blur_outset); |
| 709 gfx::Rect expected_root_damage_rect(child_damage_rect); | 723 gfx::Rect expected_root_damage_rect(child_damage_rect); |
| 710 expected_root_damage_rect.Offset(200, 200); | 724 expected_root_damage_rect.Offset(200, 200); |
| 711 gfx::Rect expected_total_damage_rect = expected_root_damage_rect; | 725 gfx::Rect expected_total_damage_rect = expected_root_damage_rect; |
| 712 expected_total_damage_rect.Union(original_rect); | 726 expected_total_damage_rect.Union(original_rect); |
| 713 EXPECT_EQ(expected_total_damage_rect, root_damage_rect); | 727 EXPECT_EQ(expected_total_damage_rect, root_damage_rect); |
| 714 EXPECT_EQ(expected_child_damage_rect, child_damage_rect); | 728 EXPECT_EQ(expected_child_damage_rect, child_damage_rect); |
| 715 | 729 |
| 716 // Setting the update rect should damage only the affected area (original, | 730 // Setting the update rect should damage only the affected area (original, |
| 717 // outset by 3 * blur sigma * DSF). | 731 // outset by 3 * blur sigma * DSF). |
| 718 ClearDamageForAllSurfaces(root); | 732 ClearDamageForAllSurfaces(root); |
| 719 child->SetUpdateRect(gfx::Rect(30, 30)); | 733 child->SetUpdateRect(gfx::Rect(30, 30)); |
| 720 EmulateDrawingOneFrame(root, device_scale_factor); | 734 EmulateDrawingOneFrame(root, device_scale_factor); |
| 721 | 735 |
| 722 root_damage_rect = | 736 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 723 root->render_surface()->damage_tracker()->current_damage_rect(); | 737 &root_damage_rect)); |
| 724 child_damage_rect = | 738 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 725 child->render_surface()->damage_tracker()->current_damage_rect(); | 739 &child_damage_rect)); |
| 726 | 740 |
| 727 EXPECT_EQ(expected_root_damage_rect, root_damage_rect); | 741 EXPECT_EQ(expected_root_damage_rect, root_damage_rect); |
| 728 EXPECT_EQ(expected_child_damage_rect, child_damage_rect); | 742 EXPECT_EQ(expected_child_damage_rect, child_damage_rect); |
| 729 } | 743 } |
| 730 | 744 |
| 731 TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { | 745 TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { |
| 732 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 746 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 733 LayerImpl* child1 = root->test_properties()->children[0]; | 747 LayerImpl* child1 = root->test_properties()->children[0]; |
| 734 LayerImpl* child2 = root->test_properties()->children[1]; | 748 LayerImpl* child2 = root->test_properties()->children[1]; |
| 735 | 749 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 748 | 762 |
| 749 // CASE 1: Setting the update rect should cause the corresponding damage to | 763 // CASE 1: Setting the update rect should cause the corresponding damage to |
| 750 // the surface, blurred based on the size of the child's background | 764 // the surface, blurred based on the size of the child's background |
| 751 // blur filter. Note that child1's render surface has a size of | 765 // blur filter. Note that child1's render surface has a size of |
| 752 // 206x208 due to contributions from grand_child1 and grand_child2. | 766 // 206x208 due to contributions from grand_child1 and grand_child2. |
| 753 ClearDamageForAllSurfaces(root); | 767 ClearDamageForAllSurfaces(root); |
| 754 root->SetUpdateRect(gfx::Rect(297, 297, 2, 2)); | 768 root->SetUpdateRect(gfx::Rect(297, 297, 2, 2)); |
| 755 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 769 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 756 EmulateDrawingOneFrame(root); | 770 EmulateDrawingOneFrame(root); |
| 757 | 771 |
| 758 gfx::Rect root_damage_rect = | 772 gfx::Rect root_damage_rect; |
| 759 root->render_surface()->damage_tracker()->current_damage_rect(); | 773 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 774 &root_damage_rect)); |
| 760 // Damage position on the surface should be a composition of the damage on | 775 // Damage position on the surface should be a composition of the damage on |
| 761 // the root and on child2. Damage on the root should be: position of | 776 // the root and on child2. Damage on the root should be: position of |
| 762 // update_rect (297, 297), but expanded by the blur outsets. | 777 // update_rect (297, 297), but expanded by the blur outsets. |
| 763 gfx::Rect expected_damage_rect = gfx::Rect(297, 297, 2, 2); | 778 gfx::Rect expected_damage_rect = gfx::Rect(297, 297, 2, 2); |
| 764 | 779 |
| 765 // 6px spread for a 2px blur. | 780 // 6px spread for a 2px blur. |
| 766 expected_damage_rect.Inset(-6, -6, -6, -6); | 781 expected_damage_rect.Inset(-6, -6, -6, -6); |
| 767 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); | 782 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
| 768 | 783 |
| 769 // CASE 2: Setting the update rect should cause the corresponding damage to | 784 // CASE 2: Setting the update rect should cause the corresponding damage to |
| 770 // the surface, blurred based on the size of the child's background | 785 // the surface, blurred based on the size of the child's background |
| 771 // blur filter. Since the damage extends to the right/bottom outside | 786 // blur filter. Since the damage extends to the right/bottom outside |
| 772 // of the blurred layer, only the left/top should end up expanded. | 787 // of the blurred layer, only the left/top should end up expanded. |
| 773 ClearDamageForAllSurfaces(root); | 788 ClearDamageForAllSurfaces(root); |
| 774 root->SetUpdateRect(gfx::Rect(297, 297, 30, 30)); | 789 root->SetUpdateRect(gfx::Rect(297, 297, 30, 30)); |
| 775 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 790 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 776 EmulateDrawingOneFrame(root); | 791 EmulateDrawingOneFrame(root); |
| 777 | 792 |
| 778 root_damage_rect = | 793 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 779 root->render_surface()->damage_tracker()->current_damage_rect(); | 794 &root_damage_rect)); |
| 780 // Damage position on the surface should be a composition of the damage on | 795 // Damage position on the surface should be a composition of the damage on |
| 781 // the root and on child2. Damage on the root should be: position of | 796 // the root and on child2. Damage on the root should be: position of |
| 782 // update_rect (297, 297), but expanded on the left/top by the blur outsets. | 797 // update_rect (297, 297), but expanded on the left/top by the blur outsets. |
| 783 expected_damage_rect = gfx::Rect(297, 297, 30, 30); | 798 expected_damage_rect = gfx::Rect(297, 297, 30, 30); |
| 784 | 799 |
| 785 // 6px spread for a 2px blur. | 800 // 6px spread for a 2px blur. |
| 786 expected_damage_rect.Inset(-6, -6, 0, 0); | 801 expected_damage_rect.Inset(-6, -6, 0, 0); |
| 787 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); | 802 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
| 788 | 803 |
| 789 // CASE 3: Setting this update rect outside the blurred content_bounds of the | 804 // CASE 3: Setting this update rect outside the blurred content_bounds of the |
| 790 // blurred child1 will not cause it to be expanded. | 805 // blurred child1 will not cause it to be expanded. |
| 791 ClearDamageForAllSurfaces(root); | 806 ClearDamageForAllSurfaces(root); |
| 792 root->SetUpdateRect(gfx::Rect(30, 30, 2, 2)); | 807 root->SetUpdateRect(gfx::Rect(30, 30, 2, 2)); |
| 793 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 808 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 794 EmulateDrawingOneFrame(root); | 809 EmulateDrawingOneFrame(root); |
| 795 | 810 |
| 796 root_damage_rect = | 811 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 797 root->render_surface()->damage_tracker()->current_damage_rect(); | 812 &root_damage_rect)); |
| 798 // Damage on the root should be: position of update_rect (30, 30), not | 813 // Damage on the root should be: position of update_rect (30, 30), not |
| 799 // expanded. | 814 // expanded. |
| 800 expected_damage_rect = gfx::Rect(30, 30, 2, 2); | 815 expected_damage_rect = gfx::Rect(30, 30, 2, 2); |
| 801 | 816 |
| 802 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); | 817 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
| 803 | 818 |
| 804 // CASE 4: Setting this update rect inside the blurred content_bounds but | 819 // CASE 4: Setting this update rect inside the blurred content_bounds but |
| 805 // outside the original content_bounds of the blurred child1 will | 820 // outside the original content_bounds of the blurred child1 will |
| 806 // cause it to be expanded. | 821 // cause it to be expanded. |
| 807 ClearDamageForAllSurfaces(root); | 822 ClearDamageForAllSurfaces(root); |
| 808 root->SetUpdateRect(gfx::Rect(99, 99, 1, 1)); | 823 root->SetUpdateRect(gfx::Rect(99, 99, 1, 1)); |
| 809 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 824 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 810 EmulateDrawingOneFrame(root); | 825 EmulateDrawingOneFrame(root); |
| 811 | 826 |
| 812 root_damage_rect = | 827 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 813 root->render_surface()->damage_tracker()->current_damage_rect(); | 828 &root_damage_rect)); |
| 814 // Damage on the root should be: the originally damaged rect (99,99 1x1) | 829 // Damage on the root should be: the originally damaged rect (99,99 1x1) |
| 815 // plus the rect that can influence with a 2px blur (93,93 13x13) intersected | 830 // plus the rect that can influence with a 2px blur (93,93 13x13) intersected |
| 816 // with the surface rect (100,100 206x208). So no additional damage occurs | 831 // with the surface rect (100,100 206x208). So no additional damage occurs |
| 817 // above or to the left, but there is additional damage within the blurred | 832 // above or to the left, but there is additional damage within the blurred |
| 818 // area. | 833 // area. |
| 819 expected_damage_rect = gfx::Rect(99, 99, 7, 7); | 834 expected_damage_rect = gfx::Rect(99, 99, 7, 7); |
| 820 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); | 835 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
| 821 | 836 |
| 822 // CASE 5: Setting the update rect on child2, which is above child1, will | 837 // CASE 5: Setting the update rect on child2, which is above child1, will |
| 823 // not get blurred by child1, so it does not need to get expanded. | 838 // not get blurred by child1, so it does not need to get expanded. |
| 824 ClearDamageForAllSurfaces(root); | 839 ClearDamageForAllSurfaces(root); |
| 825 child2->SetUpdateRect(gfx::Rect(1, 1)); | 840 child2->SetUpdateRect(gfx::Rect(1, 1)); |
| 826 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 841 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 827 EmulateDrawingOneFrame(root); | 842 EmulateDrawingOneFrame(root); |
| 828 | 843 |
| 829 root_damage_rect = | 844 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 830 root->render_surface()->damage_tracker()->current_damage_rect(); | 845 &root_damage_rect)); |
| 831 // Damage on child2 should be: position of update_rect offset by the child's | 846 // Damage on child2 should be: position of update_rect offset by the child's |
| 832 // position (11, 11), and not expanded by anything. | 847 // position (11, 11), and not expanded by anything. |
| 833 expected_damage_rect = gfx::Rect(11, 11, 1, 1); | 848 expected_damage_rect = gfx::Rect(11, 11, 1, 1); |
| 834 | 849 |
| 835 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); | 850 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
| 836 | 851 |
| 837 // CASE 6: Setting the update rect on child1 will also blur the damage, so | 852 // CASE 6: Setting the update rect on child1 will also blur the damage, so |
| 838 // that any pixels needed for the blur are redrawn in the current | 853 // that any pixels needed for the blur are redrawn in the current |
| 839 // frame. | 854 // frame. |
| 840 ClearDamageForAllSurfaces(root); | 855 ClearDamageForAllSurfaces(root); |
| 841 child1->SetUpdateRect(gfx::Rect(1, 1)); | 856 child1->SetUpdateRect(gfx::Rect(1, 1)); |
| 842 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 857 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 843 EmulateDrawingOneFrame(root); | 858 EmulateDrawingOneFrame(root); |
| 844 | 859 |
| 845 root_damage_rect = | 860 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 846 root->render_surface()->damage_tracker()->current_damage_rect(); | 861 &root_damage_rect)); |
| 847 // Damage on child1 should be: position of update_rect offset by the child's | 862 // Damage on child1 should be: position of update_rect offset by the child's |
| 848 // position (100, 100), and expanded by the damage. | 863 // position (100, 100), and expanded by the damage. |
| 849 | 864 |
| 850 // Damage should be (0,0 1x1), offset by the 100,100 offset of child1 in | 865 // Damage should be (0,0 1x1), offset by the 100,100 offset of child1 in |
| 851 // root, and expanded 6px for the 2px blur (i.e., 94,94 13x13), but there | 866 // root, and expanded 6px for the 2px blur (i.e., 94,94 13x13), but there |
| 852 // should be no damage outside child1 (i.e. none above or to the left of | 867 // should be no damage outside child1 (i.e. none above or to the left of |
| 853 // 100,100. | 868 // 100,100. |
| 854 expected_damage_rect = gfx::Rect(100, 100, 7, 7); | 869 expected_damage_rect = gfx::Rect(100, 100, 7, 7); |
| 855 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); | 870 EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); |
| 856 } | 871 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 870 child2->SetDrawsContent(true); | 885 child2->SetDrawsContent(true); |
| 871 root->test_properties()->AddChild(std::move(child2)); | 886 root->test_properties()->AddChild(std::move(child2)); |
| 872 } | 887 } |
| 873 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 888 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 874 EmulateDrawingOneFrame(root); | 889 EmulateDrawingOneFrame(root); |
| 875 | 890 |
| 876 // Sanity check - all 3 layers should be on the same render surface; render | 891 // Sanity check - all 3 layers should be on the same render surface; render |
| 877 // surfaces are tested elsewhere. | 892 // surfaces are tested elsewhere. |
| 878 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); | 893 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); |
| 879 | 894 |
| 880 gfx::Rect root_damage_rect = | 895 gfx::Rect root_damage_rect; |
| 881 root->render_surface()->damage_tracker()->current_damage_rect(); | 896 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 897 &root_damage_rect)); |
| 882 EXPECT_EQ(gfx::Rect(400, 380, 6, 8).ToString(), root_damage_rect.ToString()); | 898 EXPECT_EQ(gfx::Rect(400, 380, 6, 8).ToString(), root_damage_rect.ToString()); |
| 883 | 899 |
| 884 // CASE 2: If the layer is removed, its entire old layer becomes exposed, not | 900 // CASE 2: If the layer is removed, its entire old layer becomes exposed, not |
| 885 // just the last update rect. | 901 // just the last update rect. |
| 886 | 902 |
| 887 // Advance one frame without damage so that we know the damage rect is not | 903 // Advance one frame without damage so that we know the damage rect is not |
| 888 // leftover from the previous case. | 904 // leftover from the previous case. |
| 889 ClearDamageForAllSurfaces(root); | 905 ClearDamageForAllSurfaces(root); |
| 890 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 906 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 891 EmulateDrawingOneFrame(root); | 907 EmulateDrawingOneFrame(root); |
| 892 | 908 |
| 893 root_damage_rect = | 909 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 894 root->render_surface()->damage_tracker()->current_damage_rect(); | 910 &root_damage_rect)); |
| 895 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 911 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 896 | 912 |
| 897 // Then, test removing child1. | 913 // Then, test removing child1. |
| 898 root->test_properties()->RemoveChild(child1); | 914 root->test_properties()->RemoveChild(child1); |
| 899 child1 = NULL; | 915 child1 = NULL; |
| 900 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 916 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 901 EmulateDrawingOneFrame(root); | 917 EmulateDrawingOneFrame(root); |
| 902 | 918 |
| 903 root_damage_rect = | 919 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 904 root->render_surface()->damage_tracker()->current_damage_rect(); | 920 &root_damage_rect)); |
| 905 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), | 921 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), |
| 906 root_damage_rect.ToString()); | 922 root_damage_rect.ToString()); |
| 907 } | 923 } |
| 908 | 924 |
| 909 TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) { | 925 TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) { |
| 910 // If child2 is added to the layer tree, but it doesn't have any explicit | 926 // If child2 is added to the layer tree, but it doesn't have any explicit |
| 911 // damage of its own, it should still indeed damage the target surface. | 927 // damage of its own, it should still indeed damage the target surface. |
| 912 | 928 |
| 913 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 929 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 914 | 930 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 929 ASSERT_FALSE(child2_ptr->LayerPropertyChanged()); | 945 ASSERT_FALSE(child2_ptr->LayerPropertyChanged()); |
| 930 ASSERT_TRUE(child2_ptr->update_rect().IsEmpty()); | 946 ASSERT_TRUE(child2_ptr->update_rect().IsEmpty()); |
| 931 } | 947 } |
| 932 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 948 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 933 EmulateDrawingOneFrame(root); | 949 EmulateDrawingOneFrame(root); |
| 934 | 950 |
| 935 // Sanity check - all 3 layers should be on the same render surface; render | 951 // Sanity check - all 3 layers should be on the same render surface; render |
| 936 // surfaces are tested elsewhere. | 952 // surfaces are tested elsewhere. |
| 937 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); | 953 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); |
| 938 | 954 |
| 939 gfx::Rect root_damage_rect = | 955 gfx::Rect root_damage_rect; |
| 940 root->render_surface()->damage_tracker()->current_damage_rect(); | 956 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 957 &root_damage_rect)); |
| 941 EXPECT_EQ(gfx::Rect(400, 380, 6, 8).ToString(), root_damage_rect.ToString()); | 958 EXPECT_EQ(gfx::Rect(400, 380, 6, 8).ToString(), root_damage_rect.ToString()); |
| 942 } | 959 } |
| 943 | 960 |
| 944 TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { | 961 TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { |
| 945 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 962 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 946 LayerImpl* child1 = root->test_properties()->children[0]; | 963 LayerImpl* child1 = root->test_properties()->children[0]; |
| 947 | 964 |
| 948 // In this test we don't want the above tree manipulation to be considered | 965 // In this test we don't want the above tree manipulation to be considered |
| 949 // part of the same frame. | 966 // part of the same frame. |
| 950 ClearDamageForAllSurfaces(root); | 967 ClearDamageForAllSurfaces(root); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 961 EmulateDrawingOneFrame(root); | 978 EmulateDrawingOneFrame(root); |
| 962 | 979 |
| 963 // Damaging two layers simultaneously should cause combined damage. | 980 // Damaging two layers simultaneously should cause combined damage. |
| 964 // - child1 update rect in surface space: gfx::Rect(100, 100, 1, 2); | 981 // - child1 update rect in surface space: gfx::Rect(100, 100, 1, 2); |
| 965 // - child2 update rect in surface space: gfx::Rect(400, 380, 3, 4); | 982 // - child2 update rect in surface space: gfx::Rect(400, 380, 3, 4); |
| 966 ClearDamageForAllSurfaces(root); | 983 ClearDamageForAllSurfaces(root); |
| 967 child1->SetUpdateRect(gfx::Rect(1, 2)); | 984 child1->SetUpdateRect(gfx::Rect(1, 2)); |
| 968 child2->SetUpdateRect(gfx::Rect(3, 4)); | 985 child2->SetUpdateRect(gfx::Rect(3, 4)); |
| 969 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 986 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 970 EmulateDrawingOneFrame(root); | 987 EmulateDrawingOneFrame(root); |
| 971 gfx::Rect root_damage_rect = | 988 gfx::Rect root_damage_rect; |
| 972 root->render_surface()->damage_tracker()->current_damage_rect(); | 989 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 990 &root_damage_rect)); |
| 973 EXPECT_EQ(gfx::Rect(100, 100, 303, 284).ToString(), | 991 EXPECT_EQ(gfx::Rect(100, 100, 303, 284).ToString(), |
| 974 root_damage_rect.ToString()); | 992 root_damage_rect.ToString()); |
| 975 } | 993 } |
| 976 | 994 |
| 977 TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { | 995 TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { |
| 978 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 996 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 979 LayerImpl* child1 = root->test_properties()->children[0]; | 997 LayerImpl* child1 = root->test_properties()->children[0]; |
| 980 LayerImpl* child2 = root->test_properties()->children[1]; | 998 LayerImpl* child2 = root->test_properties()->children[1]; |
| 981 LayerImpl* grand_child1 = | 999 LayerImpl* grand_child1 = |
| 982 root->test_properties()->children[0]->test_properties()->children[0]; | 1000 root->test_properties()->children[0]->test_properties()->children[0]; |
| 983 child2->test_properties()->force_render_surface = true; | 1001 child2->test_properties()->force_render_surface = true; |
| 984 grand_child1->test_properties()->force_render_surface = true; | 1002 grand_child1->test_properties()->force_render_surface = true; |
| 985 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1003 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 986 EmulateDrawingOneFrame(root); | 1004 EmulateDrawingOneFrame(root); |
| 987 gfx::Rect child_damage_rect; | 1005 gfx::Rect child_damage_rect; |
| 988 gfx::Rect root_damage_rect; | 1006 gfx::Rect root_damage_rect; |
| 989 | 1007 |
| 990 // CASE 1: Damage to a descendant surface should propagate properly to | 1008 // CASE 1: Damage to a descendant surface should propagate properly to |
| 991 // ancestor surface. | 1009 // ancestor surface. |
| 992 ClearDamageForAllSurfaces(root); | 1010 ClearDamageForAllSurfaces(root); |
| 993 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 1011 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( |
| 994 0.5f, grand_child1->effect_tree_index(), root->layer_tree_impl()); | 1012 0.5f, grand_child1->effect_tree_index(), root->layer_tree_impl()); |
| 995 EmulateDrawingOneFrame(root); | 1013 EmulateDrawingOneFrame(root); |
| 996 child_damage_rect = | 1014 EXPECT_TRUE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 997 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1015 &child_damage_rect)); |
| 998 root_damage_rect = | 1016 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 999 root->render_surface()->damage_tracker()->current_damage_rect(); | 1017 &root_damage_rect)); |
| 1000 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); | 1018 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
| 1001 EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString()); | 1019 EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString()); |
| 1002 | 1020 |
| 1003 // CASE 2: Same as previous case, but with additional damage elsewhere that | 1021 // CASE 2: Same as previous case, but with additional damage elsewhere that |
| 1004 // should be properly unioned. | 1022 // should be properly unioned. |
| 1005 // - child1 surface damage in root surface space: | 1023 // - child1 surface damage in root surface space: |
| 1006 // gfx::Rect(300, 300, 6, 8); | 1024 // gfx::Rect(300, 300, 6, 8); |
| 1007 // - child2 damage in root surface space: | 1025 // - child2 damage in root surface space: |
| 1008 // gfx::Rect(11, 11, 18, 18); | 1026 // gfx::Rect(11, 11, 18, 18); |
| 1009 ClearDamageForAllSurfaces(root); | 1027 ClearDamageForAllSurfaces(root); |
| 1010 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 1028 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( |
| 1011 0.7f, grand_child1->effect_tree_index(), root->layer_tree_impl()); | 1029 0.7f, grand_child1->effect_tree_index(), root->layer_tree_impl()); |
| 1012 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 1030 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( |
| 1013 0.7f, child2->effect_tree_index(), root->layer_tree_impl()); | 1031 0.7f, child2->effect_tree_index(), root->layer_tree_impl()); |
| 1014 EmulateDrawingOneFrame(root); | 1032 EmulateDrawingOneFrame(root); |
| 1015 child_damage_rect = | 1033 EXPECT_TRUE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1016 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1034 &child_damage_rect)); |
| 1017 root_damage_rect = | 1035 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1018 root->render_surface()->damage_tracker()->current_damage_rect(); | 1036 &root_damage_rect)); |
| 1019 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); | 1037 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
| 1020 EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(), | 1038 EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(), |
| 1021 root_damage_rect.ToString()); | 1039 root_damage_rect.ToString()); |
| 1022 } | 1040 } |
| 1023 | 1041 |
| 1024 TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantLayer) { | 1042 TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantLayer) { |
| 1025 // If descendant layer changes and affects the content bounds of the render | 1043 // If descendant layer changes and affects the content bounds of the render |
| 1026 // surface, then the entire descendant surface should be damaged, and it | 1044 // surface, then the entire descendant surface should be damaged, and it |
| 1027 // should damage its ancestor surface with the old and new surface regions. | 1045 // should damage its ancestor surface with the old and new surface regions. |
| 1028 | 1046 |
| 1029 // This is a tricky case, since only the first grand_child changes, but the | 1047 // This is a tricky case, since only the first grand_child changes, but the |
| 1030 // entire surface should be marked dirty. | 1048 // entire surface should be marked dirty. |
| 1031 | 1049 |
| 1032 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 1050 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 1033 LayerImpl* child1 = root->test_properties()->children[0]; | 1051 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1034 LayerImpl* grand_child1 = | 1052 LayerImpl* grand_child1 = |
| 1035 root->test_properties()->children[0]->test_properties()->children[0]; | 1053 root->test_properties()->children[0]->test_properties()->children[0]; |
| 1036 gfx::Rect child_damage_rect; | 1054 gfx::Rect child_damage_rect; |
| 1037 gfx::Rect root_damage_rect; | 1055 gfx::Rect root_damage_rect; |
| 1038 | 1056 |
| 1039 ClearDamageForAllSurfaces(root); | 1057 ClearDamageForAllSurfaces(root); |
| 1040 grand_child1->SetPosition(gfx::PointF(195.f, 205.f)); | 1058 grand_child1->SetPosition(gfx::PointF(195.f, 205.f)); |
| 1041 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1059 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1042 EmulateDrawingOneFrame(root); | 1060 EmulateDrawingOneFrame(root); |
| 1043 child_damage_rect = | 1061 EXPECT_TRUE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1044 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1062 &child_damage_rect)); |
| 1045 root_damage_rect = | 1063 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1046 root->render_surface()->damage_tracker()->current_damage_rect(); | 1064 &root_damage_rect)); |
| 1047 | 1065 |
| 1048 // The new surface bounds should be damaged entirely, even though only one of | 1066 // The new surface bounds should be damaged entirely, even though only one of |
| 1049 // the layers changed. | 1067 // the layers changed. |
| 1050 EXPECT_EQ(gfx::Rect(190, 190, 11, 23).ToString(), | 1068 EXPECT_EQ(gfx::Rect(190, 190, 11, 23).ToString(), |
| 1051 child_damage_rect.ToString()); | 1069 child_damage_rect.ToString()); |
| 1052 | 1070 |
| 1053 // Damage to the root surface should be the union of child1's *entire* render | 1071 // Damage to the root surface should be the union of child1's *entire* render |
| 1054 // surface (in target space), and its old exposed area (also in target | 1072 // surface (in target space), and its old exposed area (also in target |
| 1055 // space). | 1073 // space). |
| 1056 EXPECT_EQ(gfx::Rect(290, 290, 16, 23).ToString(), | 1074 EXPECT_EQ(gfx::Rect(290, 290, 16, 23).ToString(), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1073 LayerImpl* child1 = root->test_properties()->children[0]; | 1091 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1074 gfx::Rect child_damage_rect; | 1092 gfx::Rect child_damage_rect; |
| 1075 gfx::Rect root_damage_rect; | 1093 gfx::Rect root_damage_rect; |
| 1076 | 1094 |
| 1077 ClearDamageForAllSurfaces(root); | 1095 ClearDamageForAllSurfaces(root); |
| 1078 gfx::Transform translation; | 1096 gfx::Transform translation; |
| 1079 translation.Translate(-50.f, -50.f); | 1097 translation.Translate(-50.f, -50.f); |
| 1080 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 1098 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( |
| 1081 translation, child1->transform_tree_index(), root->layer_tree_impl()); | 1099 translation, child1->transform_tree_index(), root->layer_tree_impl()); |
| 1082 EmulateDrawingOneFrame(root); | 1100 EmulateDrawingOneFrame(root); |
| 1083 child_damage_rect = | 1101 EXPECT_TRUE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1084 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1102 &child_damage_rect)); |
| 1085 root_damage_rect = | 1103 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1086 root->render_surface()->damage_tracker()->current_damage_rect(); | 1104 &root_damage_rect)); |
| 1087 | 1105 |
| 1088 // The new surface bounds should be damaged entirely. | 1106 // The new surface bounds should be damaged entirely. |
| 1089 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), | 1107 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), |
| 1090 child_damage_rect.ToString()); | 1108 child_damage_rect.ToString()); |
| 1091 | 1109 |
| 1092 // The entire child1 surface and the old exposed child1 surface should damage | 1110 // The entire child1 surface and the old exposed child1 surface should damage |
| 1093 // the root surface. | 1111 // the root surface. |
| 1094 // - old child1 surface in target space: gfx::Rect(290, 290, 16, 18) | 1112 // - old child1 surface in target space: gfx::Rect(290, 290, 16, 18) |
| 1095 // - new child1 surface in target space: gfx::Rect(240, 240, 16, 18) | 1113 // - new child1 surface in target space: gfx::Rect(240, 240, 16, 18) |
| 1096 EXPECT_EQ(gfx::Rect(240, 240, 66, 68).ToString(), | 1114 EXPECT_EQ(gfx::Rect(240, 240, 66, 68).ToString(), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1107 // exposed. | 1125 // exposed. |
| 1108 ClearDamageForAllSurfaces(root); | 1126 ClearDamageForAllSurfaces(root); |
| 1109 child1->test_properties()->force_render_surface = false; | 1127 child1->test_properties()->force_render_surface = false; |
| 1110 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1128 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1111 EmulateDrawingOneFrame(root); | 1129 EmulateDrawingOneFrame(root); |
| 1112 | 1130 |
| 1113 // Sanity check that there is only one surface now. | 1131 // Sanity check that there is only one surface now. |
| 1114 ASSERT_FALSE(child1->render_surface()); | 1132 ASSERT_FALSE(child1->render_surface()); |
| 1115 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); | 1133 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); |
| 1116 | 1134 |
| 1117 root_damage_rect = | 1135 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1118 root->render_surface()->damage_tracker()->current_damage_rect(); | 1136 &root_damage_rect)); |
| 1119 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), | 1137 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), |
| 1120 root_damage_rect.ToString()); | 1138 root_damage_rect.ToString()); |
| 1121 | 1139 |
| 1122 // CASE 2: If a descendant surface appears, its entire old area becomes | 1140 // CASE 2: If a descendant surface appears, its entire old area becomes |
| 1123 // exposed. | 1141 // exposed. |
| 1124 | 1142 |
| 1125 // Cycle one frame of no change, just to sanity check that the next rect is | 1143 // Cycle one frame of no change, just to sanity check that the next rect is |
| 1126 // not because of the old damage state. | 1144 // not because of the old damage state. |
| 1127 ClearDamageForAllSurfaces(root); | 1145 ClearDamageForAllSurfaces(root); |
| 1128 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1146 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1129 EmulateDrawingOneFrame(root); | 1147 EmulateDrawingOneFrame(root); |
| 1130 root_damage_rect = | 1148 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1131 root->render_surface()->damage_tracker()->current_damage_rect(); | 1149 &root_damage_rect)); |
| 1132 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1150 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 1133 | 1151 |
| 1134 // Then change the tree so that the render surface is added back. | 1152 // Then change the tree so that the render surface is added back. |
| 1135 ClearDamageForAllSurfaces(root); | 1153 ClearDamageForAllSurfaces(root); |
| 1136 child1->test_properties()->force_render_surface = true; | 1154 child1->test_properties()->force_render_surface = true; |
| 1137 | 1155 |
| 1138 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1156 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1139 EmulateDrawingOneFrame(root); | 1157 EmulateDrawingOneFrame(root); |
| 1140 | 1158 |
| 1141 // Sanity check that there is a new surface now. | 1159 // Sanity check that there is a new surface now. |
| 1142 ASSERT_TRUE(child1->render_surface()); | 1160 ASSERT_TRUE(child1->render_surface()); |
| 1143 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); | 1161 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); |
| 1144 EXPECT_EQ(2u, child1->render_surface()->layer_list().size()); | 1162 EXPECT_EQ(2u, child1->render_surface()->layer_list().size()); |
| 1145 | 1163 |
| 1146 child_damage_rect = | 1164 EXPECT_TRUE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1147 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1165 &child_damage_rect)); |
| 1148 root_damage_rect = | 1166 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1149 root->render_surface()->damage_tracker()->current_damage_rect(); | 1167 &root_damage_rect)); |
| 1150 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), | 1168 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), |
| 1151 child_damage_rect.ToString()); | 1169 child_damage_rect.ToString()); |
| 1152 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), | 1170 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), |
| 1153 root_damage_rect.ToString()); | 1171 root_damage_rect.ToString()); |
| 1154 } | 1172 } |
| 1155 | 1173 |
| 1156 TEST_F(DamageTrackerTest, VerifyNoDamageWhenNothingChanged) { | 1174 TEST_F(DamageTrackerTest, VerifyNoDamageWhenNothingChanged) { |
| 1157 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 1175 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 1158 LayerImpl* child1 = root->test_properties()->children[0]; | 1176 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1159 gfx::Rect child_damage_rect; | 1177 gfx::Rect child_damage_rect; |
| 1160 gfx::Rect root_damage_rect; | 1178 gfx::Rect root_damage_rect; |
| 1161 | 1179 |
| 1162 // CASE 1: If nothing changes, the damage rect should be empty. | 1180 // CASE 1: If nothing changes, the damage rect should be empty. |
| 1163 // | 1181 // |
| 1164 ClearDamageForAllSurfaces(root); | 1182 ClearDamageForAllSurfaces(root); |
| 1165 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1183 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1166 EmulateDrawingOneFrame(root); | 1184 EmulateDrawingOneFrame(root); |
| 1167 child_damage_rect = | 1185 EXPECT_TRUE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1168 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1186 &child_damage_rect)); |
| 1169 root_damage_rect = | 1187 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1170 root->render_surface()->damage_tracker()->current_damage_rect(); | 1188 &root_damage_rect)); |
| 1171 EXPECT_TRUE(child_damage_rect.IsEmpty()); | 1189 EXPECT_TRUE(child_damage_rect.IsEmpty()); |
| 1172 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1190 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 1173 | 1191 |
| 1174 // CASE 2: If nothing changes twice in a row, the damage rect should still be | 1192 // CASE 2: If nothing changes twice in a row, the damage rect should still be |
| 1175 // empty. | 1193 // empty. |
| 1176 // | 1194 // |
| 1177 ClearDamageForAllSurfaces(root); | 1195 ClearDamageForAllSurfaces(root); |
| 1178 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1196 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1179 EmulateDrawingOneFrame(root); | 1197 EmulateDrawingOneFrame(root); |
| 1180 child_damage_rect = | 1198 EXPECT_TRUE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1181 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1199 &child_damage_rect)); |
| 1182 root_damage_rect = | 1200 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1183 root->render_surface()->damage_tracker()->current_damage_rect(); | 1201 &root_damage_rect)); |
| 1184 EXPECT_TRUE(child_damage_rect.IsEmpty()); | 1202 EXPECT_TRUE(child_damage_rect.IsEmpty()); |
| 1185 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1203 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 1186 } | 1204 } |
| 1187 | 1205 |
| 1188 TEST_F(DamageTrackerTest, VerifyNoDamageForUpdateRectThatDoesNotDrawContent) { | 1206 TEST_F(DamageTrackerTest, VerifyNoDamageForUpdateRectThatDoesNotDrawContent) { |
| 1189 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 1207 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 1190 LayerImpl* child1 = root->test_properties()->children[0]; | 1208 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1191 gfx::Rect child_damage_rect; | 1209 gfx::Rect child_damage_rect; |
| 1192 gfx::Rect root_damage_rect; | 1210 gfx::Rect root_damage_rect; |
| 1193 | 1211 |
| 1194 // In our specific tree, the update rect of child1 should not cause any | 1212 // In our specific tree, the update rect of child1 should not cause any |
| 1195 // damage to any surface because it does not actually draw content. | 1213 // damage to any surface because it does not actually draw content. |
| 1196 ClearDamageForAllSurfaces(root); | 1214 ClearDamageForAllSurfaces(root); |
| 1197 child1->SetUpdateRect(gfx::Rect(1, 2)); | 1215 child1->SetUpdateRect(gfx::Rect(1, 2)); |
| 1198 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1216 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1199 EmulateDrawingOneFrame(root); | 1217 EmulateDrawingOneFrame(root); |
| 1200 child_damage_rect = | 1218 EXPECT_TRUE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1201 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1219 &child_damage_rect)); |
| 1202 root_damage_rect = | 1220 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1203 root->render_surface()->damage_tracker()->current_damage_rect(); | 1221 &root_damage_rect)); |
| 1204 EXPECT_TRUE(child_damage_rect.IsEmpty()); | 1222 EXPECT_TRUE(child_damage_rect.IsEmpty()); |
| 1205 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1223 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 1206 } | 1224 } |
| 1207 | 1225 |
| 1208 TEST_F(DamageTrackerTest, VerifyDamageForMask) { | 1226 TEST_F(DamageTrackerTest, VerifyDamageForMask) { |
| 1209 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 1227 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 1210 LayerImpl* child = root->test_properties()->children[0]; | 1228 LayerImpl* child = root->test_properties()->children[0]; |
| 1211 | 1229 |
| 1212 // In the current implementation of the damage tracker, changes to mask | 1230 // In the current implementation of the damage tracker, changes to mask |
| 1213 // layers should damage the entire corresponding surface. | 1231 // layers should damage the entire corresponding surface. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1237 } | 1255 } |
| 1238 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1256 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1239 EmulateDrawingOneFrame(root); | 1257 EmulateDrawingOneFrame(root); |
| 1240 | 1258 |
| 1241 // CASE 1: the update_rect on a mask layer should damage the entire target | 1259 // CASE 1: the update_rect on a mask layer should damage the entire target |
| 1242 // surface. | 1260 // surface. |
| 1243 ClearDamageForAllSurfaces(root); | 1261 ClearDamageForAllSurfaces(root); |
| 1244 mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); | 1262 mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); |
| 1245 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1263 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1246 EmulateDrawingOneFrame(root); | 1264 EmulateDrawingOneFrame(root); |
| 1247 gfx::Rect child_damage_rect = | 1265 gfx::Rect child_damage_rect; |
| 1248 child->render_surface()->damage_tracker()->current_damage_rect(); | 1266 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1267 &child_damage_rect)); |
| 1249 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); | 1268 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); |
| 1250 | 1269 |
| 1251 // CASE 2: a property change on the mask layer should damage the entire | 1270 // CASE 2: a property change on the mask layer should damage the entire |
| 1252 // target surface. | 1271 // target surface. |
| 1253 | 1272 |
| 1254 // Advance one frame without damage so that we know the damage rect is not | 1273 // Advance one frame without damage so that we know the damage rect is not |
| 1255 // leftover from the previous case. | 1274 // leftover from the previous case. |
| 1256 ClearDamageForAllSurfaces(root); | 1275 ClearDamageForAllSurfaces(root); |
| 1257 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1276 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1258 EmulateDrawingOneFrame(root); | 1277 EmulateDrawingOneFrame(root); |
| 1259 child_damage_rect = | 1278 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1260 child->render_surface()->damage_tracker()->current_damage_rect(); | 1279 &child_damage_rect)); |
| 1261 EXPECT_TRUE(child_damage_rect.IsEmpty()); | 1280 EXPECT_TRUE(child_damage_rect.IsEmpty()); |
| 1262 | 1281 |
| 1263 // Then test the property change. | 1282 // Then test the property change. |
| 1264 ClearDamageForAllSurfaces(root); | 1283 ClearDamageForAllSurfaces(root); |
| 1265 mask_layer->NoteLayerPropertyChanged(); | 1284 mask_layer->NoteLayerPropertyChanged(); |
| 1266 | 1285 |
| 1267 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1286 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1268 EmulateDrawingOneFrame(root); | 1287 EmulateDrawingOneFrame(root); |
| 1269 child_damage_rect = | 1288 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1270 child->render_surface()->damage_tracker()->current_damage_rect(); | 1289 &child_damage_rect)); |
| 1271 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); | 1290 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); |
| 1272 | 1291 |
| 1273 // CASE 3: removing the mask also damages the entire target surface. | 1292 // CASE 3: removing the mask also damages the entire target surface. |
| 1274 // | 1293 // |
| 1275 | 1294 |
| 1276 // Advance one frame without damage so that we know the damage rect is not | 1295 // Advance one frame without damage so that we know the damage rect is not |
| 1277 // leftover from the previous case. | 1296 // leftover from the previous case. |
| 1278 ClearDamageForAllSurfaces(root); | 1297 ClearDamageForAllSurfaces(root); |
| 1279 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1298 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1280 EmulateDrawingOneFrame(root); | 1299 EmulateDrawingOneFrame(root); |
| 1281 child_damage_rect = | 1300 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1282 child->render_surface()->damage_tracker()->current_damage_rect(); | 1301 &child_damage_rect)); |
| 1283 EXPECT_TRUE(child_damage_rect.IsEmpty()); | 1302 EXPECT_TRUE(child_damage_rect.IsEmpty()); |
| 1284 | 1303 |
| 1285 // Then test mask removal. | 1304 // Then test mask removal. |
| 1286 ClearDamageForAllSurfaces(root); | 1305 ClearDamageForAllSurfaces(root); |
| 1287 child->test_properties()->SetMaskLayer(nullptr); | 1306 child->test_properties()->SetMaskLayer(nullptr); |
| 1288 child->NoteLayerPropertyChanged(); | 1307 child->NoteLayerPropertyChanged(); |
| 1289 ASSERT_TRUE(child->LayerPropertyChanged()); | 1308 ASSERT_TRUE(child->LayerPropertyChanged()); |
| 1290 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1309 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1291 EmulateDrawingOneFrame(root); | 1310 EmulateDrawingOneFrame(root); |
| 1292 | 1311 |
| 1293 // Sanity check that a render surface still exists. | 1312 // Sanity check that a render surface still exists. |
| 1294 ASSERT_TRUE(child->render_surface()); | 1313 ASSERT_TRUE(child->render_surface()); |
| 1295 | 1314 |
| 1296 child_damage_rect = | 1315 EXPECT_TRUE(child->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1297 child->render_surface()->damage_tracker()->current_damage_rect(); | 1316 &child_damage_rect)); |
| 1298 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); | 1317 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); |
| 1299 } | 1318 } |
| 1300 | 1319 |
| 1301 TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { | 1320 TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { |
| 1302 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 1321 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 1303 LayerImpl* child = root->test_properties()->children[0]; | 1322 LayerImpl* child = root->test_properties()->children[0]; |
| 1304 | 1323 |
| 1305 // Case 1: This test ensures that when the tracker is given damage, that | 1324 // Case 1: This test ensures that when the tracker is given damage, that |
| 1306 // it is included with any other partial damage. | 1325 // it is included with any other partial damage. |
| 1307 // | 1326 // |
| 1308 ClearDamageForAllSurfaces(root); | 1327 ClearDamageForAllSurfaces(root); |
| 1309 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); | 1328 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
| 1310 root->render_surface()->damage_tracker()->AddDamageNextUpdate( | 1329 root->render_surface()->damage_tracker()->AddDamageNextUpdate( |
| 1311 gfx::Rect(15, 16, 32, 33)); | 1330 gfx::Rect(15, 16, 32, 33)); |
| 1312 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1331 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1313 EmulateDrawingOneFrame(root); | 1332 EmulateDrawingOneFrame(root); |
| 1314 gfx::Rect root_damage_rect = | 1333 gfx::Rect root_damage_rect; |
| 1315 root->render_surface()->damage_tracker()->current_damage_rect(); | 1334 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1335 &root_damage_rect)); |
| 1316 EXPECT_EQ(gfx::UnionRects(gfx::Rect(15, 16, 32, 33), | 1336 EXPECT_EQ(gfx::UnionRects(gfx::Rect(15, 16, 32, 33), |
| 1317 gfx::Rect(100 + 10, 100 + 11, 12, 13)).ToString(), | 1337 gfx::Rect(100 + 10, 100 + 11, 12, 13)).ToString(), |
| 1318 root_damage_rect.ToString()); | 1338 root_damage_rect.ToString()); |
| 1319 | 1339 |
| 1320 // Case 2: An additional sanity check that adding damage works even when | 1340 // Case 2: An additional sanity check that adding damage works even when |
| 1321 // nothing on the layer tree changed. | 1341 // nothing on the layer tree changed. |
| 1322 // | 1342 // |
| 1323 ClearDamageForAllSurfaces(root); | 1343 ClearDamageForAllSurfaces(root); |
| 1324 root->render_surface()->damage_tracker()->AddDamageNextUpdate( | 1344 root->render_surface()->damage_tracker()->AddDamageNextUpdate( |
| 1325 gfx::Rect(30, 31, 14, 15)); | 1345 gfx::Rect(30, 31, 14, 15)); |
| 1326 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1346 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1327 EmulateDrawingOneFrame(root); | 1347 EmulateDrawingOneFrame(root); |
| 1328 root_damage_rect = | 1348 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1329 root->render_surface()->damage_tracker()->current_damage_rect(); | 1349 &root_damage_rect)); |
| 1330 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); | 1350 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); |
| 1331 } | 1351 } |
| 1332 | 1352 |
| 1333 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { | 1353 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { |
| 1334 // Though it should never happen, its a good idea to verify that the damage | 1354 // Though it should never happen, its a good idea to verify that the damage |
| 1335 // tracker does not crash when it receives an empty layer_list. | 1355 // tracker does not crash when it receives an empty layer_list. |
| 1336 | 1356 |
| 1337 std::unique_ptr<LayerImpl> root = | 1357 std::unique_ptr<LayerImpl> root = |
| 1338 LayerImpl::Create(host_impl_.active_tree(), 1); | 1358 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 1339 root->test_properties()->force_render_surface = true; | 1359 root->test_properties()->force_render_surface = true; |
| 1340 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); | 1360 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1341 LayerImpl* root_ptr = host_impl_.active_tree()->root_layer_for_testing(); | 1361 LayerImpl* root_ptr = host_impl_.active_tree()->root_layer_for_testing(); |
| 1342 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1362 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1343 EmulateDrawingOneFrame(root_ptr); | 1363 EmulateDrawingOneFrame(root_ptr); |
| 1344 | 1364 |
| 1345 DCHECK_EQ(root_ptr->render_surface(), root_ptr->render_target()); | 1365 DCHECK_EQ(root_ptr->render_surface(), root_ptr->render_target()); |
| 1346 RenderSurfaceImpl* target_surface = root_ptr->render_surface(); | 1366 RenderSurfaceImpl* target_surface = root_ptr->render_surface(); |
| 1347 | 1367 |
| 1348 LayerImplList empty_list; | 1368 LayerImplList empty_list; |
| 1349 target_surface->damage_tracker()->UpdateDamageTrackingState( | 1369 target_surface->damage_tracker()->UpdateDamageTrackingState( |
| 1350 empty_list, target_surface, false, gfx::Rect(), NULL, FilterOperations()); | 1370 empty_list, target_surface, false, gfx::Rect(), NULL, FilterOperations()); |
| 1351 | 1371 |
| 1352 gfx::Rect damage_rect = | 1372 gfx::Rect damage_rect; |
| 1353 target_surface->damage_tracker()->current_damage_rect(); | 1373 EXPECT_TRUE( |
| 1374 target_surface->damage_tracker()->GetDamageRectIfValid(&damage_rect)); |
| 1354 EXPECT_TRUE(damage_rect.IsEmpty()); | 1375 EXPECT_TRUE(damage_rect.IsEmpty()); |
| 1355 } | 1376 } |
| 1356 | 1377 |
| 1357 TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { | 1378 TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { |
| 1358 // If damage is not cleared, it should accumulate. | 1379 // If damage is not cleared, it should accumulate. |
| 1359 | 1380 |
| 1360 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 1381 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 1361 LayerImpl* child = root->test_properties()->children[0]; | 1382 LayerImpl* child = root->test_properties()->children[0]; |
| 1362 | 1383 |
| 1363 ClearDamageForAllSurfaces(root); | 1384 ClearDamageForAllSurfaces(root); |
| 1364 child->SetUpdateRect(gfx::Rect(10.f, 11.f, 1.f, 2.f)); | 1385 child->SetUpdateRect(gfx::Rect(10.f, 11.f, 1.f, 2.f)); |
| 1365 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1386 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1366 EmulateDrawingOneFrame(root); | 1387 EmulateDrawingOneFrame(root); |
| 1367 | 1388 |
| 1368 // Sanity check damage after the first frame; this isnt the actual test yet. | 1389 // Sanity check damage after the first frame; this isnt the actual test yet. |
| 1369 gfx::Rect root_damage_rect = | 1390 gfx::Rect root_damage_rect; |
| 1370 root->render_surface()->damage_tracker()->current_damage_rect(); | 1391 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1392 &root_damage_rect)); |
| 1371 EXPECT_EQ(gfx::Rect(110, 111, 1, 2).ToString(), root_damage_rect.ToString()); | 1393 EXPECT_EQ(gfx::Rect(110, 111, 1, 2).ToString(), root_damage_rect.ToString()); |
| 1372 | 1394 |
| 1373 // New damage, without having cleared the previous damage, should be unioned | 1395 // New damage, without having cleared the previous damage, should be unioned |
| 1374 // to the previous one. | 1396 // to the previous one. |
| 1375 child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); | 1397 child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); |
| 1376 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1398 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1377 EmulateDrawingOneFrame(root); | 1399 EmulateDrawingOneFrame(root); |
| 1378 root_damage_rect = | 1400 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1379 root->render_surface()->damage_tracker()->current_damage_rect(); | 1401 &root_damage_rect)); |
| 1380 EXPECT_EQ(gfx::Rect(110, 111, 11, 16).ToString(), | 1402 EXPECT_EQ(gfx::Rect(110, 111, 11, 16).ToString(), |
| 1381 root_damage_rect.ToString()); | 1403 root_damage_rect.ToString()); |
| 1382 | 1404 |
| 1383 // If we notify the damage tracker that we drew the damaged area, then damage | 1405 // If we notify the damage tracker that we drew the damaged area, then damage |
| 1384 // should be emptied. | 1406 // should be emptied. |
| 1385 root->render_surface()->damage_tracker()->DidDrawDamagedArea(); | 1407 root->render_surface()->damage_tracker()->DidDrawDamagedArea(); |
| 1386 root_damage_rect = | 1408 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1387 root->render_surface()->damage_tracker()->current_damage_rect(); | 1409 &root_damage_rect)); |
| 1388 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1410 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 1389 | 1411 |
| 1390 // Damage should remain empty even after one frame, since there's yet no new | 1412 // Damage should remain empty even after one frame, since there's yet no new |
| 1391 // damage. | 1413 // damage. |
| 1392 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1414 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1393 EmulateDrawingOneFrame(root); | 1415 EmulateDrawingOneFrame(root); |
| 1394 root_damage_rect = | 1416 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1395 root->render_surface()->damage_tracker()->current_damage_rect(); | 1417 &root_damage_rect)); |
| 1396 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1418 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 1397 } | 1419 } |
| 1398 | 1420 |
| 1399 TEST_F(DamageTrackerTest, HugeDamageRect) { | 1421 TEST_F(DamageTrackerTest, HugeDamageRect) { |
| 1400 // This number is so large that we start losting floating point accuracy. | 1422 // This number is so large that we start losting floating point accuracy. |
| 1401 const int kBigNumber = 900000000; | 1423 const int kBigNumber = 900000000; |
| 1402 // Walk over a range to find floating point inaccuracy boundaries that move | 1424 // Walk over a range to find floating point inaccuracy boundaries that move |
| 1403 // toward the wrong direction. | 1425 // toward the wrong direction. |
| 1404 const int kRange = 5000; | 1426 const int kRange = 5000; |
| 1405 | 1427 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1419 float device_scale_factor = 1.f; | 1441 float device_scale_factor = 1.f; |
| 1420 // Visible rects computed from combining clips in target space and root | 1442 // Visible rects computed from combining clips in target space and root |
| 1421 // space don't match because of the loss in floating point accuracy. So, we | 1443 // space don't match because of the loss in floating point accuracy. So, we |
| 1422 // skip verify_clip_tree_calculations. | 1444 // skip verify_clip_tree_calculations. |
| 1423 bool skip_verify_visible_rect_calculations = true; | 1445 bool skip_verify_visible_rect_calculations = true; |
| 1424 EmulateDrawingOneFrame(root, device_scale_factor, | 1446 EmulateDrawingOneFrame(root, device_scale_factor, |
| 1425 skip_verify_visible_rect_calculations); | 1447 skip_verify_visible_rect_calculations); |
| 1426 | 1448 |
| 1427 // The expected damage should cover the visible part of the child layer, | 1449 // The expected damage should cover the visible part of the child layer, |
| 1428 // which is (0, 0, i, i) in the viewport. | 1450 // which is (0, 0, i, i) in the viewport. |
| 1429 gfx::Rect root_damage_rect = | 1451 gfx::Rect root_damage_rect; |
| 1430 root->render_surface()->damage_tracker()->current_damage_rect(); | 1452 EXPECT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1453 &root_damage_rect)); |
| 1431 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1454 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1432 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1455 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1433 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1456 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1434 } | 1457 } |
| 1435 } | 1458 } |
| 1436 | 1459 |
| 1460 TEST_F(DamageTrackerTest, DamageRectTooBig) { |
| 1461 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(2); |
| 1462 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1463 LayerImpl* child2 = root->test_properties()->children[1]; |
| 1464 |
| 1465 // Really far left. |
| 1466 child1->SetPosition(gfx::PointF(std::numeric_limits<int>::min() + 100, 0)); |
| 1467 child1->SetBounds(gfx::Size(1, 1)); |
| 1468 |
| 1469 // Really far right. |
| 1470 child2->SetPosition(gfx::PointF(std::numeric_limits<int>::max() - 100, 0)); |
| 1471 child2->SetBounds(gfx::Size(1, 1)); |
| 1472 |
| 1473 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1474 float device_scale_factor = 1.f; |
| 1475 bool skip_verify_visible_rect_calculations = true; |
| 1476 EmulateDrawingOneFrame(root, device_scale_factor, |
| 1477 skip_verify_visible_rect_calculations); |
| 1478 |
| 1479 // The expected damage would be too large to store in a gfx::Rect, so we |
| 1480 // should damage everything (ie, we don't have a valid rect). |
| 1481 gfx::Rect damage_rect; |
| 1482 EXPECT_FALSE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1483 &damage_rect)); |
| 1484 EXPECT_EQ(root->render_surface()->content_rect(), |
| 1485 root->render_surface()->GetDamageRect()); |
| 1486 } |
| 1487 |
| 1488 TEST_F(DamageTrackerTest, DamageRectTooBigWithFilter) { |
| 1489 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(2); |
| 1490 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1491 LayerImpl* child2 = root->test_properties()->children[1]; |
| 1492 |
| 1493 FilterOperations filters; |
| 1494 filters.Append(FilterOperation::CreateBlurFilter(5.f)); |
| 1495 root->SetDrawsContent(true); |
| 1496 root->test_properties()->background_filters = filters; |
| 1497 |
| 1498 // Really far left. |
| 1499 child1->SetPosition(gfx::PointF(std::numeric_limits<int>::min() + 100, 0)); |
| 1500 child1->SetBounds(gfx::Size(1, 1)); |
| 1501 |
| 1502 // Really far right. |
| 1503 child2->SetPosition(gfx::PointF(std::numeric_limits<int>::max() - 100, 0)); |
| 1504 child2->SetBounds(gfx::Size(1, 1)); |
| 1505 |
| 1506 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1507 float device_scale_factor = 1.f; |
| 1508 bool skip_verify_visible_rect_calculations = true; |
| 1509 EmulateDrawingOneFrame(root, device_scale_factor, |
| 1510 skip_verify_visible_rect_calculations); |
| 1511 |
| 1512 // The expected damage would be too large to store in a gfx::Rect, so we |
| 1513 // should damage everything (ie, we don't have a valid rect). |
| 1514 gfx::Rect damage_rect; |
| 1515 EXPECT_FALSE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1516 &damage_rect)); |
| 1517 EXPECT_EQ(root->render_surface()->content_rect(), |
| 1518 root->render_surface()->GetDamageRect()); |
| 1519 } |
| 1520 |
| 1521 TEST_F(DamageTrackerTest, DamageRectTooBigInRenderSurface) { |
| 1522 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 1523 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1524 LayerImpl* grandchild1 = child1->test_properties()->children[0]; |
| 1525 LayerImpl* grandchild2 = child1->test_properties()->children[1]; |
| 1526 |
| 1527 // Really far left. |
| 1528 grandchild1->SetPosition( |
| 1529 gfx::PointF(std::numeric_limits<int>::min() + 500, 0)); |
| 1530 grandchild1->SetBounds(gfx::Size(1, 1)); |
| 1531 grandchild1->SetDrawsContent(true); |
| 1532 |
| 1533 // Really far right. |
| 1534 grandchild2->SetPosition( |
| 1535 gfx::PointF(std::numeric_limits<int>::max() - 500, 0)); |
| 1536 grandchild2->SetBounds(gfx::Size(1, 1)); |
| 1537 grandchild2->SetDrawsContent(true); |
| 1538 |
| 1539 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1540 float device_scale_factor = 1.f; |
| 1541 bool skip_verify_visible_rect_calculations = true; |
| 1542 LayerImplList render_surface_layer_list; |
| 1543 ExecuteCalculateDrawProperties(root, device_scale_factor, |
| 1544 skip_verify_visible_rect_calculations, |
| 1545 &render_surface_layer_list); |
| 1546 |
| 1547 auto* surface = child1->render_surface(); |
| 1548 surface->damage_tracker()->UpdateDamageTrackingState( |
| 1549 surface->layer_list(), surface, false, surface->content_rect(), |
| 1550 surface->MaskLayer(), surface->Filters()); |
| 1551 surface = root->render_surface(); |
| 1552 surface->damage_tracker()->UpdateDamageTrackingState( |
| 1553 surface->layer_list(), surface, false, surface->content_rect(), |
| 1554 surface->MaskLayer(), surface->Filters()); |
| 1555 |
| 1556 // The expected damage would be too large to store in a gfx::Rect, so we |
| 1557 // should damage everything on child1. |
| 1558 gfx::Rect damage_rect; |
| 1559 EXPECT_FALSE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1560 &damage_rect)); |
| 1561 EXPECT_EQ(child1->render_surface()->content_rect(), |
| 1562 child1->render_surface()->GetDamageRect()); |
| 1563 |
| 1564 // However, the root should just use the child1 render surface's content rect |
| 1565 // as damage. |
| 1566 ASSERT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1567 &damage_rect)); |
| 1568 EXPECT_TRUE(damage_rect.Contains(root->render_surface()->content_rect())); |
| 1569 EXPECT_TRUE(damage_rect.Contains( |
| 1570 gfx::ToEnclosingRect(child1->render_surface()->DrawableContentRect()))); |
| 1571 EXPECT_EQ(damage_rect, root->render_surface()->GetDamageRect()); |
| 1572 |
| 1573 // Add new damage, without changing properties, which goes down a different |
| 1574 // path in the damage tracker. |
| 1575 root->layer_tree_impl()->ResetAllChangeTracking(); |
| 1576 grandchild1->AddDamageRect(gfx::Rect(grandchild1->bounds())); |
| 1577 grandchild2->AddDamageRect(gfx::Rect(grandchild1->bounds())); |
| 1578 |
| 1579 // Recompute all damage / properties. |
| 1580 render_surface_layer_list.clear(); |
| 1581 ExecuteCalculateDrawProperties(root, device_scale_factor, |
| 1582 skip_verify_visible_rect_calculations, |
| 1583 &render_surface_layer_list); |
| 1584 surface = child1->render_surface(); |
| 1585 surface->damage_tracker()->UpdateDamageTrackingState( |
| 1586 surface->layer_list(), surface, false, surface->content_rect(), |
| 1587 surface->MaskLayer(), surface->Filters()); |
| 1588 surface = root->render_surface(); |
| 1589 surface->damage_tracker()->UpdateDamageTrackingState( |
| 1590 surface->layer_list(), surface, false, surface->content_rect(), |
| 1591 surface->MaskLayer(), surface->Filters()); |
| 1592 |
| 1593 // Child1 should still not have a valid rect, since the union of the damage of |
| 1594 // its children is not representable by a single rect. |
| 1595 EXPECT_FALSE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1596 &damage_rect)); |
| 1597 EXPECT_EQ(child1->render_surface()->content_rect(), |
| 1598 child1->render_surface()->GetDamageRect()); |
| 1599 |
| 1600 // Root should have valid damage and contain both its content rect and the |
| 1601 // drawable content rect of child1. |
| 1602 ASSERT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1603 &damage_rect)); |
| 1604 EXPECT_TRUE(damage_rect.Contains(root->render_surface()->content_rect())); |
| 1605 EXPECT_TRUE(damage_rect.Contains( |
| 1606 gfx::ToEnclosingRect(child1->render_surface()->DrawableContentRect()))); |
| 1607 EXPECT_EQ(damage_rect, root->render_surface()->GetDamageRect()); |
| 1608 } |
| 1609 |
| 1610 TEST_F(DamageTrackerTest, DamageRectTooBigInRenderSurfaceWithFilter) { |
| 1611 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 1612 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1613 LayerImpl* grandchild1 = child1->test_properties()->children[0]; |
| 1614 LayerImpl* grandchild2 = child1->test_properties()->children[1]; |
| 1615 |
| 1616 // Set up a moving pixels filter on the child. |
| 1617 FilterOperations filters; |
| 1618 filters.Append(FilterOperation::CreateBlurFilter(5.f)); |
| 1619 child1->SetDrawsContent(true); |
| 1620 child1->test_properties()->background_filters = filters; |
| 1621 |
| 1622 // Really far left. |
| 1623 grandchild1->SetPosition( |
| 1624 gfx::PointF(std::numeric_limits<int>::min() + 500, 0)); |
| 1625 grandchild1->SetBounds(gfx::Size(1, 1)); |
| 1626 grandchild1->SetDrawsContent(true); |
| 1627 |
| 1628 // Really far right. |
| 1629 grandchild2->SetPosition( |
| 1630 gfx::PointF(std::numeric_limits<int>::max() - 500, 0)); |
| 1631 grandchild2->SetBounds(gfx::Size(1, 1)); |
| 1632 grandchild2->SetDrawsContent(true); |
| 1633 |
| 1634 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1635 float device_scale_factor = 1.f; |
| 1636 bool skip_verify_visible_rect_calculations = true; |
| 1637 LayerImplList render_surface_layer_list; |
| 1638 ExecuteCalculateDrawProperties(root, device_scale_factor, |
| 1639 skip_verify_visible_rect_calculations, |
| 1640 &render_surface_layer_list); |
| 1641 |
| 1642 auto* surface = child1->render_surface(); |
| 1643 surface->damage_tracker()->UpdateDamageTrackingState( |
| 1644 surface->layer_list(), surface, false, surface->content_rect(), |
| 1645 surface->MaskLayer(), surface->Filters()); |
| 1646 surface = root->render_surface(); |
| 1647 surface->damage_tracker()->UpdateDamageTrackingState( |
| 1648 surface->layer_list(), surface, false, surface->content_rect(), |
| 1649 surface->MaskLayer(), surface->Filters()); |
| 1650 |
| 1651 // The expected damage would be too large to store in a gfx::Rect, so we |
| 1652 // should damage everything on child1. |
| 1653 gfx::Rect damage_rect; |
| 1654 EXPECT_FALSE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1655 &damage_rect)); |
| 1656 EXPECT_EQ(child1->render_surface()->content_rect(), |
| 1657 child1->render_surface()->GetDamageRect()); |
| 1658 |
| 1659 // However, the root should just use the child1 render surface's content rect |
| 1660 // as damage. |
| 1661 ASSERT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1662 &damage_rect)); |
| 1663 EXPECT_TRUE(damage_rect.Contains(root->render_surface()->content_rect())); |
| 1664 EXPECT_TRUE(damage_rect.Contains( |
| 1665 gfx::ToEnclosingRect(child1->render_surface()->DrawableContentRect()))); |
| 1666 EXPECT_EQ(damage_rect, root->render_surface()->GetDamageRect()); |
| 1667 |
| 1668 // Add new damage, without changing properties, which goes down a different |
| 1669 // path in the damage tracker. |
| 1670 root->layer_tree_impl()->ResetAllChangeTracking(); |
| 1671 grandchild1->AddDamageRect(gfx::Rect(grandchild1->bounds())); |
| 1672 grandchild2->AddDamageRect(gfx::Rect(grandchild1->bounds())); |
| 1673 |
| 1674 // Recompute all damage / properties. |
| 1675 render_surface_layer_list.clear(); |
| 1676 ExecuteCalculateDrawProperties(root, device_scale_factor, |
| 1677 skip_verify_visible_rect_calculations, |
| 1678 &render_surface_layer_list); |
| 1679 surface = child1->render_surface(); |
| 1680 surface->damage_tracker()->UpdateDamageTrackingState( |
| 1681 surface->layer_list(), surface, false, surface->content_rect(), |
| 1682 surface->MaskLayer(), surface->Filters()); |
| 1683 surface = root->render_surface(); |
| 1684 surface->damage_tracker()->UpdateDamageTrackingState( |
| 1685 surface->layer_list(), surface, false, surface->content_rect(), |
| 1686 surface->MaskLayer(), surface->Filters()); |
| 1687 |
| 1688 // Child1 should still not have a valid rect, since the union of the damage of |
| 1689 // its children is not representable by a single rect. |
| 1690 EXPECT_FALSE(child1->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1691 &damage_rect)); |
| 1692 EXPECT_EQ(child1->render_surface()->content_rect(), |
| 1693 child1->render_surface()->GetDamageRect()); |
| 1694 |
| 1695 // Root should have valid damage and contain both its content rect and the |
| 1696 // drawable content rect of child1. |
| 1697 ASSERT_TRUE(root->render_surface()->damage_tracker()->GetDamageRectIfValid( |
| 1698 &damage_rect)); |
| 1699 EXPECT_TRUE(damage_rect.Contains(root->render_surface()->content_rect())); |
| 1700 EXPECT_TRUE(damage_rect.Contains( |
| 1701 gfx::ToEnclosingRect(child1->render_surface()->DrawableContentRect()))); |
| 1702 EXPECT_EQ(damage_rect, root->render_surface()->GetDamageRect()); |
| 1703 } |
| 1704 |
| 1437 } // namespace | 1705 } // namespace |
| 1438 } // namespace cc | 1706 } // namespace cc |
| OLD | NEW |