Commit 2b3d84d6 authored by danakj@chromium.org's avatar danakj@chromium.org

cc: Early out sooner in UpdateTilePriorities when !CanHaveTilings().

Also, when we cleanup tilings on the active twin, we use the pending
twin's ideal contents scale. But when the twin !CanHavTilings() there
is no need to use that ideal scale and save tilings.

R=enne@chromium.org, enne

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=278219

Review URL: https://codereview.chromium.org/334953003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278413 0039d316-1c4b-4281-b951-d872f2087c98
parent bf6cb402
...@@ -32,8 +32,8 @@ class TestablePictureImageLayerImpl : public PictureImageLayerImpl { ...@@ -32,8 +32,8 @@ class TestablePictureImageLayerImpl : public PictureImageLayerImpl {
void ScaleAndManageTilings(bool animating_transform_to_screen, void ScaleAndManageTilings(bool animating_transform_to_screen,
float maximum_animation_contents_scale) { float maximum_animation_contents_scale) {
DoPostCommitInitializationIfNeeded(); DoPostCommitInitializationIfNeeded();
UpdateIdealScales();
if (CanHaveTilings()) { if (CanHaveTilings()) {
UpdateIdealScales();
ManageTilings(animating_transform_to_screen, ManageTilings(animating_transform_to_screen,
maximum_animation_contents_scale); maximum_animation_contents_scale);
} }
......
...@@ -391,14 +391,6 @@ void PictureLayerImpl::UpdateTilePriorities() { ...@@ -391,14 +391,6 @@ void PictureLayerImpl::UpdateTilePriorities() {
TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities");
DoPostCommitInitializationIfNeeded(); DoPostCommitInitializationIfNeeded();
UpdateIdealScales();
// TODO(sohanjg): Avoid needlessly update priorities when syncing to a
// non-updated tree which will then be updated immediately afterwards.
should_update_tile_priorities_ = true;
if (CanHaveTilings()) {
ManageTilings(draw_properties().screen_space_transform_is_animating,
draw_properties().maximum_animation_contents_scale);
}
if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { if (layer_tree_impl()->device_viewport_valid_for_tile_management()) {
visible_rect_for_tile_priority_ = visible_content_rect(); visible_rect_for_tile_priority_ = visible_content_rect();
...@@ -406,6 +398,23 @@ void PictureLayerImpl::UpdateTilePriorities() { ...@@ -406,6 +398,23 @@ void PictureLayerImpl::UpdateTilePriorities() {
screen_space_transform_for_tile_priority_ = screen_space_transform(); screen_space_transform_for_tile_priority_ = screen_space_transform();
} }
if (!CanHaveTilings()) {
ideal_page_scale_ = 0.f;
ideal_device_scale_ = 0.f;
ideal_contents_scale_ = 0.f;
ideal_source_scale_ = 0.f;
SanityCheckTilingState();
return;
}
// TODO(sohanjg): Avoid needlessly update priorities when syncing to a
// non-updated tree which will then be updated immediately afterwards.
should_update_tile_priorities_ = true;
UpdateIdealScales();
ManageTilings(draw_properties().screen_space_transform_is_animating,
draw_properties().maximum_animation_contents_scale);
if (!tilings_->num_tilings()) if (!tilings_->num_tilings())
return; return;
...@@ -1150,7 +1159,7 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer( ...@@ -1150,7 +1159,7 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
float twin_low_res_scale = 0.f; float twin_low_res_scale = 0.f;
PictureLayerImpl* twin = twin_layer_; PictureLayerImpl* twin = twin_layer_;
if (twin) { if (twin && twin->CanHaveTilings()) {
min_acceptable_high_res_scale = std::min( min_acceptable_high_res_scale = std::min(
min_acceptable_high_res_scale, min_acceptable_high_res_scale,
std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_)); std::min(twin->raster_contents_scale_, twin->ideal_contents_scale_));
...@@ -1273,14 +1282,7 @@ float PictureLayerImpl::MaximumTilingContentsScale() const { ...@@ -1273,14 +1282,7 @@ float PictureLayerImpl::MaximumTilingContentsScale() const {
} }
void PictureLayerImpl::UpdateIdealScales() { void PictureLayerImpl::UpdateIdealScales() {
if (!CanHaveTilings()) { DCHECK(CanHaveTilings());
ideal_page_scale_ = draw_properties().page_scale_factor;
ideal_device_scale_ = draw_properties().device_scale_factor;
ideal_contents_scale_ = draw_properties().ideal_contents_scale;
ideal_source_scale_ =
ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_;
return;
}
float min_contents_scale = MinimumContentsScale(); float min_contents_scale = MinimumContentsScale();
DCHECK_GT(min_contents_scale, 0.f); DCHECK_GT(min_contents_scale, 0.f);
......
...@@ -2774,5 +2774,50 @@ TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { ...@@ -2774,5 +2774,50 @@ TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) {
quad_culler.shared_quad_state_list()[0]->visible_content_rect.ToString()); quad_culler.shared_quad_state_list()[0]->visible_content_rect.ToString());
} }
TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) {
gfx::Size tile_size(400, 400);
gfx::Size bounds(100000, 100);
host_impl_.CreatePendingTree();
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1);
scoped_ptr<FakePictureLayerImpl> layer_with_mask =
FakePictureLayerImpl::Create(host_impl_.pending_tree(), 2);
layer_with_mask->SetBounds(bounds);
layer_with_mask->SetContentBounds(bounds);
scoped_refptr<FakePicturePileImpl> pending_pile =
FakePicturePileImpl::CreateFilledPile(tile_size, bounds);
scoped_ptr<FakePictureLayerImpl> mask = FakePictureLayerImpl::CreateWithPile(
host_impl_.pending_tree(), 3, pending_pile);
mask->SetIsMask(true);
mask->SetBounds(bounds);
mask->SetContentBounds(bounds);
mask->SetDrawsContent(true);
FakePictureLayerImpl* pending_mask_content = mask.get();
layer_with_mask->SetMaskLayer(mask.PassAs<LayerImpl>());
scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask =
FakePictureLayerImpl::Create(host_impl_.pending_tree(), 4);
child_of_layer_with_mask->SetBounds(bounds);
child_of_layer_with_mask->SetContentBounds(bounds);
child_of_layer_with_mask->SetDrawsContent(true);
layer_with_mask->AddChild(child_of_layer_with_mask.PassAs<LayerImpl>());
root->AddChild(layer_with_mask.PassAs<LayerImpl>());
host_impl_.pending_tree()->SetRootLayer(root.Pass());
EXPECT_FALSE(pending_mask_content->tilings());
host_impl_.pending_tree()->UpdateDrawProperties();
EXPECT_NE(0u, pending_mask_content->num_tilings());
}
} // namespace } // namespace
} // namespace cc } // namespace cc
...@@ -96,8 +96,8 @@ class FakePictureLayerImpl : public PictureLayerImpl { ...@@ -96,8 +96,8 @@ class FakePictureLayerImpl : public PictureLayerImpl {
void ScaleAndManageTilings(bool animating_transform_to_screen, void ScaleAndManageTilings(bool animating_transform_to_screen,
float maximum_animation_contents_scale) { float maximum_animation_contents_scale) {
UpdateIdealScales();
if (CanHaveTilings()) { if (CanHaveTilings()) {
UpdateIdealScales();
ManageTilings(animating_transform_to_screen, ManageTilings(animating_transform_to_screen,
maximum_animation_contents_scale); maximum_animation_contents_scale);
} }
......
...@@ -6573,61 +6573,5 @@ TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) { ...@@ -6573,61 +6573,5 @@ TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) {
150u * 1024u * 1024u); 150u * 1024u * 1024u);
} }
TEST_F(LayerTreeHostImplTest, UpdateTilesForMasksWithNoVisibleContent) {
gfx::Size bounds(100000, 100);
host_impl_->CreatePendingTree();
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->pending_tree(), 1);
scoped_ptr<FakePictureLayerImpl> layer_with_mask =
FakePictureLayerImpl::Create(host_impl_->pending_tree(), 2);
layer_with_mask->SetBounds(bounds);
layer_with_mask->SetContentBounds(bounds);
scoped_ptr<FakePictureLayerImpl> mask =
FakePictureLayerImpl::Create(host_impl_->pending_tree(), 3);
mask->SetIsMask(true);
mask->SetBounds(bounds);
mask->SetContentBounds(bounds);
FakePictureLayerImpl* pending_mask_content = mask.get();
layer_with_mask->SetMaskLayer(mask.PassAs<LayerImpl>());
scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask =
FakePictureLayerImpl::Create(host_impl_->pending_tree(), 4);
child_of_layer_with_mask->SetBounds(bounds);
child_of_layer_with_mask->SetContentBounds(bounds);
child_of_layer_with_mask->SetDrawsContent(true);
layer_with_mask->AddChild(child_of_layer_with_mask.PassAs<LayerImpl>());
root->AddChild(layer_with_mask.PassAs<LayerImpl>());
host_impl_->pending_tree()->SetRootLayer(root.Pass());
gfx::Rect r1 = pending_mask_content->visible_rect_for_tile_priority();
ASSERT_EQ(0, r1.x());
ASSERT_EQ(0, r1.y());
ASSERT_EQ(0, r1.width());
ASSERT_EQ(0, r1.height());
host_impl_->ActivatePendingTree();
host_impl_->active_tree()->UpdateDrawProperties();
ASSERT_EQ(2u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
FakePictureLayerImpl* active_mask_content =
static_cast<FakePictureLayerImpl*>(
host_impl_->active_tree()->root_layer()->children()[0]->mask_layer());
gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority();
ASSERT_TRUE(!r2.IsEmpty());
}
} // namespace } // namespace
} // namespace cc } // namespace cc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment