Chromium Code Reviews| 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 4487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4498 const char* name; | 4498 const char* name; |
| 4499 const char* init_script; | 4499 const char* init_script; |
| 4500 const char* expected_result; | 4500 const char* expected_result; |
| 4501 }; | 4501 }; |
| 4502 | 4502 |
| 4503 TestCase remove_render_passes_cases[] = { | 4503 TestCase remove_render_passes_cases[] = { |
| 4504 { | 4504 { |
| 4505 "Single root pass", | 4505 "Single root pass", |
| 4506 "R0ssss\n", | 4506 "R0ssss\n", |
| 4507 "R0ssss\n" | 4507 "R0ssss\n" |
| 4508 }, | 4508 }, { |
|
danakj
2013/04/15 20:50:51
These are for cpplint.
| |
| 4509 { | |
| 4510 "Single pass - no quads", | 4509 "Single pass - no quads", |
| 4511 "R0\n", | 4510 "R0\n", |
| 4512 "R0\n" | 4511 "R0\n" |
| 4513 }, | 4512 }, { |
| 4514 { | |
| 4515 "Two passes, no removal", | 4513 "Two passes, no removal", |
| 4516 "R0ssssA0sss\n" | 4514 "R0ssssA0sss\n" |
| 4517 "A0ssss\n", | 4515 "A0ssss\n", |
| 4518 "R0ssssA0sss\n" | 4516 "R0ssssA0sss\n" |
| 4519 "A0ssss\n" | 4517 "A0ssss\n" |
| 4520 }, | 4518 }, { |
| 4521 { | |
| 4522 "Two passes, remove last", | 4519 "Two passes, remove last", |
| 4523 "R0ssssA0[ct]sss\n" | 4520 "R0ssssA0[ct]sss\n" |
| 4524 "A0ssss\n", | 4521 "A0ssss\n", |
| 4525 "R0ssssA0sss\n" | 4522 "R0ssssA0sss\n" |
| 4526 }, | 4523 }, { |
| 4527 { | |
| 4528 "Have texture but contents changed - leave pass", | 4524 "Have texture but contents changed - leave pass", |
| 4529 "R0ssssA0[t]sss\n" | 4525 "R0ssssA0[t]sss\n" |
| 4530 "A0ssss\n", | 4526 "A0ssss\n", |
| 4531 "R0ssssA0sss\n" | 4527 "R0ssssA0sss\n" |
| 4532 "A0ssss\n" | 4528 "A0ssss\n" |
| 4533 }, | 4529 }, { |
| 4534 { | |
| 4535 "Contents didn't change but no texture - leave pass", | 4530 "Contents didn't change but no texture - leave pass", |
| 4536 "R0ssssA0[c]sss\n" | 4531 "R0ssssA0[c]sss\n" |
| 4537 "A0ssss\n", | 4532 "A0ssss\n", |
| 4538 "R0ssssA0sss\n" | 4533 "R0ssssA0sss\n" |
| 4539 "A0ssss\n" | 4534 "A0ssss\n" |
| 4540 }, | 4535 }, { |
| 4541 { | |
| 4542 "Replica: two quads reference the same pass; remove", | 4536 "Replica: two quads reference the same pass; remove", |
| 4543 "R0ssssA0[ct]A0[ct]sss\n" | 4537 "R0ssssA0[ct]A0[ct]sss\n" |
| 4544 "A0ssss\n", | 4538 "A0ssss\n", |
| 4545 "R0ssssA0A0sss\n" | 4539 "R0ssssA0A0sss\n" |
| 4546 }, | 4540 }, { |
| 4547 { | |
| 4548 "Replica: two quads reference the same pass; leave", | 4541 "Replica: two quads reference the same pass; leave", |
| 4549 "R0ssssA0[c]A0[c]sss\n" | 4542 "R0ssssA0[c]A0[c]sss\n" |
| 4550 "A0ssss\n", | 4543 "A0ssss\n", |
| 4551 "R0ssssA0A0sss\n" | 4544 "R0ssssA0A0sss\n" |
| 4552 "A0ssss\n", | 4545 "A0ssss\n", |
| 4553 }, | 4546 }, { |
| 4554 { | |
| 4555 "Many passes, remove all", | 4547 "Many passes, remove all", |
| 4556 "R0ssssA0[ct]sss\n" | 4548 "R0ssssA0[ct]sss\n" |
| 4557 "A0sssB0[ct]C0[ct]s\n" | 4549 "A0sssB0[ct]C0[ct]s\n" |
| 4558 "B0sssD0[ct]ssE0[ct]F0[ct]\n" | 4550 "B0sssD0[ct]ssE0[ct]F0[ct]\n" |
| 4559 "E0ssssss\n" | 4551 "E0ssssss\n" |
| 4560 "C0G0[ct]\n" | 4552 "C0G0[ct]\n" |
| 4561 "D0sssssss\n" | 4553 "D0sssssss\n" |
| 4562 "F0sssssss\n" | 4554 "F0sssssss\n" |
| 4563 "G0sss\n", | 4555 "G0sss\n", |
| 4564 | 4556 |
| 4565 "R0ssssA0sss\n" | 4557 "R0ssssA0sss\n" |
| 4566 }, | 4558 }, { |
| 4567 { | |
| 4568 "Deep recursion, remove all", | 4559 "Deep recursion, remove all", |
| 4569 | 4560 |
| 4570 "R0sssssA0[ct]ssss\n" | 4561 "R0sssssA0[ct]ssss\n" |
| 4571 "A0ssssB0sss\n" | 4562 "A0ssssB0sss\n" |
| 4572 "B0C0\n" | 4563 "B0C0\n" |
| 4573 "C0D0\n" | 4564 "C0D0\n" |
| 4574 "D0E0\n" | 4565 "D0E0\n" |
| 4575 "E0F0\n" | 4566 "E0F0\n" |
| 4576 "F0G0\n" | 4567 "F0G0\n" |
| 4577 "G0H0\n" | 4568 "G0H0\n" |
| 4578 "H0sssI0sss\n" | 4569 "H0sssI0sss\n" |
| 4579 "I0J0\n" | 4570 "I0J0\n" |
| 4580 "J0ssss\n", | 4571 "J0ssss\n", |
| 4581 | 4572 |
| 4582 "R0sssssA0ssss\n" | 4573 "R0sssssA0ssss\n" |
| 4583 }, | 4574 }, { |
| 4584 { | |
| 4585 "Wide recursion, remove all", | 4575 "Wide recursion, remove all", |
| 4586 "R0A0[ct]B0[ct]C0[ct]D0[ct]E0[ct]F0[ct]G0[ct]H0[ct]I0[ct]J0[ct]\n" | 4576 "R0A0[ct]B0[ct]C0[ct]D0[ct]E0[ct]F0[ct]G0[ct]H0[ct]I0[ct]J0[ct]\n" |
| 4587 "A0s\n" | 4577 "A0s\n" |
| 4588 "B0s\n" | 4578 "B0s\n" |
| 4589 "C0ssss\n" | 4579 "C0ssss\n" |
| 4590 "D0ssss\n" | 4580 "D0ssss\n" |
| 4591 "E0s\n" | 4581 "E0s\n" |
| 4592 "F0\n" | 4582 "F0\n" |
| 4593 "G0s\n" | 4583 "G0s\n" |
| 4594 "H0s\n" | 4584 "H0s\n" |
| 4595 "I0s\n" | 4585 "I0s\n" |
| 4596 "J0ssss\n", | 4586 "J0ssss\n", |
| 4597 | 4587 |
| 4598 "R0A0B0C0D0E0F0G0H0I0J0\n" | 4588 "R0A0B0C0D0E0F0G0H0I0J0\n" |
| 4599 }, | 4589 }, { |
| 4600 { | |
| 4601 "Remove passes regardless of cache state", | 4590 "Remove passes regardless of cache state", |
| 4602 "R0ssssA0[ct]sss\n" | 4591 "R0ssssA0[ct]sss\n" |
| 4603 "A0sssB0C0s\n" | 4592 "A0sssB0C0s\n" |
| 4604 "B0sssD0[c]ssE0[t]F0\n" | 4593 "B0sssD0[c]ssE0[t]F0\n" |
| 4605 "E0ssssss\n" | 4594 "E0ssssss\n" |
| 4606 "C0G0\n" | 4595 "C0G0\n" |
| 4607 "D0sssssss\n" | 4596 "D0sssssss\n" |
| 4608 "F0sssssss\n" | 4597 "F0sssssss\n" |
| 4609 "G0sss\n", | 4598 "G0sss\n", |
| 4610 | 4599 |
| 4611 "R0ssssA0sss\n" | 4600 "R0ssssA0sss\n" |
| 4612 }, | 4601 }, { |
| 4613 { | |
| 4614 "Leave some passes, remove others", | 4602 "Leave some passes, remove others", |
| 4615 | 4603 |
| 4616 "R0ssssA0[c]sss\n" | 4604 "R0ssssA0[c]sss\n" |
| 4617 "A0sssB0[t]C0[ct]s\n" | 4605 "A0sssB0[t]C0[ct]s\n" |
| 4618 "B0sssD0[c]ss\n" | 4606 "B0sssD0[c]ss\n" |
| 4619 "C0G0\n" | 4607 "C0G0\n" |
| 4620 "D0sssssss\n" | 4608 "D0sssssss\n" |
| 4621 "G0sss\n", | 4609 "G0sss\n", |
| 4622 | 4610 |
| 4623 "R0ssssA0sss\n" | 4611 "R0ssssA0sss\n" |
| 4624 "A0sssB0C0s\n" | 4612 "A0sssB0C0s\n" |
| 4625 "B0sssD0ss\n" | 4613 "B0sssD0ss\n" |
| 4626 "D0sssssss\n" | 4614 "D0sssssss\n" |
| 4627 }, | 4615 }, { |
| 4628 { | |
| 4629 0, 0, 0 | 4616 0, 0, 0 |
| 4630 } | 4617 } |
| 4631 }; | 4618 }; |
| 4632 | 4619 |
| 4633 static void VerifyRenderPassTestData( | 4620 static void VerifyRenderPassTestData( |
| 4634 const TestCase& test_case, | 4621 const TestCase& test_case, |
| 4635 const RenderPassRemovalTestData& test_data) { | 4622 const RenderPassRemovalTestData& test_data) { |
| 4636 char actual_result[1024]; | 4623 char actual_result[1024]; |
| 4637 DumpRenderPassTestData(test_data, actual_result); | 4624 DumpRenderPassTestData(test_data, actual_result); |
| 4638 EXPECT_STREQ(test_case.expected_result, actual_result) << "In test case: " << | 4625 EXPECT_STREQ(test_case.expected_result, actual_result) << "In test case: " << |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5040 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 5027 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 5041 render_pass_quad->rect.ToString()); | 5028 render_pass_quad->rect.ToString()); |
| 5042 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 5029 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 5043 render_pass_quad->mask_uv_rect.ToString()); | 5030 render_pass_quad->mask_uv_rect.ToString()); |
| 5044 | 5031 |
| 5045 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | 5032 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
| 5046 host_impl_->DidDrawAllLayers(frame); | 5033 host_impl_->DidDrawAllLayers(frame); |
| 5047 } | 5034 } |
| 5048 } | 5035 } |
| 5049 | 5036 |
| 5037 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { | |
| 5038 // The replica's mask layer has bounds 100x100 but the replica is of a | |
| 5039 // layer with bounds 50x50. | |
| 5040 | |
| 5041 scoped_ptr<LayerImpl> scoped_root = | |
| 5042 LayerImpl::Create(host_impl_->active_tree(), 1); | |
| 5043 LayerImpl* root = scoped_root.get(); | |
| 5044 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | |
| 5045 | |
| 5046 scoped_ptr<LayerImpl> scoped_content_layer = | |
| 5047 LayerImpl::Create(host_impl_->active_tree(), 3); | |
| 5048 LayerImpl* content_layer = scoped_content_layer.get(); | |
| 5049 root->AddChild(scoped_content_layer.Pass()); | |
| 5050 | |
| 5051 scoped_ptr<LayerImpl> scoped_replica_layer = | |
| 5052 LayerImpl::Create(host_impl_->active_tree(), 2); | |
| 5053 LayerImpl* replica_layer = scoped_replica_layer.get(); | |
| 5054 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | |
| 5055 | |
| 5056 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | |
| 5057 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); | |
| 5058 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | |
| 5059 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | |
| 5060 | |
| 5061 gfx::Size root_size(100, 100); | |
| 5062 root->SetBounds(root_size); | |
| 5063 root->SetContentBounds(root_size); | |
| 5064 root->SetPosition(gfx::PointF()); | |
| 5065 root->SetAnchorPoint(gfx::PointF()); | |
| 5066 | |
| 5067 gfx::Size layer_size(50, 50); | |
| 5068 content_layer->SetBounds(layer_size); | |
| 5069 content_layer->SetContentBounds(layer_size); | |
| 5070 content_layer->SetPosition(gfx::PointF()); | |
| 5071 content_layer->SetAnchorPoint(gfx::PointF()); | |
| 5072 content_layer->SetDrawsContent(true); | |
| 5073 | |
| 5074 gfx::Size mask_size(100, 100); | |
| 5075 mask_layer->SetBounds(mask_size); | |
| 5076 mask_layer->SetContentBounds(mask_size); | |
| 5077 mask_layer->SetPosition(gfx::PointF()); | |
| 5078 mask_layer->SetAnchorPoint(gfx::PointF()); | |
| 5079 mask_layer->SetDrawsContent(true); | |
| 5080 | |
| 5081 // Check that the mask fills the surface. | |
| 5082 float device_scale_factor = 1.f; | |
| 5083 host_impl_->SetViewportSize(root_size); | |
| 5084 host_impl_->SetDeviceScaleFactor(device_scale_factor); | |
| 5085 { | |
| 5086 LayerTreeHostImpl::FrameData frame; | |
| 5087 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | |
| 5088 | |
| 5089 ASSERT_EQ(1u, frame.render_passes.size()); | |
| 5090 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | |
| 5091 ASSERT_EQ(DrawQuad::RENDER_PASS, | |
| 5092 frame.render_passes[0]->quad_list[1]->material); | |
| 5093 const RenderPassDrawQuad* replica_quad = | |
| 5094 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | |
| 5095 EXPECT_TRUE(replica_quad->is_replica); | |
| 5096 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | |
| 5097 replica_quad->rect.ToString()); | |
| 5098 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | |
| 5099 replica_quad->mask_uv_rect.ToString()); | |
| 5100 | |
| 5101 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | |
| 5102 host_impl_->DidDrawAllLayers(frame); | |
| 5103 } | |
| 5104 | |
| 5105 // Applying a DSF should change the render surface size, but won't affect | |
| 5106 // which part of the mask is used. | |
| 5107 device_scale_factor = 2.f; | |
| 5108 gfx::Size device_viewport = | |
| 5109 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); | |
| 5110 host_impl_->SetViewportSize(device_viewport); | |
| 5111 host_impl_->SetDeviceScaleFactor(device_scale_factor); | |
| 5112 host_impl_->active_tree()->set_needs_update_draw_properties(); | |
| 5113 { | |
| 5114 LayerTreeHostImpl::FrameData frame; | |
| 5115 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | |
| 5116 | |
| 5117 ASSERT_EQ(1u, frame.render_passes.size()); | |
| 5118 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | |
| 5119 ASSERT_EQ(DrawQuad::RENDER_PASS, | |
| 5120 frame.render_passes[0]->quad_list[1]->material); | |
| 5121 const RenderPassDrawQuad* replica_quad = | |
| 5122 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | |
| 5123 EXPECT_TRUE(replica_quad->is_replica); | |
| 5124 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | |
| 5125 replica_quad->rect.ToString()); | |
| 5126 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | |
| 5127 replica_quad->mask_uv_rect.ToString()); | |
| 5128 | |
| 5129 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | |
| 5130 host_impl_->DidDrawAllLayers(frame); | |
| 5131 } | |
| 5132 | |
| 5133 // Applying an equivalent content scale on the content layer and the mask | |
| 5134 // should still result in the same part of the mask being used. | |
| 5135 gfx::Size layer_size_large = | |
| 5136 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); | |
| 5137 content_layer->SetContentBounds(layer_size_large); | |
| 5138 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); | |
| 5139 gfx::Size mask_size_large = | |
| 5140 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); | |
| 5141 mask_layer->SetContentBounds(mask_size_large); | |
| 5142 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); | |
| 5143 host_impl_->active_tree()->set_needs_update_draw_properties(); | |
| 5144 { | |
| 5145 LayerTreeHostImpl::FrameData frame; | |
| 5146 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | |
| 5147 | |
| 5148 ASSERT_EQ(1u, frame.render_passes.size()); | |
| 5149 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | |
| 5150 ASSERT_EQ(DrawQuad::RENDER_PASS, | |
| 5151 frame.render_passes[0]->quad_list[1]->material); | |
| 5152 const RenderPassDrawQuad* replica_quad = | |
| 5153 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | |
| 5154 EXPECT_TRUE(replica_quad->is_replica); | |
| 5155 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | |
| 5156 replica_quad->rect.ToString()); | |
| 5157 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | |
| 5158 replica_quad->mask_uv_rect.ToString()); | |
| 5159 | |
| 5160 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | |
| 5161 host_impl_->DidDrawAllLayers(frame); | |
| 5162 } | |
| 5163 | |
| 5164 // Applying a different contents scale to the mask layer will still result | |
|
enne (OOO)
2013/04/15 22:20:40
I'm not sure I follow this case. Why is this the
danakj
2013/04/16 02:49:03
I think this case is wrong. It was a copy paste fr
| |
| 5165 // in the mask covering the owning layer. | |
| 5166 mask_layer->SetContentBounds(mask_size); | |
| 5167 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); | |
| 5168 host_impl_->active_tree()->set_needs_update_draw_properties(); | |
| 5169 { | |
| 5170 LayerTreeHostImpl::FrameData frame; | |
| 5171 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | |
| 5172 | |
| 5173 ASSERT_EQ(1u, frame.render_passes.size()); | |
| 5174 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | |
| 5175 ASSERT_EQ(DrawQuad::RENDER_PASS, | |
| 5176 frame.render_passes[0]->quad_list[1]->material); | |
| 5177 const RenderPassDrawQuad* replica_quad = | |
| 5178 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | |
| 5179 EXPECT_TRUE(replica_quad->is_replica); | |
| 5180 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | |
| 5181 replica_quad->rect.ToString()); | |
| 5182 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | |
| 5183 replica_quad->mask_uv_rect.ToString()); | |
| 5184 | |
| 5185 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | |
| 5186 host_impl_->DidDrawAllLayers(frame); | |
| 5187 } | |
| 5188 } | |
| 5189 | |
| 5190 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedLayer) { | |
| 5191 // The replica is of a layer with bounds 50x50, but it has a child that causes | |
| 5192 // the surface bounds to be larger. | |
| 5193 | |
| 5194 scoped_ptr<LayerImpl> scoped_root = | |
| 5195 LayerImpl::Create(host_impl_->active_tree(), 1); | |
| 5196 LayerImpl* root = scoped_root.get(); | |
| 5197 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); | |
| 5198 | |
| 5199 scoped_ptr<LayerImpl> scoped_content_layer = | |
| 5200 LayerImpl::Create(host_impl_->active_tree(), 2); | |
| 5201 LayerImpl* content_layer = scoped_content_layer.get(); | |
| 5202 root->AddChild(scoped_content_layer.Pass()); | |
| 5203 | |
| 5204 scoped_ptr<LayerImpl> scoped_content_child_layer = | |
| 5205 LayerImpl::Create(host_impl_->active_tree(), 3); | |
| 5206 LayerImpl* content_child_layer = scoped_content_child_layer.get(); | |
| 5207 content_layer->AddChild(scoped_content_child_layer.Pass()); | |
| 5208 | |
| 5209 scoped_ptr<LayerImpl> scoped_replica_layer = | |
| 5210 LayerImpl::Create(host_impl_->active_tree(), 4); | |
| 5211 LayerImpl* replica_layer = scoped_replica_layer.get(); | |
| 5212 content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); | |
| 5213 | |
| 5214 scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = | |
| 5215 FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); | |
| 5216 FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); | |
| 5217 replica_layer->SetMaskLayer(scoped_mask_layer.PassAs<LayerImpl>()); | |
| 5218 | |
| 5219 gfx::Size root_size(100, 100); | |
| 5220 root->SetBounds(root_size); | |
| 5221 root->SetContentBounds(root_size); | |
| 5222 root->SetPosition(gfx::PointF()); | |
| 5223 root->SetAnchorPoint(gfx::PointF()); | |
| 5224 | |
| 5225 gfx::Size layer_size(50, 50); | |
| 5226 content_layer->SetBounds(layer_size); | |
| 5227 content_layer->SetContentBounds(layer_size); | |
| 5228 content_layer->SetPosition(gfx::PointF()); | |
| 5229 content_layer->SetAnchorPoint(gfx::PointF()); | |
| 5230 content_layer->SetDrawsContent(true); | |
| 5231 | |
| 5232 gfx::Size child_size(50, 50); | |
| 5233 content_child_layer->SetBounds(child_size); | |
| 5234 content_child_layer->SetContentBounds(child_size); | |
| 5235 content_child_layer->SetPosition(gfx::Point(50, 0)); | |
| 5236 content_child_layer->SetAnchorPoint(gfx::PointF()); | |
| 5237 content_child_layer->SetDrawsContent(true); | |
| 5238 | |
| 5239 gfx::Size mask_size(50, 50); | |
| 5240 mask_layer->SetBounds(mask_size); | |
| 5241 mask_layer->SetContentBounds(mask_size); | |
| 5242 mask_layer->SetPosition(gfx::PointF()); | |
| 5243 mask_layer->SetAnchorPoint(gfx::PointF()); | |
| 5244 mask_layer->SetDrawsContent(true); | |
| 5245 | |
| 5246 float device_scale_factor = 1.f; | |
| 5247 host_impl_->SetViewportSize(root_size); | |
| 5248 host_impl_->SetDeviceScaleFactor(device_scale_factor); | |
| 5249 { | |
| 5250 LayerTreeHostImpl::FrameData frame; | |
| 5251 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | |
| 5252 | |
| 5253 ASSERT_EQ(1u, frame.render_passes.size()); | |
| 5254 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | |
| 5255 | |
| 5256 // The surface is 100x50. | |
| 5257 ASSERT_EQ(DrawQuad::RENDER_PASS, | |
| 5258 frame.render_passes[0]->quad_list[0]->material); | |
| 5259 const RenderPassDrawQuad* render_pass_quad = | |
| 5260 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | |
| 5261 EXPECT_FALSE(render_pass_quad->is_replica); | |
| 5262 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), | |
| 5263 render_pass_quad->rect.ToString()); | |
| 5264 | |
| 5265 // The mask covers the owning layer only. | |
| 5266 ASSERT_EQ(DrawQuad::RENDER_PASS, | |
| 5267 frame.render_passes[0]->quad_list[1]->material); | |
| 5268 const RenderPassDrawQuad* replica_quad = | |
| 5269 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | |
| 5270 EXPECT_TRUE(replica_quad->is_replica); | |
| 5271 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), | |
| 5272 replica_quad->rect.ToString()); | |
| 5273 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), | |
|
enne (OOO)
2013/04/15 22:20:40
This 2.f is unexpected in a uv rect. Why would th
danakj
2013/04/16 02:49:03
Right, it should be 1.f
| |
| 5274 replica_quad->mask_uv_rect.ToString()); | |
| 5275 | |
| 5276 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | |
| 5277 host_impl_->DidDrawAllLayers(frame); | |
| 5278 } | |
| 5279 | |
| 5280 // Move the child to (-50, 0) instead. Now the mask should be moved to still | |
|
enne (OOO)
2013/04/15 22:20:40
It should?
danakj
2013/04/16 02:49:03
Ya, 0,0 in the surface texture is not inside the b
| |
| 5281 // cover the layer being replicated. | |
| 5282 content_child_layer->SetPosition(gfx::Point(-50, 0)); | |
| 5283 { | |
| 5284 LayerTreeHostImpl::FrameData frame; | |
| 5285 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | |
| 5286 | |
| 5287 ASSERT_EQ(1u, frame.render_passes.size()); | |
| 5288 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | |
| 5289 | |
| 5290 // The surface is 100x50 with its origin at (-50, 0). | |
| 5291 ASSERT_EQ(DrawQuad::RENDER_PASS, | |
| 5292 frame.render_passes[0]->quad_list[0]->material); | |
| 5293 const RenderPassDrawQuad* render_pass_quad = | |
| 5294 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | |
| 5295 EXPECT_FALSE(render_pass_quad->is_replica); | |
| 5296 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), | |
| 5297 render_pass_quad->rect.ToString()); | |
| 5298 | |
| 5299 // The mask covers the owning layer only. | |
| 5300 ASSERT_EQ(DrawQuad::RENDER_PASS, | |
| 5301 frame.render_passes[0]->quad_list[1]->material); | |
| 5302 const RenderPassDrawQuad* replica_quad = | |
| 5303 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | |
| 5304 EXPECT_TRUE(replica_quad->is_replica); | |
| 5305 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), | |
| 5306 replica_quad->rect.ToString()); | |
| 5307 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), | |
| 5308 replica_quad->mask_uv_rect.ToString()); | |
| 5309 | |
| 5310 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | |
| 5311 host_impl_->DidDrawAllLayers(frame); | |
| 5312 } | |
| 5313 } | |
| 5314 | |
| 5050 } // namespace | 5315 } // namespace |
| 5051 } // namespace cc | 5316 } // namespace cc |
| OLD | NEW |