| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "cc/layers/layer_iterator.h" | 8 #include "cc/layers/layer_iterator.h" |
| 9 #include "cc/output/copy_output_request.h" | 9 #include "cc/output/copy_output_request.h" |
| 10 #include "cc/output/copy_output_result.h" | 10 #include "cc/output/copy_output_result.h" |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 471 |
| 472 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) { | 472 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) { |
| 473 EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread()); | 473 EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread()); |
| 474 EXPECT_EQ(copy_layer_->bounds().ToString(), result->size().ToString()); | 474 EXPECT_EQ(copy_layer_->bounds().ToString(), result->size().ToString()); |
| 475 EndTest(); | 475 EndTest(); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 478 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 479 Renderer* renderer = host_impl->renderer(); | 479 Renderer* renderer = host_impl->renderer(); |
| 480 | 480 |
| 481 LayerImpl* root = host_impl->active_tree()->root_layer(); | 481 LayerImpl* parent = |
| 482 LayerImpl* grand_parent = root->children()[0]; | 482 host_impl->active_tree()->LayerById(parent_layer_->id()); |
| 483 LayerImpl* parent = grand_parent->children()[0]; | 483 LayerImpl* copy_layer = |
| 484 LayerImpl* copy_layer = parent->children()[0]; | 484 host_impl->active_tree()->LayerById(copy_layer_->id()); |
| 485 | 485 |
| 486 // |parent| owns a surface, but it was hidden and not part of the copy | 486 // |parent| owns a surface, but it was hidden and not part of the copy |
| 487 // request so it should not allocate any resource. | 487 // request so it should not allocate any resource. |
| 488 EXPECT_FALSE(renderer->HasAllocatedResourcesForTesting( | 488 EXPECT_FALSE(renderer->HasAllocatedResourcesForTesting( |
| 489 parent->render_surface()->GetRenderPassId())); | 489 parent->render_surface()->GetRenderPassId())); |
| 490 | 490 |
| 491 // |copy_layer| should have been rendered to a texture since it was needed | 491 // |copy_layer| should have been rendered to a texture since it was needed |
| 492 // for a copy request. | 492 // for a copy request. |
| 493 if (did_draw_) { | 493 if (did_draw_) { |
| 494 // TODO(crbug.com/564832): Ignore the extra frame that occurs due to copy | 494 // TODO(crbug.com/564832): Ignore the extra frame that occurs due to copy |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 PostSetNeedsCommitToMainThread(); | 647 PostSetNeedsCommitToMainThread(); |
| 648 | 648 |
| 649 // Prevent drawing. | 649 // Prevent drawing. |
| 650 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); | 650 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); |
| 651 | 651 |
| 652 AddCopyRequest(copy_layer_.get()); | 652 AddCopyRequest(copy_layer_.get()); |
| 653 } | 653 } |
| 654 | 654 |
| 655 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 655 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 656 if (impl->active_tree()->source_frame_number() == 0) { | 656 if (impl->active_tree()->source_frame_number() == 0) { |
| 657 LayerImpl* root = impl->active_tree()->root_layer(); | 657 EXPECT_TRUE(impl->active_tree()->LayerById(copy_layer_->id())); |
| 658 EXPECT_TRUE(root->children()[0]->HasCopyRequest()); | |
| 659 saw_copy_request_ = true; | 658 saw_copy_request_ = true; |
| 660 } | 659 } |
| 661 } | 660 } |
| 662 | 661 |
| 663 void DidCommit() override { | 662 void DidCommit() override { |
| 664 if (layer_tree_host()->source_frame_number() == 1) { | 663 if (layer_tree_host()->source_frame_number() == 1) { |
| 665 // Allow drawing. | 664 // Allow drawing. |
| 666 layer_tree_host()->SetViewportSize(gfx::Size(root_->bounds())); | 665 layer_tree_host()->SetViewportSize(gfx::Size(root_->bounds())); |
| 667 | 666 |
| 668 AddCopyRequest(copy_layer_.get()); | 667 AddCopyRequest(copy_layer_.get()); |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 &LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest:: | 1185 &LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest:: |
| 1187 CopyOutputCallback, | 1186 CopyOutputCallback, |
| 1188 base::Unretained(this)))); | 1187 base::Unretained(this)))); |
| 1189 } | 1188 } |
| 1190 } | 1189 } |
| 1191 | 1190 |
| 1192 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 1191 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 1193 LayerTreeHostImpl::FrameData* frame_data, | 1192 LayerTreeHostImpl::FrameData* frame_data, |
| 1194 DrawResult draw_result) override { | 1193 DrawResult draw_result) override { |
| 1195 LayerImpl* root = host_impl->active_tree()->root_layer(); | 1194 LayerImpl* root = host_impl->active_tree()->root_layer(); |
| 1196 LayerImpl* child = root->children()[0]; | 1195 LayerImpl* child = host_impl->active_tree()->LayerById(child_->id()); |
| 1197 | 1196 |
| 1198 bool saw_root = false; | 1197 bool saw_root = false; |
| 1199 bool saw_child = false; | 1198 bool saw_child = false; |
| 1200 for (LayerIterator it = | 1199 for (LayerIterator it = |
| 1201 LayerIterator::Begin(frame_data->render_surface_layer_list); | 1200 LayerIterator::Begin(frame_data->render_surface_layer_list); |
| 1202 it != LayerIterator::End(frame_data->render_surface_layer_list); | 1201 it != LayerIterator::End(frame_data->render_surface_layer_list); |
| 1203 ++it) { | 1202 ++it) { |
| 1204 if (it.represents_itself()) { | 1203 if (it.represents_itself()) { |
| 1205 if (*it == root) | 1204 if (*it == root) |
| 1206 saw_root = true; | 1205 saw_root = true; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 int num_draws_; | 1264 int num_draws_; |
| 1266 bool copy_happened_; | 1265 bool copy_happened_; |
| 1267 bool draw_happened_; | 1266 bool draw_happened_; |
| 1268 }; | 1267 }; |
| 1269 | 1268 |
| 1270 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1269 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| 1271 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); | 1270 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); |
| 1272 | 1271 |
| 1273 } // namespace | 1272 } // namespace |
| 1274 } // namespace cc | 1273 } // namespace cc |
| OLD | NEW |