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