diff options
author | danakj <danakj@chromium.org> | 2015-06-09 10:18:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-09 17:19:30 +0000 |
commit | b0abc0dab520325f2b8cf9acc3308dfaf2cb2652 (patch) | |
tree | c0ad4178e32a386eba4ef161612b6da7d83441d0 | |
parent | ac2ffadacece2698f02b414f55fa7372c720e828 (diff) | |
download | chromium_src-b0abc0dab520325f2b8cf9acc3308dfaf2cb2652.zip chromium_src-b0abc0dab520325f2b8cf9acc3308dfaf2cb2652.tar.gz chromium_src-b0abc0dab520325f2b8cf9acc3308dfaf2cb2652.tar.bz2 |
Implement WebGraphicsContext3D's lost context methods on GLES2Impl
Implement isContextLost and GetGraphicsResetStatusARB in the base
WebGraphicsContext3DImpl instead of its subclasses, by just having
then both call through to GLES2Interface::GetGraphicsResetStatusKHR.
R=piman@chromium.org
BUG=492447
Review URL: https://codereview.chromium.org/1169923004
Cr-Commit-Position: refs/heads/master@{#333512}
6 files changed, 12 insertions, 65 deletions
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index bd60ecc..0c77e5b 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc @@ -333,21 +333,6 @@ WebGraphicsContext3DCommandBufferImpl::GetContextSupport() { return real_gl_.get(); } -bool WebGraphicsContext3DCommandBufferImpl::isContextLost() { - return initialize_failed_ || - (command_buffer_ && IsCommandBufferContextLost()) || - context_lost_reason_ != GL_NO_ERROR; -} - -WGC3Denum WebGraphicsContext3DCommandBufferImpl::getGraphicsResetStatusARB() { - if (IsCommandBufferContextLost() && - context_lost_reason_ == GL_NO_ERROR) { - return GL_UNKNOWN_CONTEXT_RESET_ARB; - } - - return context_lost_reason_; -} - bool WebGraphicsContext3DCommandBufferImpl::IsCommandBufferContextLost() { // If the channel shut down unexpectedly, let that supersede the // command buffer's state. @@ -382,33 +367,9 @@ WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( share_context); } -namespace { - -WGC3Denum convertReason(gpu::error::ContextLostReason reason) { - switch (reason) { - case gpu::error::kGuilty: - return GL_GUILTY_CONTEXT_RESET_ARB; - case gpu::error::kInnocent: - return GL_INNOCENT_CONTEXT_RESET_ARB; - case gpu::error::kOutOfMemory: - case gpu::error::kMakeCurrentFailed: - case gpu::error::kUnknown: - case gpu::error::kGpuChannelLost: - return GL_UNKNOWN_CONTEXT_RESET_ARB; - } - - NOTREACHED(); - return GL_UNKNOWN_CONTEXT_RESET_ARB; -} - -} // anonymous namespace - void WebGraphicsContext3DCommandBufferImpl::OnContextLost() { - context_lost_reason_ = - convertReason(command_buffer_->GetLastState().context_lost_reason); - if (context_lost_callback_) { + if (context_lost_callback_) context_lost_callback_->onContextLost(); - } share_group_->RemoveAllContexts(); diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h index 115e167..0eca015 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h @@ -145,12 +145,6 @@ class WebGraphicsContext3DCommandBufferImpl CONTENT_EXPORT bool InitializeOnCurrentThread(); - //---------------------------------------------------------------------- - // WebGraphicsContext3D methods - virtual bool isContextLost(); - - virtual blink::WGC3Denum getGraphicsResetStatusARB(); - void SetContextType(CommandBufferContextType type) { context_type_ = type; } diff --git a/gpu/blink/webgraphicscontext3d_impl.cc b/gpu/blink/webgraphicscontext3d_impl.cc index 8645c23..123ba79 100644 --- a/gpu/blink/webgraphicscontext3d_impl.cc +++ b/gpu/blink/webgraphicscontext3d_impl.cc @@ -185,7 +185,6 @@ WebGraphicsContext3DImpl::WebGraphicsContext3DImpl() : initialized_(false), initialize_failed_(false), context_lost_callback_(0), - context_lost_reason_(GL_NO_ERROR), error_message_callback_(0), gl_(NULL), flush_id_(0) { @@ -1174,6 +1173,14 @@ void WebGraphicsContext3DImpl::waitSync(WGC3Dsync sync, gl_->WaitSync(reinterpret_cast<GLsync>(sync), flags, timeout); } +bool WebGraphicsContext3DImpl::isContextLost() { + return getGraphicsResetStatusARB() != GL_NO_ERROR; +} + +blink::WGC3Denum WebGraphicsContext3DImpl::getGraphicsResetStatusARB() { + return gl_->GetGraphicsResetStatusKHR(); +} + GrGLInterface* WebGraphicsContext3DImpl::createGrGLInterface() { return skia_bindings::CreateCommandBufferSkiaGLBinding(); } diff --git a/gpu/blink/webgraphicscontext3d_impl.h b/gpu/blink/webgraphicscontext3d_impl.h index b11c1f4..c053f88 100644 --- a/gpu/blink/webgraphicscontext3d_impl.h +++ b/gpu/blink/webgraphicscontext3d_impl.h @@ -921,6 +921,9 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DImpl blink::WGC3Dbitfield flags, blink::WGC3Duint64 timeout); + virtual bool isContextLost(); + virtual blink::WGC3Denum getGraphicsResetStatusARB(); + virtual GrGLInterface* createGrGLInterface(); ::gpu::gles2::GLES2Interface* GetGLInterface() { @@ -950,7 +953,6 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DImpl bool initialize_failed_; WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_; - blink::WGC3Denum context_lost_reason_; WebGraphicsContext3D::WebGraphicsErrorMessageCallback* error_message_callback_; diff --git a/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc b/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc index e661fc9..4f83fa3 100644 --- a/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -154,23 +154,12 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::SetLock(base::Lock* lock) { context_->SetLock(lock); } -bool WebGraphicsContext3DInProcessCommandBufferImpl::isContextLost() { - return context_lost_reason_ != GL_NO_ERROR; -} - -WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl:: - getGraphicsResetStatusARB() { - return context_lost_reason_; -} - ::gpu::ContextSupport* WebGraphicsContext3DInProcessCommandBufferImpl::GetContextSupport() { return real_gl_; } void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { - // TODO(kbr): improve the precision here. - context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; if (context_lost_callback_) { context_lost_callback_->onContextLost(); } diff --git a/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h b/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h index fa7542c..d463582 100644 --- a/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -59,12 +59,6 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl bool InitializeOnCurrentThread(); void SetLock(base::Lock* lock); - //---------------------------------------------------------------------- - // WebGraphicsContext3D methods - virtual bool isContextLost(); - - virtual blink::WGC3Denum getGraphicsResetStatusARB(); - ::gpu::ContextSupport* GetContextSupport(); ::gpu::gles2::GLES2Implementation* GetImplementation() { |