Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 1449133002: TaskGraphRunner refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #elif defined(OS_ANDROID) 76 #elif defined(OS_ANDROID)
76 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor_android.h" 77 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor_android.h"
77 #endif 78 #endif
78 79
79 using cc::ContextProvider; 80 using cc::ContextProvider;
80 using gpu::gles2::GLES2Interface; 81 using gpu::gles2::GLES2Interface;
81 82
82 static const int kNumRetriesBeforeSoftwareFallback = 4; 83 static const int kNumRetriesBeforeSoftwareFallback = 4;
83 84
84 namespace content { 85 namespace content {
85 namespace {
86
87 class RasterThread : public base::SimpleThread {
88 public:
89 RasterThread(cc::TaskGraphRunner* task_graph_runner)
90 : base::SimpleThread("CompositorTileWorker1"),
91 task_graph_runner_(task_graph_runner) {}
92
93 // Overridden from base::SimpleThread:
94 void Run() override { task_graph_runner_->Run(); }
95
96 private:
97 cc::TaskGraphRunner* task_graph_runner_;
98
99 DISALLOW_COPY_AND_ASSIGN(RasterThread);
100 };
101
102 } // namespace
103 86
104 struct GpuProcessTransportFactory::PerCompositorData { 87 struct GpuProcessTransportFactory::PerCompositorData {
105 int surface_id; 88 int surface_id;
106 BrowserCompositorOutputSurface* surface; 89 BrowserCompositorOutputSurface* surface;
107 ReflectorImpl* reflector; 90 ReflectorImpl* reflector;
108 scoped_ptr<cc::OnscreenDisplayClient> display_client; 91 scoped_ptr<cc::OnscreenDisplayClient> display_client;
109 92
110 PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {} 93 PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {}
111 }; 94 };
112 95
113 GpuProcessTransportFactory::GpuProcessTransportFactory() 96 GpuProcessTransportFactory::GpuProcessTransportFactory()
114 : next_surface_id_namespace_(1u), 97 : next_surface_id_namespace_(1u),
115 task_graph_runner_(new cc::TaskGraphRunner), 98 task_graph_runner_(new cc::SingleThreadTaskGraphRunner),
116 callback_factory_(this) { 99 callback_factory_(this) {
117 ui::Layer::InitializeUILayerSettings(); 100 ui::Layer::InitializeUILayerSettings();
118 cc::SetClientNameForMetrics("Browser"); 101 cc::SetClientNameForMetrics("Browser");
119 102
120 if (UseSurfacesEnabled()) 103 if (UseSurfacesEnabled())
121 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager); 104 surface_manager_ = make_scoped_ptr(new cc::SurfaceManager);
122 105
123 raster_thread_.reset(new RasterThread(task_graph_runner_.get())); 106 task_graph_runner_->Start("CompositorTileWorker1",
124 raster_thread_->Start(); 107 base::SimpleThread::Options());
125 #if defined(OS_WIN) 108 #if defined(OS_WIN)
126 software_backing_.reset(new OutputDeviceBacking); 109 software_backing_.reset(new OutputDeviceBacking);
127 #endif 110 #endif
128 } 111 }
129 112
130 GpuProcessTransportFactory::~GpuProcessTransportFactory() { 113 GpuProcessTransportFactory::~GpuProcessTransportFactory() {
131 DCHECK(per_compositor_data_.empty()); 114 DCHECK(per_compositor_data_.empty());
132 115
133 // Make sure the lost context callback doesn't try to run during destruction. 116 // Make sure the lost context callback doesn't try to run during destruction.
134 callback_factory_.InvalidateWeakPtrs(); 117 callback_factory_.InvalidateWeakPtrs();
135 118
136 task_graph_runner_->Shutdown(); 119 task_graph_runner_->Shutdown();
137 if (raster_thread_)
138 raster_thread_->Join();
139 } 120 }
140 121
141 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 122 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
142 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() { 123 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() {
143 #if defined(OS_ANDROID) 124 #if defined(OS_ANDROID)
144 // TODO(mfomitchev): crbug.com/546716 125 // TODO(mfomitchev): crbug.com/546716
145 return CreateContextCommon(scoped_refptr<GpuChannelHost>(nullptr), 0); 126 return CreateContextCommon(scoped_refptr<GpuChannelHost>(nullptr), 0);
146 #else 127 #else
147 CauseForGpuLaunch cause = 128 CauseForGpuLaunch cause =
148 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; 129 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, 657 FOR_EACH_OBSERVER(ImageTransportFactoryObserver,
677 observer_list_, 658 observer_list_,
678 OnLostResources()); 659 OnLostResources());
679 660
680 // Kill things that use the shared context before killing the shared context. 661 // Kill things that use the shared context before killing the shared context.
681 lost_gl_helper.reset(); 662 lost_gl_helper.reset();
682 lost_shared_main_thread_contexts = NULL; 663 lost_shared_main_thread_contexts = NULL;
683 } 664 }
684 665
685 } // namespace content 666 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/gpu_process_transport_factory.h ('k') | content/browser/renderer_host/compositor_impl_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698