diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-02 14:43:13 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-02 14:43:13 +0000 |
commit | 828a3933dbfe452718e6602d1afaa2db4d80ab76 (patch) | |
tree | 56af77629470fae86de042bc0f9922e57bd5fafe /webkit/common | |
parent | f3cad76934b9282f7a8d795b27862210ad9f488a (diff) | |
download | chromium_src-828a3933dbfe452718e6602d1afaa2db4d80ab76.zip chromium_src-828a3933dbfe452718e6602d1afaa2db4d80ab76.tar.gz chromium_src-828a3933dbfe452718e6602d1afaa2db4d80ab76.tar.bz2 |
gpu: Lose context when BeginQueryEXT fails to allocate.
Instead of crashes, raise a GL_OUT_OF_MEMORY error. Since compositor
does not want to deal with these errors and it would leave it in a
bad state, add the ability to lose the context when GL_OUT_OF_MEMORY
occurs.
R=dmichael@chromium.org, jamesr@chromium.org, piman@chromium.org, piman
BUG=351587
Review URL: https://codereview.chromium.org/199443004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/common')
4 files changed, 34 insertions, 13 deletions
diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc index 6f1be9c..e9d2558 100644 --- a/webkit/common/gpu/context_provider_in_process.cc +++ b/webkit/common/gpu/context_provider_in_process.cc @@ -48,7 +48,8 @@ scoped_refptr<ContextProviderInProcess> ContextProviderInProcess::Create( // static scoped_refptr<ContextProviderInProcess> -ContextProviderInProcess::CreateOffscreen() { +ContextProviderInProcess::CreateOffscreen( + bool lose_context_when_out_of_memory) { blink::WebGraphicsContext3D::Attributes attributes; attributes.depth = false; attributes.stencil = true; @@ -58,7 +59,8 @@ ContextProviderInProcess::CreateOffscreen() { return Create( WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( - attributes), "Offscreen"); + attributes, lose_context_when_out_of_memory), + "Offscreen"); } ContextProviderInProcess::ContextProviderInProcess( diff --git a/webkit/common/gpu/context_provider_in_process.h b/webkit/common/gpu/context_provider_in_process.h index fc1d15c..c42585f 100644 --- a/webkit/common/gpu/context_provider_in_process.h +++ b/webkit/common/gpu/context_provider_in_process.h @@ -26,9 +26,9 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, const std::string& debug_name); - // Calls Create() with a default factory method for creating an offscreen - // context. - static scoped_refptr<ContextProviderInProcess> CreateOffscreen(); + // Uses default attributes for creating an offscreen context. + static scoped_refptr<ContextProviderInProcess> CreateOffscreen( + bool lose_context_when_out_of_memory); virtual blink::WebGraphicsContext3D* WebContext3D() OVERRIDE; diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index 3c6d608..992bcb4 100644 --- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -73,20 +73,29 @@ static base::LazyInstance<GLES2Initializer> g_gles2_initializer = scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( const blink::WebGraphicsContext3D::Attributes& attributes, + bool lose_context_when_out_of_memory, gfx::AcceleratedWidget window) { DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone); + bool is_offscreen = false; return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( - scoped_ptr< ::gpu::GLInProcessContext>(), attributes, false, window)); + scoped_ptr< ::gpu::GLInProcessContext>(), + attributes, + lose_context_when_out_of_memory, + is_offscreen, + window)); } // static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( - const blink::WebGraphicsContext3D::Attributes& attributes) { + const blink::WebGraphicsContext3D::Attributes& attributes, + bool lose_context_when_out_of_memory) { + bool is_offscreen = true; return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( scoped_ptr< ::gpu::GLInProcessContext>(), attributes, - true, + lose_context_when_out_of_memory, + is_offscreen, gfx::kNullAcceleratedWidget)); } @@ -94,10 +103,13 @@ scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( scoped_ptr< ::gpu::GLInProcessContext> context, const blink::WebGraphicsContext3D::Attributes& attributes) { + bool lose_context_when_out_of_memory = false; // Not used. + bool is_offscreen = true; // Not used. return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( context.Pass(), attributes, - true /* is_offscreen. Not used. */, + lose_context_when_out_of_memory, + is_offscreen, gfx::kNullAcceleratedWidget /* window. Not used. */)); } @@ -105,6 +117,7 @@ WebGraphicsContext3DInProcessCommandBufferImpl:: WebGraphicsContext3DInProcessCommandBufferImpl( scoped_ptr< ::gpu::GLInProcessContext> context, const blink::WebGraphicsContext3D::Attributes& attributes, + bool lose_context_when_out_of_memory, bool is_offscreen, gfx::AcceleratedWidget window) : is_offscreen_(is_offscreen), @@ -116,8 +129,8 @@ WebGraphicsContext3DInProcessCommandBufferImpl:: context_lost_callback_(NULL), context_lost_reason_(GL_NO_ERROR), attributes_(attributes), - flush_id_(0) { -} + lose_context_when_out_of_memory_(lose_context_when_out_of_memory), + flush_id_(0) {} WebGraphicsContext3DInProcessCommandBufferImpl:: ~WebGraphicsContext3DInProcessCommandBufferImpl() { @@ -155,7 +168,9 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() { gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; ::gpu::GLInProcessContextAttribs attrib_struct; - ConvertAttributes(attributes_, &attrib_struct), + ConvertAttributes(attributes_, &attrib_struct); + attrib_struct.lose_context_when_out_of_memory = + lose_context_when_out_of_memory_; context_.reset(GLInProcessContext::CreateContext( is_offscreen_, diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h index f278bb0..0e4348d 100644 --- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -52,11 +52,13 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> CreateViewContext( const blink::WebGraphicsContext3D::Attributes& attributes, + bool lose_context_when_out_of_memory, gfx::AcceleratedWidget window); static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> CreateOffscreenContext( - const blink::WebGraphicsContext3D::Attributes& attributes); + const blink::WebGraphicsContext3D::Attributes& attributes, + bool lose_context_when_out_of_memory); static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext( @@ -571,6 +573,7 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl WebGraphicsContext3DInProcessCommandBufferImpl( scoped_ptr< ::gpu::GLInProcessContext> context, const blink::WebGraphicsContext3D::Attributes& attributes, + bool lose_context_when_out_of_memory, bool is_offscreen, gfx::AcceleratedWidget window); @@ -598,6 +601,7 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl WGC3Denum context_lost_reason_; blink::WebGraphicsContext3D::Attributes attributes_; + bool lose_context_when_out_of_memory_; // Errors raised by synthesizeGLError(). std::vector<WGC3Denum> synthetic_errors_; |