| 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 "content/browser/compositor/gpu_process_transport_factory.h" | 5 #include "content/browser/compositor/gpu_process_transport_factory.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 manager, compositor->surface_id_allocator(), context_provider)); | 214 manager, compositor->surface_id_allocator(), context_provider)); |
| 215 display_client->set_surface_output_surface(output_surface.get()); | 215 display_client->set_surface_output_surface(output_surface.get()); |
| 216 output_surface->set_display_client(display_client.get()); | 216 output_surface->set_display_client(display_client.get()); |
| 217 display_client->display()->Resize(compositor->size()); | 217 display_client->display()->Resize(compositor->size()); |
| 218 data->display_client = display_client.Pass(); | 218 data->display_client = display_client.Pass(); |
| 219 compositor->SetOutputSurface(output_surface.Pass()); | 219 compositor->SetOutputSurface(output_surface.Pass()); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 | 222 |
| 223 if (!context_provider.get()) { | 223 if (!context_provider.get()) { |
| 224 if (compositor_thread_.get()) { | 224 #if defined(OS_CHROMEOS) |
| 225 LOG(FATAL) << "Failed to create UI context, but can't use software" | 225 LOG(FATAL) << "Shouldn't use software compositing on ChromeOS."; |
| 226 " compositing with browser threaded compositing. Aborting."; | 226 #endif |
| 227 } | |
| 228 | 227 |
| 229 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( | 228 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface( |
| 230 new SoftwareBrowserCompositorOutputSurface( | 229 new SoftwareBrowserCompositorOutputSurface( |
| 231 CreateSoftwareOutputDevice(compositor.get()), | 230 CreateSoftwareOutputDevice(compositor.get()), |
| 232 data->surface_id, | 231 data->surface_id, |
| 233 &output_surface_map_, | 232 &output_surface_map_, |
| 234 compositor->vsync_manager())); | 233 compositor->vsync_manager())); |
| 235 compositor->SetOutputSurface(surface.Pass()); | 234 compositor->SetOutputSurface(surface.Pass()); |
| 236 return; | 235 return; |
| 237 } | 236 } |
| 238 | 237 |
| 239 scoped_ptr<BrowserCompositorOutputSurface> surface; | 238 scoped_ptr<BrowserCompositorOutputSurface> surface; |
| 240 #if defined(USE_OZONE) | 239 #if defined(USE_OZONE) |
| 241 if (ui::SurfaceFactoryOzone::GetInstance()->CanShowPrimaryPlaneAsOverlay()) { | 240 if (ui::SurfaceFactoryOzone::GetInstance()->CanShowPrimaryPlaneAsOverlay()) { |
| 242 surface.reset(new GpuSurfacelessBrowserCompositorOutputSurface( | 241 surface.reset(new GpuSurfacelessBrowserCompositorOutputSurface( |
| 243 context_provider, data->surface_id, &output_surface_map_, | 242 context_provider, data->surface_id, &output_surface_map_, |
| 244 compositor->vsync_manager(), | 243 compositor->vsync_manager(), |
| 245 CreateOverlayCandidateValidator(compositor->widget()), GL_RGB, | 244 CreateOverlayCandidateValidator(compositor->widget()), GL_RGB, |
| 246 compositor_thread_ != nullptr, | |
| 247 BrowserGpuMemoryBufferManager::current())); | 245 BrowserGpuMemoryBufferManager::current())); |
| 248 } | 246 } |
| 249 #endif | 247 #endif |
| 250 if (!surface) | 248 if (!surface) |
| 251 surface.reset(new GpuBrowserCompositorOutputSurface( | 249 surface.reset(new GpuBrowserCompositorOutputSurface( |
| 252 context_provider, | 250 context_provider, |
| 253 data->surface_id, | 251 data->surface_id, |
| 254 &output_surface_map_, | 252 &output_surface_map_, |
| 255 compositor->vsync_manager(), | 253 compositor->vsync_manager(), |
| 256 CreateOverlayCandidateValidator(compositor->widget()))); | 254 CreateOverlayCandidateValidator(compositor->widget()))); |
| 257 | 255 |
| 258 if (data->reflector.get()) | 256 if (data->reflector.get()) |
| 259 data->reflector->ReattachToOutputSurfaceFromMainThread(surface.get()); | 257 data->reflector->ReattachToOutputSurfaceFromMainThread(surface.get()); |
| 260 | 258 |
| 261 compositor->SetOutputSurface(surface.Pass()); | 259 compositor->SetOutputSurface(surface.Pass()); |
| 262 } | 260 } |
| 263 | 261 |
| 264 scoped_refptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( | 262 scoped_refptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( |
| 265 ui::Compositor* source, | 263 ui::Compositor* source, |
| 266 ui::Layer* target) { | 264 ui::Layer* target) { |
| 267 PerCompositorData* data = per_compositor_data_[source]; | 265 PerCompositorData* data = per_compositor_data_[source]; |
| 268 DCHECK(data); | 266 DCHECK(data); |
| 269 | 267 |
| 270 data->reflector = new ReflectorImpl(source, | 268 data->reflector = new ReflectorImpl(source, target, &output_surface_map_, |
| 271 target, | 269 nullptr, // Compositor message loop. |
| 272 &output_surface_map_, | |
| 273 GetCompositorMessageLoop(), | |
| 274 data->surface_id); | 270 data->surface_id); |
| 275 return data->reflector; | 271 return data->reflector; |
| 276 } | 272 } |
| 277 | 273 |
| 278 void GpuProcessTransportFactory::RemoveReflector( | 274 void GpuProcessTransportFactory::RemoveReflector( |
| 279 scoped_refptr<ui::Reflector> reflector) { | 275 scoped_refptr<ui::Reflector> reflector) { |
| 280 ReflectorImpl* reflector_impl = | 276 ReflectorImpl* reflector_impl = |
| 281 static_cast<ReflectorImpl*>(reflector.get()); | 277 static_cast<ReflectorImpl*>(reflector.get()); |
| 282 PerCompositorData* data = | 278 PerCompositorData* data = |
| 283 per_compositor_data_[reflector_impl->mirrored_compositor()]; | 279 per_compositor_data_[reflector_impl->mirrored_compositor()]; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 318 |
| 323 gpu::GpuMemoryBufferManager* | 319 gpu::GpuMemoryBufferManager* |
| 324 GpuProcessTransportFactory::GetGpuMemoryBufferManager() { | 320 GpuProcessTransportFactory::GetGpuMemoryBufferManager() { |
| 325 return BrowserGpuMemoryBufferManager::current(); | 321 return BrowserGpuMemoryBufferManager::current(); |
| 326 } | 322 } |
| 327 | 323 |
| 328 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { | 324 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { |
| 329 return this; | 325 return this; |
| 330 } | 326 } |
| 331 | 327 |
| 332 base::MessageLoopProxy* GpuProcessTransportFactory::GetCompositorMessageLoop() { | |
| 333 if (!compositor_thread_) | |
| 334 return NULL; | |
| 335 return compositor_thread_->message_loop_proxy().get(); | |
| 336 } | |
| 337 | |
| 338 gfx::GLSurfaceHandle GpuProcessTransportFactory::GetSharedSurfaceHandle() { | 328 gfx::GLSurfaceHandle GpuProcessTransportFactory::GetSharedSurfaceHandle() { |
| 339 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( | 329 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle( |
| 340 gfx::kNullPluginWindow, gfx::NULL_TRANSPORT); | 330 gfx::kNullPluginWindow, gfx::NULL_TRANSPORT); |
| 341 handle.parent_client_id = | 331 handle.parent_client_id = |
| 342 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId(); | 332 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId(); |
| 343 return handle; | 333 return handle; |
| 344 } | 334 } |
| 345 | 335 |
| 346 scoped_ptr<cc::SurfaceIdAllocator> | 336 scoped_ptr<cc::SurfaceIdAllocator> |
| 347 GpuProcessTransportFactory::CreateSurfaceIdAllocator() { | 337 GpuProcessTransportFactory::CreateSurfaceIdAllocator() { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 502 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 513 observer_list_, | 503 observer_list_, |
| 514 OnLostResources()); | 504 OnLostResources()); |
| 515 | 505 |
| 516 // Kill things that use the shared context before killing the shared context. | 506 // Kill things that use the shared context before killing the shared context. |
| 517 lost_gl_helper.reset(); | 507 lost_gl_helper.reset(); |
| 518 lost_shared_main_thread_contexts = NULL; | 508 lost_shared_main_thread_contexts = NULL; |
| 519 } | 509 } |
| 520 | 510 |
| 521 } // namespace content | 511 } // namespace content |
| OLD | NEW |