| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // surfaces to ancestors. | 56 // surfaces to ancestors. |
| 57 for (int i = render_surface_layer_list.size() - 1; i >= 0; --i) { | 57 for (int i = render_surface_layer_list.size() - 1; i >= 0; --i) { |
| 58 RenderSurfaceImpl* target_surface = | 58 RenderSurfaceImpl* target_surface = |
| 59 render_surface_layer_list[i]->render_surface(); | 59 render_surface_layer_list[i]->render_surface(); |
| 60 target_surface->damage_tracker()->UpdateDamageTrackingState( | 60 target_surface->damage_tracker()->UpdateDamageTrackingState( |
| 61 target_surface->layer_list(), | 61 target_surface->layer_list(), |
| 62 target_surface->OwningLayerId(), | 62 target_surface->OwningLayerId(), |
| 63 target_surface->SurfacePropertyChangedOnlyFromDescendant(), | 63 target_surface->SurfacePropertyChangedOnlyFromDescendant(), |
| 64 target_surface->content_rect(), | 64 target_surface->content_rect(), |
| 65 render_surface_layer_list[i]->mask_layer(), | 65 render_surface_layer_list[i]->mask_layer(), |
| 66 render_surface_layer_list[i]->filters(), | 66 render_surface_layer_list[i]->filters()); |
| 67 render_surface_layer_list[i]->filter().get()); | |
| 68 } | 67 } |
| 69 | 68 |
| 70 root->ResetAllChangeTrackingForSubtree(); | 69 root->ResetAllChangeTrackingForSubtree(); |
| 71 } | 70 } |
| 72 | 71 |
| 73 class DamageTrackerTest : public testing::Test { | 72 class DamageTrackerTest : public testing::Test { |
| 74 public: | 73 public: |
| 75 DamageTrackerTest() : host_impl_(&proxy_) {} | 74 DamageTrackerTest() : host_impl_(&proxy_) {} |
| 76 | 75 |
| 77 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() { | 76 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | 438 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); |
| 440 LayerImpl* child = root->children()[0]; | 439 LayerImpl* child = root->children()[0]; |
| 441 gfx::RectF root_damage_rect, child_damage_rect; | 440 gfx::RectF root_damage_rect, child_damage_rect; |
| 442 | 441 |
| 443 // Allow us to set damage on child too. | 442 // Allow us to set damage on child too. |
| 444 child->SetDrawsContent(true); | 443 child->SetDrawsContent(true); |
| 445 | 444 |
| 446 skia::RefPtr<SkImageFilter> filter = | 445 skia::RefPtr<SkImageFilter> filter = |
| 447 skia::AdoptRef(new SkBlurImageFilter(SkIntToScalar(2), | 446 skia::AdoptRef(new SkBlurImageFilter(SkIntToScalar(2), |
| 448 SkIntToScalar(2))); | 447 SkIntToScalar(2))); |
| 448 FilterOperations filters; |
| 449 filters.Append(FilterOperation::CreateReferenceFilter(filter)); |
| 449 | 450 |
| 450 // Setting the filter will damage the whole surface. | 451 // Setting the filter will damage the whole surface. |
| 451 ClearDamageForAllSurfaces(root.get()); | 452 ClearDamageForAllSurfaces(root.get()); |
| 452 child->SetFilter(filter); | 453 child->SetFilters(filters); |
| 453 EmulateDrawingOneFrame(root.get()); | 454 EmulateDrawingOneFrame(root.get()); |
| 454 root_damage_rect = | 455 root_damage_rect = |
| 455 root->render_surface()->damage_tracker()->current_damage_rect(); | 456 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 456 child_damage_rect = | 457 child_damage_rect = |
| 457 child->render_surface()->damage_tracker()->current_damage_rect(); | 458 child->render_surface()->damage_tracker()->current_damage_rect(); |
| 458 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100.f, 100.f, 30.f, 30.f), root_damage_rect); | 459 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100.f, 100.f, 30.f, 30.f), root_damage_rect); |
| 459 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 30.f, 30.f), child_damage_rect); | 460 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 30.f, 30.f), child_damage_rect); |
| 460 | 461 |
| 461 // CASE 1: Setting the update rect should damage the whole surface (for now) | 462 // CASE 1: Setting the update rect should damage the whole surface (for now) |
| 462 ClearDamageForAllSurfaces(root.get()); | 463 ClearDamageForAllSurfaces(root.get()); |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 ASSERT_TRUE(root == root->render_target()); | 1291 ASSERT_TRUE(root == root->render_target()); |
| 1291 RenderSurfaceImpl* target_surface = root->render_surface(); | 1292 RenderSurfaceImpl* target_surface = root->render_surface(); |
| 1292 | 1293 |
| 1293 LayerImplList empty_list; | 1294 LayerImplList empty_list; |
| 1294 target_surface->damage_tracker()->UpdateDamageTrackingState( | 1295 target_surface->damage_tracker()->UpdateDamageTrackingState( |
| 1295 empty_list, | 1296 empty_list, |
| 1296 target_surface->OwningLayerId(), | 1297 target_surface->OwningLayerId(), |
| 1297 false, | 1298 false, |
| 1298 gfx::Rect(), | 1299 gfx::Rect(), |
| 1299 NULL, | 1300 NULL, |
| 1300 FilterOperations(), | 1301 FilterOperations()); |
| 1301 NULL); | |
| 1302 | 1302 |
| 1303 gfx::RectF damage_rect = | 1303 gfx::RectF damage_rect = |
| 1304 target_surface->damage_tracker()->current_damage_rect(); | 1304 target_surface->damage_tracker()->current_damage_rect(); |
| 1305 EXPECT_TRUE(damage_rect.IsEmpty()); | 1305 EXPECT_TRUE(damage_rect.IsEmpty()); |
| 1306 } | 1306 } |
| 1307 | 1307 |
| 1308 TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { | 1308 TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { |
| 1309 // If damage is not cleared, it should accumulate. | 1309 // If damage is not cleared, it should accumulate. |
| 1310 | 1310 |
| 1311 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | 1311 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1338 // Damage should remain empty even after one frame, since there's yet no new | 1338 // Damage should remain empty even after one frame, since there's yet no new |
| 1339 // damage. | 1339 // damage. |
| 1340 EmulateDrawingOneFrame(root.get()); | 1340 EmulateDrawingOneFrame(root.get()); |
| 1341 root_damage_rect = | 1341 root_damage_rect = |
| 1342 root->render_surface()->damage_tracker()->current_damage_rect(); | 1342 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1343 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1343 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 } // namespace | 1346 } // namespace |
| 1347 } // namespace cc | 1347 } // namespace cc |
| OLD | NEW |