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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 35ab4ecd08337a77dcb129615ca53d7817e2c77d..c33a67109568b1dffc9e109a4a88a75805eab48c 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -173,6 +173,17 @@ static void AddHistogramSample(void* hist, int sample) {
histogram->Add(sample);
}
+class RenderThreadImpl::GpuVDAContextLostCallback
+ : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
+ public:
+ GpuVDAContextLostCallback() {}
+ virtual ~GpuVDAContextLostCallback() {}
+ virtual void onContextLost() {
+ ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind(
+ &RenderThreadImpl::OnGpuVDAContextLoss));
+ }
+};
+
RenderThreadImpl* RenderThreadImpl::current() {
return lazy_tls.Pointer()->Get();
}
@@ -262,6 +273,8 @@ void RenderThreadImpl::Init() {
WebKit::WebCompositor::setPartialSwapEnabled(
command_line.HasSwitch(switches::kEnablePartialSwap));
+ context_lost_cb_.reset(new GpuVDAContextLostCallback());
+
// Note that under Linux, the media library will normally already have
// been initialized by the Zygote before this instance became a Renderer.
FilePath media_path;
@@ -746,27 +759,30 @@ void RenderThreadImpl::PostponeIdleNotification() {
idle_notifications_to_skip_ = 2;
}
-base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>
-RenderThreadImpl::GetGpuVDAContext3D() {
- // If we already handed out a pointer to a context and it's been lost, create
- // a new one.
- if (gpu_vda_context3d_.get() && gpu_vda_context3d_->isContextLost()) {
- if (compositor_thread()) {
- compositor_thread()->GetWebThread()->message_loop()->DeleteSoon(
- FROM_HERE, gpu_vda_context3d_.release());
- } else {
- gpu_vda_context3d_.reset();
- }
+/* static */
+void RenderThreadImpl::OnGpuVDAContextLoss() {
+ RenderThreadImpl* self = RenderThreadImpl::current();
+ DCHECK(self);
+ if (!self->gpu_vda_context3d_.get())
+ return;
+ if (self->compositor_thread()) {
+ self->compositor_thread()->GetWebThread()->message_loop()->DeleteSoon(
+ FROM_HERE, self->gpu_vda_context3d_.release());
+ } else {
+ self->gpu_vda_context3d_.reset();
}
+}
+
+WebGraphicsContext3DCommandBufferImpl*
+RenderThreadImpl::GetGpuVDAContext3D() {
if (!gpu_vda_context3d_.get()) {
gpu_vda_context3d_.reset(
WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
this, WebKit::WebGraphicsContext3D::Attributes(),
GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D")));
+ gpu_vda_context3d_->setContextLostCallback(context_lost_cb_.get());
}
- if (!gpu_vda_context3d_.get())
- return base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>();
- return gpu_vda_context3d_->AsWeakPtr();
+ return gpu_vda_context3d_.get();
}
content::AudioRendererMixerManager*
« 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