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> |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 base::Histogram* histogram = base::Histogram::FactoryGet( | 166 base::Histogram* histogram = base::Histogram::FactoryGet( |
167 name, min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag); | 167 name, min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag); |
168 return histogram; | 168 return histogram; |
169 } | 169 } |
170 | 170 |
171 static void AddHistogramSample(void* hist, int sample) { | 171 static void AddHistogramSample(void* hist, int sample) { |
172 base::Histogram* histogram = static_cast<base::Histogram*>(hist); | 172 base::Histogram* histogram = static_cast<base::Histogram*>(hist); |
173 histogram->Add(sample); | 173 histogram->Add(sample); |
174 } | 174 } |
175 | 175 |
| 176 RenderThreadImpl::GpuVDAContextLostCallback::GpuVDAContextLostCallback() {} |
| 177 |
| 178 RenderThreadImpl::GpuVDAContextLostCallback::~GpuVDAContextLostCallback() {} |
| 179 |
| 180 void RenderThreadImpl::GpuVDAContextLostCallback::onContextLost() { |
| 181 ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind( |
| 182 &RenderThreadImpl::OnGpuVDAContextLoss)); |
| 183 } |
| 184 |
176 RenderThreadImpl* RenderThreadImpl::current() { | 185 RenderThreadImpl* RenderThreadImpl::current() { |
177 return lazy_tls.Pointer()->Get(); | 186 return lazy_tls.Pointer()->Get(); |
178 } | 187 } |
179 | 188 |
180 // When we run plugins in process, we actually run them on the render thread, | 189 // When we run plugins in process, we actually run them on the render thread, |
181 // which means that we need to make the render thread pump UI events. | 190 // which means that we need to make the render thread pump UI events. |
182 RenderThreadImpl::RenderThreadImpl() { | 191 RenderThreadImpl::RenderThreadImpl() { |
183 Init(); | 192 Init(); |
184 } | 193 } |
185 | 194 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) | 264 if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) |
256 RegisterExtension(content::GpuBenchmarkingExtension::Get()); | 265 RegisterExtension(content::GpuBenchmarkingExtension::Get()); |
257 | 266 |
258 WebKit::WebCompositor::setAcceleratedAnimationEnabled( | 267 WebKit::WebCompositor::setAcceleratedAnimationEnabled( |
259 !command_line.HasSwitch(switches::kDisableThreadedAnimation)); | 268 !command_line.HasSwitch(switches::kDisableThreadedAnimation)); |
260 WebKit::WebCompositor::setPerTilePaintingEnabled( | 269 WebKit::WebCompositor::setPerTilePaintingEnabled( |
261 command_line.HasSwitch(switches::kEnablePerTilePainting)); | 270 command_line.HasSwitch(switches::kEnablePerTilePainting)); |
262 WebKit::WebCompositor::setPartialSwapEnabled( | 271 WebKit::WebCompositor::setPartialSwapEnabled( |
263 command_line.HasSwitch(switches::kEnablePartialSwap)); | 272 command_line.HasSwitch(switches::kEnablePartialSwap)); |
264 | 273 |
| 274 context_lost_cb_.reset(new GpuVDAContextLostCallback()); |
| 275 |
265 // Note that under Linux, the media library will normally already have | 276 // Note that under Linux, the media library will normally already have |
266 // been initialized by the Zygote before this instance became a Renderer. | 277 // been initialized by the Zygote before this instance became a Renderer. |
267 FilePath media_path; | 278 FilePath media_path; |
268 PathService::Get(content::DIR_MEDIA_LIBS, &media_path); | 279 PathService::Get(content::DIR_MEDIA_LIBS, &media_path); |
269 if (!media_path.empty()) | 280 if (!media_path.empty()) |
270 media::InitializeMediaLibrary(media_path); | 281 media::InitializeMediaLibrary(media_path); |
271 | 282 |
272 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 283 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
273 } | 284 } |
274 | 285 |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 } | 750 } |
740 | 751 |
741 void RenderThreadImpl::UpdateHistograms(int sequence_number) { | 752 void RenderThreadImpl::UpdateHistograms(int sequence_number) { |
742 child_histogram_message_filter()->SendHistograms(sequence_number); | 753 child_histogram_message_filter()->SendHistograms(sequence_number); |
743 } | 754 } |
744 | 755 |
745 void RenderThreadImpl::PostponeIdleNotification() { | 756 void RenderThreadImpl::PostponeIdleNotification() { |
746 idle_notifications_to_skip_ = 2; | 757 idle_notifications_to_skip_ = 2; |
747 } | 758 } |
748 | 759 |
749 base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> | 760 /* static */ |
| 761 void RenderThreadImpl::OnGpuVDAContextLoss() { |
| 762 RenderThreadImpl* self = RenderThreadImpl::current(); |
| 763 DCHECK(self); |
| 764 if (!self->gpu_vda_context3d_.get()) |
| 765 return; |
| 766 if (self->compositor_thread()) { |
| 767 self->compositor_thread()->GetWebThread()->message_loop()->DeleteSoon( |
| 768 FROM_HERE, self->gpu_vda_context3d_.release()); |
| 769 } else { |
| 770 self->gpu_vda_context3d_.reset(); |
| 771 } |
| 772 } |
| 773 |
| 774 WebGraphicsContext3DCommandBufferImpl* |
750 RenderThreadImpl::GetGpuVDAContext3D() { | 775 RenderThreadImpl::GetGpuVDAContext3D() { |
751 // If we already handed out a pointer to a context and it's been lost, create | |
752 // a new one. | |
753 if (gpu_vda_context3d_.get() && gpu_vda_context3d_->isContextLost()) { | |
754 if (compositor_thread()) { | |
755 compositor_thread()->GetWebThread()->message_loop()->DeleteSoon( | |
756 FROM_HERE, gpu_vda_context3d_.release()); | |
757 } else { | |
758 gpu_vda_context3d_.reset(); | |
759 } | |
760 } | |
761 if (!gpu_vda_context3d_.get()) { | 776 if (!gpu_vda_context3d_.get()) { |
762 gpu_vda_context3d_.reset( | 777 gpu_vda_context3d_.reset( |
763 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 778 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
764 this, WebKit::WebGraphicsContext3D::Attributes(), | 779 this, WebKit::WebGraphicsContext3D::Attributes(), |
765 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"))); | 780 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"))); |
| 781 gpu_vda_context3d_->setContextLostCallback(context_lost_cb_.get()); |
766 } | 782 } |
767 if (!gpu_vda_context3d_.get()) | 783 return gpu_vda_context3d_.get(); |
768 return base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>(); | |
769 return gpu_vda_context3d_->AsWeakPtr(); | |
770 } | 784 } |
771 | 785 |
772 content::AudioRendererMixerManager* | 786 content::AudioRendererMixerManager* |
773 RenderThreadImpl::GetAudioRendererMixerManager() { | 787 RenderThreadImpl::GetAudioRendererMixerManager() { |
774 if (!audio_renderer_mixer_manager_.get()) { | 788 if (!audio_renderer_mixer_manager_.get()) { |
775 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( | 789 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( |
776 audio_hardware::GetOutputSampleRate(), | 790 audio_hardware::GetOutputSampleRate(), |
777 audio_hardware::GetOutputBufferSize())); | 791 audio_hardware::GetOutputBufferSize())); |
778 } | 792 } |
779 | 793 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 | 1055 |
1042 scoped_refptr<base::MessageLoopProxy> | 1056 scoped_refptr<base::MessageLoopProxy> |
1043 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 1057 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
1044 DCHECK(message_loop() == MessageLoop::current()); | 1058 DCHECK(message_loop() == MessageLoop::current()); |
1045 if (!file_thread_.get()) { | 1059 if (!file_thread_.get()) { |
1046 file_thread_.reset(new base::Thread("Renderer::FILE")); | 1060 file_thread_.reset(new base::Thread("Renderer::FILE")); |
1047 file_thread_->Start(); | 1061 file_thread_->Start(); |
1048 } | 1062 } |
1049 return file_thread_->message_loop_proxy(); | 1063 return file_thread_->message_loop_proxy(); |
1050 } | 1064 } |
OLD | NEW |