diff options
author | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-10 01:47:41 +0000 |
---|---|---|
committer | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-10 01:47:41 +0000 |
commit | aa351637499a15c75ade4e29d92d861be2bad5eb (patch) | |
tree | 94e5ecf69d4988455641fe004b49d05fbeefb439 /chrome/renderer | |
parent | 63de8affc2abbfe6c2bf10c6a6696b4c4cdc92b8 (diff) | |
download | chromium_src-aa351637499a15c75ade4e29d92d861be2bad5eb.zip chromium_src-aa351637499a15c75ade4e29d92d861be2bad5eb.tar.gz chromium_src-aa351637499a15c75ade4e29d92d861be2bad5eb.tar.bz2 |
Handle lost contexts in PPAPI.
BUG=chromium-os:12905 and friends
TEST=go to youtube with pepper flash, kill gpu process, obeserve no crash.
Review URL: http://codereview.chromium.org/6657025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/pepper_platform_context_3d_impl.cc | 33 | ||||
-rw-r--r-- | chrome/renderer/pepper_platform_context_3d_impl.h | 7 |
2 files changed, 32 insertions, 8 deletions
diff --git a/chrome/renderer/pepper_platform_context_3d_impl.cc b/chrome/renderer/pepper_platform_context_3d_impl.cc index c581a86..47a0958 100644 --- a/chrome/renderer/pepper_platform_context_3d_impl.cc +++ b/chrome/renderer/pepper_platform_context_3d_impl.cc @@ -14,7 +14,8 @@ #ifdef ENABLE_GPU PlatformContext3DImpl::PlatformContext3DImpl(ggl::Context* parent_context) : parent_context_(parent_context), - command_buffer_(NULL) { + command_buffer_(NULL), + callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } PlatformContext3DImpl::~PlatformContext3DImpl() { @@ -67,11 +68,13 @@ bool PlatformContext3DImpl::Init() { CommandBufferProxy* parent_command_buffer = ggl::GetCommandBufferProxy(parent_context_); command_buffer_ = channel_->CreateOffscreenCommandBuffer( - parent_command_buffer, - gfx::Size(1, 1), - "*", - attribs, - parent_texture_id_); + parent_command_buffer, + gfx::Size(1, 1), + "*", + attribs, + parent_texture_id_); + command_buffer_->SetChannelErrorCallback(callback_factory_.NewCallback( + &PlatformContext3DImpl::OnContextLost)); if (!command_buffer_) return false; @@ -89,10 +92,24 @@ unsigned PlatformContext3DImpl::GetBackingTextureId() { return parent_texture_id_; } -gpu::CommandBuffer* - PlatformContext3DImpl::GetCommandBuffer() { +gpu::CommandBuffer* PlatformContext3DImpl::GetCommandBuffer() { return command_buffer_; } +void PlatformContext3DImpl::SetContextLostCallback(Callback0::Type* callback) { + context_lost_callback_.reset(callback); +} + +void PlatformContext3DImpl::OnContextLost() { + DCHECK(command_buffer_); + + // We will lose the parent context soon (it will be reallocated by the main + // page). + parent_context_ = NULL; + parent_texture_id_ = 0; + if (context_lost_callback_.get()) + context_lost_callback_->Run(); +} + #endif // ENABLE_GPU diff --git a/chrome/renderer/pepper_platform_context_3d_impl.h b/chrome/renderer/pepper_platform_context_3d_impl.h index 463355a..dedbc79 100644 --- a/chrome/renderer/pepper_platform_context_3d_impl.h +++ b/chrome/renderer/pepper_platform_context_3d_impl.h @@ -4,6 +4,9 @@ #ifndef CHROME_RENDERER_PEPPER_PLATFORM_CONTEXT_3D_IMPL_H_ #define CHROME_RENDERER_PEPPER_PLATFORM_CONTEXT_3D_IMPL_H_ +#include "base/callback.h" +#include "base/scoped_callback_factory.h" +#include "base/scoped_ptr.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #ifdef ENABLE_GPU @@ -33,14 +36,18 @@ class PlatformContext3DImpl virtual void SetSwapBuffersCallback(Callback0::Type* callback); virtual unsigned GetBackingTextureId(); virtual gpu::CommandBuffer* GetCommandBuffer(); + virtual void SetContextLostCallback(Callback0::Type* callback); private: bool InitRaw(); + void OnContextLost(); ggl::Context* parent_context_; scoped_refptr<GpuChannelHost> channel_; unsigned int parent_texture_id_; CommandBufferProxy* command_buffer_; + scoped_ptr<Callback0::Type> context_lost_callback_; + base::ScopedCallbackFactory<PlatformContext3DImpl> callback_factory_; }; #endif // ENABLE_GPU |