Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
=================================================================== |
--- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 261814) |
+++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy) |
@@ -541,7 +541,8 @@ |
// This class implements GLES2Decoder so we don't have to expose all the GLES2 |
// cmd stuff to outside this class. |
class GLES2DecoderImpl : public GLES2Decoder, |
- public FramebufferManager::TextureDetachObserver { |
+ public FramebufferManager::TextureDetachObserver, |
+ public ErrorStateClient { |
public: |
explicit GLES2DecoderImpl(ContextGroup* group); |
virtual ~GLES2DecoderImpl(); |
@@ -669,6 +670,9 @@ |
virtual void OnTextureRefDetachedFromFramebuffer( |
TextureRef* texture) OVERRIDE; |
+ // Overriden from ErrorStateClient. |
+ virtual void OnOutOfMemoryError() OVERRIDE; |
+ |
// Helpers to facilitate calling into compatible extensions. |
static void RenderbufferStorageMultisampleHelper( |
const FeatureInfo* feature_info, |
@@ -1720,6 +1724,9 @@ |
bool compile_shader_always_succeeds_; |
+ // An optional behaviour to lose the context and group when OOM. |
+ bool lose_context_when_out_of_memory_; |
+ |
// Log extra info. |
bool service_logging_; |
@@ -2185,7 +2192,7 @@ |
: GLES2Decoder(), |
group_(group), |
logger_(&debug_marker_manager_), |
- state_(group_->feature_info(), &logger_), |
+ state_(group_->feature_info(), this, &logger_), |
unpack_flip_y_(false), |
unpack_premultiply_alpha_(false), |
unpack_unpremultiply_alpha_(false), |
@@ -2218,6 +2225,7 @@ |
frag_depth_explicitly_enabled_(false), |
draw_buffers_explicitly_enabled_(false), |
compile_shader_always_succeeds_(false), |
+ lose_context_when_out_of_memory_(false), |
service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kEnableGPUServiceLoggingGPU)), |
viewport_max_width_(0), |
@@ -2291,6 +2299,10 @@ |
if (!attrib_parser.Parse(attribs)) |
return false; |
+ // Save the loseContextWhenOutOfMemory context creation attribute. |
+ lose_context_when_out_of_memory_ = |
+ attrib_parser.lose_context_when_out_of_memory_; |
+ |
// If the failIfMajorPerformanceCaveat context creation attribute was true |
// and we are using a software renderer, fail. |
if (attrib_parser.fail_if_major_perf_caveat_ && |
@@ -10565,6 +10577,13 @@ |
DoDidUseTexImageIfNeeded(texture, texture->target()); |
} |
+void GLES2DecoderImpl::OnOutOfMemoryError() { |
+ if (lose_context_when_out_of_memory_) { |
+ group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); |
+ LoseContext(GL_GUILTY_CONTEXT_RESET_ARB); |
+ } |
+} |
+ |
// Include the auto-generated part of this file. We split this because it means |
// we can easily edit the non-auto generated parts right here in this file |
// instead of having to edit some template or the code generator. |