Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698