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

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

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