| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/test/pixel_test_delegating_output_surface.h" | 5 #include "cc/test/pixel_test_delegating_output_surface.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "cc/output/begin_frame_args.h" | 13 #include "cc/output/begin_frame_args.h" |
| 14 #include "cc/output/compositor_frame_ack.h" | 14 #include "cc/output/compositor_frame_ack.h" |
| 15 #include "cc/output/direct_renderer.h" | 15 #include "cc/output/direct_renderer.h" |
| 16 #include "cc/output/texture_mailbox_deleter.h" |
| 17 #include "cc/scheduler/begin_frame_source.h" |
| 16 #include "cc/scheduler/delay_based_time_source.h" | 18 #include "cc/scheduler/delay_based_time_source.h" |
| 17 #include "cc/test/begin_frame_args_test.h" | 19 #include "cc/test/begin_frame_args_test.h" |
| 18 #include "cc/test/pixel_test_output_surface.h" | 20 #include "cc/test/pixel_test_output_surface.h" |
| 19 #include "cc/test/pixel_test_software_output_device.h" | 21 #include "cc/test/pixel_test_software_output_device.h" |
| 20 #include "cc/test/test_in_process_context_provider.h" | 22 #include "cc/test/test_in_process_context_provider.h" |
| 21 | 23 |
| 22 static constexpr uint32_t kCompositorSurfaceNamespace = 1; | 24 static constexpr uint32_t kCompositorSurfaceNamespace = 1; |
| 23 | 25 |
| 24 namespace cc { | 26 namespace cc { |
| 25 | 27 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 gfx::Size surface_expansion_size(40, 60); | 64 gfx::Size surface_expansion_size(40, 60); |
| 63 | 65 |
| 64 // The PixelTestOutputSurface is owned by the Display. | 66 // The PixelTestOutputSurface is owned by the Display. |
| 65 std::unique_ptr<PixelTestOutputSurface> output_surface; | 67 std::unique_ptr<PixelTestOutputSurface> output_surface; |
| 66 | 68 |
| 67 if (!context_provider()) { | 69 if (!context_provider()) { |
| 68 std::unique_ptr<PixelTestSoftwareOutputDevice> software_output_device( | 70 std::unique_ptr<PixelTestSoftwareOutputDevice> software_output_device( |
| 69 new PixelTestSoftwareOutputDevice); | 71 new PixelTestSoftwareOutputDevice); |
| 70 software_output_device->set_surface_expansion_size(surface_expansion_size); | 72 software_output_device->set_surface_expansion_size(surface_expansion_size); |
| 71 output_surface = base::MakeUnique<PixelTestOutputSurface>( | 73 output_surface = base::MakeUnique<PixelTestOutputSurface>( |
| 72 std::move(software_output_device), nullptr); | 74 std::move(software_output_device)); |
| 73 } else { | 75 } else { |
| 74 scoped_refptr<TestInProcessContextProvider> context( | 76 scoped_refptr<TestInProcessContextProvider> context( |
| 75 new TestInProcessContextProvider(nullptr)); | 77 new TestInProcessContextProvider(nullptr)); |
| 76 bool flipped_output_surface = false; | 78 bool flipped_output_surface = false; |
| 77 output_surface = base::MakeUnique<PixelTestOutputSurface>( | 79 output_surface = base::MakeUnique<PixelTestOutputSurface>( |
| 78 std::move(context), nullptr, flipped_output_surface, nullptr); | 80 std::move(context), nullptr, flipped_output_surface); |
| 79 } | 81 } |
| 80 output_surface->set_surface_expansion_size(surface_expansion_size); | 82 output_surface->set_surface_expansion_size(surface_expansion_size); |
| 81 | 83 |
| 82 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); | 84 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); |
| 83 CHECK(task_runner); | 85 CHECK(task_runner); |
| 84 | 86 |
| 85 display_.reset(new Display(surface_manager_.get(), shared_bitmap_manager_, | 87 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; |
| 86 gpu_memory_buffer_manager_, RendererSettings(), | 88 std::unique_ptr<DisplayScheduler> scheduler; |
| 87 surface_id_allocator_->id_namespace(), task_runner, | 89 if (!synchronous_composite_) { |
| 88 std::move(output_surface))); | 90 begin_frame_source.reset(new BackToBackBeginFrameSource( |
| 91 base::MakeUnique<DelayBasedTimeSource>(task_runner))); |
| 92 scheduler.reset(new DisplayScheduler( |
| 93 begin_frame_source.get(), task_runner, |
| 94 output_surface->capabilities().max_frames_pending)); |
| 95 } |
| 96 |
| 97 display_.reset(new Display( |
| 98 surface_manager_.get(), shared_bitmap_manager_, |
| 99 gpu_memory_buffer_manager_, RendererSettings(), |
| 100 surface_id_allocator_->id_namespace(), std::move(begin_frame_source), |
| 101 std::move(output_surface), std::move(scheduler), |
| 102 base::MakeUnique<TextureMailboxDeleter>(task_runner))); |
| 89 display_->SetEnlargePassTextureAmountForTesting(enlarge_pass_texture_amount_); | 103 display_->SetEnlargePassTextureAmountForTesting(enlarge_pass_texture_amount_); |
| 90 | 104 |
| 91 if (synchronous_composite_) { | 105 bool init = display_->Initialize(&display_client_); |
| 92 bool init = display_->InitializeSynchronous(&display_client_); | 106 CHECK(init); |
| 93 CHECK(init); | |
| 94 } else { | |
| 95 begin_frame_source_.reset(new BackToBackBeginFrameSource( | |
| 96 base::MakeUnique<DelayBasedTimeSource>(task_runner))); | |
| 97 display_->SetBeginFrameSource(begin_frame_source_.get()); | |
| 98 | |
| 99 bool init = display_->Initialize(&display_client_); | |
| 100 CHECK(init); | |
| 101 } | |
| 102 | |
| 103 return true; | 107 return true; |
| 104 } | 108 } |
| 105 | 109 |
| 106 void PixelTestDelegatingOutputSurface::DetachFromClient() { | 110 void PixelTestDelegatingOutputSurface::DetachFromClient() { |
| 107 if (!delegated_surface_id_.is_null()) | 111 if (!delegated_surface_id_.is_null()) |
| 108 surface_factory_->Destroy(delegated_surface_id_); | 112 surface_factory_->Destroy(delegated_surface_id_); |
| 109 surface_manager_->UnregisterSurfaceFactoryClient( | 113 surface_manager_->UnregisterSurfaceFactoryClient( |
| 110 surface_id_allocator_->id_namespace()); | 114 surface_id_allocator_->id_namespace()); |
| 111 | 115 |
| 112 display_ = nullptr; | 116 display_ = nullptr; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 ack.resources = resources; | 169 ack.resources = resources; |
| 166 client_->ReclaimResources(&ack); | 170 client_->ReclaimResources(&ack); |
| 167 } | 171 } |
| 168 | 172 |
| 169 void PixelTestDelegatingOutputSurface::SetBeginFrameSource( | 173 void PixelTestDelegatingOutputSurface::SetBeginFrameSource( |
| 170 BeginFrameSource* begin_frame_source) { | 174 BeginFrameSource* begin_frame_source) { |
| 171 client_->SetBeginFrameSource(begin_frame_source); | 175 client_->SetBeginFrameSource(begin_frame_source); |
| 172 } | 176 } |
| 173 | 177 |
| 174 } // namespace cc | 178 } // namespace cc |
| OLD | NEW |