OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/delegated_renderer_layer_impl.h" | 5 #include "cc/layers/delegated_renderer_layer_impl.h" |
6 | 6 |
7 #include "cc/base/scoped_ptr_vector.h" | 7 #include "cc/base/scoped_ptr_vector.h" |
8 #include "cc/layers/solid_color_layer_impl.h" | 8 #include "cc/layers/solid_color_layer_impl.h" |
9 #include "cc/quads/render_pass_draw_quad.h" | 9 #include "cc/quads/render_pass_draw_quad.h" |
10 #include "cc/quads/solid_color_draw_quad.h" | 10 #include "cc/quads/solid_color_draw_quad.h" |
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 // The layer outputs one quad, which is partially occluded. | 1500 // The layer outputs one quad, which is partially occluded. |
1501 EXPECT_EQ(1u, impl.quad_list().size()); | 1501 EXPECT_EQ(1u, impl.quad_list().size()); |
1502 EXPECT_EQ(1u, partially_occluded_count); | 1502 EXPECT_EQ(1u, partially_occluded_count); |
1503 // The quad in the contributing surface is at (211,300) in the root. | 1503 // The quad in the contributing surface is at (211,300) in the root. |
1504 // The occlusion extends to 500 in the x-axis, pushing the left of the | 1504 // The occlusion extends to 500 in the x-axis, pushing the left of the |
1505 // visible part of the quad to 500 - 211 = 300 - 11 inside the quad. | 1505 // visible part of the quad to 500 - 211 = 300 - 11 inside the quad. |
1506 EXPECT_EQ(gfx::Rect(300 - 11, 0, 100 + 11, 500).ToString(), | 1506 EXPECT_EQ(gfx::Rect(300 - 11, 0, 100 + 11, 500).ToString(), |
1507 impl.quad_list()[0]->visible_rect.ToString()); | 1507 impl.quad_list()[0]->visible_rect.ToString()); |
1508 } | 1508 } |
1509 } | 1509 } |
| 1510 { |
| 1511 gfx::Rect occluded(0, 0, 500, 1000); |
| 1512 // Move the occlusion to where it is in the contributing surface. |
| 1513 occluded -= quad_rect.OffsetFromOrigin() + gfx::Vector2d(11, 0); |
| 1514 |
| 1515 SCOPED_TRACE("Contributing render pass with transformed root"); |
| 1516 |
| 1517 delegated_renderer_layer_impl->SetTransform(transform); |
| 1518 impl.CalcDrawProps(viewport_size); |
| 1519 |
| 1520 impl.AppendQuadsForPassWithOcclusion( |
| 1521 delegated_renderer_layer_impl, pass2_id, occluded); |
| 1522 size_t partially_occluded_count = 0; |
| 1523 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion( |
| 1524 impl.quad_list(), |
| 1525 gfx::Rect(quad_rect.size()), |
| 1526 occluded, |
| 1527 &partially_occluded_count); |
| 1528 // The layer outputs one quad, which is partially occluded. |
| 1529 EXPECT_EQ(1u, impl.quad_list().size()); |
| 1530 EXPECT_EQ(1u, partially_occluded_count); |
| 1531 // The quad in the contributing surface is at (222,300) in the transformed |
| 1532 // root. The occlusion extends to 500 in the x-axis, pushing the left of the |
| 1533 // visible part of the quad to 500 - 222 = 300 - 22 inside the quad. |
| 1534 EXPECT_EQ(gfx::Rect(300 - 22, 0, 100 + 22, 500).ToString(), |
| 1535 impl.quad_list()[0]->visible_rect.ToString()); |
| 1536 } |
1510 } | 1537 } |
1511 | 1538 |
1512 TEST_F(DelegatedRendererLayerImplTest, PushPropertiesTo) { | 1539 TEST_F(DelegatedRendererLayerImplTest, PushPropertiesTo) { |
1513 gfx::Size layer_size(1000, 1000); | 1540 gfx::Size layer_size(1000, 1000); |
1514 | 1541 |
1515 scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer_impl = | 1542 scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer_impl = |
1516 FakeDelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 5); | 1543 FakeDelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 5); |
1517 delegated_renderer_layer_impl->SetBounds(layer_size); | 1544 delegated_renderer_layer_impl->SetBounds(layer_size); |
1518 delegated_renderer_layer_impl->SetContentBounds(layer_size); | 1545 delegated_renderer_layer_impl->SetContentBounds(layer_size); |
1519 delegated_renderer_layer_impl->SetDrawsContent(true); | 1546 delegated_renderer_layer_impl->SetDrawsContent(true); |
(...skipping 12 matching lines...) Expand all Loading... |
1532 scoped_ptr<DelegatedRendererLayerImpl> other_layer = | 1559 scoped_ptr<DelegatedRendererLayerImpl> other_layer = |
1533 DelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 6); | 1560 DelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 6); |
1534 | 1561 |
1535 delegated_renderer_layer_impl->PushPropertiesTo(other_layer.get()); | 1562 delegated_renderer_layer_impl->PushPropertiesTo(other_layer.get()); |
1536 | 1563 |
1537 EXPECT_EQ(0.5f, other_layer->inverse_device_scale_factor()); | 1564 EXPECT_EQ(0.5f, other_layer->inverse_device_scale_factor()); |
1538 } | 1565 } |
1539 | 1566 |
1540 } // namespace | 1567 } // namespace |
1541 } // namespace cc | 1568 } // namespace cc |
OLD | NEW |