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_BGRA_EXT; | 349 format = GL_BGRA_EXT; |
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 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 664 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
659 observer_list_, | 665 observer_list_, |
660 OnLostResources()); | 666 OnLostResources()); |
661 | 667 |
662 // Kill things that use the shared context before killing the shared context. | 668 // Kill things that use the shared context before killing the shared context. |
663 lost_gl_helper.reset(); | 669 lost_gl_helper.reset(); |
664 lost_shared_main_thread_contexts = NULL; | 670 lost_shared_main_thread_contexts = NULL; |
665 } | 671 } |
666 | 672 |
667 } // namespace content | 673 } // namespace content |
OLD | NEW |