diff options
author | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 19:17:52 +0000 |
---|---|---|
committer | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 19:17:52 +0000 |
commit | 4dadd1488df25a60eeb907a158653a2a7a7459e8 (patch) | |
tree | 463898eb541747ed76132f275ba176f773482a50 /content/renderer/render_widget_fullscreen_pepper.cc | |
parent | 1950891c3ac95a2d42511f7f97c0a8cb7f928210 (diff) | |
download | chromium_src-4dadd1488df25a60eeb907a158653a2a7a7459e8.zip chromium_src-4dadd1488df25a60eeb907a158653a2a7a7459e8.tar.gz chromium_src-4dadd1488df25a60eeb907a158653a2a7a7459e8.tar.bz2 |
Lost context fixes
This makes sure that after a GPU context lost event, we don't try to re-create a
context based on the lost one.
BUG=chromium-os:13537
TEST=with pepper flash, run multiple flash sites in multiple tabs, make sure they use the GPU process. kill the gpu process, and check that renderers don't crash.
Review URL: http://codereview.chromium.org/6726048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80042 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/render_widget_fullscreen_pepper.cc')
-rw-r--r-- | content/renderer/render_widget_fullscreen_pepper.cc | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc index 3d85b29..8284523 100644 --- a/content/renderer/render_widget_fullscreen_pepper.cc +++ b/content/renderer/render_widget_fullscreen_pepper.cc @@ -4,6 +4,7 @@ #include "content/renderer/render_widget_fullscreen_pepper.h" +#include "base/message_loop.h" #include "chrome/renderer/render_thread.h" #include "content/renderer/ggl.h" #include "content/renderer/gpu_channel_host.h" @@ -134,6 +135,16 @@ class PepperWidget : public WebWidget { DISALLOW_COPY_AND_ASSIGN(PepperWidget); }; +void DestroyContext(ggl::Context* context, GLuint program, GLuint buffer) { + DCHECK(context); + gpu::gles2::GLES2Implementation* gl = ggl::GetImplementation(context); + if (program) + gl->DeleteProgram(program); + if (buffer) + gl->DeleteBuffers(1, &buffer); + ggl::DestroyContext(context); +} + } // anonymous namespace // static @@ -161,7 +172,8 @@ RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( } RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { - DestroyContext(); + if (context_) + DestroyContext(context_, program_, buffer_); } void RenderWidgetFullscreenPepper::Invalidate() { @@ -271,29 +283,21 @@ void RenderWidgetFullscreenPepper::CreateContext() { "GL_OES_packed_depth_stencil GL_OES_depth24", attribs, active_url_); - if (!context_ || !InitContext()) { - DestroyContext(); + if (!context_) + return; + + if (!InitContext()) { + DestroyContext(context_, program_, buffer_); + context_ = NULL; return; } + ggl::SetSwapBuffersCallback( context_, NewCallback(this, &RenderWidgetFullscreenPepper::DidFlushPaint)); -} - -void RenderWidgetFullscreenPepper::DestroyContext() { - if (context_) { - gpu::gles2::GLES2Implementation* gl = ggl::GetImplementation(context_); - if (program_) { - gl->DeleteProgram(program_); - program_ = 0; - } - if (buffer_) { - gl->DeleteBuffers(1, &buffer_); - buffer_ = 0; - } - ggl::DestroyContext(context_); - context_ = NULL; - } + ggl::SetContextLostCallback( + context_, + NewCallback(this, &RenderWidgetFullscreenPepper::OnLostContext)); } namespace { @@ -397,3 +401,17 @@ bool RenderWidgetFullscreenPepper::CheckCompositing() { } return compositing; } + +void RenderWidgetFullscreenPepper::OnLostContext() { + if (!context_) + return; + // Destroy the context later, in case we got called from InitContext for + // example. We still need to reset context_ now so that a new context gets + // created when the plugin recreates its own. + MessageLoop::current()->PostTask( + FROM_HERE, + NewRunnableFunction(DestroyContext, context_, program_, buffer_)); + context_ = NULL; + program_ = 0; + buffer_ = 0; +} |