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

Side by Side Diff: cc/trees/layer_tree_host_unittest_picture.cc

Issue 799463005: cc: Mirror LiveTilesRect and tiles between active and recycled trees. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: noswap-ltr: . Created 6 years 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
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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "cc/test/fake_content_layer_client.h" 7 #include "cc/test/fake_content_layer_client.h"
8 #include "cc/test/fake_picture_layer.h" 8 #include "cc/test/fake_picture_layer.h"
9 #include "cc/test/fake_picture_layer_impl.h" 9 #include "cc/test/fake_picture_layer_impl.h"
10 #include "cc/test/layer_tree_test.h" 10 #include "cc/test/layer_tree_test.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 void AfterTest() override {} 184 void AfterTest() override {}
185 185
186 gfx::Size tile_size_; 186 gfx::Size tile_size_;
187 FakeContentLayerClient client_; 187 FakeContentLayerClient client_;
188 scoped_refptr<FakePictureLayer> picture_; 188 scoped_refptr<FakePictureLayer> picture_;
189 }; 189 };
190 190
191 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( 191 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
192 LayerTreeHostPictureTestResizeViewportWithGpuRaster); 192 LayerTreeHostPictureTestResizeViewportWithGpuRaster);
193 193
194 class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
195 : public LayerTreeHostPictureTest {
196 void SetupTree() override {
197 frame_ = 0;
198 did_post_commit_ = false;
199
200 scoped_refptr<Layer> root = Layer::Create();
201 root->SetBounds(gfx::Size(100, 100));
202
203 // The layer is big enough that the live tiles rect won't cover the full
204 // layer.
205 client_.set_fill_with_nonsolid_color(true);
206 picture_ = FakePictureLayer::Create(&client_);
207 picture_->SetBounds(gfx::Size(100, 100000));
208 root->AddChild(picture_);
209
210 layer_tree_host()->SetRootLayer(root);
211 LayerTreeHostPictureTest::SetupTree();
212 }
213
214 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
215
216 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
217 LayerImpl* child = impl->active_tree()->root_layer()->children()[0];
218 FakePictureLayerImpl* picture_impl =
219 static_cast<FakePictureLayerImpl*>(child);
220 FakePictureLayerImpl* recycled_impl = static_cast<FakePictureLayerImpl*>(
221 picture_impl->GetRecycledTwinLayer());
222
223 switch (++frame_) {
224 case 1: {
225 PictureLayerTiling* tiling = picture_impl->HighResTiling();
226 PictureLayerTiling* recycled_tiling = recycled_impl->HighResTiling();
227 int num_tiles_y = tiling->TilingDataForTesting().num_tiles_y();
228
229 // There should be tiles at the top of the picture layer but not at the
230 // bottom.
231 EXPECT_TRUE(tiling->TileAt(0, 0));
232 EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
233
234 // The recycled tiling matches it.
235 EXPECT_TRUE(recycled_tiling->TileAt(0, 0));
236 EXPECT_FALSE(recycled_tiling->TileAt(0, num_tiles_y));
237
238 // Make the bottom of the layer visible.
239 picture_impl->SetPosition(gfx::PointF(0.f, -100000.f + 100.f));
240 impl->SetNeedsRedraw();
241 break;
242 }
243 case 2: {
244 PictureLayerTiling* tiling = picture_impl->HighResTiling();
245 PictureLayerTiling* recycled_tiling = recycled_impl->HighResTiling();
246
247 // There not be tiles at the top of the layer now.
248 EXPECT_FALSE(tiling->TileAt(0, 0));
249
250 // The recycled twin tiling should not have unshared tiles at the top
251 // either.
252 EXPECT_FALSE(recycled_tiling->TileAt(0, 0));
253
254 // Make the top of the layer visible again.
255 picture_impl->SetPosition(gfx::PointF());
256 impl->SetNeedsRedraw();
257 break;
258 }
259 case 3: {
260 PictureLayerTiling* tiling = picture_impl->HighResTiling();
261 PictureLayerTiling* recycled_tiling = recycled_impl->HighResTiling();
262 int num_tiles_y = tiling->TilingDataForTesting().num_tiles_y();
263
264 // There should be tiles at the top of the picture layer again.
265 EXPECT_TRUE(tiling->TileAt(0, 0));
266 EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
267
268 // The recycled tiling should also have tiles at the top.
269 EXPECT_TRUE(recycled_tiling->TileAt(0, 0));
270 EXPECT_FALSE(recycled_tiling->TileAt(0, num_tiles_y));
271
272 // Make a new main frame without changing the picture layer at all, so
273 // it won't need to update or push properties.
274 did_post_commit_ = true;
275 PostSetNeedsCommitToMainThread();
276 break;
277 }
278 }
279 }
280
281 void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override {
282 LayerImpl* child = impl->sync_tree()->root_layer()->children()[0];
283 FakePictureLayerImpl* picture_impl =
284 static_cast<FakePictureLayerImpl*>(child);
285 PictureLayerTiling* tiling = picture_impl->HighResTiling();
286 int num_tiles_y = tiling->TilingDataForTesting().num_tiles_y();
287
288 // The pending layer should always have tiles at the top of it each commit.
289 // The tile is part of the required for activation set so it should exist.
290 EXPECT_TRUE(tiling->TileAt(0, 0));
291 EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
292
293 if (did_post_commit_)
294 EndTest();
295 }
296
297 void AfterTest() override {}
298
299 int frame_;
300 bool did_post_commit_;
301 FakeContentLayerClient client_;
302 scoped_refptr<FakePictureLayer> picture_;
303 };
304
305 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
306 LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree);
307
194 } // namespace 308 } // namespace
195 } // namespace cc 309 } // namespace cc
OLDNEW
« cc/resources/picture_layer_tiling.cc ('K') | « cc/resources/picture_layer_tiling_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698