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

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

Issue 2828353003: Determine mask UVs based on texture size (Closed)
Patch Set: Feedback Created 3 years, 7 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 7035 matching lines...) Expand 10 before | Expand all | Expand 10 after
7046 : public LayerTreeTestMaskLayerWithDifferentBounds { 7046 : public LayerTreeTestMaskLayerWithDifferentBounds {
7047 public: 7047 public:
7048 void InitializeSettings(LayerTreeSettings* settings) override { 7048 void InitializeSettings(LayerTreeSettings* settings) override {
7049 settings->enable_mask_tiling = true; 7049 settings->enable_mask_tiling = true;
7050 } 7050 }
7051 }; 7051 };
7052 7052
7053 SINGLE_AND_MULTI_THREAD_TEST_F( 7053 SINGLE_AND_MULTI_THREAD_TEST_F(
7054 LayerTreeTestMultiTextureMaskLayerWithDifferentBounds); 7054 LayerTreeTestMultiTextureMaskLayerWithDifferentBounds);
7055 7055
7056 class LayerTreeTestMaskWithNonExactTextureSize : public LayerTreeTest {
7057 protected:
7058 void SetupTree() override {
7059 // The masked layer has bounds 100x100, but is allocated a 120x150 texture.
7060
7061 scoped_refptr<Layer> root = Layer::Create();
7062
7063 scoped_refptr<FakePictureLayer> content_layer =
7064 FakePictureLayer::Create(&client_);
7065 root->AddChild(content_layer);
7066
7067 std::unique_ptr<RecordingSource> recording_source =
7068 FakeRecordingSource::CreateFilledRecordingSource(gfx::Size(100, 100));
7069 PaintFlags paint1, paint2;
7070 static_cast<FakeRecordingSource*>(recording_source.get())
7071 ->add_draw_rect_with_flags(gfx::Rect(0, 0, 100, 90), paint1);
7072 static_cast<FakeRecordingSource*>(recording_source.get())
7073 ->add_draw_rect_with_flags(gfx::Rect(0, 90, 100, 10), paint2);
7074 client_.set_fill_with_nonsolid_color(true);
7075 static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord();
7076
7077 scoped_refptr<FakePictureLayer> mask_layer =
7078 FakePictureLayer::CreateWithRecordingSource(
7079 &client_, std::move(recording_source));
7080 content_layer->SetMaskLayer(mask_layer.get());
7081
7082 gfx::Size root_size(100, 100);
7083 root->SetBounds(root_size);
7084
7085 gfx::Size layer_size(100, 100);
7086 content_layer->SetBounds(layer_size);
7087
7088 gfx::Size mask_size(100, 100);
7089 gfx::Size mask_texture_size(120, 150);
7090 mask_layer->SetBounds(mask_size);
7091 mask_layer->SetLayerMaskType(Layer::LayerMaskType::SINGLE_TEXTURE_MASK);
7092 mask_layer->set_fixed_tile_size(mask_texture_size);
7093
7094 layer_tree_host()->SetRootLayer(root);
7095 LayerTreeTest::SetupTree();
7096 client_.set_bounds(root->bounds());
7097 }
7098
7099 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
7100
7101 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
7102 LayerTreeHostImpl::FrameData* frame_data,
7103 DrawResult draw_result) override {
7104 EXPECT_EQ(2u, frame_data->render_passes.size());
7105 RenderPass* root_pass = frame_data->render_passes.back().get();
7106 EXPECT_EQ(2u, root_pass->quad_list.size());
7107
7108 // There's a solid color quad under everything.
7109 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material);
7110
7111 // The surface is 100x100
7112 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material);
7113 const RenderPassDrawQuad* render_pass_quad =
7114 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front());
7115 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
7116 render_pass_quad->rect.ToString());
7117 // The mask layer is 100x100, but is backed by a 120x150 image.
7118 EXPECT_EQ(gfx::RectF(0.0f, 0.0f, 100.f / 120.0f, 100.f / 150.0f).ToString(),
7119 render_pass_quad->mask_uv_rect.ToString());
7120 EndTest();
7121 return draw_result;
7122 }
7123
7124 void AfterTest() override {}
7125
7126 int mask_layer_id_;
7127 FakeContentLayerClient client_;
7128 };
7129
7130 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestMaskWithNonExactTextureSize);
7131
7056 class LayerTreeTestPageScaleFlags : public LayerTreeTest { 7132 class LayerTreeTestPageScaleFlags : public LayerTreeTest {
7057 protected: 7133 protected:
7058 void SetupTree() override { 7134 void SetupTree() override {
7059 // -root 7135 // -root
7060 // -pre page scale 7136 // -pre page scale
7061 // -page scale 7137 // -page scale
7062 // -page scale child1 7138 // -page scale child1
7063 // -page scale grandchild 7139 // -page scale grandchild
7064 // -page scale child2 7140 // -page scale child2
7065 // -post page scale 7141 // -post page scale
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
7645 void AfterTest() override {} 7721 void AfterTest() override {}
7646 7722
7647 private: 7723 private:
7648 bool received_ack_ = false; 7724 bool received_ack_ = false;
7649 }; 7725 };
7650 7726
7651 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); 7727 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease);
7652 7728
7653 } // namespace 7729 } // namespace
7654 } // namespace cc 7730 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_pixeltest_masks.cc ('K') | « cc/trees/layer_tree_host_pixeltest_masks.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698