| 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 6524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6535 | 6535 |
| 6536 void AfterTest() override {} | 6536 void AfterTest() override {} |
| 6537 | 6537 |
| 6538 private: | 6538 private: |
| 6539 scoped_refptr<Layer> root; | 6539 scoped_refptr<Layer> root; |
| 6540 scoped_refptr<Layer> child; | 6540 scoped_refptr<Layer> child; |
| 6541 }; | 6541 }; |
| 6542 | 6542 |
| 6543 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateCopyRequests); | 6543 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateCopyRequests); |
| 6544 | 6544 |
| 6545 class LayerTreeTestMaskLayerForSurfaceWithContentRectNotAtOrigin | |
| 6546 : public LayerTreeTest { | |
| 6547 protected: | |
| 6548 void SetupTree() override { | |
| 6549 // The masked layer has bounds 50x50, but it has a child that causes | |
| 6550 // the surface bounds to be larger. It also has a parent that clips the | |
| 6551 // masked layer and its surface. | |
| 6552 | |
| 6553 scoped_refptr<Layer> root = Layer::Create(); | |
| 6554 | |
| 6555 scoped_refptr<FakePictureLayer> content_layer = | |
| 6556 FakePictureLayer::Create(&client_); | |
| 6557 | |
| 6558 std::unique_ptr<RecordingSource> recording_source = | |
| 6559 FakeRecordingSource::CreateFilledRecordingSource(gfx::Size(100, 100)); | |
| 6560 PaintFlags paint1, paint2; | |
| 6561 static_cast<FakeRecordingSource*>(recording_source.get()) | |
| 6562 ->add_draw_rect_with_flags(gfx::Rect(0, 0, 100, 90), paint1); | |
| 6563 static_cast<FakeRecordingSource*>(recording_source.get()) | |
| 6564 ->add_draw_rect_with_flags(gfx::Rect(0, 90, 100, 10), paint2); | |
| 6565 client_.set_fill_with_nonsolid_color(true); | |
| 6566 static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord(); | |
| 6567 | |
| 6568 scoped_refptr<FakePictureLayer> mask_layer = | |
| 6569 FakePictureLayer::CreateWithRecordingSource( | |
| 6570 &client_, std::move(recording_source)); | |
| 6571 content_layer->SetMaskLayer(mask_layer.get()); | |
| 6572 | |
| 6573 gfx::Size root_size(100, 100); | |
| 6574 root->SetBounds(root_size); | |
| 6575 | |
| 6576 gfx::Size layer_size(100, 100); | |
| 6577 content_layer->SetBounds(layer_size); | |
| 6578 | |
| 6579 gfx::Size mask_size(100, 100); | |
| 6580 mask_layer->SetBounds(mask_size); | |
| 6581 mask_layer->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); | |
| 6582 mask_layer_id_ = mask_layer->id(); | |
| 6583 | |
| 6584 layer_tree_host()->SetRootLayer(root); | |
| 6585 LayerTreeTest::SetupTree(); | |
| 6586 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create(); | |
| 6587 outer_viewport_scroll_layer->SetBounds(layer_size); | |
| 6588 CreateVirtualViewportLayers(root.get(), outer_viewport_scroll_layer, | |
| 6589 gfx::Size(50, 50), gfx::Size(50, 50), | |
| 6590 layer_tree_host()); | |
| 6591 outer_viewport_scroll_layer->scroll_clip_layer()->SetMasksToBounds(true); | |
| 6592 outer_viewport_scroll_layer->AddChild(content_layer); | |
| 6593 | |
| 6594 client_.set_bounds(root->bounds()); | |
| 6595 outer_viewport_scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | |
| 6596 } | |
| 6597 | |
| 6598 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
| 6599 | |
| 6600 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | |
| 6601 LayerTreeHostImpl::FrameData* frame_data, | |
| 6602 DrawResult draw_result) override { | |
| 6603 EXPECT_EQ(2u, frame_data->render_passes.size()); | |
| 6604 RenderPass* root_pass = frame_data->render_passes.back().get(); | |
| 6605 EXPECT_EQ(2u, root_pass->quad_list.size()); | |
| 6606 | |
| 6607 // There's a solid color quad under everything. | |
| 6608 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material); | |
| 6609 | |
| 6610 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); | |
| 6611 const RenderPassDrawQuad* render_pass_quad = | |
| 6612 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); | |
| 6613 EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), | |
| 6614 render_pass_quad->rect.ToString()); | |
| 6615 if (host_impl->settings().enable_mask_tiling) { | |
| 6616 PictureLayerImpl* mask_layer_impl = static_cast<PictureLayerImpl*>( | |
| 6617 host_impl->active_tree()->LayerById(mask_layer_id_)); | |
| 6618 gfx::SizeF texture_size( | |
| 6619 mask_layer_impl->CalculateTileSize(mask_layer_impl->bounds())); | |
| 6620 EXPECT_EQ( | |
| 6621 gfx::RectF(50.f / texture_size.width(), 50.f / texture_size.height(), | |
| 6622 50.f / texture_size.width(), 50.f / texture_size.height()) | |
| 6623 .ToString(), | |
| 6624 render_pass_quad->mask_uv_rect.ToString()); | |
| 6625 } else { | |
| 6626 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(50.f, 50.f, 50.f, 50.f), 1.f / 100.f) | |
| 6627 .ToString(), | |
| 6628 render_pass_quad->mask_uv_rect.ToString()); | |
| 6629 } | |
| 6630 EndTest(); | |
| 6631 return draw_result; | |
| 6632 } | |
| 6633 | |
| 6634 void AfterTest() override {} | |
| 6635 | |
| 6636 int mask_layer_id_; | |
| 6637 FakeContentLayerClient client_; | |
| 6638 }; | |
| 6639 | |
| 6640 SINGLE_AND_MULTI_THREAD_TEST_F( | |
| 6641 LayerTreeTestMaskLayerForSurfaceWithContentRectNotAtOrigin); | |
| 6642 | |
| 6643 class LayerTreeTestMaskLayerForSurfaceWithClippedLayer : public LayerTreeTest { | 6545 class LayerTreeTestMaskLayerForSurfaceWithClippedLayer : public LayerTreeTest { |
| 6644 protected: | 6546 protected: |
| 6645 void SetupTree() override { | 6547 void SetupTree() override { |
| 6646 // The masked layer has bounds 50x50, but it has a child that causes | 6548 // The masked layer has bounds 50x50, but it has a child that causes |
| 6647 // the surface bounds to be larger. It also has a parent that clips the | 6549 // the surface bounds to be larger. It also has a parent that clips the |
| 6648 // masked layer and its surface. | 6550 // masked layer and its surface. |
| 6649 | 6551 |
| 6650 scoped_refptr<Layer> root = Layer::Create(); | 6552 scoped_refptr<Layer> root = Layer::Create(); |
| 6651 | 6553 |
| 6652 scoped_refptr<Layer> clipping_layer = Layer::Create(); | 6554 scoped_refptr<Layer> clipping_layer = Layer::Create(); |
| 6653 root->AddChild(clipping_layer); | 6555 root->AddChild(clipping_layer); |
| 6654 | 6556 |
| 6655 scoped_refptr<FakePictureLayer> content_layer = | 6557 scoped_refptr<FakePictureLayer> content_layer = |
| 6656 FakePictureLayer::Create(&client_); | 6558 FakePictureLayer::Create(&client_); |
| 6657 clipping_layer->AddChild(content_layer); | 6559 clipping_layer->AddChild(content_layer); |
| 6658 | 6560 |
| 6659 scoped_refptr<FakePictureLayer> content_child_layer = | 6561 scoped_refptr<FakePictureLayer> content_child_layer = |
| 6660 FakePictureLayer::Create(&client_); | 6562 FakePictureLayer::Create(&client_); |
| 6661 content_layer->AddChild(content_child_layer); | 6563 content_layer->AddChild(content_child_layer); |
| 6662 | 6564 |
| 6663 std::unique_ptr<RecordingSource> recording_source = | |
| 6664 FakeRecordingSource::CreateFilledRecordingSource(gfx::Size(100, 100)); | |
| 6665 PaintFlags paint1, paint2; | |
| 6666 static_cast<FakeRecordingSource*>(recording_source.get()) | |
| 6667 ->add_draw_rect_with_flags(gfx::Rect(0, 0, 100, 90), paint1); | |
| 6668 static_cast<FakeRecordingSource*>(recording_source.get()) | |
| 6669 ->add_draw_rect_with_flags(gfx::Rect(0, 90, 100, 10), paint2); | |
| 6670 client_.set_fill_with_nonsolid_color(true); | |
| 6671 static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord(); | |
| 6672 | |
| 6673 scoped_refptr<FakePictureLayer> mask_layer = | 6565 scoped_refptr<FakePictureLayer> mask_layer = |
| 6674 FakePictureLayer::CreateWithRecordingSource( | 6566 FakePictureLayer::Create(&client_); |
| 6675 &client_, std::move(recording_source)); | |
| 6676 content_layer->SetMaskLayer(mask_layer.get()); | 6567 content_layer->SetMaskLayer(mask_layer.get()); |
| 6677 | 6568 |
| 6678 gfx::Size root_size(100, 100); | 6569 gfx::Size root_size(100, 100); |
| 6679 root->SetBounds(root_size); | 6570 root->SetBounds(root_size); |
| 6680 | 6571 |
| 6681 gfx::PointF clipping_origin(20.f, 10.f); | 6572 gfx::PointF clipping_origin(20.f, 10.f); |
| 6682 gfx::Size clipping_size(10, 20); | 6573 gfx::Size clipping_size(10, 20); |
| 6683 clipping_layer->SetBounds(clipping_size); | 6574 clipping_layer->SetBounds(clipping_size); |
| 6684 clipping_layer->SetPosition(clipping_origin); | 6575 clipping_layer->SetPosition(clipping_origin); |
| 6685 clipping_layer->SetMasksToBounds(true); | 6576 clipping_layer->SetMasksToBounds(true); |
| 6686 | 6577 |
| 6687 gfx::Size layer_size(50, 50); | 6578 gfx::Size layer_size(50, 50); |
| 6688 content_layer->SetBounds(layer_size); | 6579 content_layer->SetBounds(layer_size); |
| 6689 content_layer->SetPosition(gfx::PointF() - | 6580 content_layer->SetPosition(gfx::PointF() - |
| 6690 clipping_origin.OffsetFromOrigin()); | 6581 clipping_origin.OffsetFromOrigin()); |
| 6691 | 6582 |
| 6692 gfx::Size child_size(50, 50); | 6583 gfx::Size child_size(50, 50); |
| 6693 content_child_layer->SetBounds(child_size); | 6584 content_child_layer->SetBounds(child_size); |
| 6694 content_child_layer->SetPosition(gfx::PointF(20.f, 0.f)); | 6585 content_child_layer->SetPosition(gfx::PointF(20.f, 0.f)); |
| 6695 | 6586 |
| 6696 gfx::Size mask_size(100, 100); | 6587 gfx::Size mask_size(100, 100); |
| 6697 mask_layer->SetBounds(mask_size); | 6588 mask_layer->SetBounds(mask_size); |
| 6698 mask_layer->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); | 6589 mask_layer->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); |
| 6699 mask_layer_id_ = mask_layer->id(); | |
| 6700 | 6590 |
| 6701 layer_tree_host()->SetRootLayer(root); | 6591 layer_tree_host()->SetRootLayer(root); |
| 6702 LayerTreeTest::SetupTree(); | 6592 LayerTreeTest::SetupTree(); |
| 6703 client_.set_bounds(root->bounds()); | 6593 client_.set_bounds(root->bounds()); |
| 6704 } | 6594 } |
| 6705 | 6595 |
| 6706 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 6596 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 6707 | 6597 |
| 6708 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 6598 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 6709 LayerTreeHostImpl::FrameData* frame_data, | 6599 LayerTreeHostImpl::FrameData* frame_data, |
| 6710 DrawResult draw_result) override { | 6600 DrawResult draw_result) override { |
| 6711 EXPECT_EQ(2u, frame_data->render_passes.size()); | 6601 EXPECT_EQ(2u, frame_data->render_passes.size()); |
| 6712 RenderPass* root_pass = frame_data->render_passes.back().get(); | 6602 RenderPass* root_pass = frame_data->render_passes.back().get(); |
| 6713 EXPECT_EQ(2u, root_pass->quad_list.size()); | 6603 EXPECT_EQ(2u, root_pass->quad_list.size()); |
| 6714 | 6604 |
| 6715 // There's a solid color quad under everything. | 6605 // There's a solid color quad under everything. |
| 6716 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material); | 6606 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material); |
| 6717 | 6607 |
| 6718 // The surface is clipped to 10x20. | 6608 // The surface is clipped to 10x20. |
| 6719 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); | 6609 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); |
| 6720 const RenderPassDrawQuad* render_pass_quad = | 6610 const RenderPassDrawQuad* render_pass_quad = |
| 6721 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); | 6611 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); |
| 6722 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), | 6612 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), |
| 6723 render_pass_quad->rect.ToString()); | 6613 render_pass_quad->rect.ToString()); |
| 6724 // The masked layer is 50x50, but the surface size is 10x20. So the texture | 6614 // The masked layer is 50x50, but the surface size is 10x20. So the texture |
| 6725 // coords in the mask are scaled by 10/50 and 20/50. | 6615 // coords in the mask are scaled by 10/50 and 20/50. |
| 6726 // The surface is clipped to (20,10) so the mask texture coords are offset | 6616 // The surface is clipped to (20,10) so the mask texture coords are offset |
| 6727 // by 20/50 and 10/50 | 6617 // by 20/50 and 10/50 |
| 6728 if (host_impl->settings().enable_mask_tiling) { | 6618 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 1.f / 50.f) |
| 6729 PictureLayerImpl* mask_layer_impl = static_cast<PictureLayerImpl*>( | 6619 .ToString(), |
| 6730 host_impl->active_tree()->LayerById(mask_layer_id_)); | 6620 render_pass_quad->mask_uv_rect.ToString()); |
| 6731 gfx::SizeF texture_size( | |
| 6732 mask_layer_impl->CalculateTileSize(mask_layer_impl->bounds())); | |
| 6733 EXPECT_EQ( | |
| 6734 gfx::RectF(20.f / texture_size.width(), 10.f / texture_size.height(), | |
| 6735 10.f / texture_size.width(), 20.f / texture_size.height()) | |
| 6736 .ToString(), | |
| 6737 render_pass_quad->mask_uv_rect.ToString()); | |
| 6738 } else { | |
| 6739 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 1.f / 50.f) | |
| 6740 .ToString(), | |
| 6741 render_pass_quad->mask_uv_rect.ToString()); | |
| 6742 } | |
| 6743 EndTest(); | 6621 EndTest(); |
| 6744 return draw_result; | 6622 return draw_result; |
| 6745 } | 6623 } |
| 6746 | 6624 |
| 6747 void AfterTest() override {} | 6625 void AfterTest() override {} |
| 6748 | 6626 |
| 6749 int mask_layer_id_; | |
| 6750 FakeContentLayerClient client_; | 6627 FakeContentLayerClient client_; |
| 6751 }; | 6628 }; |
| 6752 | 6629 |
| 6753 SINGLE_AND_MULTI_THREAD_TEST_F( | 6630 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 6754 LayerTreeTestMaskLayerForSurfaceWithClippedLayer); | 6631 LayerTreeTestMaskLayerForSurfaceWithClippedLayer); |
| 6755 | 6632 |
| 6756 class LayerTreeTestMaskLayerWithScaling : public LayerTreeTest { | 6633 class LayerTreeTestMaskLayerWithScaling : public LayerTreeTest { |
| 6757 protected: | 6634 protected: |
| 6758 void InitializeSettings(LayerTreeSettings* settings) override { | 6635 void InitializeSettings(LayerTreeSettings* settings) override { |
| 6759 settings->layer_transforms_should_scale_layer_contents = true; | 6636 settings->layer_transforms_should_scale_layer_contents = true; |
| 6760 } | 6637 } |
| 6761 | 6638 |
| 6762 void SetupTree() override { | 6639 void SetupTree() override { |
| 6763 // Root | 6640 // Root |
| 6764 // | | 6641 // | |
| 6765 // +-- Scaling Layer (adds a 2x scale) | 6642 // +-- Scaling Layer (adds a 2x scale) |
| 6766 // | | 6643 // | |
| 6767 // +-- Content Layer | 6644 // +-- Content Layer |
| 6768 // +--Mask | 6645 // +--Mask |
| 6769 | 6646 |
| 6770 scoped_refptr<Layer> root = Layer::Create(); | 6647 scoped_refptr<Layer> root = Layer::Create(); |
| 6771 | 6648 |
| 6772 scoped_refptr<Layer> scaling_layer = Layer::Create(); | 6649 scoped_refptr<Layer> scaling_layer = Layer::Create(); |
| 6773 root->AddChild(scaling_layer); | 6650 root->AddChild(scaling_layer); |
| 6774 | 6651 |
| 6775 scoped_refptr<FakePictureLayer> content_layer = | 6652 scoped_refptr<FakePictureLayer> content_layer = |
| 6776 FakePictureLayer::Create(&client_); | 6653 FakePictureLayer::Create(&client_); |
| 6777 scaling_layer->AddChild(content_layer); | 6654 scaling_layer->AddChild(content_layer); |
| 6778 | 6655 |
| 6779 std::unique_ptr<RecordingSource> recording_source = | |
| 6780 FakeRecordingSource::CreateFilledRecordingSource(gfx::Size(100, 100)); | |
| 6781 PaintFlags paint1, paint2; | |
| 6782 static_cast<FakeRecordingSource*>(recording_source.get()) | |
| 6783 ->add_draw_rect_with_flags(gfx::Rect(0, 0, 100, 10), paint1); | |
| 6784 static_cast<FakeRecordingSource*>(recording_source.get()) | |
| 6785 ->add_draw_rect_with_flags(gfx::Rect(0, 10, 100, 90), paint2); | |
| 6786 client_.set_fill_with_nonsolid_color(true); | |
| 6787 static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord(); | |
| 6788 | |
| 6789 scoped_refptr<FakePictureLayer> mask_layer = | 6656 scoped_refptr<FakePictureLayer> mask_layer = |
| 6790 FakePictureLayer::CreateWithRecordingSource( | 6657 FakePictureLayer::Create(&client_); |
| 6791 &client_, std::move(recording_source)); | |
| 6792 content_layer->SetMaskLayer(mask_layer.get()); | 6658 content_layer->SetMaskLayer(mask_layer.get()); |
| 6793 | 6659 |
| 6794 gfx::Size root_size(100, 100); | 6660 gfx::Size root_size(100, 100); |
| 6795 root->SetBounds(root_size); | 6661 root->SetBounds(root_size); |
| 6796 | 6662 |
| 6797 gfx::Size scaling_layer_size(50, 50); | 6663 gfx::Size scaling_layer_size(50, 50); |
| 6798 scaling_layer->SetBounds(scaling_layer_size); | 6664 scaling_layer->SetBounds(scaling_layer_size); |
| 6799 gfx::Transform scale; | 6665 gfx::Transform scale; |
| 6800 scale.Scale(2.f, 2.f); | 6666 scale.Scale(2.f, 2.f); |
| 6801 scaling_layer->SetTransform(scale); | 6667 scaling_layer->SetTransform(scale); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6824 | 6690 |
| 6825 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); | 6691 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); |
| 6826 const RenderPassDrawQuad* render_pass_quad = | 6692 const RenderPassDrawQuad* render_pass_quad = |
| 6827 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); | 6693 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); |
| 6828 switch (host_impl->active_tree()->source_frame_number()) { | 6694 switch (host_impl->active_tree()->source_frame_number()) { |
| 6829 case 0: | 6695 case 0: |
| 6830 // Check that the tree scaling is correctly taken into account for the | 6696 // Check that the tree scaling is correctly taken into account for the |
| 6831 // mask, that should fully map onto the quad. | 6697 // mask, that should fully map onto the quad. |
| 6832 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 6698 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 6833 render_pass_quad->rect.ToString()); | 6699 render_pass_quad->rect.ToString()); |
| 6834 if (host_impl->settings().enable_mask_tiling) { | 6700 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6835 EXPECT_EQ( | 6701 render_pass_quad->mask_uv_rect.ToString()); |
| 6836 gfx::RectF(0.f, 0.f, 100.f / 128.f, 100.f / 128.f).ToString(), | |
| 6837 render_pass_quad->mask_uv_rect.ToString()); | |
| 6838 } else { | |
| 6839 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | |
| 6840 render_pass_quad->mask_uv_rect.ToString()); | |
| 6841 } | |
| 6842 break; | 6702 break; |
| 6843 case 1: | 6703 case 1: |
| 6844 // Applying a DSF should change the render surface size, but won't | 6704 // Applying a DSF should change the render surface size, but won't |
| 6845 // affect which part of the mask is used. | 6705 // affect which part of the mask is used. |
| 6846 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), | 6706 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), |
| 6847 render_pass_quad->rect.ToString()); | 6707 render_pass_quad->rect.ToString()); |
| 6848 if (host_impl->settings().enable_mask_tiling) { | 6708 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6849 EXPECT_EQ( | 6709 render_pass_quad->mask_uv_rect.ToString()); |
| 6850 gfx::RectF(0.f, 0.f, 100.f / 128.f, 100.f / 128.f).ToString(), | |
| 6851 render_pass_quad->mask_uv_rect.ToString()); | |
| 6852 } else { | |
| 6853 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | |
| 6854 render_pass_quad->mask_uv_rect.ToString()); | |
| 6855 } | |
| 6856 EndTest(); | 6710 EndTest(); |
| 6857 break; | 6711 break; |
| 6858 } | 6712 } |
| 6859 return draw_result; | 6713 return draw_result; |
| 6860 } | 6714 } |
| 6861 | 6715 |
| 6862 void DidCommit() override { | 6716 void DidCommit() override { |
| 6863 switch (layer_tree_host()->SourceFrameNumber()) { | 6717 switch (layer_tree_host()->SourceFrameNumber()) { |
| 6864 case 1: | 6718 case 1: |
| 6865 gfx::Size double_root_size(200, 200); | 6719 gfx::Size double_root_size(200, 200); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6881 void SetupTree() override { | 6735 void SetupTree() override { |
| 6882 // The mask layer has bounds 100x100 but is attached to a layer with bounds | 6736 // The mask layer has bounds 100x100 but is attached to a layer with bounds |
| 6883 // 50x50. | 6737 // 50x50. |
| 6884 | 6738 |
| 6885 scoped_refptr<Layer> root = Layer::Create(); | 6739 scoped_refptr<Layer> root = Layer::Create(); |
| 6886 | 6740 |
| 6887 scoped_refptr<FakePictureLayer> content_layer = | 6741 scoped_refptr<FakePictureLayer> content_layer = |
| 6888 FakePictureLayer::Create(&client_); | 6742 FakePictureLayer::Create(&client_); |
| 6889 root->AddChild(content_layer); | 6743 root->AddChild(content_layer); |
| 6890 | 6744 |
| 6891 std::unique_ptr<RecordingSource> recording_source = | |
| 6892 FakeRecordingSource::CreateFilledRecordingSource(gfx::Size(100, 100)); | |
| 6893 PaintFlags paint1, paint2; | |
| 6894 static_cast<FakeRecordingSource*>(recording_source.get()) | |
| 6895 ->add_draw_rect_with_flags(gfx::Rect(0, 0, 100, 90), paint1); | |
| 6896 static_cast<FakeRecordingSource*>(recording_source.get()) | |
| 6897 ->add_draw_rect_with_flags(gfx::Rect(0, 90, 100, 10), paint2); | |
| 6898 client_.set_fill_with_nonsolid_color(true); | |
| 6899 static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord(); | |
| 6900 | |
| 6901 scoped_refptr<FakePictureLayer> mask_layer = | 6745 scoped_refptr<FakePictureLayer> mask_layer = |
| 6902 FakePictureLayer::CreateWithRecordingSource( | 6746 FakePictureLayer::Create(&client_); |
| 6903 &client_, std::move(recording_source)); | |
| 6904 content_layer->SetMaskLayer(mask_layer.get()); | 6747 content_layer->SetMaskLayer(mask_layer.get()); |
| 6905 | 6748 |
| 6906 gfx::Size root_size(100, 100); | 6749 gfx::Size root_size(100, 100); |
| 6907 root->SetBounds(root_size); | 6750 root->SetBounds(root_size); |
| 6908 | 6751 |
| 6909 gfx::Size layer_size(50, 50); | 6752 gfx::Size layer_size(50, 50); |
| 6910 content_layer->SetBounds(layer_size); | 6753 content_layer->SetBounds(layer_size); |
| 6911 | 6754 |
| 6912 gfx::Size mask_size(100, 100); | 6755 gfx::Size mask_size(100, 100); |
| 6913 mask_layer->SetBounds(mask_size); | 6756 mask_layer->SetBounds(mask_size); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 6931 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material); | 6774 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material); |
| 6932 | 6775 |
| 6933 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); | 6776 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); |
| 6934 const RenderPassDrawQuad* render_pass_quad = | 6777 const RenderPassDrawQuad* render_pass_quad = |
| 6935 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); | 6778 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); |
| 6936 switch (host_impl->active_tree()->source_frame_number()) { | 6779 switch (host_impl->active_tree()->source_frame_number()) { |
| 6937 case 0: | 6780 case 0: |
| 6938 // Check that the mask fills the surface. | 6781 // Check that the mask fills the surface. |
| 6939 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 6782 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 6940 render_pass_quad->rect.ToString()); | 6783 render_pass_quad->rect.ToString()); |
| 6941 if (host_impl->settings().enable_mask_tiling) { | 6784 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6942 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 128.f, 50.f / 128.f).ToString(), | 6785 render_pass_quad->mask_uv_rect.ToString()); |
| 6943 render_pass_quad->mask_uv_rect.ToString()); | |
| 6944 } else { | |
| 6945 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | |
| 6946 render_pass_quad->mask_uv_rect.ToString()); | |
| 6947 } | |
| 6948 break; | 6786 break; |
| 6949 case 1: | 6787 case 1: |
| 6950 // Applying a DSF should change the render surface size, but won't | 6788 // Applying a DSF should change the render surface size, but won't |
| 6951 // affect which part of the mask is used. | 6789 // affect which part of the mask is used. |
| 6952 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 6790 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 6953 render_pass_quad->rect.ToString()); | 6791 render_pass_quad->rect.ToString()); |
| 6954 if (host_impl->settings().enable_mask_tiling) { | 6792 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6955 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 128.f, 50.f / 128.f).ToString(), | 6793 render_pass_quad->mask_uv_rect.ToString()); |
| 6956 render_pass_quad->mask_uv_rect.ToString()); | |
| 6957 } else { | |
| 6958 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | |
| 6959 render_pass_quad->mask_uv_rect.ToString()); | |
| 6960 } | |
| 6961 EndTest(); | 6794 EndTest(); |
| 6962 break; | 6795 break; |
| 6963 } | 6796 } |
| 6964 return draw_result; | 6797 return draw_result; |
| 6965 } | 6798 } |
| 6966 | 6799 |
| 6967 void DidCommit() override { | 6800 void DidCommit() override { |
| 6968 switch (layer_tree_host()->SourceFrameNumber()) { | 6801 switch (layer_tree_host()->SourceFrameNumber()) { |
| 6969 case 1: | 6802 case 1: |
| 6970 gfx::Size double_root_size(200, 200); | 6803 gfx::Size double_root_size(200, 200); |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7493 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index()); | 7326 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index()); |
| 7494 } | 7327 } |
| 7495 | 7328 |
| 7496 void AfterTest() override {} | 7329 void AfterTest() override {} |
| 7497 }; | 7330 }; |
| 7498 | 7331 |
| 7499 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists); | 7332 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists); |
| 7500 | 7333 |
| 7501 } // namespace | 7334 } // namespace |
| 7502 } // namespace cc | 7335 } // namespace cc |
| OLD | NEW |