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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | 440 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); |
442 LayerImpl* child = root->children()[0]; | 441 LayerImpl* child = root->children()[0]; |
443 gfx::RectF root_damage_rect, child_damage_rect; | 442 gfx::RectF root_damage_rect, child_damage_rect; |
444 | 443 |
445 // Allow us to set damage on child too. | 444 // Allow us to set damage on child too. |
446 child->SetDrawsContent(true); | 445 child->SetDrawsContent(true); |
447 | 446 |
448 skia::RefPtr<SkImageFilter> filter = | 447 skia::RefPtr<SkImageFilter> filter = |
449 skia::AdoptRef(new SkBlurImageFilter(SkIntToScalar(2), | 448 skia::AdoptRef(new SkBlurImageFilter(SkIntToScalar(2), |
450 SkIntToScalar(2))); | 449 SkIntToScalar(2))); |
| 450 FilterOperations filters; |
| 451 filters.Append(FilterOperation::CreateReferenceFilter(filter)); |
451 | 452 |
452 // Setting the filter will damage the whole surface. | 453 // Setting the filter will damage the whole surface. |
453 ClearDamageForAllSurfaces(root.get()); | 454 ClearDamageForAllSurfaces(root.get()); |
454 child->SetFilter(filter); | 455 child->SetFilters(filters); |
455 EmulateDrawingOneFrame(root.get()); | 456 EmulateDrawingOneFrame(root.get()); |
456 root_damage_rect = | 457 root_damage_rect = |
457 root->render_surface()->damage_tracker()->current_damage_rect(); | 458 root->render_surface()->damage_tracker()->current_damage_rect(); |
458 child_damage_rect = | 459 child_damage_rect = |
459 child->render_surface()->damage_tracker()->current_damage_rect(); | 460 child->render_surface()->damage_tracker()->current_damage_rect(); |
460 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100.f, 100.f, 30.f, 30.f), root_damage_rect); | 461 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100.f, 100.f, 30.f, 30.f), root_damage_rect); |
461 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 30.f, 30.f), child_damage_rect); | 462 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 30.f, 30.f), child_damage_rect); |
462 | 463 |
463 // CASE 1: Setting the update rect should damage the whole surface (for now) | 464 // CASE 1: Setting the update rect should damage the whole surface (for now) |
464 ClearDamageForAllSurfaces(root.get()); | 465 ClearDamageForAllSurfaces(root.get()); |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 ASSERT_TRUE(root == root->render_target()); | 1293 ASSERT_TRUE(root == root->render_target()); |
1293 RenderSurfaceImpl* target_surface = root->render_surface(); | 1294 RenderSurfaceImpl* target_surface = root->render_surface(); |
1294 | 1295 |
1295 LayerImplList empty_list; | 1296 LayerImplList empty_list; |
1296 target_surface->damage_tracker()->UpdateDamageTrackingState( | 1297 target_surface->damage_tracker()->UpdateDamageTrackingState( |
1297 empty_list, | 1298 empty_list, |
1298 target_surface->OwningLayerId(), | 1299 target_surface->OwningLayerId(), |
1299 false, | 1300 false, |
1300 gfx::Rect(), | 1301 gfx::Rect(), |
1301 NULL, | 1302 NULL, |
1302 FilterOperations(), | 1303 FilterOperations()); |
1303 NULL); | |
1304 | 1304 |
1305 gfx::RectF damage_rect = | 1305 gfx::RectF damage_rect = |
1306 target_surface->damage_tracker()->current_damage_rect(); | 1306 target_surface->damage_tracker()->current_damage_rect(); |
1307 EXPECT_TRUE(damage_rect.IsEmpty()); | 1307 EXPECT_TRUE(damage_rect.IsEmpty()); |
1308 } | 1308 } |
1309 | 1309 |
1310 TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { | 1310 TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { |
1311 // If damage is not cleared, it should accumulate. | 1311 // If damage is not cleared, it should accumulate. |
1312 | 1312 |
1313 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | 1313 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); |
(...skipping 26 matching lines...) Expand all Loading... |
1340 // Damage should remain empty even after one frame, since there's yet no new | 1340 // Damage should remain empty even after one frame, since there's yet no new |
1341 // damage. | 1341 // damage. |
1342 EmulateDrawingOneFrame(root.get()); | 1342 EmulateDrawingOneFrame(root.get()); |
1343 root_damage_rect = | 1343 root_damage_rect = |
1344 root->render_surface()->damage_tracker()->current_damage_rect(); | 1344 root->render_surface()->damage_tracker()->current_damage_rect(); |
1345 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1345 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
1346 } | 1346 } |
1347 | 1347 |
1348 } // namespace | 1348 } // namespace |
1349 } // namespace cc | 1349 } // namespace cc |
OLD | NEW |