OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 6556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6567 ManagedMemoryPolicy mem_policy(300 * 1024 * 1024); // 300MB | 6567 ManagedMemoryPolicy mem_policy(300 * 1024 * 1024); // 300MB |
6568 | 6568 |
6569 // Verify implicit limits are calculated correctly with no overflows | 6569 // Verify implicit limits are calculated correctly with no overflows |
6570 host_impl_->SetMemoryPolicy(mem_policy); | 6570 host_impl_->SetMemoryPolicy(mem_policy); |
6571 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, | 6571 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, |
6572 300u * 1024u * 1024u); | 6572 300u * 1024u * 1024u); |
6573 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, | 6573 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, |
6574 150u * 1024u * 1024u); | 6574 150u * 1024u * 1024u); |
6575 } | 6575 } |
6576 | 6576 |
6577 TEST_F(LayerTreeHostImplTest, UpdateTilesForMasksWithNoVisibleContent) { | |
6578 gfx::Size bounds(100000, 100); | |
6579 | |
6580 host_impl_->CreatePendingTree(); | |
6581 | |
6582 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->pending_tree(), 1); | |
6583 | |
6584 scoped_ptr<FakePictureLayerImpl> layer_with_mask = | |
6585 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 2); | |
6586 | |
6587 layer_with_mask->SetBounds(bounds); | |
6588 layer_with_mask->SetContentBounds(bounds); | |
6589 | |
6590 scoped_ptr<FakePictureLayerImpl> mask = | |
6591 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 3); | |
6592 | |
6593 mask->SetIsMask(true); | |
6594 mask->SetBounds(bounds); | |
6595 mask->SetContentBounds(bounds); | |
6596 | |
6597 FakePictureLayerImpl* pending_mask_content = mask.get(); | |
6598 layer_with_mask->SetMaskLayer(mask.PassAs<LayerImpl>()); | |
6599 | |
6600 scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = | |
6601 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 4); | |
6602 | |
6603 child_of_layer_with_mask->SetBounds(bounds); | |
6604 child_of_layer_with_mask->SetContentBounds(bounds); | |
6605 child_of_layer_with_mask->SetDrawsContent(true); | |
6606 | |
6607 layer_with_mask->AddChild(child_of_layer_with_mask.PassAs<LayerImpl>()); | |
6608 | |
6609 root->AddChild(layer_with_mask.PassAs<LayerImpl>()); | |
6610 | |
6611 host_impl_->pending_tree()->SetRootLayer(root.Pass()); | |
6612 | |
6613 gfx::Rect r1 = pending_mask_content->visible_rect_for_tile_priority(); | |
6614 ASSERT_EQ(0, r1.x()); | |
6615 ASSERT_EQ(0, r1.y()); | |
6616 ASSERT_EQ(0, r1.width()); | |
6617 ASSERT_EQ(0, r1.height()); | |
6618 | |
6619 host_impl_->ActivatePendingTree(); | |
6620 | |
6621 host_impl_->active_tree()->UpdateDrawProperties(); | |
6622 | |
6623 ASSERT_EQ(2u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); | |
6624 | |
6625 FakePictureLayerImpl* active_mask_content = | |
6626 static_cast<FakePictureLayerImpl*>( | |
6627 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); | |
6628 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); | |
6629 | |
6630 ASSERT_TRUE(!r2.IsEmpty()); | |
6631 } | |
6632 | |
6633 } // namespace | 6577 } // namespace |
6634 } // namespace cc | 6578 } // namespace cc |
OLD | NEW |