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