| 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/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.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/base/histograms.h" | 17 #include "cc/base/histograms.h" |
| 18 #include "cc/output/compositor_frame.h" | 18 #include "cc/output/compositor_frame.h" |
| 19 #include "cc/output/output_surface.h" | 19 #include "cc/output/output_surface.h" |
| 20 #include "cc/raster/single_thread_task_graph_runner.h" |
| 20 #include "cc/raster/task_graph_runner.h" | 21 #include "cc/raster/task_graph_runner.h" |
| 21 #include "cc/surfaces/onscreen_display_client.h" | 22 #include "cc/surfaces/onscreen_display_client.h" |
| 22 #include "cc/surfaces/surface_display_output_surface.h" | 23 #include "cc/surfaces/surface_display_output_surface.h" |
| 23 #include "cc/surfaces/surface_manager.h" | 24 #include "cc/surfaces/surface_manager.h" |
| 24 #include "content/browser/compositor/browser_compositor_output_surface.h" | 25 #include "content/browser/compositor/browser_compositor_output_surface.h" |
| 25 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" | 26 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" |
| 26 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 27 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
| 27 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 28 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
| 28 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" | 29 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
| 29 #include "content/browser/compositor/reflector_impl.h" | 30 #include "content/browser/compositor/reflector_impl.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 #include "content/browser/compositor/software_output_device_mac.h" | 70 #include "content/browser/compositor/software_output_device_mac.h" |
| 70 #include "ui/base/cocoa/remote_layer_api.h" | 71 #include "ui/base/cocoa/remote_layer_api.h" |
| 71 #endif | 72 #endif |
| 72 | 73 |
| 73 using cc::ContextProvider; | 74 using cc::ContextProvider; |
| 74 using gpu::gles2::GLES2Interface; | 75 using gpu::gles2::GLES2Interface; |
| 75 | 76 |
| 76 static const int kNumRetriesBeforeSoftwareFallback = 4; | 77 static const int kNumRetriesBeforeSoftwareFallback = 4; |
| 77 | 78 |
| 78 namespace content { | 79 namespace content { |
| 79 namespace { | |
| 80 | |
| 81 class RasterThread : public base::SimpleThread { | |
| 82 public: | |
| 83 RasterThread(cc::TaskGraphRunner* task_graph_runner) | |
| 84 : base::SimpleThread("CompositorTileWorker1"), | |
| 85 task_graph_runner_(task_graph_runner) {} | |
| 86 | |
| 87 // Overridden from base::SimpleThread: | |
| 88 void Run() override { task_graph_runner_->Run(); } | |
| 89 | |
| 90 private: | |
| 91 cc::TaskGraphRunner* task_graph_runner_; | |
| 92 | |
| 93 DISALLOW_COPY_AND_ASSIGN(RasterThread); | |
| 94 }; | |
| 95 | |
| 96 } // namespace | |
| 97 | 80 |
| 98 struct GpuProcessTransportFactory::PerCompositorData { | 81 struct GpuProcessTransportFactory::PerCompositorData { |
| 99 int surface_id; | 82 int surface_id; |
| 100 BrowserCompositorOutputSurface* surface; | 83 BrowserCompositorOutputSurface* surface; |
| 101 ReflectorImpl* reflector; | 84 ReflectorImpl* reflector; |
| 102 scoped_ptr<cc::OnscreenDisplayClient> display_client; | 85 scoped_ptr<cc::OnscreenDisplayClient> display_client; |
| 103 | 86 |
| 104 PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {} | 87 PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {} |
| 105 }; | 88 }; |
| 106 | 89 |
| 107 GpuProcessTransportFactory::GpuProcessTransportFactory() | 90 GpuProcessTransportFactory::GpuProcessTransportFactory() |
| 108 : next_surface_id_namespace_(1u), | 91 : next_surface_id_namespace_(1u), |
| 109 task_graph_runner_(new cc::TaskGraphRunner), | 92 task_graph_runner_(new cc::SingleThreadTaskGraphRunner), |
| 110 callback_factory_(this) { | 93 callback_factory_(this) { |
| 111 ui::Layer::InitializeUILayerSettings(); | 94 ui::Layer::InitializeUILayerSettings(); |
| 112 cc::SetClientNameForMetrics("Browser"); | 95 cc::SetClientNameForMetrics("Browser"); |
| 113 | 96 |
| 114 if (UseSurfacesEnabled()) | 97 if (UseSurfacesEnabled()) |
| 115 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); | 98 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); |
| 116 | 99 |
| 117 raster_thread_.reset(new RasterThread(task_graph_runner_.get())); | 100 task_graph_runner_->Start("CompositorTileWorker1", |
| 118 raster_thread_->Start(); | 101 base::SimpleThread::Options()); |
| 119 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
| 120 software_backing_.reset(new OutputDeviceBacking); | 103 software_backing_.reset(new OutputDeviceBacking); |
| 121 #endif | 104 #endif |
| 122 } | 105 } |
| 123 | 106 |
| 124 GpuProcessTransportFactory::~GpuProcessTransportFactory() { | 107 GpuProcessTransportFactory::~GpuProcessTransportFactory() { |
| 125 DCHECK(per_compositor_data_.empty()); | 108 DCHECK(per_compositor_data_.empty()); |
| 126 | 109 |
| 127 // Make sure the lost context callback doesn't try to run during destruction. | 110 // Make sure the lost context callback doesn't try to run during destruction. |
| 128 callback_factory_.InvalidateWeakPtrs(); | 111 callback_factory_.InvalidateWeakPtrs(); |
| 129 | 112 |
| 130 task_graph_runner_->Shutdown(); | 113 task_graph_runner_->Shutdown(); |
| 131 if (raster_thread_) | |
| 132 raster_thread_->Join(); | |
| 133 } | 114 } |
| 134 | 115 |
| 135 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 116 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
| 136 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { | 117 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { |
| 137 #if defined(OS_ANDROID) | 118 #if defined(OS_ANDROID) |
| 138 // TODO(mfomitchev): crbug.com/546716 | 119 // TODO(mfomitchev): crbug.com/546716 |
| 139 return CreateContextCommon(scoped_refptr<GpuChannelHost>(nullptr), 0); | 120 return CreateContextCommon(scoped_refptr<GpuChannelHost>(nullptr), 0); |
| 140 #else | 121 #else |
| 141 CauseForGpuLaunch cause = | 122 CauseForGpuLaunch cause = |
| 142 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 123 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, | 652 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, |
| 672 observer_list_, | 653 observer_list_, |
| 673 OnLostResources()); | 654 OnLostResources()); |
| 674 | 655 |
| 675 // Kill things that use the shared context before killing the shared context. | 656 // Kill things that use the shared context before killing the shared context. |
| 676 lost_gl_helper.reset(); | 657 lost_gl_helper.reset(); |
| 677 lost_shared_main_thread_contexts = NULL; | 658 lost_shared_main_thread_contexts = NULL; |
| 678 } | 659 } |
| 679 | 660 |
| 680 } // namespace content | 661 } // namespace content |
| OLD | NEW |