OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/compositor/test/in_process_context_factory.h" | 5 #include "ui/compositor/test/in_process_context_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 168 } |
169 | 169 |
170 if (surface_manager_) { | 170 if (surface_manager_) { |
171 std::unique_ptr<cc::DelayBasedBeginFrameSource> begin_frame_source( | 171 std::unique_ptr<cc::DelayBasedBeginFrameSource> begin_frame_source( |
172 new cc::DelayBasedBeginFrameSource( | 172 new cc::DelayBasedBeginFrameSource( |
173 base::MakeUnique<cc::DelayBasedTimeSource>( | 173 base::MakeUnique<cc::DelayBasedTimeSource>( |
174 compositor->task_runner().get()))); | 174 compositor->task_runner().get()))); |
175 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 175 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
176 begin_frame_source.get(), compositor->task_runner().get(), | 176 begin_frame_source.get(), compositor->task_runner().get(), |
177 display_output_surface->capabilities().max_frames_pending)); | 177 display_output_surface->capabilities().max_frames_pending)); |
178 per_compositor_data_[compositor.get()] = base::MakeUnique<cc::Display>( | 178 auto& data = per_compositor_data_[compositor.get()]; |
| 179 data.display = base::MakeUnique<cc::Display>( |
179 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), | 180 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), |
180 compositor->GetRendererSettings(), std::move(begin_frame_source), | 181 compositor->GetRendererSettings(), std::move(begin_frame_source), |
181 std::move(display_output_surface), std::move(scheduler), | 182 std::move(display_output_surface), std::move(scheduler), |
182 base::MakeUnique<cc::TextureMailboxDeleter>( | 183 base::MakeUnique<cc::TextureMailboxDeleter>( |
183 compositor->task_runner().get())); | 184 compositor->task_runner().get())); |
| 185 data.display->Resize(compositor->size()); |
| 186 data.display->SetVisible(per_compositor_data_[compositor.get()].visible); |
184 | 187 |
185 auto* display = per_compositor_data_[compositor.get()].get(); | |
186 std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 188 std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
187 new cc::SurfaceDisplayOutputSurface( | 189 new cc::SurfaceDisplayOutputSurface( |
188 surface_manager_, compositor->surface_id_allocator(), display, | 190 surface_manager_, compositor->surface_id_allocator(), |
189 context_provider, shared_worker_context_provider_)); | 191 data.display.get(), context_provider, |
| 192 shared_worker_context_provider_)); |
190 compositor->SetOutputSurface(std::move(surface_output_surface)); | 193 compositor->SetOutputSurface(std::move(surface_output_surface)); |
191 } else { | 194 } else { |
192 compositor->SetOutputSurface(std::move(display_output_surface)); | 195 compositor->SetOutputSurface(std::move(display_output_surface)); |
193 } | 196 } |
194 } | 197 } |
195 | 198 |
196 std::unique_ptr<Reflector> InProcessContextFactory::CreateReflector( | 199 std::unique_ptr<Reflector> InProcessContextFactory::CreateReflector( |
197 Compositor* mirrored_compositor, | 200 Compositor* mirrored_compositor, |
198 Layer* mirroring_layer) { | 201 Layer* mirroring_layer) { |
199 return base::WrapUnique(new FakeReflector); | 202 return base::WrapUnique(new FakeReflector); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 251 } |
249 | 252 |
250 uint32_t InProcessContextFactory::AllocateSurfaceClientId() { | 253 uint32_t InProcessContextFactory::AllocateSurfaceClientId() { |
251 return next_surface_client_id_++; | 254 return next_surface_client_id_++; |
252 } | 255 } |
253 | 256 |
254 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { | 257 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { |
255 return surface_manager_; | 258 return surface_manager_; |
256 } | 259 } |
257 | 260 |
| 261 void InProcessContextFactory::SetDisplayVisible(ui::Compositor* compositor, |
| 262 bool visible) { |
| 263 if (!per_compositor_data_.count(compositor)) |
| 264 return; |
| 265 per_compositor_data_[compositor].display->SetVisible(visible); |
| 266 } |
| 267 |
258 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 268 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
259 const gfx::Size& size) { | 269 const gfx::Size& size) { |
260 if (!per_compositor_data_.count(compositor)) | 270 if (!per_compositor_data_.count(compositor)) |
261 return; | 271 return; |
262 per_compositor_data_[compositor]->Resize(size); | 272 per_compositor_data_[compositor].display->Resize(size); |
263 } | 273 } |
264 | 274 |
265 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { | 275 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { |
266 observer_list_.AddObserver(observer); | 276 observer_list_.AddObserver(observer); |
267 } | 277 } |
268 | 278 |
269 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { | 279 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { |
270 observer_list_.RemoveObserver(observer); | 280 observer_list_.RemoveObserver(observer); |
271 } | 281 } |
272 | 282 |
| 283 InProcessContextFactory::PerCompositorData::PerCompositorData() = default; |
| 284 InProcessContextFactory::PerCompositorData::~PerCompositorData() = default; |
| 285 InProcessContextFactory::PerCompositorData::PerCompositorData( |
| 286 PerCompositorData&&) = default; |
| 287 InProcessContextFactory::PerCompositorData& |
| 288 InProcessContextFactory::PerCompositorData::operator=(PerCompositorData&&) = |
| 289 default; |
| 290 |
273 } // namespace ui | 291 } // namespace ui |
OLD | NEW |