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_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
10 #include "cc/layers/content_layer_client.h" | 10 #include "cc/layers/content_layer_client.h" |
(...skipping 8504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8515 // We should have one render surface, as the others are clipped out. | 8515 // We should have one render surface, as the others are clipped out. |
8516 ASSERT_EQ(1u, render_surface_layer_list.size()); | 8516 ASSERT_EQ(1u, render_surface_layer_list.size()); |
8517 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 8517 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); |
8518 | 8518 |
8519 // The root render surface should only have 1 contributing layer, since the | 8519 // The root render surface should only have 1 contributing layer, since the |
8520 // other layers are empty/clipped away. | 8520 // other layers are empty/clipped away. |
8521 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 8521 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
8522 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 8522 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); |
8523 } | 8523 } |
8524 | 8524 |
| 8525 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { |
| 8526 FakeImplProxy proxy; |
| 8527 FakeLayerTreeHostImpl host_impl(&proxy); |
| 8528 host_impl.CreatePendingTree(); |
| 8529 const gfx::Transform identity_matrix; |
| 8530 |
| 8531 scoped_refptr<Layer> root = Layer::Create(); |
| 8532 SetLayerPropertiesForTesting(root.get(), |
| 8533 identity_matrix, |
| 8534 identity_matrix, |
| 8535 gfx::PointF(), |
| 8536 gfx::PointF(), |
| 8537 gfx::Size(50, 50), |
| 8538 false); |
| 8539 root->SetIsDrawable(true); |
| 8540 |
| 8541 // The surface is moved slightly outside of the viewport. |
| 8542 scoped_refptr<Layer> surface = Layer::Create(); |
| 8543 SetLayerPropertiesForTesting(surface.get(), |
| 8544 identity_matrix, |
| 8545 identity_matrix, |
| 8546 gfx::PointF(), |
| 8547 gfx::PointF(-10, -20), |
| 8548 gfx::Size(), |
| 8549 false); |
| 8550 surface->SetForceRenderSurface(true); |
| 8551 |
| 8552 scoped_refptr<Layer> surface_child = Layer::Create(); |
| 8553 SetLayerPropertiesForTesting(surface_child.get(), |
| 8554 identity_matrix, |
| 8555 identity_matrix, |
| 8556 gfx::PointF(), |
| 8557 gfx::PointF(), |
| 8558 gfx::Size(50, 50), |
| 8559 false); |
| 8560 surface_child->SetIsDrawable(true); |
| 8561 |
| 8562 surface->AddChild(surface_child); |
| 8563 root->AddChild(surface); |
| 8564 |
| 8565 RenderSurfaceLayerList render_surface_layer_list; |
| 8566 int dummy_max_texture_size = 512; |
| 8567 LayerTreeHostCommon::CalculateDrawProperties(root.get(), |
| 8568 root->bounds(), |
| 8569 gfx::Transform(), |
| 8570 1.f, |
| 8571 1.f, |
| 8572 NULL, |
| 8573 dummy_max_texture_size, |
| 8574 false, |
| 8575 true, // can_adjust_raster_scale |
| 8576 &render_surface_layer_list); |
| 8577 |
| 8578 // The visible_content_rect for the |surface_child| should not be clipped by |
| 8579 // the viewport. |
| 8580 EXPECT_EQ(gfx::Rect(50, 50).ToString(), |
| 8581 surface_child->visible_content_rect().ToString()); |
| 8582 } |
| 8583 |
8525 } // namespace | 8584 } // namespace |
8526 } // namespace cc | 8585 } // namespace cc |
OLD | NEW |