diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-27 03:24:50 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-27 03:24:50 +0000 |
commit | 1786d84c72c33d3fcece9622b98c5d584f6b1b31 (patch) | |
tree | ca2ee4a55d69ed76aa9890b244ce7873126b4826 /webkit/gpu | |
parent | 1400e6dc12c13f62aa300dd4468019a08388daec (diff) | |
download | chromium_src-1786d84c72c33d3fcece9622b98c5d584f6b1b31.zip chromium_src-1786d84c72c33d3fcece9622b98c5d584f6b1b31.tar.gz chromium_src-1786d84c72c33d3fcece9622b98c5d584f6b1b31.tar.bz2 |
Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
Adds signalSyncPoint() support to our command buffer implementations
of WebGraphicsContext3D. Because we have to use a raw callback pointer
for WebGraphicsContext3D and this is not great, I've added a
SyncPointHelper class that adapts a base::Closure() for use with the
signalSyncPoint() method.
Tests:
GLRendererPixelTest.SignalSyncPoint
GLRendererPixelTest.SignalSyncPointOnLostContext
R=jamesr, piman
BUG=179896
Review URL: https://chromiumcodereview.appspot.com/14126014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196930 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/gpu')
-rw-r--r-- | webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc | 79 | ||||
-rw-r--r-- | webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h | 6 |
2 files changed, 81 insertions, 4 deletions
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index c63e855..c0d0113 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -139,6 +139,12 @@ class GLInProcessContext { // problem communicating with the GPU process. bool IsCommandBufferContextLost(); + void LoseContext(uint32 current, uint32 other); + + void SetSignalSyncPointCallback( + scoped_ptr< + WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback> callback); + CommandBufferService* GetCommandBufferService(); ::gpu::gles2::GLES2Decoder* GetDecoder(); @@ -166,6 +172,8 @@ class GLInProcessContext { scoped_ptr<GLES2CmdHelper> gles2_helper_; scoped_ptr<TransferBuffer> transfer_buffer_; scoped_ptr<GLES2Implementation> gles2_implementation_; + scoped_ptr<WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback> + signal_sync_point_callback_; Error last_error_; bool share_resources_; bool context_lost_; @@ -281,6 +289,12 @@ AutoLockAndDecoderDetachThread::~AutoLockAndDecoderDetachThread() { } // namespace +static void CallAndDestroy( + scoped_ptr< + WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback> callback) { + callback->onSyncPointReached(); +} + void GLInProcessContext::PumpCommands() { if (!context_lost_) { AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(), @@ -288,9 +302,15 @@ void GLInProcessContext::PumpCommands() { decoder_->MakeCurrent(); gpu_scheduler_->PutChanged(); ::gpu::CommandBuffer::State state = command_buffer_->GetState(); - if (::gpu::error::IsError(state.error)) { + if (::gpu::error::IsError(state.error)) context_lost_ = true; - } + } + + if (!context_lost_ && signal_sync_point_callback_) { + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&CallAndDestroy, + base::Passed(&signal_sync_point_callback_))); } } @@ -368,6 +388,18 @@ bool GLInProcessContext::IsCommandBufferContextLost() { return ::gpu::error::IsError(state.error); } +void GLInProcessContext::LoseContext(uint32 current, uint32 other) { + gles2_implementation_->LoseContextCHROMIUM(current, other); + gles2_implementation_->Finish(); + DCHECK(IsCommandBufferContextLost()); +} + +void GLInProcessContext::SetSignalSyncPointCallback( + scoped_ptr< + WebKit::WebGraphicsContext3D::WebGraphicsSyncPointCallback> callback) { + signal_sync_point_callback_ = callback.Pass(); +} + CommandBufferService* GLInProcessContext::GetCommandBufferService() { return command_buffer_.get(); } @@ -454,8 +486,19 @@ bool GLInProcessContext::Initialize( { AutoLockAndDecoderDetachThread lock(g_decoder_lock.Get(), g_all_shared_contexts.Get()); - if (share_resources_ && !g_all_shared_contexts.Get().empty()) - context_group = *g_all_shared_contexts.Get().begin(); + if (share_resources_ && !g_all_shared_contexts.Get().empty()) { + for (std::set<GLInProcessContext*>::iterator it = + g_all_shared_contexts.Get().begin(); + it != g_all_shared_contexts.Get().end(); + ++it) { + if (!(*it)->IsCommandBufferContextLost()) { + context_group = *it; + break; + } + } + if (!context_group) + share_group = new gfx::GLShareGroup; + } // TODO(gman): This needs to be true if this is Pepper. bool bind_generates_resource = false; @@ -604,6 +647,15 @@ void GLInProcessContext::Destroy() { void GLInProcessContext::OnContextLost() { if (!context_lost_callback_.is_null()) context_lost_callback_.Run(); + + context_lost_ = true; + if (share_resources_) { + for (std::set<GLInProcessContext*>::iterator it = + g_all_shared_contexts.Get().begin(); + it != g_all_shared_contexts.Get().end(); + ++it) + (*it)->context_lost_ = true; + } } // static @@ -1791,6 +1843,25 @@ DELEGATE_TO_GL_2(consumeTextureCHROMIUM, ConsumeTextureCHROMIUM, DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT, WGC3Dsizei, const WGC3Denum*) +unsigned WebGraphicsContext3DInProcessCommandBufferImpl::insertSyncPoint() { + shallowFlushCHROMIUM(); + return 0; +} + +void WebGraphicsContext3DInProcessCommandBufferImpl::signalSyncPoint( + unsigned sync_point, + WebGraphicsSyncPointCallback* callback) { + // Take ownership of the callback. + context_->SetSignalSyncPointCallback(make_scoped_ptr(callback)); + // Stick something in the command buffer. + shallowFlushCHROMIUM(); +} + +void WebGraphicsContext3DInProcessCommandBufferImpl::loseContextCHROMIUM( + WGC3Denum current, WGC3Denum other) { + context_->LoseContext(current, other); +} + DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM, AsyncTexImage2DCHROMIUM, WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dint, WGC3Denum, WGC3Denum, const void*) diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h index e04e9e2..28e96d5 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -537,6 +537,12 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl virtual void drawBuffersEXT(WGC3Dsizei n, const WGC3Denum* bufs); + virtual unsigned insertSyncPoint(); + virtual void signalSyncPoint(unsigned sync_point, + WebGraphicsSyncPointCallback* callback); + + virtual void loseContextCHROMIUM(WGC3Denum current, WGC3Denum other); + protected: virtual GrGLInterface* onCreateGrGLInterface(); |