Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 502453003: cc: Remove tiles from recycle tree that were deleted on active. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: don't maintain recycled twin Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 std::vector<SkRect> rects_; 46 std::vector<SkRect> rects_;
47 }; 47 };
48 48
49 class PictureLayerImplTest : public testing::Test { 49 class PictureLayerImplTest : public testing::Test {
50 public: 50 public:
51 PictureLayerImplTest() 51 PictureLayerImplTest()
52 : proxy_(base::MessageLoopProxy::current()), 52 : proxy_(base::MessageLoopProxy::current()),
53 host_impl_(ImplSidePaintingSettings(), 53 host_impl_(ImplSidePaintingSettings(),
54 &proxy_, 54 &proxy_,
55 &shared_bitmap_manager_), 55 &shared_bitmap_manager_),
56 id_(7) {} 56 id_(7),
57 pending_layer_(NULL),
58 old_pending_layer_(NULL),
59 active_layer_(NULL) {}
57 60
58 explicit PictureLayerImplTest(const LayerTreeSettings& settings) 61 explicit PictureLayerImplTest(const LayerTreeSettings& settings)
59 : proxy_(base::MessageLoopProxy::current()), 62 : proxy_(base::MessageLoopProxy::current()),
60 host_impl_(settings, &proxy_, &shared_bitmap_manager_), 63 host_impl_(settings, &proxy_, &shared_bitmap_manager_),
61 id_(7) {} 64 id_(7) {}
62 65
63 virtual ~PictureLayerImplTest() { 66 virtual ~PictureLayerImplTest() {
64 } 67 }
65 68
66 virtual void SetUp() OVERRIDE { 69 virtual void SetUp() OVERRIDE {
(...skipping 12 matching lines...) Expand all
79 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 82 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
80 scoped_refptr<FakePicturePileImpl> active_pile = 83 scoped_refptr<FakePicturePileImpl> active_pile =
81 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 84 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
82 85
83 SetupTrees(pending_pile, active_pile); 86 SetupTrees(pending_pile, active_pile);
84 } 87 }
85 88
86 void ActivateTree() { 89 void ActivateTree() {
87 host_impl_.ActivateSyncTree(); 90 host_impl_.ActivateSyncTree();
88 CHECK(!host_impl_.pending_tree()); 91 CHECK(!host_impl_.pending_tree());
92 CHECK(host_impl_.recycle_tree());
93 old_pending_layer_ = pending_layer_;
89 pending_layer_ = NULL; 94 pending_layer_ = NULL;
90 active_layer_ = static_cast<FakePictureLayerImpl*>( 95 active_layer_ = static_cast<FakePictureLayerImpl*>(
91 host_impl_.active_tree()->LayerById(id_)); 96 host_impl_.active_tree()->LayerById(id_));
92 } 97 }
93 98
94 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, 99 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds,
95 const gfx::Size& tile_size) { 100 const gfx::Size& tile_size) {
96 SetupDefaultTrees(layer_bounds); 101 SetupDefaultTrees(layer_bounds);
97 pending_layer_->set_fixed_tile_size(tile_size); 102 pending_layer_->set_fixed_tile_size(tile_size);
98 active_layer_->set_fixed_tile_size(tile_size); 103 active_layer_->set_fixed_tile_size(tile_size);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 EXPECT_RECT_EQ(*rect_iter, mock_canvas.rects_[0]); 264 EXPECT_RECT_EQ(*rect_iter, mock_canvas.rects_[0]);
260 rect_iter++; 265 rect_iter++;
261 } 266 }
262 } 267 }
263 268
264 FakeImplProxy proxy_; 269 FakeImplProxy proxy_;
265 TestSharedBitmapManager shared_bitmap_manager_; 270 TestSharedBitmapManager shared_bitmap_manager_;
266 FakeLayerTreeHostImpl host_impl_; 271 FakeLayerTreeHostImpl host_impl_;
267 int id_; 272 int id_;
268 FakePictureLayerImpl* pending_layer_; 273 FakePictureLayerImpl* pending_layer_;
274 FakePictureLayerImpl* old_pending_layer_;
269 FakePictureLayerImpl* active_layer_; 275 FakePictureLayerImpl* active_layer_;
270 276
271 private: 277 private:
272 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); 278 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest);
273 }; 279 };
274 280
275 TEST_F(PictureLayerImplTest, TileGridAlignment) { 281 TEST_F(PictureLayerImplTest, TileGridAlignment) {
276 host_impl_.SetDeviceScaleFactor(1.f); 282 host_impl_.SetDeviceScaleFactor(1.f);
277 TestTileGridAlignmentCommon(); 283 TestTileGridAlignmentCommon();
278 } 284 }
(...skipping 3859 matching lines...) Expand 10 before | Expand all | Expand 10 after
4138 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); 4144 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles));
4139 } 4145 }
4140 4146
4141 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); 4147 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
4142 4148
4143 VerifyEvictionConsidersOcclusion(pending_layer_, 4149 VerifyEvictionConsidersOcclusion(pending_layer_,
4144 total_expected_occluded_tile_count); 4150 total_expected_occluded_tile_count);
4145 VerifyEvictionConsidersOcclusion(active_layer_, 4151 VerifyEvictionConsidersOcclusion(active_layer_,
4146 total_expected_occluded_tile_count); 4152 total_expected_occluded_tile_count);
4147 } 4153 }
4154
4155 TEST_F(PictureLayerImplTest, RecycledTwinLayer) {
4156 gfx::Size tile_size(102, 102);
4157 gfx::Size layer_bounds(1000, 1000);
4158
4159 scoped_refptr<FakePicturePileImpl> pile =
4160 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4161 SetupPendingTree(pile);
4162 EXPECT_FALSE(pending_layer_->GetRecycledTwinLayer());
4163
4164 ActivateTree();
4165 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer());
4166 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer());
4167
4168 SetupPendingTree(pile);
4169 EXPECT_FALSE(pending_layer_->GetRecycledTwinLayer());
4170 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer());
4171
4172 ActivateTree();
4173 EXPECT_TRUE(active_layer_->GetRecycledTwinLayer());
4174 EXPECT_EQ(old_pending_layer_, active_layer_->GetRecycledTwinLayer());
4175
4176 host_impl_.ResetRecycleTreeForTesting();
4177 EXPECT_FALSE(active_layer_->GetRecycledTwinLayer());
4178 }
4179
4148 } // namespace 4180 } // namespace
4149 } // namespace cc 4181 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698