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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 PixelTestDelegatingOutputSurface::PixelTestDelegatingOutputSurface( | 25 PixelTestDelegatingOutputSurface::PixelTestDelegatingOutputSurface( |
26 scoped_refptr<ContextProvider> compositor_context_provider, | 26 scoped_refptr<ContextProvider> compositor_context_provider, |
27 scoped_refptr<ContextProvider> worker_context_provider, | 27 scoped_refptr<ContextProvider> worker_context_provider, |
28 SharedBitmapManager* shared_bitmap_manager, | 28 SharedBitmapManager* shared_bitmap_manager, |
29 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 29 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
30 bool allow_force_reclaim_resources, | 30 bool allow_force_reclaim_resources, |
31 bool synchronous_composite) | 31 bool synchronous_composite) |
32 : OutputSurface(std::move(compositor_context_provider), | 32 : OutputSurface(std::move(compositor_context_provider), |
33 std::move(worker_context_provider), | 33 std::move(worker_context_provider), |
34 nullptr), | 34 nullptr), |
| 35 shared_bitmap_manager_(shared_bitmap_manager), |
| 36 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
35 allow_force_reclaim_resources_(allow_force_reclaim_resources), | 37 allow_force_reclaim_resources_(allow_force_reclaim_resources), |
36 synchronous_composite_(synchronous_composite), | 38 synchronous_composite_(synchronous_composite), |
37 surface_manager_(new SurfaceManager), | 39 surface_manager_(new SurfaceManager), |
38 surface_id_allocator_( | 40 surface_id_allocator_( |
39 new SurfaceIdAllocator(kCompositorSurfaceNamespace)), | 41 new SurfaceIdAllocator(kCompositorSurfaceNamespace)), |
40 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), | 42 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), |
41 display_(new Display(&display_client_, | |
42 surface_manager_.get(), | |
43 shared_bitmap_manager, | |
44 gpu_memory_buffer_manager, | |
45 RendererSettings(), | |
46 surface_id_allocator_->id_namespace())), | |
47 weak_ptrs_(this) { | 43 weak_ptrs_(this) { |
48 capabilities_.delegated_rendering = true; | 44 capabilities_.delegated_rendering = true; |
49 capabilities_.can_force_reclaim_resources = allow_force_reclaim_resources_; | 45 capabilities_.can_force_reclaim_resources = allow_force_reclaim_resources_; |
50 | 46 |
51 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); | 47 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); |
52 } | 48 } |
53 | 49 |
54 PixelTestDelegatingOutputSurface::~PixelTestDelegatingOutputSurface() {} | 50 PixelTestDelegatingOutputSurface::~PixelTestDelegatingOutputSurface() {} |
55 | 51 |
56 bool PixelTestDelegatingOutputSurface::BindToClient( | 52 bool PixelTestDelegatingOutputSurface::BindToClient( |
(...skipping 21 matching lines...) Expand all Loading... |
78 new TestInProcessContextProvider(nullptr)); | 74 new TestInProcessContextProvider(nullptr)); |
79 bool flipped_output_surface = false; | 75 bool flipped_output_surface = false; |
80 output_surface = base::MakeUnique<PixelTestOutputSurface>( | 76 output_surface = base::MakeUnique<PixelTestOutputSurface>( |
81 std::move(context), nullptr, flipped_output_surface, nullptr); | 77 std::move(context), nullptr, flipped_output_surface, nullptr); |
82 } | 78 } |
83 output_surface->set_surface_expansion_size(surface_expansion_size); | 79 output_surface->set_surface_expansion_size(surface_expansion_size); |
84 | 80 |
85 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); | 81 auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); |
86 CHECK(task_runner); | 82 CHECK(task_runner); |
87 | 83 |
| 84 display_.reset(new Display(surface_manager_.get(), shared_bitmap_manager_, |
| 85 gpu_memory_buffer_manager_, RendererSettings(), |
| 86 surface_id_allocator_->id_namespace(), task_runner, |
| 87 std::move(output_surface))); |
| 88 display_->SetEnlargePassTextureAmountForTesting(enlarge_pass_texture_amount_); |
| 89 |
88 if (synchronous_composite_) { | 90 if (synchronous_composite_) { |
89 bool init = | 91 bool init = display_->InitializeSynchronous(&display_client_); |
90 display_->InitializeSynchronous(std::move(output_surface), task_runner); | |
91 CHECK(init); | 92 CHECK(init); |
92 } else { | 93 } else { |
93 begin_frame_source_.reset(new BackToBackBeginFrameSource(task_runner)); | 94 begin_frame_source_.reset(new BackToBackBeginFrameSource(task_runner)); |
94 display_->SetBeginFrameSource(begin_frame_source_.get()); | 95 display_->SetBeginFrameSource(begin_frame_source_.get()); |
95 | 96 |
96 bool init = display_->Initialize(std::move(output_surface), task_runner); | 97 bool init = display_->Initialize(&display_client_); |
97 CHECK(init); | 98 CHECK(init); |
98 } | 99 } |
99 | 100 |
100 return true; | 101 return true; |
101 } | 102 } |
102 | 103 |
103 void PixelTestDelegatingOutputSurface::DetachFromClient() { | 104 void PixelTestDelegatingOutputSurface::DetachFromClient() { |
104 if (!delegated_surface_id_.is_null()) | 105 if (!delegated_surface_id_.is_null()) |
105 surface_factory_->Destroy(delegated_surface_id_); | 106 surface_factory_->Destroy(delegated_surface_id_); |
106 surface_manager_->UnregisterSurfaceFactoryClient( | 107 surface_manager_->UnregisterSurfaceFactoryClient( |
(...skipping 25 matching lines...) Expand all Loading... |
132 frame->AssignTo(my_frame.get()); | 133 frame->AssignTo(my_frame.get()); |
133 surface_factory_->SubmitCompositorFrame( | 134 surface_factory_->SubmitCompositorFrame( |
134 delegated_surface_id_, std::move(my_frame), | 135 delegated_surface_id_, std::move(my_frame), |
135 base::Bind(&PixelTestDelegatingOutputSurface::DrawCallback, | 136 base::Bind(&PixelTestDelegatingOutputSurface::DrawCallback, |
136 weak_ptrs_.GetWeakPtr())); | 137 weak_ptrs_.GetWeakPtr())); |
137 | 138 |
138 if (synchronous_composite_) | 139 if (synchronous_composite_) |
139 display_->DrawAndSwap(); | 140 display_->DrawAndSwap(); |
140 } | 141 } |
141 | 142 |
| 143 void PixelTestDelegatingOutputSurface::SetEnlargePassTextureAmount( |
| 144 const gfx::Size& amount) { |
| 145 DCHECK(!HasClient()); |
| 146 enlarge_pass_texture_amount_ = amount; |
| 147 } |
| 148 |
142 void PixelTestDelegatingOutputSurface::DrawCallback(SurfaceDrawStatus) { | 149 void PixelTestDelegatingOutputSurface::DrawCallback(SurfaceDrawStatus) { |
143 client_->DidSwapBuffersComplete(); | 150 client_->DidSwapBuffersComplete(); |
144 } | 151 } |
145 | 152 |
146 void PixelTestDelegatingOutputSurface::ForceReclaimResources() { | 153 void PixelTestDelegatingOutputSurface::ForceReclaimResources() { |
147 if (allow_force_reclaim_resources_ && !delegated_surface_id_.is_null()) { | 154 if (allow_force_reclaim_resources_ && !delegated_surface_id_.is_null()) { |
148 surface_factory_->SubmitCompositorFrame(delegated_surface_id_, nullptr, | 155 surface_factory_->SubmitCompositorFrame(delegated_surface_id_, nullptr, |
149 SurfaceFactory::DrawCallback()); | 156 SurfaceFactory::DrawCallback()); |
150 } | 157 } |
151 } | 158 } |
152 | 159 |
153 void PixelTestDelegatingOutputSurface::ReturnResources( | 160 void PixelTestDelegatingOutputSurface::ReturnResources( |
154 const ReturnedResourceArray& resources) { | 161 const ReturnedResourceArray& resources) { |
155 CompositorFrameAck ack; | 162 CompositorFrameAck ack; |
156 ack.resources = resources; | 163 ack.resources = resources; |
157 client_->ReclaimResources(&ack); | 164 client_->ReclaimResources(&ack); |
158 } | 165 } |
159 | 166 |
160 void PixelTestDelegatingOutputSurface::SetBeginFrameSource( | 167 void PixelTestDelegatingOutputSurface::SetBeginFrameSource( |
161 BeginFrameSource* begin_frame_source) { | 168 BeginFrameSource* begin_frame_source) { |
162 client_->SetBeginFrameSource(begin_frame_source); | 169 client_->SetBeginFrameSource(begin_frame_source); |
163 } | 170 } |
164 | 171 |
165 void PixelTestDelegatingOutputSurface::SetEnlargePassTextureAmount( | |
166 const gfx::Size& amount) { | |
167 display_->SetEnlargePassTextureAmountForTesting(amount); | |
168 } | |
169 | |
170 } // namespace cc | 172 } // namespace cc |
OLD | NEW |