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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
16 #include "base/threading/simple_thread.h" | 16 #include "base/threading/simple_thread.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "cc/base/histograms.h" | 19 #include "cc/base/histograms.h" |
20 #include "cc/output/compositor_frame.h" | 20 #include "cc/output/compositor_frame.h" |
21 #include "cc/output/output_surface.h" | 21 #include "cc/output/output_surface.h" |
22 #include "cc/raster/single_thread_task_graph_runner.h" | 22 #include "cc/raster/single_thread_task_graph_runner.h" |
23 #include "cc/raster/task_graph_runner.h" | 23 #include "cc/raster/task_graph_runner.h" |
24 #include "cc/surfaces/onscreen_display_client.h" | 24 #include "cc/surfaces/onscreen_display_client.h" |
25 #include "cc/surfaces/surface_display_output_surface.h" | 25 #include "cc/surfaces/surface_display_output_surface.h" |
26 #include "cc/surfaces/surface_manager.h" | 26 #include "cc/surfaces/surface_manager.h" |
| 27 #include "components/display_compositor/gl_helper.h" |
27 #include "content/browser/compositor/browser_compositor_output_surface.h" | 28 #include "content/browser/compositor/browser_compositor_output_surface.h" |
28 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" | 29 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" |
29 #include "content/browser/compositor/gl_helper.h" | |
30 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 30 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
31 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 31 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
32 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" | 32 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
33 #include "content/browser/compositor/reflector_impl.h" | 33 #include "content/browser/compositor/reflector_impl.h" |
34 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 34 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
35 #include "content/browser/compositor/software_output_device_mus.h" | 35 #include "content/browser/compositor/software_output_device_mus.h" |
36 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 36 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
37 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 37 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
38 #include "content/browser/gpu/gpu_data_manager_impl.h" | 38 #include "content/browser/gpu/gpu_data_manager_impl.h" |
39 #include "content/browser/gpu/gpu_surface_tracker.h" | 39 #include "content/browser/gpu/gpu_surface_tracker.h" |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 if (data->surface_id) | 481 if (data->surface_id) |
482 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); | 482 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); |
483 delete data; | 483 delete data; |
484 per_compositor_data_.erase(it); | 484 per_compositor_data_.erase(it); |
485 if (per_compositor_data_.empty()) { | 485 if (per_compositor_data_.empty()) { |
486 // Destroying the GLHelper may cause some async actions to be cancelled, | 486 // Destroying the GLHelper may cause some async actions to be cancelled, |
487 // causing things to request a new GLHelper. Due to crbug.com/176091 the | 487 // causing things to request a new GLHelper. Due to crbug.com/176091 the |
488 // GLHelper created in this case would be lost/leaked if we just reset() | 488 // GLHelper created in this case would be lost/leaked if we just reset() |
489 // on the |gl_helper_| variable directly. So instead we call reset() on a | 489 // on the |gl_helper_| variable directly. So instead we call reset() on a |
490 // local std::unique_ptr. | 490 // local std::unique_ptr. |
491 std::unique_ptr<GLHelper> helper = std::move(gl_helper_); | 491 std::unique_ptr<display_compositor::GLHelper> helper = |
| 492 std::move(gl_helper_); |
492 | 493 |
493 // If there are any observer left at this point, make sure they clean up | 494 // If there are any observer left at this point, make sure they clean up |
494 // before we destroy the GLHelper. | 495 // before we destroy the GLHelper. |
495 FOR_EACH_OBSERVER( | 496 FOR_EACH_OBSERVER( |
496 ImageTransportFactoryObserver, observer_list_, OnLostResources()); | 497 ImageTransportFactoryObserver, observer_list_, OnLostResources()); |
497 | 498 |
498 helper.reset(); | 499 helper.reset(); |
499 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " | 500 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " |
500 "GLHelper to be created."; | 501 "GLHelper to be created."; |
501 } | 502 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 PerCompositorData* data = it->second; | 548 PerCompositorData* data = it->second; |
548 DCHECK(data); | 549 DCHECK(data); |
549 if (data->display_client) | 550 if (data->display_client) |
550 data->display_client->display()->Resize(size); | 551 data->display_client->display()->Resize(size); |
551 } | 552 } |
552 | 553 |
553 cc::SurfaceManager* GpuProcessTransportFactory::GetSurfaceManager() { | 554 cc::SurfaceManager* GpuProcessTransportFactory::GetSurfaceManager() { |
554 return surface_manager_.get(); | 555 return surface_manager_.get(); |
555 } | 556 } |
556 | 557 |
557 GLHelper* GpuProcessTransportFactory::GetGLHelper() { | 558 display_compositor::GLHelper* GpuProcessTransportFactory::GetGLHelper() { |
558 if (!gl_helper_ && !per_compositor_data_.empty()) { | 559 if (!gl_helper_ && !per_compositor_data_.empty()) { |
559 scoped_refptr<cc::ContextProvider> provider = | 560 scoped_refptr<cc::ContextProvider> provider = |
560 SharedMainThreadContextProvider(); | 561 SharedMainThreadContextProvider(); |
561 if (provider.get()) | 562 if (provider.get()) |
562 gl_helper_.reset(new GLHelper(provider->ContextGL(), | 563 gl_helper_.reset(new display_compositor::GLHelper( |
563 provider->ContextSupport())); | 564 provider->ContextGL(), provider->ContextSupport())); |
564 } | 565 } |
565 return gl_helper_.get(); | 566 return gl_helper_.get(); |
566 } | 567 } |
567 | 568 |
568 void GpuProcessTransportFactory::AddObserver( | 569 void GpuProcessTransportFactory::AddObserver( |
569 ImageTransportFactoryObserver* observer) { | 570 ImageTransportFactoryObserver* observer) { |
570 observer_list_.AddObserver(observer); | 571 observer_list_.AddObserver(observer); |
571 } | 572 } |
572 | 573 |
573 void GpuProcessTransportFactory::RemoveObserver( | 574 void GpuProcessTransportFactory::RemoveObserver( |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 LOG(ERROR) << "Lost UI shared context."; | 669 LOG(ERROR) << "Lost UI shared context."; |
669 | 670 |
670 // Keep old resources around while we call the observers, but ensure that | 671 // Keep old resources around while we call the observers, but ensure that |
671 // new resources are created if needed. | 672 // new resources are created if needed. |
672 // Kill shared contexts for both threads in tandem so they are always in | 673 // Kill shared contexts for both threads in tandem so they are always in |
673 // the same share group. | 674 // the same share group. |
674 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = | 675 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = |
675 shared_main_thread_contexts_; | 676 shared_main_thread_contexts_; |
676 shared_main_thread_contexts_ = NULL; | 677 shared_main_thread_contexts_ = NULL; |
677 | 678 |
678 std::unique_ptr<GLHelper> lost_gl_helper = std::move(gl_helper_); | 679 std::unique_ptr<display_compositor::GLHelper> lost_gl_helper = |
| 680 std::move(gl_helper_); |
679 | 681 |
680 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 682 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
681 observer_list_, | 683 observer_list_, |
682 OnLostResources()); | 684 OnLostResources()); |
683 | 685 |
684 // Kill things that use the shared context before killing the shared context. | 686 // Kill things that use the shared context before killing the shared context. |
685 lost_gl_helper.reset(); | 687 lost_gl_helper.reset(); |
686 lost_shared_main_thread_contexts = NULL; | 688 lost_shared_main_thread_contexts = NULL; |
687 } | 689 } |
688 | 690 |
689 } // namespace content | 691 } // namespace content |
OLD | NEW |