| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 317 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
| 318 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 318 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| 319 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 319 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
| 320 callback_factory_.GetWeakPtr(), compositor, | 320 callback_factory_.GetWeakPtr(), compositor, |
| 321 create_gpu_output_surface, num_attempts + 1)); | 321 create_gpu_output_surface, num_attempts + 1)); |
| 322 return; | 322 return; |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 | 325 |
| 326 scoped_ptr<BrowserCompositorOutputSurface> surface; | 326 scoped_ptr<BrowserCompositorOutputSurface> surface; |
| 327 scoped_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source = |
| 328 cc::SyntheticBeginFrameSource::Create( |
| 329 compositor->task_runner().get(), |
| 330 cc::BeginFrameArgs::DefaultInterval()); |
| 327 if (!create_gpu_output_surface) { | 331 if (!create_gpu_output_surface) { |
| 328 surface = make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( | 332 surface = make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( |
| 329 CreateSoftwareOutputDevice(compositor.get()), | 333 CreateSoftwareOutputDevice(compositor.get()), |
| 330 compositor->vsync_manager())); | 334 compositor->vsync_manager(), std::move(synthetic_begin_frame_source))); |
| 331 } else { | 335 } else { |
| 332 DCHECK(context_provider); | 336 DCHECK(context_provider); |
| 333 ContextProvider::Capabilities capabilities = | 337 ContextProvider::Capabilities capabilities = |
| 334 context_provider->ContextCapabilities(); | 338 context_provider->ContextCapabilities(); |
| 335 if (!data->surface_id) { | 339 if (!data->surface_id) { |
| 336 surface = make_scoped_ptr(new OffscreenBrowserCompositorOutputSurface( | 340 surface = make_scoped_ptr(new OffscreenBrowserCompositorOutputSurface( |
| 337 context_provider, shared_worker_context_provider_, | 341 context_provider, shared_worker_context_provider_, |
| 338 compositor->vsync_manager(), | 342 compositor->vsync_manager(), std::move(synthetic_begin_frame_source), |
| 339 scoped_ptr<BrowserCompositorOverlayCandidateValidator>())); | 343 scoped_ptr<BrowserCompositorOverlayCandidateValidator>())); |
| 340 } else if (capabilities.gpu.surfaceless) { | 344 } else if (capabilities.gpu.surfaceless) { |
| 341 GLenum target = GL_TEXTURE_2D; | 345 GLenum target = GL_TEXTURE_2D; |
| 342 GLenum format = GL_RGB; | 346 GLenum format = GL_RGB; |
| 343 #if defined(OS_MACOSX) | 347 #if defined(OS_MACOSX) |
| 344 target = GL_TEXTURE_RECTANGLE_ARB; | 348 target = GL_TEXTURE_RECTANGLE_ARB; |
| 345 format = GL_RGBA; | 349 format = GL_RGBA; |
| 346 #endif | 350 #endif |
| 347 surface = | 351 surface = |
| 348 make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface( | 352 make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface( |
| 349 context_provider, shared_worker_context_provider_, | 353 context_provider, shared_worker_context_provider_, |
| 350 data->surface_id, compositor->vsync_manager(), | 354 data->surface_id, compositor->vsync_manager(), |
| 355 std::move(synthetic_begin_frame_source), |
| 351 CreateOverlayCandidateValidator(compositor->widget()), target, | 356 CreateOverlayCandidateValidator(compositor->widget()), target, |
| 352 format, BrowserGpuMemoryBufferManager::current())); | 357 format, BrowserGpuMemoryBufferManager::current())); |
| 353 } else { | 358 } else { |
| 354 scoped_ptr<BrowserCompositorOverlayCandidateValidator> validator; | 359 scoped_ptr<BrowserCompositorOverlayCandidateValidator> validator; |
| 355 #if !defined(OS_MACOSX) | 360 #if !defined(OS_MACOSX) |
| 356 // Overlays are only supported on surfaceless output surfaces on Mac. | 361 // Overlays are only supported on surfaceless output surfaces on Mac. |
| 357 validator = CreateOverlayCandidateValidator(compositor->widget()); | 362 validator = CreateOverlayCandidateValidator(compositor->widget()); |
| 358 #endif | 363 #endif |
| 359 surface = make_scoped_ptr(new GpuBrowserCompositorOutputSurface( | 364 surface = make_scoped_ptr(new GpuBrowserCompositorOutputSurface( |
| 360 context_provider, shared_worker_context_provider_, | 365 context_provider, shared_worker_context_provider_, |
| 361 compositor->vsync_manager(), std::move(validator))); | 366 compositor->vsync_manager(), std::move(synthetic_begin_frame_source), |
| 367 std::move(validator))); |
| 362 } | 368 } |
| 363 } | 369 } |
| 364 | 370 |
| 365 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an | 371 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an |
| 366 // output_surface_map_ here. | 372 // output_surface_map_ here. |
| 367 output_surface_map_.AddWithID(surface.get(), data->surface_id); | 373 output_surface_map_.AddWithID(surface.get(), data->surface_id); |
| 368 data->surface = surface.get(); | 374 data->surface = surface.get(); |
| 369 if (data->reflector) | 375 if (data->reflector) |
| 370 data->reflector->OnSourceSurfaceReady(data->surface); | 376 data->reflector->OnSourceSurfaceReady(data->surface); |
| 371 | 377 |
| 372 #if defined(OS_WIN) | 378 #if defined(OS_WIN) |
| 373 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( | 379 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( |
| 374 compositor->widget()); | 380 compositor->widget()); |
| 375 #endif | 381 #endif |
| 376 | 382 |
| 377 // This gets a bit confusing. Here we have a ContextProvider in the |surface| | 383 // This gets a bit confusing. Here we have a ContextProvider in the |surface| |
| 378 // configured to render directly to this widget. We need to make an | 384 // configured to render directly to this widget. We need to make an |
| 379 // OnscreenDisplayClient associated with that context, then return a | 385 // OnscreenDisplayClient associated with that context, then return a |
| 380 // SurfaceDisplayOutputSurface set up to draw to the display's surface. | 386 // SurfaceDisplayOutputSurface set up to draw to the display's surface. |
| 381 cc::SurfaceManager* manager = surface_manager_.get(); | 387 cc::SurfaceManager* manager = surface_manager_.get(); |
| 382 scoped_ptr<cc::OnscreenDisplayClient> display_client( | 388 scoped_ptr<cc::OnscreenDisplayClient> display_client( |
| 383 new cc::OnscreenDisplayClient( | 389 new cc::OnscreenDisplayClient( |
| 384 std::move(surface), manager, HostSharedBitmapManager::current(), | 390 std::move(surface), manager, HostSharedBitmapManager::current(), |
| 385 BrowserGpuMemoryBufferManager::current(), | 391 BrowserGpuMemoryBufferManager::current(), |
| 386 compositor->GetRendererSettings(), compositor->task_runner())); | 392 compositor->GetRendererSettings(), compositor->task_runner(), |
| 393 compositor->surface_id_allocator()->id_namespace())); |
| 387 | 394 |
| 388 scoped_ptr<cc::SurfaceDisplayOutputSurface> output_surface( | 395 scoped_ptr<cc::SurfaceDisplayOutputSurface> output_surface( |
| 389 new cc::SurfaceDisplayOutputSurface( | 396 new cc::SurfaceDisplayOutputSurface( |
| 390 manager, compositor->surface_id_allocator(), context_provider, | 397 manager, compositor->surface_id_allocator(), context_provider, |
| 391 shared_worker_context_provider_)); | 398 shared_worker_context_provider_)); |
| 392 display_client->set_surface_output_surface(output_surface.get()); | 399 display_client->set_surface_output_surface(output_surface.get()); |
| 393 output_surface->set_display_client(display_client.get()); | 400 output_surface->set_display_client(display_client.get()); |
| 394 display_client->display()->Resize(compositor->size()); | 401 display_client->display()->Resize(compositor->size()); |
| 395 data->display_client = std::move(display_client); | 402 data->display_client = std::move(display_client); |
| 396 compositor->SetOutputSurface(std::move(output_surface)); | 403 compositor->SetOutputSurface(std::move(output_surface)); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 665 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 659 observer_list_, | 666 observer_list_, |
| 660 OnLostResources()); | 667 OnLostResources()); |
| 661 | 668 |
| 662 // Kill things that use the shared context before killing the shared context. | 669 // Kill things that use the shared context before killing the shared context. |
| 663 lost_gl_helper.reset(); | 670 lost_gl_helper.reset(); |
| 664 lost_shared_main_thread_contexts = NULL; | 671 lost_shared_main_thread_contexts = NULL; |
| 665 } | 672 } |
| 666 | 673 |
| 667 } // namespace content | 674 } // namespace content |
| OLD | NEW |