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

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

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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/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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // The bounds() just mirror the pile size. 212 // The bounds() just mirror the pile size.
213 pending_layer->SetBounds(raster_source->GetSize()); 213 pending_layer->SetBounds(raster_source->GetSize());
214 pending_layer->SetContentBounds(raster_source->GetSize()); 214 pending_layer->SetContentBounds(raster_source->GetSize());
215 pending_layer->SetRasterSourceOnPending(raster_source, invalidation); 215 pending_layer->SetRasterSourceOnPending(raster_source, invalidation);
216 216
217 pending_root->AddChild(pending_layer.Pass()); 217 pending_root->AddChild(pending_layer.Pass());
218 pending_tree->SetRootLayer(pending_root.Pass()); 218 pending_tree->SetRootLayer(pending_root.Pass());
219 219
220 pending_layer_ = static_cast<FakePictureLayerImpl*>( 220 pending_layer_ = static_cast<FakePictureLayerImpl*>(
221 host_impl_.pending_tree()->LayerById(id_)); 221 host_impl_.pending_tree()->LayerById(id_));
222 pending_layer_->DoPostCommitInitializationIfNeeded();
223 222
224 // Add tilings/tiles for the layer. 223 // Add tilings/tiles for the layer.
225 host_impl_.pending_tree()->UpdateDrawProperties(); 224 host_impl_.pending_tree()->UpdateDrawProperties();
226 } 225 }
227 226
228 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, 227 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer,
229 float ideal_contents_scale, 228 float ideal_contents_scale,
230 float device_scale_factor, 229 float device_scale_factor,
231 float page_scale_factor, 230 float page_scale_factor,
232 float maximum_animation_contents_scale, 231 float maximum_animation_contents_scale,
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 2069
2071 pending_layer_ = static_cast<FakePictureLayerImpl*>( 2070 pending_layer_ = static_cast<FakePictureLayerImpl*>(
2072 host_impl_.pending_tree()->LayerById(id_)); 2071 host_impl_.pending_tree()->LayerById(id_));
2073 2072
2074 // Set some state on the pending layer, make sure it is not clobbered 2073 // Set some state on the pending layer, make sure it is not clobbered
2075 // by a sync from the active layer. This could happen because if the 2074 // by a sync from the active layer. This could happen because if the
2076 // pending layer has not been post-commit initialized it will attempt 2075 // pending layer has not been post-commit initialized it will attempt
2077 // to sync from the active layer. 2076 // to sync from the active layer.
2078 float raster_page_scale = 10.f * pending_layer_->raster_page_scale(); 2077 float raster_page_scale = 10.f * pending_layer_->raster_page_scale();
2079 pending_layer_->set_raster_page_scale(raster_page_scale); 2078 pending_layer_->set_raster_page_scale(raster_page_scale);
2080 EXPECT_TRUE(pending_layer_->needs_post_commit_initialization());
2081 2079
2082 host_impl_.ActivateSyncTree(); 2080 host_impl_.ActivateSyncTree();
2083 2081
2084 active_layer_ = static_cast<FakePictureLayerImpl*>( 2082 active_layer_ = static_cast<FakePictureLayerImpl*>(
2085 host_impl_.active_tree()->LayerById(id_)); 2083 host_impl_.active_tree()->LayerById(id_));
2086 2084
2087 EXPECT_EQ(0u, active_layer_->num_tilings()); 2085 EXPECT_EQ(0u, active_layer_->num_tilings());
2088 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale()); 2086 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale());
2089 EXPECT_FALSE(active_layer_->needs_post_commit_initialization());
2090 } 2087 }
2091 2088
2092 TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) { 2089 TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) {
2093 gfx::Size layer_bounds(1500, 1500); 2090 gfx::Size layer_bounds(1500, 1500);
2094 gfx::Size tile_size(100, 100); 2091 gfx::Size tile_size(100, 100);
2095 2092
2096 scoped_refptr<FakePicturePileImpl> pending_pile = 2093 scoped_refptr<FakePicturePileImpl> pending_pile =
2097 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2094 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2098 2095
2099 SetupPendingTree(pending_pile); 2096 SetupPendingTree(pending_pile);
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after
3610 } 3607 }
3611 3608
3612 TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) { 3609 TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) {
3613 gfx::Size tile_size(400, 400); 3610 gfx::Size tile_size(400, 400);
3614 gfx::Size bounds(100000, 100); 3611 gfx::Size bounds(100000, 100);
3615 3612
3616 host_impl_.CreatePendingTree(); 3613 host_impl_.CreatePendingTree();
3617 3614
3618 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); 3615 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1);
3619 3616
3617 scoped_refptr<FakePicturePileImpl> pending_pile =
3618 FakePicturePileImpl::CreateFilledPile(tile_size, bounds);
3620 scoped_ptr<FakePictureLayerImpl> layer_with_mask = 3619 scoped_ptr<FakePictureLayerImpl> layer_with_mask =
3621 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 2); 3620 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2,
3621 pending_pile);
3622 layer_with_mask->SetBounds(bounds); 3622 layer_with_mask->SetBounds(bounds);
3623 layer_with_mask->SetContentBounds(bounds); 3623 layer_with_mask->SetContentBounds(bounds);
3624 3624
3625 scoped_refptr<FakePicturePileImpl> pending_pile = 3625 scoped_refptr<FakePicturePileImpl> mask_pile =
3626 FakePicturePileImpl::CreateFilledPile(tile_size, bounds); 3626 FakePicturePileImpl::CreateFilledPile(tile_size, bounds);
3627 scoped_ptr<FakePictureLayerImpl> mask = 3627 scoped_ptr<FakePictureLayerImpl> mask =
3628 FakePictureLayerImpl::CreateMaskWithRasterSource( 3628 FakePictureLayerImpl::CreateMaskWithRasterSource(
3629 host_impl_.pending_tree(), 3, pending_pile); 3629 host_impl_.pending_tree(), 3, mask_pile);
3630 mask->SetBounds(bounds); 3630 mask->SetBounds(bounds);
3631 mask->SetContentBounds(bounds); 3631 mask->SetContentBounds(bounds);
3632 mask->SetDrawsContent(true); 3632 mask->SetDrawsContent(true);
3633 layer_with_mask->SetMaskLayer(mask.Pass()); 3633 layer_with_mask->SetMaskLayer(mask.Pass());
3634 3634
3635 FakePictureLayerImpl* pending_mask = 3635 FakePictureLayerImpl* pending_mask =
3636 static_cast<FakePictureLayerImpl*>(layer_with_mask->mask_layer()); 3636 static_cast<FakePictureLayerImpl*>(layer_with_mask->mask_layer());
3637 3637
3638 scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = 3638 scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask =
3639 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 4); 3639 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 4,
3640 pending_pile);
3640 child_of_layer_with_mask->SetBounds(bounds); 3641 child_of_layer_with_mask->SetBounds(bounds);
3641 child_of_layer_with_mask->SetContentBounds(bounds); 3642 child_of_layer_with_mask->SetContentBounds(bounds);
3642 child_of_layer_with_mask->SetDrawsContent(true); 3643 child_of_layer_with_mask->SetDrawsContent(true);
3643 layer_with_mask->AddChild(child_of_layer_with_mask.Pass()); 3644 layer_with_mask->AddChild(child_of_layer_with_mask.Pass());
3644 root->AddChild(layer_with_mask.Pass()); 3645 root->AddChild(layer_with_mask.Pass());
3645 3646
3646 host_impl_.pending_tree()->SetRootLayer(root.Pass()); 3647 host_impl_.pending_tree()->SetRootLayer(root.Pass());
3647 3648
3648 EXPECT_EQ(0u, pending_mask->num_tilings()); 3649 EXPECT_EQ(0u, pending_mask->num_tilings());
3649 host_impl_.pending_tree()->UpdateDrawProperties(); 3650 host_impl_.pending_tree()->UpdateDrawProperties();
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4758 result = layer->CalculateTileSize(gfx::Size(447, 400));
4758 EXPECT_EQ(result.width(), 448); 4759 EXPECT_EQ(result.width(), 448);
4759 EXPECT_EQ(result.height(), 448); 4760 EXPECT_EQ(result.height(), 448);
4760 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4761 result = layer->CalculateTileSize(gfx::Size(500, 499));
4761 EXPECT_EQ(result.width(), 512); 4762 EXPECT_EQ(result.width(), 512);
4762 EXPECT_EQ(result.height(), 500 + 2); 4763 EXPECT_EQ(result.height(), 500 + 2);
4763 } 4764 }
4764 4765
4765 } // namespace 4766 } // namespace
4766 } // namespace cc 4767 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698