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

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: . 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
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..35ae77508bdea6148b4d8bee6f93bf8e5e1e1519 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -746,27 +746,41 @@ 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();
- }
+class GpuVDAContextLostCallback
+ : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
+ public:
+ virtual void onContextLost() {
+ ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind(
+ &RenderThreadImpl::OnGpuVDAContextLoss));
+ }
+};
+
+/* 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() {
+ static GpuVDAContextLostCallback* context_lost_cb =
+ new GpuVDAContextLostCallback();
piman 2012/08/13 17:23:35 Why the need to leak it? Could it be a scoped_ptr
Ami GONE FROM CHROMIUM 2012/08/13 17:38:16 Done, at the cost of having to #include "third_pa
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);
}
- if (!gpu_vda_context3d_.get())
- return base::WeakPtr<WebGraphicsContext3DCommandBufferImpl>();
- return gpu_vda_context3d_->AsWeakPtr();
+ return gpu_vda_context3d_.get();
}
content::AudioRendererMixerManager*

Powered by Google App Engine
This is Rietveld 408576698