| 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 7300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7311 } | 7311 } |
| 7312 | 7312 |
| 7313 void AfterTest() override {} | 7313 void AfterTest() override {} |
| 7314 | 7314 |
| 7315 int mask_layer_id_; | 7315 int mask_layer_id_; |
| 7316 FakeContentLayerClient client_; | 7316 FakeContentLayerClient client_; |
| 7317 }; | 7317 }; |
| 7318 | 7318 |
| 7319 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestMaskWithNonExactTextureSize); | 7319 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestMaskWithNonExactTextureSize); |
| 7320 | 7320 |
| 7321 class LayerTreeTestSolidColorMaskLayer : public LayerTreeTest { |
| 7322 protected: |
| 7323 void SetupTree() override { |
| 7324 // Root |
| 7325 // | |
| 7326 // +-- Content Layer |
| 7327 // +--Mask |
| 7328 scoped_refptr<Layer> root = Layer::Create(); |
| 7329 scoped_refptr<FakePictureLayer> content_layer = |
| 7330 FakePictureLayer::Create(&client_); |
| 7331 root->AddChild(content_layer); |
| 7332 gfx::Size content_size(100, 100); |
| 7333 std::unique_ptr<RecordingSource> recording_source = |
| 7334 FakeRecordingSource::CreateFilledRecordingSource(content_size); |
| 7335 PaintFlags paint; |
| 7336 static_cast<FakeRecordingSource*>(recording_source.get()) |
| 7337 ->add_draw_rect_with_flags(gfx::Rect(content_size), paint); |
| 7338 |
| 7339 client_.set_fill_with_nonsolid_color(true); |
| 7340 static_cast<FakeRecordingSource*>(recording_source.get())->Rerecord(); |
| 7341 scoped_refptr<FakePictureLayer> mask_layer = |
| 7342 FakePictureLayer::CreateWithRecordingSource( |
| 7343 &client_, std::move(recording_source)); |
| 7344 content_layer->SetMaskLayer(mask_layer.get()); |
| 7345 gfx::Size root_size(100, 100); |
| 7346 root->SetBounds(root_size); |
| 7347 content_layer->SetBounds(content_size); |
| 7348 |
| 7349 mask_layer->SetBounds(content_size); |
| 7350 mask_layer->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); |
| 7351 |
| 7352 layer_tree_host()->SetRootLayer(root); |
| 7353 LayerTreeTest::SetupTree(); |
| 7354 client_.set_bounds(root->bounds()); |
| 7355 } |
| 7356 |
| 7357 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 7358 |
| 7359 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 7360 LayerTreeHostImpl::FrameData* frame_data, |
| 7361 DrawResult draw_result) override { |
| 7362 EXPECT_EQ(2u, frame_data->render_passes.size()); |
| 7363 RenderPass* root_pass = frame_data->render_passes.back().get(); |
| 7364 EXPECT_EQ(2u, root_pass->quad_list.size()); |
| 7365 |
| 7366 // There's a solid color quad under everything. |
| 7367 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material); |
| 7368 |
| 7369 // Mask layer tiles should not be skipped even if the mask layer is solid |
| 7370 // color. |
| 7371 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); |
| 7372 const RenderPassDrawQuad* render_pass_quad = |
| 7373 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); |
| 7374 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 7375 render_pass_quad->rect.ToString()); |
| 7376 EXPECT_EQ(gfx::RectF().ToString(), |
| 7377 |
| 7378 render_pass_quad->mask_uv_rect.ToString()); |
| 7379 EndTest(); |
| 7380 return draw_result; |
| 7381 } |
| 7382 |
| 7383 void AfterTest() override {} |
| 7384 |
| 7385 FakeContentLayerClient client_; |
| 7386 }; |
| 7387 |
| 7388 class LayerTreeTestSingleTextureSolidColorMaskLayer |
| 7389 : public LayerTreeTestSolidColorMaskLayer { |
| 7390 public: |
| 7391 void InitializeSettings(LayerTreeSettings* settings) override { |
| 7392 settings->enable_mask_tiling = false; |
| 7393 } |
| 7394 }; |
| 7395 |
| 7396 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestSingleTextureSolidColorMaskLayer); |
| 7397 |
| 7398 class LayerTreeTestMultiTextureSolidColorMaskLayer |
| 7399 : public LayerTreeTestSolidColorMaskLayer { |
| 7400 public: |
| 7401 void InitializeSettings(LayerTreeSettings* settings) override { |
| 7402 settings->enable_mask_tiling = true; |
| 7403 } |
| 7404 }; |
| 7405 |
| 7406 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestMultiTextureSolidColorMaskLayer); |
| 7407 |
| 7321 class LayerTreeTestPageScaleFlags : public LayerTreeTest { | 7408 class LayerTreeTestPageScaleFlags : public LayerTreeTest { |
| 7322 protected: | 7409 protected: |
| 7323 void SetupTree() override { | 7410 void SetupTree() override { |
| 7324 // -root | 7411 // -root |
| 7325 // -pre page scale | 7412 // -pre page scale |
| 7326 // -page scale | 7413 // -page scale |
| 7327 // -page scale child1 | 7414 // -page scale child1 |
| 7328 // -page scale grandchild | 7415 // -page scale grandchild |
| 7329 // -page scale child2 | 7416 // -page scale child2 |
| 7330 // -post page scale | 7417 // -post page scale |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7937 void AfterTest() override {} | 8024 void AfterTest() override {} |
| 7938 | 8025 |
| 7939 private: | 8026 private: |
| 7940 bool received_ack_ = false; | 8027 bool received_ack_ = false; |
| 7941 }; | 8028 }; |
| 7942 | 8029 |
| 7943 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); | 8030 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); |
| 7944 | 8031 |
| 7945 } // namespace | 8032 } // namespace |
| 7946 } // namespace cc | 8033 } // namespace cc |
| OLD | NEW |