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