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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 10832264: Fix lifecycle-vs-threads of GpuVDAContext3D. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fwd declare callback class. Created 8 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 class RenderThreadImpl::GpuVDAContextLostCallback
177 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
178 public:
179 GpuVDAContextLostCallback() {}
180 virtual ~GpuVDAContextLostCallback() {}
181 virtual void onContextLost() {
182 ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind(
183 &RenderThreadImpl::OnGpuVDAContextLoss));
184 }
185 };
186
176 RenderThreadImpl* RenderThreadImpl::current() { 187 RenderThreadImpl* RenderThreadImpl::current() {
177 return lazy_tls.Pointer()->Get(); 188 return lazy_tls.Pointer()->Get();
178 } 189 }
179 190
180 // When we run plugins in process, we actually run them on the render thread, 191 // 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. 192 // which means that we need to make the render thread pump UI events.
182 RenderThreadImpl::RenderThreadImpl() { 193 RenderThreadImpl::RenderThreadImpl() {
183 Init(); 194 Init();
184 } 195 }
185 196
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) 266 if (command_line.HasSwitch(switches::kEnableGpuBenchmarking))
256 RegisterExtension(content::GpuBenchmarkingExtension::Get()); 267 RegisterExtension(content::GpuBenchmarkingExtension::Get());
257 268
258 WebKit::WebCompositor::setAcceleratedAnimationEnabled( 269 WebKit::WebCompositor::setAcceleratedAnimationEnabled(
259 !command_line.HasSwitch(switches::kDisableThreadedAnimation)); 270 !command_line.HasSwitch(switches::kDisableThreadedAnimation));
260 WebKit::WebCompositor::setPerTilePaintingEnabled( 271 WebKit::WebCompositor::setPerTilePaintingEnabled(
261 command_line.HasSwitch(switches::kEnablePerTilePainting)); 272 command_line.HasSwitch(switches::kEnablePerTilePainting));
262 WebKit::WebCompositor::setPartialSwapEnabled( 273 WebKit::WebCompositor::setPartialSwapEnabled(
263 command_line.HasSwitch(switches::kEnablePartialSwap)); 274 command_line.HasSwitch(switches::kEnablePartialSwap));
264 275
276 context_lost_cb_.reset(new GpuVDAContextLostCallback());
277
265 // Note that under Linux, the media library will normally already have 278 // Note that under Linux, the media library will normally already have
266 // been initialized by the Zygote before this instance became a Renderer. 279 // been initialized by the Zygote before this instance became a Renderer.
267 FilePath media_path; 280 FilePath media_path;
268 PathService::Get(content::DIR_MEDIA_LIBS, &media_path); 281 PathService::Get(content::DIR_MEDIA_LIBS, &media_path);
269 if (!media_path.empty()) 282 if (!media_path.empty())
270 media::InitializeMediaLibrary(media_path); 283 media::InitializeMediaLibrary(media_path);
271 284
272 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); 285 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, "");
273 } 286 }
274 287
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 } 752 }
740 753
741 void RenderThreadImpl::UpdateHistograms(int sequence_number) { 754 void RenderThreadImpl::UpdateHistograms(int sequence_number) {
742 child_histogram_message_filter()->SendHistograms(sequence_number); 755 child_histogram_message_filter()->SendHistograms(sequence_number);
743 } 756 }
744 757
745 void RenderThreadImpl::PostponeIdleNotification() { 758 void RenderThreadImpl::PostponeIdleNotification() {
746 idle_notifications_to_skip_ = 2; 759 idle_notifications_to_skip_ = 2;
747 } 760 }
748 761
749 base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> 762 /* static */
763 void RenderThreadImpl::OnGpuVDAContextLoss() {
764 RenderThreadImpl* self = RenderThreadImpl::current();
765 DCHECK(self);
766 if (!self->gpu_vda_context3d_.get())
767 return;
768 if (self->compositor_thread()) {
769 self->compositor_thread()->GetWebThread()->message_loop()->DeleteSoon(
770 FROM_HERE, self->gpu_vda_context3d_.release());
771 } else {
772 self->gpu_vda_context3d_.reset();
773 }
774 }
775
776 WebGraphicsContext3DCommandBufferImpl*
750 RenderThreadImpl::GetGpuVDAContext3D() { 777 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()) { 778 if (!gpu_vda_context3d_.get()) {
762 gpu_vda_context3d_.reset( 779 gpu_vda_context3d_.reset(
763 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 780 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
764 this, WebKit::WebGraphicsContext3D::Attributes(), 781 this, WebKit::WebGraphicsContext3D::Attributes(),
765 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"))); 782 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D")));
783 gpu_vda_context3d_->setContextLostCallback(context_lost_cb_.get());
766 } 784 }
767 if (!gpu_vda_context3d_.get()) 785 return gpu_vda_context3d_.get();
768 return base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>();
769 return gpu_vda_context3d_->AsWeakPtr();
770 } 786 }
771 787
772 content::AudioRendererMixerManager* 788 content::AudioRendererMixerManager*
773 RenderThreadImpl::GetAudioRendererMixerManager() { 789 RenderThreadImpl::GetAudioRendererMixerManager() {
774 if (!audio_renderer_mixer_manager_.get()) { 790 if (!audio_renderer_mixer_manager_.get()) {
775 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( 791 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager(
776 audio_hardware::GetOutputSampleRate(), 792 audio_hardware::GetOutputSampleRate(),
777 audio_hardware::GetOutputBufferSize())); 793 audio_hardware::GetOutputBufferSize()));
778 } 794 }
779 795
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 1057
1042 scoped_refptr<base::MessageLoopProxy> 1058 scoped_refptr<base::MessageLoopProxy>
1043 RenderThreadImpl::GetFileThreadMessageLoopProxy() { 1059 RenderThreadImpl::GetFileThreadMessageLoopProxy() {
1044 DCHECK(message_loop() == MessageLoop::current()); 1060 DCHECK(message_loop() == MessageLoop::current());
1045 if (!file_thread_.get()) { 1061 if (!file_thread_.get()) {
1046 file_thread_.reset(new base::Thread("Renderer::FILE")); 1062 file_thread_.reset(new base::Thread("Renderer::FILE"));
1047 file_thread_->Start(); 1063 file_thread_->Start();
1048 } 1064 }
1049 return file_thread_->message_loop_proxy(); 1065 return file_thread_->message_loop_proxy();
1050 } 1066 }
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698