OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 std::vector<SkRect> rects_; | 45 std::vector<SkRect> rects_; |
46 }; | 46 }; |
47 | 47 |
48 class PictureLayerImplTest : public testing::Test { | 48 class PictureLayerImplTest : public testing::Test { |
49 public: | 49 public: |
50 PictureLayerImplTest() | 50 PictureLayerImplTest() |
51 : proxy_(base::MessageLoopProxy::current()), | 51 : proxy_(base::MessageLoopProxy::current()), |
52 host_impl_(ImplSidePaintingSettings(), | 52 host_impl_(ImplSidePaintingSettings(), |
53 &proxy_, | 53 &proxy_, |
54 &shared_bitmap_manager_), | 54 &shared_bitmap_manager_), |
55 id_(7) {} | 55 id_(7), |
| 56 pending_layer_(NULL), |
| 57 old_pending_layer_(NULL), |
| 58 active_layer_(NULL) {} |
56 | 59 |
57 explicit PictureLayerImplTest(const LayerTreeSettings& settings) | 60 explicit PictureLayerImplTest(const LayerTreeSettings& settings) |
58 : proxy_(base::MessageLoopProxy::current()), | 61 : proxy_(base::MessageLoopProxy::current()), |
59 host_impl_(settings, &proxy_, &shared_bitmap_manager_), | 62 host_impl_(settings, &proxy_, &shared_bitmap_manager_), |
60 id_(7) {} | 63 id_(7) {} |
61 | 64 |
62 virtual ~PictureLayerImplTest() { | 65 virtual ~PictureLayerImplTest() { |
63 } | 66 } |
64 | 67 |
65 virtual void SetUp() OVERRIDE { | 68 virtual void SetUp() OVERRIDE { |
(...skipping 12 matching lines...) Expand all Loading... |
78 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 81 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
79 scoped_refptr<FakePicturePileImpl> active_pile = | 82 scoped_refptr<FakePicturePileImpl> active_pile = |
80 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 83 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
81 | 84 |
82 SetupTrees(pending_pile, active_pile); | 85 SetupTrees(pending_pile, active_pile); |
83 } | 86 } |
84 | 87 |
85 void ActivateTree() { | 88 void ActivateTree() { |
86 host_impl_.ActivateSyncTree(); | 89 host_impl_.ActivateSyncTree(); |
87 CHECK(!host_impl_.pending_tree()); | 90 CHECK(!host_impl_.pending_tree()); |
| 91 old_pending_layer_ = pending_layer_; |
88 pending_layer_ = NULL; | 92 pending_layer_ = NULL; |
89 active_layer_ = static_cast<FakePictureLayerImpl*>( | 93 active_layer_ = static_cast<FakePictureLayerImpl*>( |
90 host_impl_.active_tree()->LayerById(id_)); | 94 host_impl_.active_tree()->LayerById(id_)); |
91 } | 95 } |
92 | 96 |
93 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, | 97 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, |
94 const gfx::Size& tile_size) { | 98 const gfx::Size& tile_size) { |
95 SetupDefaultTrees(layer_bounds); | 99 SetupDefaultTrees(layer_bounds); |
96 pending_layer_->set_fixed_tile_size(tile_size); | 100 pending_layer_->set_fixed_tile_size(tile_size); |
97 active_layer_->set_fixed_tile_size(tile_size); | 101 active_layer_->set_fixed_tile_size(tile_size); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 EXPECT_RECT_EQ(*rect_iter, mock_canvas.rects_[0]); | 262 EXPECT_RECT_EQ(*rect_iter, mock_canvas.rects_[0]); |
259 rect_iter++; | 263 rect_iter++; |
260 } | 264 } |
261 } | 265 } |
262 | 266 |
263 FakeImplProxy proxy_; | 267 FakeImplProxy proxy_; |
264 TestSharedBitmapManager shared_bitmap_manager_; | 268 TestSharedBitmapManager shared_bitmap_manager_; |
265 FakeLayerTreeHostImpl host_impl_; | 269 FakeLayerTreeHostImpl host_impl_; |
266 int id_; | 270 int id_; |
267 FakePictureLayerImpl* pending_layer_; | 271 FakePictureLayerImpl* pending_layer_; |
| 272 FakePictureLayerImpl* old_pending_layer_; |
268 FakePictureLayerImpl* active_layer_; | 273 FakePictureLayerImpl* active_layer_; |
269 | 274 |
270 private: | 275 private: |
271 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); | 276 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); |
272 }; | 277 }; |
273 | 278 |
274 TEST_F(PictureLayerImplTest, TileGridAlignment) { | 279 TEST_F(PictureLayerImplTest, TileGridAlignment) { |
275 host_impl_.SetDeviceScaleFactor(1.f); | 280 host_impl_.SetDeviceScaleFactor(1.f); |
276 TestTileGridAlignmentCommon(); | 281 TestTileGridAlignmentCommon(); |
277 } | 282 } |
(...skipping 3711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3989 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); | 3994 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); |
3990 } | 3995 } |
3991 | 3996 |
3992 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3997 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
3993 | 3998 |
3994 VerifyEvictionConsidersOcclusion(pending_layer_, | 3999 VerifyEvictionConsidersOcclusion(pending_layer_, |
3995 total_expected_occluded_tile_count); | 4000 total_expected_occluded_tile_count); |
3996 VerifyEvictionConsidersOcclusion(active_layer_, | 4001 VerifyEvictionConsidersOcclusion(active_layer_, |
3997 total_expected_occluded_tile_count); | 4002 total_expected_occluded_tile_count); |
3998 } | 4003 } |
| 4004 |
| 4005 TEST_F(PictureLayerImplTest, RecycledTwinLayer) { |
| 4006 gfx::Size tile_size(102, 102); |
| 4007 gfx::Size layer_bounds(1000, 1000); |
| 4008 |
| 4009 scoped_refptr<FakePicturePileImpl> pile = |
| 4010 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4011 SetupPendingTree(pile); |
| 4012 EXPECT_FALSE(pending_layer_->GetRecycledTwinLayer()); |
| 4013 |
| 4014 ActivateTree(); |
| 4015 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer()); |
| 4016 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer()); |
| 4017 |
| 4018 SetupPendingTree(pile); |
| 4019 EXPECT_FALSE(pending_layer_->GetRecycledTwinLayer()); |
| 4020 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); |
| 4021 |
| 4022 ActivateTree(); |
| 4023 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer()); |
| 4024 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer()); |
| 4025 } |
| 4026 |
3999 } // namespace | 4027 } // namespace |
4000 } // namespace cc | 4028 } // namespace cc |
OLD | NEW |