Chromium Code Reviews| 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 "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
| 8 #include "cc/layers/layer_impl.h" | 8 #include "cc/layers/layer_impl.h" |
| 9 #include "cc/output/filter_operation.h" | 9 #include "cc/output/filter_operation.h" |
| 10 #include "cc/output/filter_operations.h" | 10 #include "cc/output/filter_operations.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 child->SetUpdateRect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); | 261 child->SetUpdateRect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); |
| 262 EmulateDrawingOneFrame(root.get()); | 262 EmulateDrawingOneFrame(root.get()); |
| 263 | 263 |
| 264 // Damage position on the surface should be: position of update_rect (20, 25) | 264 // Damage position on the surface should be: position of update_rect (20, 25) |
| 265 // relative to the child (100, 100). | 265 // relative to the child (100, 100). |
| 266 root_damage_rect = | 266 root_damage_rect = |
| 267 root->render_surface()->damage_tracker()->current_damage_rect(); | 267 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 268 EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString()); | 268 EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString()); |
| 269 } | 269 } |
| 270 | 270 |
| 271 TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { | |
| 272 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | |
| 273 LayerImpl* child = root->children()[0]; | |
| 274 | |
| 275 // CASE 1: Setting the layer damage rect should cause the corresponding damage | |
|
reveman
2014/04/21 18:48:26
nit: you're not setting, you're adding a damage re
| |
| 276 // to the surface. | |
| 277 ClearDamageForAllSurfaces(root.get()); | |
| 278 child->AddDamageRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); | |
| 279 EmulateDrawingOneFrame(root.get()); | |
| 280 | |
| 281 // Damage position on the surface should be: position of layer damage_rect | |
| 282 // (10, 11) relative to the child (100, 100). | |
| 283 gfx::Rect root_damage_rect = | |
| 284 root->render_surface()->damage_tracker()->current_damage_rect(); | |
| 285 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), | |
| 286 root_damage_rect.ToString()); | |
|
reveman
2014/04/21 18:48:26
nit: as the api is AddDamageRect I think you shoul
| |
| 287 | |
| 288 // CASE 2: The same layer damage rect twice in a row still produces the same | |
| 289 // damage. | |
| 290 ClearDamageForAllSurfaces(root.get()); | |
| 291 child->AddDamageRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); | |
| 292 EmulateDrawingOneFrame(root.get()); | |
| 293 root_damage_rect = | |
| 294 root->render_surface()->damage_tracker()->current_damage_rect(); | |
| 295 EXPECT_EQ(gfx::Rect(110, 111, 12, 13).ToString(), | |
| 296 root_damage_rect.ToString()); | |
| 297 | |
| 298 // CASE 3: Setting a different layer damage rect should cause damage on the | |
| 299 // new damaged region, but no additional exposed old region. | |
| 300 ClearDamageForAllSurfaces(root.get()); | |
| 301 child->AddDamageRect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); | |
| 302 EmulateDrawingOneFrame(root.get()); | |
| 303 | |
| 304 // Damage position on the surface should be: position of layer damage_rect | |
| 305 // (20, 25) relative to the child (100, 100). | |
| 306 root_damage_rect = | |
| 307 root->render_surface()->damage_tracker()->current_damage_rect(); | |
| 308 EXPECT_EQ(gfx::Rect(120, 125, 1, 2).ToString(), root_damage_rect.ToString()); | |
| 309 } | |
|
reveman
2014/04/21 18:48:26
could you include a test where you add more than o
| |
| 310 | |
| 311 TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) { | |
| 312 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | |
| 313 LayerImpl* child = root->children()[0]; | |
| 314 | |
| 315 // CASE 1: Setting the layer damage rect and update rect should cause the | |
| 316 // corresponding damage to the surface. | |
| 317 ClearDamageForAllSurfaces(root.get()); | |
| 318 child->AddDamageRect(gfx::RectF(5.f, 6.f, 12.f, 13.f)); | |
| 319 child->SetUpdateRect(gfx::RectF(15.f, 16.f, 14.f, 10.f)); | |
| 320 EmulateDrawingOneFrame(root.get()); | |
| 321 | |
| 322 // Damage position on the surface should be: position of unified layer | |
| 323 // damage_rect and update rect (5, 6) | |
| 324 // relative to the child (100, 100). | |
| 325 gfx::Rect root_damage_rect = | |
| 326 root->render_surface()->damage_tracker()->current_damage_rect(); | |
| 327 EXPECT_EQ(gfx::Rect(105, 106, 24, 20).ToString(), | |
| 328 root_damage_rect.ToString()); | |
| 329 | |
| 330 // CASE 2: The same layer damage rect and update rect twice in a row still | |
| 331 // produces the same damage. | |
| 332 ClearDamageForAllSurfaces(root.get()); | |
| 333 child->AddDamageRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); | |
| 334 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 14.f, 15.f)); | |
| 335 EmulateDrawingOneFrame(root.get()); | |
| 336 root_damage_rect = | |
| 337 root->render_surface()->damage_tracker()->current_damage_rect(); | |
| 338 EXPECT_EQ(gfx::Rect(110, 111, 14, 15).ToString(), | |
| 339 root_damage_rect.ToString()); | |
| 340 | |
| 341 // CASE 3: Setting a different layer damage rect and update rect should cause | |
| 342 // damage on the new damaged region, but no additional exposed old region. | |
| 343 ClearDamageForAllSurfaces(root.get()); | |
| 344 child->AddDamageRect(gfx::RectF(20.f, 25.f, 2.f, 3.f)); | |
| 345 child->SetUpdateRect(gfx::RectF(5.f, 10.f, 7.f, 8.f)); | |
| 346 EmulateDrawingOneFrame(root.get()); | |
| 347 | |
| 348 // Damage position on the surface should be: position of unified layer damage | |
| 349 // rect and update rect (5, 10) relative to the child (100, 100). | |
| 350 root_damage_rect = | |
| 351 root->render_surface()->damage_tracker()->current_damage_rect(); | |
| 352 EXPECT_EQ(gfx::Rect(105, 110, 17, 18).ToString(), | |
| 353 root_damage_rect.ToString()); | |
| 354 } | |
| 355 | |
| 271 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { | 356 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { |
| 272 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | 357 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); |
| 273 LayerImpl* child = root->children()[0]; | 358 LayerImpl* child = root->children()[0]; |
| 274 | 359 |
| 275 // CASE 1: The layer's property changed flag takes priority over update rect. | 360 // CASE 1: The layer's property changed flag takes priority over update rect. |
| 276 // | 361 // |
| 277 ClearDamageForAllSurfaces(root.get()); | 362 ClearDamageForAllSurfaces(root.get()); |
| 278 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); | 363 child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); |
| 279 child->SetOpacity(0.5f); | 364 child->SetOpacity(0.5f); |
| 280 EmulateDrawingOneFrame(root.get()); | 365 EmulateDrawingOneFrame(root.get()); |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1381 gfx::Rect root_damage_rect = | 1466 gfx::Rect root_damage_rect = |
| 1382 root->render_surface()->damage_tracker()->current_damage_rect(); | 1467 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1383 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1468 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1384 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1469 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1385 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1470 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1386 } | 1471 } |
| 1387 } | 1472 } |
| 1388 | 1473 |
| 1389 } // namespace | 1474 } // namespace |
| 1390 } // namespace cc | 1475 } // namespace cc |
| OLD | NEW |