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