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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; | 96 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); | 98 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); |
99 }; | 99 }; |
100 | 100 |
101 } // namespace | 101 } // namespace |
102 | 102 |
103 InProcessContextFactory::InProcessContextFactory( | 103 InProcessContextFactory::InProcessContextFactory( |
104 bool context_factory_for_test, | 104 bool context_factory_for_test, |
105 cc::SurfaceManager* surface_manager) | 105 cc::SurfaceManager* surface_manager) |
106 : next_surface_id_namespace_(1u), | 106 : next_surface_client_id_(1u), |
107 use_test_surface_(true), | 107 use_test_surface_(true), |
108 context_factory_for_test_(context_factory_for_test), | 108 context_factory_for_test_(context_factory_for_test), |
109 surface_manager_(surface_manager) { | 109 surface_manager_(surface_manager) { |
110 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) | 110 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone) |
111 << "If running tests, ensure that main() is calling " | 111 << "If running tests, ensure that main() is calling " |
112 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; | 112 << "gl::GLSurfaceTestSupport::InitializeOneOff()"; |
113 } | 113 } |
114 | 114 |
115 InProcessContextFactory::~InProcessContextFactory() { | 115 InProcessContextFactory::~InProcessContextFactory() { |
116 DCHECK(per_compositor_data_.empty()); | 116 DCHECK(per_compositor_data_.empty()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 std::unique_ptr<cc::DelayBasedBeginFrameSource> begin_frame_source( | 172 std::unique_ptr<cc::DelayBasedBeginFrameSource> begin_frame_source( |
173 new cc::DelayBasedBeginFrameSource( | 173 new cc::DelayBasedBeginFrameSource( |
174 base::MakeUnique<cc::DelayBasedTimeSource>( | 174 base::MakeUnique<cc::DelayBasedTimeSource>( |
175 compositor->task_runner().get()))); | 175 compositor->task_runner().get()))); |
176 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 176 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
177 begin_frame_source.get(), compositor->task_runner().get(), | 177 begin_frame_source.get(), compositor->task_runner().get(), |
178 display_output_surface->capabilities().max_frames_pending)); | 178 display_output_surface->capabilities().max_frames_pending)); |
179 per_compositor_data_[compositor.get()] = base::MakeUnique<cc::Display>( | 179 per_compositor_data_[compositor.get()] = base::MakeUnique<cc::Display>( |
180 surface_manager_, GetSharedBitmapManager(), GetGpuMemoryBufferManager(), | 180 surface_manager_, GetSharedBitmapManager(), GetGpuMemoryBufferManager(), |
181 compositor->GetRendererSettings(), | 181 compositor->GetRendererSettings(), |
182 compositor->surface_id_allocator()->id_namespace(), | 182 compositor->surface_id_allocator()->client_id(), |
183 std::move(begin_frame_source), std::move(display_output_surface), | 183 std::move(begin_frame_source), std::move(display_output_surface), |
184 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( | 184 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( |
185 compositor->task_runner().get())); | 185 compositor->task_runner().get())); |
186 | 186 |
187 auto* display = per_compositor_data_[compositor.get()].get(); | 187 auto* display = per_compositor_data_[compositor.get()].get(); |
188 std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 188 std::unique_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
189 new cc::SurfaceDisplayOutputSurface( | 189 new cc::SurfaceDisplayOutputSurface( |
190 surface_manager_, compositor->surface_id_allocator(), display, | 190 surface_manager_, compositor->surface_id_allocator(), display, |
191 context_provider, shared_worker_context_provider_)); | 191 context_provider, shared_worker_context_provider_)); |
192 compositor->SetOutputSurface(std::move(surface_output_surface)); | 192 compositor->SetOutputSurface(std::move(surface_output_surface)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return &gpu_memory_buffer_manager_; | 245 return &gpu_memory_buffer_manager_; |
246 } | 246 } |
247 | 247 |
248 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { | 248 cc::TaskGraphRunner* InProcessContextFactory::GetTaskGraphRunner() { |
249 return &task_graph_runner_; | 249 return &task_graph_runner_; |
250 } | 250 } |
251 | 251 |
252 std::unique_ptr<cc::SurfaceIdAllocator> | 252 std::unique_ptr<cc::SurfaceIdAllocator> |
253 InProcessContextFactory::CreateSurfaceIdAllocator() { | 253 InProcessContextFactory::CreateSurfaceIdAllocator() { |
254 std::unique_ptr<cc::SurfaceIdAllocator> allocator( | 254 std::unique_ptr<cc::SurfaceIdAllocator> allocator( |
255 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); | 255 new cc::SurfaceIdAllocator(next_surface_client_id_++)); |
256 if (surface_manager_) | 256 if (surface_manager_) |
257 allocator->RegisterSurfaceIdNamespace(surface_manager_); | 257 allocator->RegisterSurfaceClientId(surface_manager_); |
258 return allocator; | 258 return allocator; |
259 } | 259 } |
260 | 260 |
261 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { | 261 cc::SurfaceManager* InProcessContextFactory::GetSurfaceManager() { |
262 return surface_manager_; | 262 return surface_manager_; |
263 } | 263 } |
264 | 264 |
265 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 265 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
266 const gfx::Size& size) { | 266 const gfx::Size& size) { |
267 if (!per_compositor_data_.count(compositor)) | 267 if (!per_compositor_data_.count(compositor)) |
268 return; | 268 return; |
269 per_compositor_data_[compositor]->Resize(size); | 269 per_compositor_data_[compositor]->Resize(size); |
270 } | 270 } |
271 | 271 |
272 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { | 272 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { |
273 observer_list_.AddObserver(observer); | 273 observer_list_.AddObserver(observer); |
274 } | 274 } |
275 | 275 |
276 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { | 276 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { |
277 observer_list_.RemoveObserver(observer); | 277 observer_list_.RemoveObserver(observer); |
278 } | 278 } |
279 | 279 |
280 } // namespace ui | 280 } // namespace ui |
OLD | NEW |