| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/surfaces/display.h" | 5 #include "cc/surfaces/display.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/test/null_task_runner.h" | 9 #include "base/test/null_task_runner.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| 11 #include "cc/output/copy_output_result.h" | 11 #include "cc/output/copy_output_result.h" |
| 12 #include "cc/output/delegated_frame_data.h" | |
| 13 #include "cc/output/texture_mailbox_deleter.h" | 12 #include "cc/output/texture_mailbox_deleter.h" |
| 14 #include "cc/quads/render_pass.h" | 13 #include "cc/quads/render_pass.h" |
| 15 #include "cc/resources/shared_bitmap_manager.h" | 14 #include "cc/resources/shared_bitmap_manager.h" |
| 16 #include "cc/scheduler/begin_frame_source.h" | 15 #include "cc/scheduler/begin_frame_source.h" |
| 17 #include "cc/surfaces/display_client.h" | 16 #include "cc/surfaces/display_client.h" |
| 18 #include "cc/surfaces/display_scheduler.h" | 17 #include "cc/surfaces/display_scheduler.h" |
| 19 #include "cc/surfaces/frame_sink_id.h" | 18 #include "cc/surfaces/frame_sink_id.h" |
| 20 #include "cc/surfaces/surface.h" | 19 #include "cc/surfaces/surface.h" |
| 21 #include "cc/surfaces/surface_factory.h" | 20 #include "cc/surfaces/surface_factory.h" |
| 22 #include "cc/surfaces/surface_factory_client.h" | 21 #include "cc/surfaces/surface_factory_client.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, | 134 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, |
| 136 settings, std::move(begin_frame_source), std::move(output_surface), | 135 settings, std::move(begin_frame_source), std::move(output_surface), |
| 137 std::move(scheduler), | 136 std::move(scheduler), |
| 138 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); | 137 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); |
| 139 display_->SetVisible(true); | 138 display_->SetVisible(true); |
| 140 } | 139 } |
| 141 | 140 |
| 142 protected: | 141 protected: |
| 143 void SubmitCompositorFrame(RenderPassList* pass_list, | 142 void SubmitCompositorFrame(RenderPassList* pass_list, |
| 144 const LocalFrameId& local_frame_id) { | 143 const LocalFrameId& local_frame_id) { |
| 145 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | |
| 146 pass_list->swap(frame_data->render_pass_list); | |
| 147 | |
| 148 CompositorFrame frame; | 144 CompositorFrame frame; |
| 149 frame.delegated_frame_data = std::move(frame_data); | 145 pass_list->swap(frame.render_pass_list); |
| 150 | 146 |
| 151 factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), | 147 factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), |
| 152 SurfaceFactory::DrawCallback()); | 148 SurfaceFactory::DrawCallback()); |
| 153 } | 149 } |
| 154 | 150 |
| 155 SurfaceManager manager_; | 151 SurfaceManager manager_; |
| 156 FakeSurfaceFactoryClient surface_factory_client_; | 152 FakeSurfaceFactoryClient surface_factory_client_; |
| 157 SurfaceFactory factory_; | 153 SurfaceFactory factory_; |
| 158 SurfaceIdAllocator id_allocator_; | 154 SurfaceIdAllocator id_allocator_; |
| 159 scoped_refptr<base::NullTaskRunner> task_runner_; | 155 scoped_refptr<base::NullTaskRunner> task_runner_; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // Pass has no damage, so shouldn't be swapped, but latency info should be | 334 // Pass has no damage, so shouldn't be swapped, but latency info should be |
| 339 // saved for next swap. | 335 // saved for next swap. |
| 340 { | 336 { |
| 341 pass = RenderPass::Create(); | 337 pass = RenderPass::Create(); |
| 342 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 338 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 343 pass->damage_rect = gfx::Rect(10, 10, 0, 0); | 339 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 344 pass->id = RenderPassId(1, 1); | 340 pass->id = RenderPassId(1, 1); |
| 345 | 341 |
| 346 pass_list.push_back(std::move(pass)); | 342 pass_list.push_back(std::move(pass)); |
| 347 scheduler_->ResetDamageForTest(); | 343 scheduler_->ResetDamageForTest(); |
| 348 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | |
| 349 pass_list.swap(frame_data->render_pass_list); | |
| 350 | 344 |
| 351 CompositorFrame frame; | 345 CompositorFrame frame; |
| 352 frame.delegated_frame_data = std::move(frame_data); | 346 pass_list.swap(frame.render_pass_list); |
| 353 frame.metadata.latency_info.push_back(ui::LatencyInfo()); | 347 frame.metadata.latency_info.push_back(ui::LatencyInfo()); |
| 354 | 348 |
| 355 factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), | 349 factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), |
| 356 SurfaceFactory::DrawCallback()); | 350 SurfaceFactory::DrawCallback()); |
| 357 EXPECT_TRUE(scheduler_->damaged); | 351 EXPECT_TRUE(scheduler_->damaged); |
| 358 EXPECT_FALSE(scheduler_->display_resized_); | 352 EXPECT_FALSE(scheduler_->display_resized_); |
| 359 EXPECT_FALSE(scheduler_->has_new_root_surface); | 353 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 360 | 354 |
| 361 scheduler_->swapped = false; | 355 scheduler_->swapped = false; |
| 362 display_->DrawAndSwap(); | 356 display_->DrawAndSwap(); |
| 363 EXPECT_TRUE(scheduler_->swapped); | 357 EXPECT_TRUE(scheduler_->swapped); |
| 364 EXPECT_EQ(4u, output_surface_->num_sent_frames()); | 358 EXPECT_EQ(4u, output_surface_->num_sent_frames()); |
| 365 } | 359 } |
| 366 | 360 |
| 367 // Resize should cause a swap if no frame was swapped at the previous size. | 361 // Resize should cause a swap if no frame was swapped at the previous size. |
| 368 { | 362 { |
| 369 scheduler_->swapped = false; | 363 scheduler_->swapped = false; |
| 370 display_->Resize(gfx::Size(200, 200)); | 364 display_->Resize(gfx::Size(200, 200)); |
| 371 EXPECT_FALSE(scheduler_->swapped); | 365 EXPECT_FALSE(scheduler_->swapped); |
| 372 EXPECT_EQ(4u, output_surface_->num_sent_frames()); | 366 EXPECT_EQ(4u, output_surface_->num_sent_frames()); |
| 373 | 367 |
| 374 pass = RenderPass::Create(); | 368 pass = RenderPass::Create(); |
| 375 pass->output_rect = gfx::Rect(0, 0, 200, 200); | 369 pass->output_rect = gfx::Rect(0, 0, 200, 200); |
| 376 pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 370 pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
| 377 pass->id = RenderPassId(1, 1); | 371 pass->id = RenderPassId(1, 1); |
| 378 | 372 |
| 379 pass_list.push_back(std::move(pass)); | 373 pass_list.push_back(std::move(pass)); |
| 380 scheduler_->ResetDamageForTest(); | 374 scheduler_->ResetDamageForTest(); |
| 381 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | |
| 382 pass_list.swap(frame_data->render_pass_list); | |
| 383 | 375 |
| 384 CompositorFrame frame; | 376 CompositorFrame frame; |
| 385 frame.delegated_frame_data = std::move(frame_data); | 377 pass_list.swap(frame.render_pass_list); |
| 386 | 378 |
| 387 factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), | 379 factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), |
| 388 SurfaceFactory::DrawCallback()); | 380 SurfaceFactory::DrawCallback()); |
| 389 EXPECT_TRUE(scheduler_->damaged); | 381 EXPECT_TRUE(scheduler_->damaged); |
| 390 EXPECT_FALSE(scheduler_->display_resized_); | 382 EXPECT_FALSE(scheduler_->display_resized_); |
| 391 EXPECT_FALSE(scheduler_->has_new_root_surface); | 383 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 392 | 384 |
| 393 scheduler_->swapped = false; | 385 scheduler_->swapped = false; |
| 394 display_->Resize(gfx::Size(100, 100)); | 386 display_->Resize(gfx::Size(100, 100)); |
| 395 EXPECT_TRUE(scheduler_->swapped); | 387 EXPECT_TRUE(scheduler_->swapped); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 // Verify DidLoseOutputSurface callback is hooked up correctly. | 515 // Verify DidLoseOutputSurface callback is hooked up correctly. |
| 524 EXPECT_EQ(0, client.loss_count()); | 516 EXPECT_EQ(0, client.loss_count()); |
| 525 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( | 517 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( |
| 526 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 518 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 527 output_surface_->context_provider()->ContextGL()->Flush(); | 519 output_surface_->context_provider()->ContextGL()->Flush(); |
| 528 EXPECT_EQ(1, client.loss_count()); | 520 EXPECT_EQ(1, client.loss_count()); |
| 529 } | 521 } |
| 530 | 522 |
| 531 } // namespace | 523 } // namespace |
| 532 } // namespace cc | 524 } // namespace cc |
| OLD | NEW |