diff options
4 files changed, 52 insertions, 1 deletions
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index 9767b13..0c86574 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc @@ -44,6 +44,26 @@ void ClearSharedContexts() { } // namespace anonymous +class WebGraphicsContext3DErrorMessageCallback + : public gpu::gles2::GLES2Implementation::ErrorMessageCallback { + public: + WebGraphicsContext3DErrorMessageCallback( + WebGraphicsContext3DCommandBufferImpl* context) + : context_(context) { + } + + virtual void OnErrorMessage(const char* msg, int id) OVERRIDE; + + private: + WebGraphicsContext3DCommandBufferImpl* context_; + + DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DErrorMessageCallback); +}; + +void WebGraphicsContext3DErrorMessageCallback::OnErrorMessage( + const char* msg, int id) { + context_->OnErrorMessage(msg, id); +} WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( int surface_id, @@ -72,6 +92,10 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( WebGraphicsContext3DCommandBufferImpl:: ~WebGraphicsContext3DCommandBufferImpl() { + if (gl_) { + gl_->SetErrorMessageCallback(NULL); + } + if (host_) { if (host_->WillGpuSwitchOccur(false, gpu_preference_)) { host_->ForciblyCloseChannel(); @@ -203,6 +227,10 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnErrorMessage, weak_ptr_factory_.GetWeakPtr())); + client_error_message_callback_.reset( + new WebGraphicsContext3DErrorMessageCallback(this)); + gl_->SetErrorMessageCallback(client_error_message_callback_.get()); + // TODO(gman): Remove this. const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) { diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h index 0ea9348..dd0620a 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h @@ -56,6 +56,8 @@ class WebGraphicsContext3DSwapBuffersClient { virtual void OnViewContextSwapBuffersAborted() = 0; }; +class WebGraphicsContext3DErrorMessageCallback; + class WebGraphicsContext3DCommandBufferImpl : public WebKit::WebGraphicsContext3D { public: @@ -501,6 +503,8 @@ class WebGraphicsContext3DCommandBufferImpl #endif private: + friend class WebGraphicsContext3DErrorMessageCallback; + // Initialize the underlying GL context. May be called multiple times; second // and subsequent calls are ignored. Must be called from the thread that is // going to use this object to issue GL commands (which might not be the main @@ -543,6 +547,8 @@ class WebGraphicsContext3DCommandBufferImpl WebGraphicsContext3D::WebGraphicsErrorMessageCallback* error_message_callback_; + scoped_ptr<WebGraphicsContext3DErrorMessageCallback> + client_error_message_callback_; WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* swapbuffers_complete_callback_; diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index c3a2c24..7965689 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -607,7 +607,8 @@ GLES2Implementation::GLES2Implementation( sharing_resources_(share_resources), bind_generates_resource_(bind_generates_resource), use_count_(0), - current_query_(NULL) { + current_query_(NULL), + error_message_callback_(NULL) { GPU_DCHECK(helper); GPU_DCHECK(transfer_buffer); GPU_CLIENT_LOG_CODE_BLOCK({ @@ -829,6 +830,10 @@ void GLES2Implementation::SetGLError(GLenum error, const char* msg) { if (msg) { last_error_ = msg; } + if (error_message_callback_) { + std::string temp(GLES2Util::GetStringError(error) + " : " + msg); + error_message_callback_->OnErrorMessage(temp.c_str(), 0); + } error_bits_ |= GLES2Util::GLErrorToErrorBit(error); } diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 2b5312a..4e5334a 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -108,6 +108,12 @@ class IdHandlerInterface { // shared memory and synchronization issues. class GLES2_IMPL_EXPORT GLES2Implementation { public: + class ErrorMessageCallback { + public: + virtual ~ErrorMessageCallback() { } + virtual void OnErrorMessage(const char* msg, int id) = 0; + }; + // Stores client side cached GL state. struct GLState { GLState() @@ -215,6 +221,10 @@ class GLES2_IMPL_EXPORT GLES2Implementation { void FreeUnusedSharedMemory(); void FreeEverything(); + void SetErrorMessageCallback(ErrorMessageCallback* callback) { + error_message_callback_ = callback; + } + private: friend class ClientSideBufferHelper; friend class GLES2ImplementationTest; @@ -522,6 +532,8 @@ class GLES2_IMPL_EXPORT GLES2Implementation { scoped_ptr<QueryTracker> query_tracker_; QueryTracker::Query* current_query_; + ErrorMessageCallback* error_message_callback_; + DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); }; |