| 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" |
| 11 #include "cc/test/fake_impl_proxy.h" | 11 #include "cc/test/fake_impl_proxy.h" |
| 12 #include "cc/test/fake_layer_tree_host_impl.h" | 12 #include "cc/test/fake_layer_tree_host_impl.h" |
| 13 #include "cc/test/geometry_test_utils.h" | 13 #include "cc/test/geometry_test_utils.h" |
| 14 #include "cc/test/test_shared_bitmap_manager.h" |
| 14 #include "cc/trees/layer_tree_host_common.h" | 15 #include "cc/trees/layer_tree_host_common.h" |
| 15 #include "cc/trees/single_thread_proxy.h" | 16 #include "cc/trees/single_thread_proxy.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 18 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 18 #include "ui/gfx/quad_f.h" | 19 #include "ui/gfx/quad_f.h" |
| 19 | 20 |
| 20 namespace cc { | 21 namespace cc { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 void ExecuteCalculateDrawProperties(LayerImpl* root, | 24 void ExecuteCalculateDrawProperties(LayerImpl* root, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 target_surface->content_rect(), | 65 target_surface->content_rect(), |
| 65 render_surface_layer_list[i]->mask_layer(), | 66 render_surface_layer_list[i]->mask_layer(), |
| 66 render_surface_layer_list[i]->filters()); | 67 render_surface_layer_list[i]->filters()); |
| 67 } | 68 } |
| 68 | 69 |
| 69 root->ResetAllChangeTrackingForSubtree(); | 70 root->ResetAllChangeTrackingForSubtree(); |
| 70 } | 71 } |
| 71 | 72 |
| 72 class DamageTrackerTest : public testing::Test { | 73 class DamageTrackerTest : public testing::Test { |
| 73 public: | 74 public: |
| 74 DamageTrackerTest() : host_impl_(&proxy_) {} | 75 DamageTrackerTest() : host_impl_(&proxy_, &shared_bitmap_manager_) {} |
| 75 | 76 |
| 76 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() { | 77 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() { |
| 77 scoped_ptr<LayerImpl> root = | 78 scoped_ptr<LayerImpl> root = |
| 78 LayerImpl::Create(host_impl_.active_tree(), 1); | 79 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 79 scoped_ptr<LayerImpl> child = | 80 scoped_ptr<LayerImpl> child = |
| 80 LayerImpl::Create(host_impl_.active_tree(), 2); | 81 LayerImpl::Create(host_impl_.active_tree(), 2); |
| 81 | 82 |
| 82 root->SetPosition(gfx::PointF()); | 83 root->SetPosition(gfx::PointF()); |
| 83 root->SetAnchorPoint(gfx::PointF()); | 84 root->SetAnchorPoint(gfx::PointF()); |
| 84 root->SetBounds(gfx::Size(500, 500)); | 85 root->SetBounds(gfx::Size(500, 500)); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 175 |
| 175 // Setup includes going past the first frame which always damages | 176 // Setup includes going past the first frame which always damages |
| 176 // everything, so that we can actually perform specific tests. | 177 // everything, so that we can actually perform specific tests. |
| 177 EmulateDrawingOneFrame(root.get()); | 178 EmulateDrawingOneFrame(root.get()); |
| 178 | 179 |
| 179 return root.Pass(); | 180 return root.Pass(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 protected: | 183 protected: |
| 183 FakeImplProxy proxy_; | 184 FakeImplProxy proxy_; |
| 185 TestSharedBitmapManager shared_bitmap_manager_; |
| 184 FakeLayerTreeHostImpl host_impl_; | 186 FakeLayerTreeHostImpl host_impl_; |
| 185 }; | 187 }; |
| 186 | 188 |
| 187 TEST_F(DamageTrackerTest, SanityCheckTestTreeWithOneSurface) { | 189 TEST_F(DamageTrackerTest, SanityCheckTestTreeWithOneSurface) { |
| 188 // Sanity check that the simple test tree will actually produce the expected | 190 // Sanity check that the simple test tree will actually produce the expected |
| 189 // render surfaces and layer lists. | 191 // render surfaces and layer lists. |
| 190 | 192 |
| 191 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | 193 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); |
| 192 | 194 |
| 193 EXPECT_EQ(2u, root->render_surface()->layer_list().size()); | 195 EXPECT_EQ(2u, root->render_surface()->layer_list().size()); |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 // 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 |
| 1339 // damage. | 1341 // damage. |
| 1340 EmulateDrawingOneFrame(root.get()); | 1342 EmulateDrawingOneFrame(root.get()); |
| 1341 root_damage_rect = | 1343 root_damage_rect = |
| 1342 root->render_surface()->damage_tracker()->current_damage_rect(); | 1344 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1343 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1345 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 1344 } | 1346 } |
| 1345 | 1347 |
| 1346 } // namespace | 1348 } // namespace |
| 1347 } // namespace cc | 1349 } // namespace cc |
| OLD | NEW |