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

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

Issue 2717533005: cc: RenderSurfaceImpl tile mask layer. (Closed)
Patch Set: Fix init problems on mac. 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
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 6550 matching lines...) Expand 10 before | Expand all | Expand 10 after
6561 root->AddChild(clipping_layer); 6561 root->AddChild(clipping_layer);
6562 6562
6563 scoped_refptr<FakePictureLayer> content_layer = 6563 scoped_refptr<FakePictureLayer> content_layer =
6564 FakePictureLayer::Create(&client_); 6564 FakePictureLayer::Create(&client_);
6565 clipping_layer->AddChild(content_layer); 6565 clipping_layer->AddChild(content_layer);
6566 6566
6567 scoped_refptr<FakePictureLayer> content_child_layer = 6567 scoped_refptr<FakePictureLayer> content_child_layer =
6568 FakePictureLayer::Create(&client_); 6568 FakePictureLayer::Create(&client_);
6569 content_layer->AddChild(content_child_layer); 6569 content_layer->AddChild(content_child_layer);
6570 6570
6571 std::unique_ptr<RecordingSource> recording_source =
6572 FakeRecordingSource::CreateFilledRecordingSource(gfx::Size(100, 100));
6573 PaintFlags paint1, paint2;
6574 static_cast<FakeRecordingSource*>(recording_source.get())
6575 ->add_draw_rect_with_flags(gfx::Rect(0, 0, 100, 90), paint1);
6576 static_cast<FakeRecordingSource*>(recording_source.get())
6577 ->add_draw_rect_with_flags(gfx::Rect(0, 90, 100, 10), paint2);
6578 client_.set_fill_with_nonsolid_color(true);
6579 static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord();
6580
6571 scoped_refptr<FakePictureLayer> mask_layer = 6581 scoped_refptr<FakePictureLayer> mask_layer =
6572 FakePictureLayer::Create(&client_); 6582 FakePictureLayer::CreateWithRecordingSource(
6583 &client_, std::move(recording_source));
6573 content_layer->SetMaskLayer(mask_layer.get()); 6584 content_layer->SetMaskLayer(mask_layer.get());
6574 6585
6575 gfx::Size root_size(100, 100); 6586 gfx::Size root_size(100, 100);
6576 root->SetBounds(root_size); 6587 root->SetBounds(root_size);
6577 6588
6578 gfx::PointF clipping_origin(20.f, 10.f); 6589 gfx::PointF clipping_origin(20.f, 10.f);
6579 gfx::Size clipping_size(10, 20); 6590 gfx::Size clipping_size(10, 20);
6580 clipping_layer->SetBounds(clipping_size); 6591 clipping_layer->SetBounds(clipping_size);
6581 clipping_layer->SetPosition(clipping_origin); 6592 clipping_layer->SetPosition(clipping_origin);
6582 clipping_layer->SetMasksToBounds(true); 6593 clipping_layer->SetMasksToBounds(true);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
6614 // The surface is clipped to 10x20. 6625 // The surface is clipped to 10x20.
6615 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); 6626 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material);
6616 const RenderPassDrawQuad* render_pass_quad = 6627 const RenderPassDrawQuad* render_pass_quad =
6617 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); 6628 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front());
6618 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), 6629 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(),
6619 render_pass_quad->rect.ToString()); 6630 render_pass_quad->rect.ToString());
6620 // The masked layer is 50x50, but the surface size is 10x20. So the texture 6631 // The masked layer is 50x50, but the surface size is 10x20. So the texture
6621 // coords in the mask are scaled by 10/50 and 20/50. 6632 // coords in the mask are scaled by 10/50 and 20/50.
6622 // The surface is clipped to (20,10) so the mask texture coords are offset 6633 // The surface is clipped to (20,10) so the mask texture coords are offset
6623 // by 20/50 and 10/50 6634 // by 20/50 and 10/50
6624 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 1.f / 50.f) 6635 if (host_impl->settings().enable_mask_tiling) {
enne (OOO) 2017/03/28 14:10:22 Hmm. What's the end state of mask tiling? I assu
sunxd 2017/03/29 16:00:24 The flag is going away once we fix the AA and filt
enne (OOO) 2017/03/29 16:07:25 Ok, then it sounds like we needs two kinds of test
sunxd 2017/03/30 13:56:37 I can, but the flag will go away shortly. Single t
sunxd 2017/04/04 13:58:04 As this change blocks AA patch, can I write the te
6625 .ToString(), 6636 EXPECT_EQ(
6626 render_pass_quad->mask_uv_rect.ToString()); 6637 gfx::RectF(20.f / 128.f, 10.f / 128.f, 10.f / 128.f, 20.f / 128.f)
enne (OOO) 2017/03/28 14:10:22 Where does 128 come from? I'm guessing that's roun
sunxd 2017/03/29 16:00:24 It's an unchecked round up with 64. While 64 is de
enne (OOO) 2017/03/29 16:07:25 Can you make this based on the resource size, or s
sunxd 2017/03/30 13:56:37 Done.
6638 .ToString(),
6639 render_pass_quad->mask_uv_rect.ToString());
6640 } else {
6641 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 1.f / 50.f)
6642 .ToString(),
6643 render_pass_quad->mask_uv_rect.ToString());
6644 }
6627 EndTest(); 6645 EndTest();
6628 return draw_result; 6646 return draw_result;
6629 } 6647 }
6630 6648
6631 void AfterTest() override {} 6649 void AfterTest() override {}
6632 6650
6633 FakeContentLayerClient client_; 6651 FakeContentLayerClient client_;
6634 }; 6652 };
6635 6653
6636 SINGLE_AND_MULTI_THREAD_TEST_F( 6654 SINGLE_AND_MULTI_THREAD_TEST_F(
(...skipping 15 matching lines...) Expand all
6652 6670
6653 scoped_refptr<Layer> root = Layer::Create(); 6671 scoped_refptr<Layer> root = Layer::Create();
6654 6672
6655 scoped_refptr<Layer> scaling_layer = Layer::Create(); 6673 scoped_refptr<Layer> scaling_layer = Layer::Create();
6656 root->AddChild(scaling_layer); 6674 root->AddChild(scaling_layer);
6657 6675
6658 scoped_refptr<FakePictureLayer> content_layer = 6676 scoped_refptr<FakePictureLayer> content_layer =
6659 FakePictureLayer::Create(&client_); 6677 FakePictureLayer::Create(&client_);
6660 scaling_layer->AddChild(content_layer); 6678 scaling_layer->AddChild(content_layer);
6661 6679
6680 std::unique_ptr<RecordingSource> recording_source =
6681 FakeRecordingSource::CreateFilledRecordingSource(gfx::Size(100, 100));
6682 PaintFlags paint1, paint2;
6683 static_cast<FakeRecordingSource*>(recording_source.get())
6684 ->add_draw_rect_with_flags(gfx::Rect(0, 0, 100, 10), paint1);
6685 static_cast<FakeRecordingSource*>(recording_source.get())
6686 ->add_draw_rect_with_flags(gfx::Rect(0, 10, 100, 90), paint2);
6687 client_.set_fill_with_nonsolid_color(true);
6688 static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord();
6689
6662 scoped_refptr<FakePictureLayer> mask_layer = 6690 scoped_refptr<FakePictureLayer> mask_layer =
6663 FakePictureLayer::Create(&client_); 6691 FakePictureLayer::CreateWithRecordingSource(
6692 &client_, std::move(recording_source));
6664 content_layer->SetMaskLayer(mask_layer.get()); 6693 content_layer->SetMaskLayer(mask_layer.get());
6665 6694
6666 gfx::Size root_size(100, 100); 6695 gfx::Size root_size(100, 100);
6667 root->SetBounds(root_size); 6696 root->SetBounds(root_size);
6668 6697
6669 gfx::Size scaling_layer_size(50, 50); 6698 gfx::Size scaling_layer_size(50, 50);
6670 scaling_layer->SetBounds(scaling_layer_size); 6699 scaling_layer->SetBounds(scaling_layer_size);
6671 gfx::Transform scale; 6700 gfx::Transform scale;
6672 scale.Scale(2.f, 2.f); 6701 scale.Scale(2.f, 2.f);
6673 scaling_layer->SetTransform(scale); 6702 scaling_layer->SetTransform(scale);
(...skipping 22 matching lines...) Expand all
6696 6725
6697 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); 6726 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material);
6698 const RenderPassDrawQuad* render_pass_quad = 6727 const RenderPassDrawQuad* render_pass_quad =
6699 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); 6728 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front());
6700 switch (host_impl->active_tree()->source_frame_number()) { 6729 switch (host_impl->active_tree()->source_frame_number()) {
6701 case 0: 6730 case 0:
6702 // Check that the tree scaling is correctly taken into account for the 6731 // Check that the tree scaling is correctly taken into account for the
6703 // mask, that should fully map onto the quad. 6732 // mask, that should fully map onto the quad.
6704 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 6733 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
6705 render_pass_quad->rect.ToString()); 6734 render_pass_quad->rect.ToString());
6706 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 6735 if (host_impl->settings().enable_mask_tiling) {
6707 render_pass_quad->mask_uv_rect.ToString()); 6736 EXPECT_EQ(
6737 gfx::RectF(0.f, 0.f, 100.f / 128.f, 100.f / 128.f).ToString(),
enne (OOO) 2017/03/28 14:10:22 Are there any unit tests that have multiple mask t
sunxd 2017/03/29 16:00:24 I think this test is testing multiple tiles if the
enne (OOO) 2017/03/29 16:07:25 As I said above, can you make it work with both ki
sunxd 2017/03/30 13:56:37 Acknowledged.
6738 render_pass_quad->mask_uv_rect.ToString());
6739 } else {
6740 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
6741 render_pass_quad->mask_uv_rect.ToString());
6742 }
6708 break; 6743 break;
6709 case 1: 6744 case 1:
6710 // Applying a DSF should change the render surface size, but won't 6745 // Applying a DSF should change the render surface size, but won't
6711 // affect which part of the mask is used. 6746 // affect which part of the mask is used.
6712 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 6747 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
6713 render_pass_quad->rect.ToString()); 6748 render_pass_quad->rect.ToString());
6714 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 6749 if (host_impl->settings().enable_mask_tiling) {
6715 render_pass_quad->mask_uv_rect.ToString()); 6750 EXPECT_EQ(
6751 gfx::RectF(0.f, 0.f, 100.f / 128.f, 100.f / 128.f).ToString(),
6752 render_pass_quad->mask_uv_rect.ToString());
6753 } else {
6754 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
6755 render_pass_quad->mask_uv_rect.ToString());
6756 }
6716 EndTest(); 6757 EndTest();
6717 break; 6758 break;
6718 } 6759 }
6719 return draw_result; 6760 return draw_result;
6720 } 6761 }
6721 6762
6722 void DidCommit() override { 6763 void DidCommit() override {
6723 switch (layer_tree_host()->SourceFrameNumber()) { 6764 switch (layer_tree_host()->SourceFrameNumber()) {
6724 case 1: 6765 case 1:
6725 gfx::Size double_root_size(200, 200); 6766 gfx::Size double_root_size(200, 200);
(...skipping 15 matching lines...) Expand all
6741 void SetupTree() override { 6782 void SetupTree() override {
6742 // The mask layer has bounds 100x100 but is attached to a layer with bounds 6783 // The mask layer has bounds 100x100 but is attached to a layer with bounds
6743 // 50x50. 6784 // 50x50.
6744 6785
6745 scoped_refptr<Layer> root = Layer::Create(); 6786 scoped_refptr<Layer> root = Layer::Create();
6746 6787
6747 scoped_refptr<FakePictureLayer> content_layer = 6788 scoped_refptr<FakePictureLayer> content_layer =
6748 FakePictureLayer::Create(&client_); 6789 FakePictureLayer::Create(&client_);
6749 root->AddChild(content_layer); 6790 root->AddChild(content_layer);
6750 6791
6792 std::unique_ptr<RecordingSource> recording_source =
6793 FakeRecordingSource::CreateFilledRecordingSource(gfx::Size(100, 100));
6794 PaintFlags paint1, paint2;
6795 static_cast<FakeRecordingSource*>(recording_source.get())
6796 ->add_draw_rect_with_flags(gfx::Rect(0, 0, 100, 90), paint1);
6797 static_cast<FakeRecordingSource*>(recording_source.get())
6798 ->add_draw_rect_with_flags(gfx::Rect(0, 90, 100, 10), paint2);
6799 client_.set_fill_with_nonsolid_color(true);
6800 static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord();
6801
6751 scoped_refptr<FakePictureLayer> mask_layer = 6802 scoped_refptr<FakePictureLayer> mask_layer =
6752 FakePictureLayer::Create(&client_); 6803 FakePictureLayer::CreateWithRecordingSource(
6804 &client_, std::move(recording_source));
6753 content_layer->SetMaskLayer(mask_layer.get()); 6805 content_layer->SetMaskLayer(mask_layer.get());
6754 6806
6755 gfx::Size root_size(100, 100); 6807 gfx::Size root_size(100, 100);
6756 root->SetBounds(root_size); 6808 root->SetBounds(root_size);
6757 6809
6758 gfx::Size layer_size(50, 50); 6810 gfx::Size layer_size(50, 50);
6759 content_layer->SetBounds(layer_size); 6811 content_layer->SetBounds(layer_size);
6760 6812
6761 gfx::Size mask_size(100, 100); 6813 gfx::Size mask_size(100, 100);
6762 mask_layer->SetBounds(mask_size); 6814 mask_layer->SetBounds(mask_size);
(...skipping 17 matching lines...) Expand all
6780 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material); 6832 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material);
6781 6833
6782 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); 6834 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material);
6783 const RenderPassDrawQuad* render_pass_quad = 6835 const RenderPassDrawQuad* render_pass_quad =
6784 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); 6836 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front());
6785 switch (host_impl->active_tree()->source_frame_number()) { 6837 switch (host_impl->active_tree()->source_frame_number()) {
6786 case 0: 6838 case 0:
6787 // Check that the mask fills the surface. 6839 // Check that the mask fills the surface.
6788 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 6840 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
6789 render_pass_quad->rect.ToString()); 6841 render_pass_quad->rect.ToString());
6790 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 6842 if (host_impl->settings().enable_mask_tiling) {
6791 render_pass_quad->mask_uv_rect.ToString()); 6843 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 128.f, 50.f / 128.f).ToString(),
6844 render_pass_quad->mask_uv_rect.ToString());
6845 } else {
6846 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
6847 render_pass_quad->mask_uv_rect.ToString());
6848 }
6792 break; 6849 break;
6793 case 1: 6850 case 1:
6794 // Applying a DSF should change the render surface size, but won't 6851 // Applying a DSF should change the render surface size, but won't
6795 // affect which part of the mask is used. 6852 // affect which part of the mask is used.
6796 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 6853 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
6797 render_pass_quad->rect.ToString()); 6854 render_pass_quad->rect.ToString());
6798 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 6855 if (host_impl->settings().enable_mask_tiling) {
6799 render_pass_quad->mask_uv_rect.ToString()); 6856 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 128.f, 50.f / 128.f).ToString(),
6857 render_pass_quad->mask_uv_rect.ToString());
6858 } else {
6859 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
6860 render_pass_quad->mask_uv_rect.ToString());
6861 }
6800 EndTest(); 6862 EndTest();
6801 break; 6863 break;
6802 } 6864 }
6803 return draw_result; 6865 return draw_result;
6804 } 6866 }
6805 6867
6806 void DidCommit() override { 6868 void DidCommit() override {
6807 switch (layer_tree_host()->SourceFrameNumber()) { 6869 switch (layer_tree_host()->SourceFrameNumber()) {
6808 case 1: 6870 case 1:
6809 gfx::Size double_root_size(200, 200); 6871 gfx::Size double_root_size(200, 200);
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
7331 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index()); 7393 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index());
7332 } 7394 }
7333 7395
7334 void AfterTest() override {} 7396 void AfterTest() override {}
7335 }; 7397 };
7336 7398
7337 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists); 7399 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists);
7338 7400
7339 } // namespace 7401 } // namespace
7340 } // namespace cc 7402 } // namespace cc
OLDNEW
« cc/output/software_renderer.cc ('K') | « cc/trees/draw_property_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698