| 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" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
| 15 #include "base/threading/simple_thread.h" | 15 #include "base/threading/simple_thread.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
| 18 #include "cc/output/output_surface.h" | 18 #include "cc/output/output_surface.h" |
| 19 #include "cc/resources/task_graph_runner.h" | 19 #include "cc/resources/task_graph_runner.h" |
| 20 #include "cc/surfaces/onscreen_display_client.h" | 20 #include "cc/surfaces/onscreen_display_client.h" |
| 21 #include "cc/surfaces/surface_display_output_surface.h" | 21 #include "cc/surfaces/surface_display_output_surface.h" |
| 22 #include "cc/surfaces/surface_manager.h" | 22 #include "cc/surfaces/surface_manager.h" |
| 23 #include "content/browser/compositor/browser_compositor_output_surface.h" | 23 #include "content/browser/compositor/browser_compositor_output_surface.h" |
| 24 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" | 24 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" |
| 25 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 25 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
| 26 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 26 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
| 27 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
| 27 #include "content/browser/compositor/reflector_impl.h" | 28 #include "content/browser/compositor/reflector_impl.h" |
| 28 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 29 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
| 29 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 30 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 30 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 31 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 31 #include "content/browser/gpu/compositor_util.h" | 32 #include "content/browser/gpu/compositor_util.h" |
| 32 #include "content/browser/gpu/gpu_data_manager_impl.h" | 33 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 33 #include "content/browser/gpu/gpu_surface_tracker.h" | 34 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 34 #include "content/browser/renderer_host/render_widget_host_impl.h" | 35 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 35 #include "content/common/gpu/client/context_provider_command_buffer.h" | 36 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 36 #include "content/common/gpu/client/gl_helper.h" | 37 #include "content/common/gpu/client/gl_helper.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 } | 277 } |
| 277 } | 278 } |
| 278 | 279 |
| 279 scoped_ptr<BrowserCompositorOutputSurface> surface; | 280 scoped_ptr<BrowserCompositorOutputSurface> surface; |
| 280 if (!create_gpu_output_surface) { | 281 if (!create_gpu_output_surface) { |
| 281 surface = make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( | 282 surface = make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( |
| 282 CreateSoftwareOutputDevice(compositor.get()), | 283 CreateSoftwareOutputDevice(compositor.get()), |
| 283 compositor->vsync_manager())); | 284 compositor->vsync_manager())); |
| 284 } else { | 285 } else { |
| 285 DCHECK(context_provider); | 286 DCHECK(context_provider); |
| 287 if (!data->surface_id) { |
| 288 surface = make_scoped_ptr(new OffscreenBrowserCompositorOutputSurface( |
| 289 context_provider, compositor->vsync_manager(), |
| 290 scoped_ptr<BrowserCompositorOverlayCandidateValidator>())); |
| 291 } else |
| 286 #if defined(USE_OZONE) | 292 #if defined(USE_OZONE) |
| 287 if (ui::SurfaceFactoryOzone::GetInstance() | 293 if (ui::SurfaceFactoryOzone::GetInstance() |
| 288 ->CanShowPrimaryPlaneAsOverlay()) { | 294 ->CanShowPrimaryPlaneAsOverlay()) { |
| 289 surface = | 295 surface = |
| 290 make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface( | 296 make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface( |
| 291 context_provider, data->surface_id, compositor->vsync_manager(), | 297 context_provider, data->surface_id, compositor->vsync_manager(), |
| 292 CreateOverlayCandidateValidator(compositor->widget()), GL_RGB, | 298 CreateOverlayCandidateValidator(compositor->widget()), GL_RGB, |
| 293 BrowserGpuMemoryBufferManager::current())); | 299 BrowserGpuMemoryBufferManager::current())); |
| 294 } else | 300 } else |
| 295 #endif | 301 #endif |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) { | 365 void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) { |
| 360 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); | 366 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); |
| 361 if (it == per_compositor_data_.end()) | 367 if (it == per_compositor_data_.end()) |
| 362 return; | 368 return; |
| 363 PerCompositorData* data = it->second; | 369 PerCompositorData* data = it->second; |
| 364 DCHECK(data); | 370 DCHECK(data); |
| 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 if (data->surface) | 373 if (data->surface) |
| 368 output_surface_map_.Remove(data->surface_id); | 374 output_surface_map_.Remove(data->surface_id); |
| 369 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); | 375 if (data->surface_id) |
| 376 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); |
| 370 delete data; | 377 delete data; |
| 371 per_compositor_data_.erase(it); | 378 per_compositor_data_.erase(it); |
| 372 if (per_compositor_data_.empty()) { | 379 if (per_compositor_data_.empty()) { |
| 373 // Destroying the GLHelper may cause some async actions to be cancelled, | 380 // Destroying the GLHelper may cause some async actions to be cancelled, |
| 374 // causing things to request a new GLHelper. Due to crbug.com/176091 the | 381 // causing things to request a new GLHelper. Due to crbug.com/176091 the |
| 375 // GLHelper created in this case would be lost/leaked if we just reset() | 382 // GLHelper created in this case would be lost/leaked if we just reset() |
| 376 // on the |gl_helper_| variable directly. So instead we call reset() on a | 383 // on the |gl_helper_| variable directly. So instead we call reset() on a |
| 377 // local scoped_ptr. | 384 // local scoped_ptr. |
| 378 scoped_ptr<GLHelper> helper = gl_helper_.Pass(); | 385 scoped_ptr<GLHelper> helper = gl_helper_.Pass(); |
| 379 | 386 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 526 |
| 520 GpuProcessTransportFactory::PerCompositorData* | 527 GpuProcessTransportFactory::PerCompositorData* |
| 521 GpuProcessTransportFactory::CreatePerCompositorData( | 528 GpuProcessTransportFactory::CreatePerCompositorData( |
| 522 ui::Compositor* compositor) { | 529 ui::Compositor* compositor) { |
| 523 DCHECK(!per_compositor_data_[compositor]); | 530 DCHECK(!per_compositor_data_[compositor]); |
| 524 | 531 |
| 525 gfx::AcceleratedWidget widget = compositor->widget(); | 532 gfx::AcceleratedWidget widget = compositor->widget(); |
| 526 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); | 533 GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); |
| 527 | 534 |
| 528 PerCompositorData* data = new PerCompositorData; | 535 PerCompositorData* data = new PerCompositorData; |
| 529 data->surface_id = tracker->AddSurfaceForNativeWidget(widget); | 536 if (compositor->widget() == gfx::kNullAcceleratedWidget) { |
| 530 tracker->SetSurfaceHandle( | 537 data->surface_id = 0; |
| 531 data->surface_id, | 538 } else { |
| 532 gfx::GLSurfaceHandle(widget, gfx::NATIVE_DIRECT)); | 539 data->surface_id = tracker->AddSurfaceForNativeWidget(widget); |
| 540 tracker->SetSurfaceHandle(data->surface_id, |
| 541 gfx::GLSurfaceHandle(widget, gfx::NATIVE_DIRECT)); |
| 542 } |
| 533 | 543 |
| 534 per_compositor_data_[compositor] = data; | 544 per_compositor_data_[compositor] = data; |
| 535 | 545 |
| 536 return data; | 546 return data; |
| 537 } | 547 } |
| 538 | 548 |
| 539 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 549 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
| 540 GpuProcessTransportFactory::CreateContextCommon( | 550 GpuProcessTransportFactory::CreateContextCommon( |
| 541 scoped_refptr<GpuChannelHost> gpu_channel_host, | 551 scoped_refptr<GpuChannelHost> gpu_channel_host, |
| 542 int surface_id) { | 552 int surface_id) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 599 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 590 observer_list_, | 600 observer_list_, |
| 591 OnLostResources()); | 601 OnLostResources()); |
| 592 | 602 |
| 593 // 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. |
| 594 lost_gl_helper.reset(); | 604 lost_gl_helper.reset(); |
| 595 lost_shared_main_thread_contexts = NULL; | 605 lost_shared_main_thread_contexts = NULL; |
| 596 } | 606 } |
| 597 | 607 |
| 598 } // namespace content | 608 } // namespace content |
| OLD | NEW |