| 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" | 16 #include "cc/output/texture_mailbox_deleter.h" |
| 17 #include "cc/scheduler/begin_frame_source.h" | 17 #include "cc/scheduler/begin_frame_source.h" |
| 18 #include "cc/scheduler/delay_based_time_source.h" | 18 #include "cc/scheduler/delay_based_time_source.h" |
| 19 #include "cc/test/begin_frame_args_test.h" | 19 #include "cc/test/begin_frame_args_test.h" |
| 20 #include "cc/test/pixel_test_output_surface.h" | 20 #include "cc/test/pixel_test_output_surface.h" |
| 21 #include "cc/test/pixel_test_software_output_device.h" | 21 #include "cc/test/pixel_test_software_output_device.h" |
| 22 #include "cc/test/test_in_process_context_provider.h" | 22 #include "cc/test/test_in_process_context_provider.h" |
| 23 | 23 |
| 24 static constexpr uint32_t kCompositorSurfaceNamespace = 1; | 24 static constexpr uint32_t kCompositorClientId = 1; |
| 25 | 25 |
| 26 namespace cc { | 26 namespace cc { |
| 27 | 27 |
| 28 PixelTestDelegatingOutputSurface::PixelTestDelegatingOutputSurface( | 28 PixelTestDelegatingOutputSurface::PixelTestDelegatingOutputSurface( |
| 29 scoped_refptr<ContextProvider> compositor_context_provider, | 29 scoped_refptr<ContextProvider> compositor_context_provider, |
| 30 scoped_refptr<ContextProvider> worker_context_provider, | 30 scoped_refptr<ContextProvider> worker_context_provider, |
| 31 scoped_refptr<ContextProvider> display_context_provider, | 31 scoped_refptr<ContextProvider> display_context_provider, |
| 32 const RendererSettings& renderer_settings, | 32 const RendererSettings& renderer_settings, |
| 33 SharedBitmapManager* shared_bitmap_manager, | 33 SharedBitmapManager* shared_bitmap_manager, |
| 34 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 34 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 35 const gfx::Size& surface_expansion_size, | 35 const gfx::Size& surface_expansion_size, |
| 36 bool allow_force_reclaim_resources, | 36 bool allow_force_reclaim_resources, |
| 37 bool synchronous_composite) | 37 bool synchronous_composite) |
| 38 : OutputSurface(std::move(compositor_context_provider), | 38 : OutputSurface(std::move(compositor_context_provider), |
| 39 std::move(worker_context_provider), | 39 std::move(worker_context_provider), |
| 40 nullptr), | 40 nullptr), |
| 41 shared_bitmap_manager_(shared_bitmap_manager), | 41 shared_bitmap_manager_(shared_bitmap_manager), |
| 42 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 42 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 43 surface_expansion_size_(surface_expansion_size), | 43 surface_expansion_size_(surface_expansion_size), |
| 44 allow_force_reclaim_resources_(allow_force_reclaim_resources), | 44 allow_force_reclaim_resources_(allow_force_reclaim_resources), |
| 45 synchronous_composite_(synchronous_composite), | 45 synchronous_composite_(synchronous_composite), |
| 46 renderer_settings_(renderer_settings), | 46 renderer_settings_(renderer_settings), |
| 47 display_context_provider_(std::move(display_context_provider)), | 47 display_context_provider_(std::move(display_context_provider)), |
| 48 surface_manager_(new SurfaceManager), | 48 surface_manager_(new SurfaceManager), |
| 49 surface_id_allocator_( | 49 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)), |
| 50 new SurfaceIdAllocator(kCompositorSurfaceNamespace)), | |
| 51 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), | 50 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), |
| 52 weak_ptrs_(this) { | 51 weak_ptrs_(this) { |
| 53 capabilities_.delegated_rendering = true; | 52 capabilities_.delegated_rendering = true; |
| 54 capabilities_.can_force_reclaim_resources = allow_force_reclaim_resources_; | 53 capabilities_.can_force_reclaim_resources = allow_force_reclaim_resources_; |
| 55 | 54 |
| 56 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); | 55 surface_id_allocator_->RegisterSurfaceClientId(surface_manager_.get()); |
| 57 } | 56 } |
| 58 | 57 |
| 59 PixelTestDelegatingOutputSurface::~PixelTestDelegatingOutputSurface() {} | 58 PixelTestDelegatingOutputSurface::~PixelTestDelegatingOutputSurface() {} |
| 60 | 59 |
| 61 bool PixelTestDelegatingOutputSurface::BindToClient( | 60 bool PixelTestDelegatingOutputSurface::BindToClient( |
| 62 OutputSurfaceClient* client) { | 61 OutputSurfaceClient* client) { |
| 63 if (!OutputSurface::BindToClient(client)) | 62 if (!OutputSurface::BindToClient(client)) |
| 64 return false; | 63 return false; |
| 65 | 64 |
| 66 surface_manager_->RegisterSurfaceFactoryClient( | 65 surface_manager_->RegisterSurfaceFactoryClient( |
| 67 surface_id_allocator_->id_namespace(), this); | 66 surface_id_allocator_->client_id(), this); |
| 68 | 67 |
| 69 // The PixelTestOutputSurface is owned by the Display. | 68 // The PixelTestOutputSurface is owned by the Display. |
| 70 std::unique_ptr<PixelTestOutputSurface> output_surface; | 69 std::unique_ptr<PixelTestOutputSurface> output_surface; |
| 71 | 70 |
| 72 if (!context_provider()) { | 71 if (!context_provider()) { |
| 73 std::unique_ptr<PixelTestSoftwareOutputDevice> software_output_device( | 72 std::unique_ptr<PixelTestSoftwareOutputDevice> software_output_device( |
| 74 new PixelTestSoftwareOutputDevice); | 73 new PixelTestSoftwareOutputDevice); |
| 75 software_output_device->set_surface_expansion_size(surface_expansion_size_); | 74 software_output_device->set_surface_expansion_size(surface_expansion_size_); |
| 76 output_surface = base::MakeUnique<PixelTestOutputSurface>( | 75 output_surface = base::MakeUnique<PixelTestOutputSurface>( |
| 77 std::move(software_output_device)); | 76 std::move(software_output_device)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 91 begin_frame_source.reset(new DelayBasedBeginFrameSource( | 90 begin_frame_source.reset(new DelayBasedBeginFrameSource( |
| 92 base::MakeUnique<DelayBasedTimeSource>(task_runner))); | 91 base::MakeUnique<DelayBasedTimeSource>(task_runner))); |
| 93 scheduler.reset(new DisplayScheduler( | 92 scheduler.reset(new DisplayScheduler( |
| 94 begin_frame_source.get(), task_runner, | 93 begin_frame_source.get(), task_runner, |
| 95 output_surface->capabilities().max_frames_pending)); | 94 output_surface->capabilities().max_frames_pending)); |
| 96 } | 95 } |
| 97 | 96 |
| 98 display_.reset(new Display( | 97 display_.reset(new Display( |
| 99 surface_manager_.get(), shared_bitmap_manager_, | 98 surface_manager_.get(), shared_bitmap_manager_, |
| 100 gpu_memory_buffer_manager_, renderer_settings_, | 99 gpu_memory_buffer_manager_, renderer_settings_, |
| 101 surface_id_allocator_->id_namespace(), std::move(begin_frame_source), | 100 surface_id_allocator_->client_id(), std::move(begin_frame_source), |
| 102 std::move(output_surface), std::move(scheduler), | 101 std::move(output_surface), std::move(scheduler), |
| 103 base::MakeUnique<TextureMailboxDeleter>(task_runner))); | 102 base::MakeUnique<TextureMailboxDeleter>(task_runner))); |
| 104 display_->SetEnlargePassTextureAmountForTesting(enlarge_pass_texture_amount_); | 103 display_->SetEnlargePassTextureAmountForTesting(enlarge_pass_texture_amount_); |
| 105 | 104 |
| 106 display_->Initialize(&display_client_); | 105 display_->Initialize(&display_client_); |
| 107 return true; | 106 return true; |
| 108 } | 107 } |
| 109 | 108 |
| 110 void PixelTestDelegatingOutputSurface::DetachFromClient() { | 109 void PixelTestDelegatingOutputSurface::DetachFromClient() { |
| 111 if (!delegated_surface_id_.is_null()) | 110 if (!delegated_surface_id_.is_null()) |
| 112 surface_factory_->Destroy(delegated_surface_id_); | 111 surface_factory_->Destroy(delegated_surface_id_); |
| 113 surface_manager_->UnregisterSurfaceFactoryClient( | 112 surface_manager_->UnregisterSurfaceFactoryClient( |
| 114 surface_id_allocator_->id_namespace()); | 113 surface_id_allocator_->client_id()); |
| 115 | 114 |
| 116 display_ = nullptr; | 115 display_ = nullptr; |
| 117 surface_factory_ = nullptr; | 116 surface_factory_ = nullptr; |
| 118 surface_id_allocator_ = nullptr; | 117 surface_id_allocator_ = nullptr; |
| 119 surface_manager_ = nullptr; | 118 surface_manager_ = nullptr; |
| 120 weak_ptrs_.InvalidateWeakPtrs(); | 119 weak_ptrs_.InvalidateWeakPtrs(); |
| 121 OutputSurface::DetachFromClient(); | 120 OutputSurface::DetachFromClient(); |
| 122 } | 121 } |
| 123 | 122 |
| 124 void PixelTestDelegatingOutputSurface::SwapBuffers(CompositorFrame frame) { | 123 void PixelTestDelegatingOutputSurface::SwapBuffers(CompositorFrame frame) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 ack.resources = resources; | 178 ack.resources = resources; |
| 180 client_->ReclaimResources(&ack); | 179 client_->ReclaimResources(&ack); |
| 181 } | 180 } |
| 182 | 181 |
| 183 void PixelTestDelegatingOutputSurface::SetBeginFrameSource( | 182 void PixelTestDelegatingOutputSurface::SetBeginFrameSource( |
| 184 BeginFrameSource* begin_frame_source) { | 183 BeginFrameSource* begin_frame_source) { |
| 185 client_->SetBeginFrameSource(begin_frame_source); | 184 client_->SetBeginFrameSource(begin_frame_source); |
| 186 } | 185 } |
| 187 | 186 |
| 188 } // namespace cc | 187 } // namespace cc |
| OLD | NEW |