OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/allocator/allocator_extension.h" | 12 #include "base/allocator/allocator_extension.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/weak_ptr.h" | |
17 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
18 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
19 #include "base/metrics/stats_table.h" | 20 #include "base/metrics/stats_table.h" |
20 #include "base/path_service.h" | 21 #include "base/path_service.h" |
21 #include "base/shared_memory.h" | 22 #include "base/shared_memory.h" |
22 #include "base/string16.h" | 23 #include "base/string16.h" |
23 #include "base/string_number_conversions.h" // Temporary | 24 #include "base/string_number_conversions.h" // Temporary |
24 #include "base/threading/thread_local.h" | 25 #include "base/threading/thread_local.h" |
25 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
26 #include "base/values.h" | 27 #include "base/values.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" | 92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" |
92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h " | 94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h " |
94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorkerReposi tory.h" | 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorkerReposi tory.h" |
96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
97 #include "ui/base/layout.h" | 98 #include "ui/base/layout.h" |
98 #include "ui/base/ui_base_switches.h" | 99 #include "ui/base/ui_base_switches.h" |
99 #include "v8/include/v8.h" | 100 #include "v8/include/v8.h" |
100 #include "webkit/glue/webkit_glue.h" | 101 #include "webkit/glue/webkit_glue.h" |
102 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | |
101 | 103 |
102 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
103 #include <windows.h> | 105 #include <windows.h> |
104 #include <objbase.h> | 106 #include <objbase.h> |
105 #include "base/win/scoped_com_initializer.h" | 107 #include "base/win/scoped_com_initializer.h" |
106 #else | 108 #else |
107 // TODO(port) | 109 // TODO(port) |
108 #include "base/memory/scoped_handle.h" | 110 #include "base/memory/scoped_handle.h" |
109 #include "content/common/np_channel_base.h" | 111 #include "content/common/np_channel_base.h" |
110 #endif | 112 #endif |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 v8::V8::SetCreateHistogramFunction(CreateHistogram); | 276 v8::V8::SetCreateHistogramFunction(CreateHistogram); |
275 } | 277 } |
276 } | 278 } |
277 | 279 |
278 RenderThreadImpl* RenderThreadImpl::current() { | 280 RenderThreadImpl* RenderThreadImpl::current() { |
279 return lazy_tls.Pointer()->Get(); | 281 return lazy_tls.Pointer()->Get(); |
280 } | 282 } |
281 | 283 |
282 // When we run plugins in process, we actually run them on the render thread, | 284 // When we run plugins in process, we actually run them on the render thread, |
283 // which means that we need to make the render thread pump UI events. | 285 // which means that we need to make the render thread pump UI events. |
284 RenderThreadImpl::RenderThreadImpl() { | 286 RenderThreadImpl::RenderThreadImpl() |
287 : shared_context_main_thread_(this), | |
piman
2013/02/11 19:15:30
nit: you'll need the ALLOW_THIS_IN_INITIALIZER_LIS
danakj
2013/02/11 20:53:36
Done.
| |
288 shared_context_compositor_thread_(this) { | |
285 Init(); | 289 Init(); |
286 } | 290 } |
287 | 291 |
288 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) | 292 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) |
289 : ChildThread(channel_name) { | 293 : ChildThread(channel_name), |
294 shared_context_main_thread_(this), | |
295 shared_context_compositor_thread_(this) { | |
290 Init(); | 296 Init(); |
291 } | 297 } |
292 | 298 |
293 void RenderThreadImpl::Init() { | 299 void RenderThreadImpl::Init() { |
294 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); | 300 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); |
295 | 301 |
296 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); | 302 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); |
297 v8::V8::SetCreateHistogramFunction(CreateHistogram); | 303 v8::V8::SetCreateHistogramFunction(CreateHistogram); |
298 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample); | 304 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample); |
299 | 305 |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1117 gpu_channel_ = new GpuChannelHost(this, 0, client_id); | 1123 gpu_channel_ = new GpuChannelHost(this, 0, client_id); |
1118 gpu_channel_->set_gpu_info(gpu_info); | 1124 gpu_channel_->set_gpu_info(gpu_info); |
1119 GetContentClient()->SetGpuInfo(gpu_info); | 1125 GetContentClient()->SetGpuInfo(gpu_info); |
1120 | 1126 |
1121 // Connect to the GPU process if a channel name was received. | 1127 // Connect to the GPU process if a channel name was received. |
1122 gpu_channel_->Connect(channel_handle); | 1128 gpu_channel_->Connect(channel_handle); |
1123 | 1129 |
1124 return GetGpuChannel(); | 1130 return GetGpuChannel(); |
1125 } | 1131 } |
1126 | 1132 |
1133 WebKit::WebGraphicsContext3D* RenderThreadImpl:: | |
1134 OffscreenContext3dForMainThread() { | |
1135 DCHECK(IsMainThread()); | |
1136 return shared_context_main_thread_.Context3d(); | |
1137 } | |
1138 WebKit::WebGraphicsContext3D* RenderThreadImpl:: | |
1139 OffscreenContext3dForCompositorThread() { | |
1140 DCHECK(IsMainThread()); | |
1141 return shared_context_compositor_thread_.Context3d(); | |
1142 } | |
1143 | |
1144 GrContext* RenderThreadImpl::OffscreenGrContextForMainThread() { | |
1145 DCHECK(IsMainThread()); | |
1146 return shared_context_main_thread_.GrContext(); | |
1147 } | |
1148 | |
1149 GrContext* RenderThreadImpl::OffscreenGrContextForCompositorThread() { | |
1150 DCHECK(IsMainThread()); | |
1151 return shared_context_compositor_thread_.GrContext(); | |
1152 } | |
1153 | |
1154 WebKit::WebGraphicsContext3D* RenderThreadImpl::CreateOffscreenContext() { | |
1155 WebKit::WebGraphicsContext3D::Attributes attributes; | |
1156 attributes.shareResources = true; | |
1157 attributes.depth = false; | |
1158 attributes.stencil = false; | |
1159 attributes.antialias = false; | |
1160 attributes.noAutomaticFlushes = true; | |
1161 | |
1162 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { | |
1163 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( | |
1164 attributes, false); | |
1165 } | |
1166 | |
1167 GURL url("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"); | |
1168 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | |
piman
2013/02/11 19:15:30
use WebGraphicsContext3DCommandBufferImpl::CreateO
danakj
2013/02/11 20:53:36
Oh, nice. Done.
| |
1169 new WebGraphicsContext3DCommandBufferImpl( | |
1170 0, | |
1171 url, | |
1172 this, | |
1173 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>())); | |
1174 if (!context->Initialize( | |
1175 attributes, | |
1176 false, | |
1177 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) | |
1178 return NULL; | |
1179 return context.release(); | |
1180 } | |
1181 | |
1127 WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( | 1182 WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( |
1128 WebKit::WebMediaStreamCenterClient* client) { | 1183 WebKit::WebMediaStreamCenterClient* client) { |
1129 #if defined(OS_ANDROID) | 1184 #if defined(OS_ANDROID) |
1130 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1185 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1131 switches::kEnableWebRTC)) | 1186 switches::kEnableWebRTC)) |
1132 return NULL; | 1187 return NULL; |
1133 #endif | 1188 #endif |
1134 | 1189 |
1135 #if defined(ENABLE_WEBRTC) | 1190 #if defined(ENABLE_WEBRTC) |
1136 if (!media_stream_center_) | 1191 if (!media_stream_center_) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 | 1251 |
1197 void RenderThreadImpl::SetFlingCurveParameters( | 1252 void RenderThreadImpl::SetFlingCurveParameters( |
1198 const std::vector<float>& new_touchpad, | 1253 const std::vector<float>& new_touchpad, |
1199 const std::vector<float>& new_touchscreen) { | 1254 const std::vector<float>& new_touchscreen) { |
1200 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1255 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
1201 new_touchscreen); | 1256 new_touchscreen); |
1202 | 1257 |
1203 } | 1258 } |
1204 | 1259 |
1205 } // namespace content | 1260 } // namespace content |
OLD | NEW |