| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 CauseForGpuLaunch cause = | 256 CauseForGpuLaunch cause = |
| 257 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 257 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
| 258 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 258 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| 259 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 259 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
| 260 callback_factory_.GetWeakPtr(), compositor, | 260 callback_factory_.GetWeakPtr(), compositor, |
| 261 create_gpu_output_surface, num_attempts + 1)); | 261 create_gpu_output_surface, num_attempts + 1)); |
| 262 return; | 262 return; |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider( |
| 267 ContextProviderCommandBuffer::Create( |
| 268 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), |
| 269 BROWSER_WORKER_CONTEXT)); |
| 270 |
| 266 scoped_ptr<BrowserCompositorOutputSurface> surface; | 271 scoped_ptr<BrowserCompositorOutputSurface> surface; |
| 267 if (!create_gpu_output_surface) { | 272 if (!create_gpu_output_surface) { |
| 268 surface = make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( | 273 surface = make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( |
| 269 CreateSoftwareOutputDevice(compositor.get()), | 274 CreateSoftwareOutputDevice(compositor.get()), |
| 270 compositor->vsync_manager())); | 275 compositor->vsync_manager())); |
| 271 } else { | 276 } else { |
| 272 DCHECK(context_provider); | 277 DCHECK(context_provider); |
| 273 if (!data->surface_id) { | 278 if (!data->surface_id) { |
| 274 surface = make_scoped_ptr(new OffscreenBrowserCompositorOutputSurface( | 279 surface = make_scoped_ptr(new OffscreenBrowserCompositorOutputSurface( |
| 275 context_provider, compositor->vsync_manager(), | 280 context_provider, compositor->vsync_manager(), |
| 276 scoped_ptr<BrowserCompositorOverlayCandidateValidator>())); | 281 scoped_ptr<BrowserCompositorOverlayCandidateValidator>())); |
| 277 } else | 282 } else |
| 278 #if defined(USE_OZONE) | 283 #if defined(USE_OZONE) |
| 279 if (ui::OzonePlatform::GetInstance() | 284 if (ui::OzonePlatform::GetInstance() |
| 280 ->GetOverlayManager() | 285 ->GetOverlayManager() |
| 281 ->CanShowPrimaryPlaneAsOverlay()) { | 286 ->CanShowPrimaryPlaneAsOverlay()) { |
| 282 surface = | 287 surface = |
| 283 make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface( | 288 make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface( |
| 284 context_provider, data->surface_id, compositor->vsync_manager(), | 289 context_provider, worker_context_provider, data->surface_id, |
| 290 compositor->vsync_manager(), |
| 285 CreateOverlayCandidateValidator(compositor->widget()), GL_RGB, | 291 CreateOverlayCandidateValidator(compositor->widget()), GL_RGB, |
| 286 BrowserGpuMemoryBufferManager::current())); | 292 BrowserGpuMemoryBufferManager::current())); |
| 287 } else | 293 } else |
| 288 #endif | 294 #endif |
| 289 { | 295 { |
| 290 surface = make_scoped_ptr(new GpuBrowserCompositorOutputSurface( | 296 surface = make_scoped_ptr(new GpuBrowserCompositorOutputSurface( |
| 291 context_provider, compositor->vsync_manager(), | 297 context_provider, worker_context_provider, |
| 298 compositor->vsync_manager(), |
| 292 CreateOverlayCandidateValidator(compositor->widget()))); | 299 CreateOverlayCandidateValidator(compositor->widget()))); |
| 293 } | 300 } |
| 294 } | 301 } |
| 295 | 302 |
| 296 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an | 303 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an |
| 297 // output_surface_map_ here. | 304 // output_surface_map_ here. |
| 298 output_surface_map_.AddWithID(surface.get(), data->surface_id); | 305 output_surface_map_.AddWithID(surface.get(), data->surface_id); |
| 299 data->surface = surface.get(); | 306 data->surface = surface.get(); |
| 300 if (data->reflector) | 307 if (data->reflector) |
| 301 data->reflector->OnSourceSurfaceReady(data->surface); | 308 data->reflector->OnSourceSurfaceReady(data->surface); |
| 302 | 309 |
| 303 if (!UseSurfacesEnabled()) { | 310 if (!UseSurfacesEnabled()) { |
| 304 compositor->SetOutputSurface(surface.Pass()); | 311 compositor->SetOutputSurface(surface.Pass()); |
| 305 return; | 312 return; |
| 306 } | 313 } |
| 307 | 314 |
| 308 // This gets a bit confusing. Here we have a ContextProvider in the |surface| | 315 // This gets a bit confusing. Here we have a ContextProvider in the |surface| |
| 309 // configured to render directly to this widget. We need to make an | 316 // configured to render directly to this widget. We need to make an |
| 310 // OnscreenDisplayClient associated with that context, then return a | 317 // OnscreenDisplayClient associated with that context, then return a |
| 311 // SurfaceDisplayOutputSurface set up to draw to the display's surface. | 318 // SurfaceDisplayOutputSurface set up to draw to the display's surface. |
| 312 cc::SurfaceManager* manager = surface_manager_.get(); | 319 cc::SurfaceManager* manager = surface_manager_.get(); |
| 313 scoped_ptr<cc::OnscreenDisplayClient> display_client( | 320 scoped_ptr<cc::OnscreenDisplayClient> display_client( |
| 314 new cc::OnscreenDisplayClient( | 321 new cc::OnscreenDisplayClient( |
| 315 surface.Pass(), manager, HostSharedBitmapManager::current(), | 322 surface.Pass(), manager, HostSharedBitmapManager::current(), |
| 316 BrowserGpuMemoryBufferManager::current(), | 323 BrowserGpuMemoryBufferManager::current(), |
| 317 compositor->GetRendererSettings(), compositor->task_runner())); | 324 compositor->GetRendererSettings(), compositor->task_runner())); |
| 318 | 325 |
| 319 scoped_ptr<cc::SurfaceDisplayOutputSurface> output_surface( | 326 scoped_ptr<cc::SurfaceDisplayOutputSurface> output_surface( |
| 320 new cc::SurfaceDisplayOutputSurface( | 327 new cc::SurfaceDisplayOutputSurface( |
| 321 manager, compositor->surface_id_allocator(), context_provider)); | 328 manager, compositor->surface_id_allocator(), context_provider, |
| 329 worker_context_provider)); |
| 322 display_client->set_surface_output_surface(output_surface.get()); | 330 display_client->set_surface_output_surface(output_surface.get()); |
| 323 output_surface->set_display_client(display_client.get()); | 331 output_surface->set_display_client(display_client.get()); |
| 324 display_client->display()->Resize(compositor->size()); | 332 display_client->display()->Resize(compositor->size()); |
| 325 data->display_client = display_client.Pass(); | 333 data->display_client = display_client.Pass(); |
| 326 compositor->SetOutputSurface(output_surface.Pass()); | 334 compositor->SetOutputSurface(output_surface.Pass()); |
| 327 } | 335 } |
| 328 | 336 |
| 329 scoped_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( | 337 scoped_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( |
| 330 ui::Compositor* source_compositor, | 338 ui::Compositor* source_compositor, |
| 331 ui::Layer* target_layer) { | 339 ui::Layer* target_layer) { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 599 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 592 observer_list_, | 600 observer_list_, |
| 593 OnLostResources()); | 601 OnLostResources()); |
| 594 | 602 |
| 595 // Kill things that use the shared context before killing the shared context. | 603 // Kill things that use the shared context before killing the shared context. |
| 596 lost_gl_helper.reset(); | 604 lost_gl_helper.reset(); |
| 597 lost_shared_main_thread_contexts = NULL; | 605 lost_shared_main_thread_contexts = NULL; |
| 598 } | 606 } |
| 599 | 607 |
| 600 } // namespace content | 608 } // namespace content |
| OLD | NEW |