diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 07:01:59 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 07:01:59 +0000 |
commit | d9a54602add9699ec4d5ebd1630c5c0c580ce8e8 (patch) | |
tree | 233319a1797c5e7dde1f080b65f876baf1869501 /gpu | |
parent | 5291380cf9274160c02d805b7425bacbcfb2a4f5 (diff) | |
download | chromium_src-d9a54602add9699ec4d5ebd1630c5c0c580ce8e8.zip chromium_src-d9a54602add9699ec4d5ebd1630c5c0c580ce8e8.tar.gz chromium_src-d9a54602add9699ec4d5ebd1630c5c0c580ce8e8.tar.bz2 |
Pipe SwapBuffers call{,backs} through ContextSupport
This plumbs the SwapBuffers calls and callbacks through the
gpu::ContextSupport interface instead of WGC3D. There are two production
paths for the callbacks - using Echo and using View IPCs. The former is
used everywhere except for single-threaded mac and guest plugin mode.
This implements the Echo path directly in GLES2Implementation and leaves
the implementation of the non-Echo path in WGC3DCommandBufferImpl. We'll
still have to clean that up to avoid having to allocate a WGC3D, but this
at least gets rid of the API dependencies from cc.
R=piman
BUG=181120
Review URL: https://codereview.chromium.org/59233007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/client/client_test_helper.h | 1 | ||||
-rw-r--r-- | gpu/command_buffer/client/context_support.h | 7 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 26 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.h | 16 | ||||
-rw-r--r-- | gpu/command_buffer/common/gpu_control.h | 3 | ||||
-rw-r--r-- | gpu/command_buffer/service/feature_info.cc | 3 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.h | 2 | ||||
-rw-r--r-- | gpu/command_buffer/service/gpu_control_service.cc | 4 | ||||
-rw-r--r-- | gpu/command_buffer/service/gpu_control_service.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/service/in_process_command_buffer.cc | 5 | ||||
-rw-r--r-- | gpu/command_buffer/service/in_process_command_buffer.h | 1 | ||||
-rw-r--r-- | gpu/gpu.gyp | 2 |
12 files changed, 66 insertions, 8 deletions
diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h index 6f0bc6d..e071f5a 100644 --- a/gpu/command_buffer/client/client_test_helper.h +++ b/gpu/command_buffer/client/client_test_helper.h @@ -99,6 +99,7 @@ class MockClientGpuControl : public GpuControl { MOCK_METHOD0(InsertSyncPoint, uint32()); MOCK_METHOD2(SignalSyncPoint, void(uint32 id, const base::Closure& callback)); + MOCK_METHOD1(Echo, void(const base::Closure& callback)); MOCK_METHOD2(SignalQuery, void(uint32 query, const base::Closure& callback)); MOCK_METHOD1(SetSurfaceVisible, void(bool visible)); diff --git a/gpu/command_buffer/client/context_support.h b/gpu/command_buffer/client/context_support.h index dcb0842..6a897208 100644 --- a/gpu/command_buffer/client/context_support.h +++ b/gpu/command_buffer/client/context_support.h @@ -6,6 +6,7 @@ #define GPU_COMMAND_BUFFER_CLIENT_CONTEXT_SUPPORT_H_ #include "base/callback.h" +#include "ui/gfx/rect.h" namespace gpu { struct ManagedMemoryStats; @@ -26,6 +27,12 @@ class ContextSupport { virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) = 0; + virtual void Swap() = 0; + virtual void PartialSwapBuffers(gfx::Rect sub_buffer) = 0; + + virtual void SetSwapBuffersCompleteCallback( + const base::Closure& callback) = 0; + protected: ContextSupport() {} virtual ~ContextSupport() {} diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 62fc6d2..b0efc37 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -2775,6 +2775,32 @@ void GLES2Implementation::GetVertexAttribiv( CheckGLError(); } +void GLES2Implementation::Swap() { + SwapBuffers(); + gpu_control_->Echo( + base::Bind(&GLES2Implementation::OnSwapBuffersComplete, + weak_ptr_factory_.GetWeakPtr())); +} + +void GLES2Implementation::PartialSwapBuffers(gfx::Rect sub_buffer) { + PostSubBufferCHROMIUM(sub_buffer.x(), + sub_buffer.y(), + sub_buffer.width(), + sub_buffer.height()); + gpu_control_->Echo(base::Bind(&GLES2Implementation::OnSwapBuffersComplete, + weak_ptr_factory_.GetWeakPtr())); +} + +void GLES2Implementation::SetSwapBuffersCompleteCallback( + const base::Closure& swap_buffers_complete_callback) { + swap_buffers_complete_callback_ = swap_buffers_complete_callback; +} + +void GLES2Implementation::OnSwapBuffersComplete() { + if (!swap_buffers_complete_callback_.is_null()) + swap_buffers_complete_callback_.Run(); +} + GLboolean GLES2Implementation::EnableFeatureCHROMIUM( const char* feature) { GPU_CLIENT_SINGLE_THREAD_CHECK(); diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index 66b33d9..6b6877f 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -215,6 +215,13 @@ class GLES2_IMPL_EXPORT GLES2Implementation virtual void GetVertexAttribiv( GLuint index, GLenum pname, GLint* params) OVERRIDE; + // ContextSupport implementation. + virtual void Swap() OVERRIDE; + virtual void PartialSwapBuffers(gfx::Rect sub_buffer) OVERRIDE; + virtual void SetSwapBuffersCompleteCallback( + const base::Closure& swap_buffers_complete_callback) + OVERRIDE; + void GetProgramInfoCHROMIUMHelper(GLuint program, std::vector<int8>* result); GLint GetAttribLocationHelper(GLuint program, const char* name); GLint GetUniformLocationHelper(GLuint program, const char* name); @@ -249,6 +256,10 @@ class GLES2_IMPL_EXPORT GLES2Implementation return capabilities_; } + GpuControl* gpu_control() { + return gpu_control_; + } + private: friend class GLES2ImplementationTest; friend class VertexArrayObjectManager; @@ -578,6 +589,8 @@ class GLES2_IMPL_EXPORT GLES2Implementation void RunIfContextNotLost(const base::Closure& callback); + void OnSwapBuffersComplete(); + bool GetBoundPixelTransferBuffer( GLenum target, const char* function_name, GLuint* buffer_id); BufferTracker::Buffer* GetBoundPixelUnpackTransferBufferIfValid( @@ -702,6 +715,9 @@ class GLES2_IMPL_EXPORT GLES2Implementation Capabilities capabilities_; + bool use_echo_for_swap_ack_; + base::Closure swap_buffers_complete_callback_; + base::WeakPtrFactory<GLES2Implementation> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); diff --git a/gpu/command_buffer/common/gpu_control.h b/gpu/command_buffer/common/gpu_control.h index 1331a25..d971972 100644 --- a/gpu/command_buffer/common/gpu_control.h +++ b/gpu/command_buffer/common/gpu_control.h @@ -60,6 +60,9 @@ class GPU_EXPORT GpuControl { virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) = 0; + // Invokes the callback once the context has been flushed. + virtual void Echo(const base::Closure& callback) = 0; + private: DISALLOW_COPY_AND_ASSIGN(GpuControl); }; diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index c9f0733..cbcf968 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -694,9 +694,6 @@ void FeatureInfo::InitializeFeatures() { feature_flags_.ext_frag_depth = true; } - if (!disallowed_features_.swap_buffer_complete_callback) - AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback"); - bool ui_gl_fence_works = extensions.Contains("GL_NV_fence") || extensions.Contains("GL_ARB_sync") || extensions.Contains("EGL_KHR_fence_sync"); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index ce65f7e..87c9335 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -43,12 +43,10 @@ class VertexArrayManager; struct DisallowedFeatures { DisallowedFeatures() : multisampling(false), - swap_buffer_complete_callback(false), gpu_memory_manager(false) { } bool multisampling; - bool swap_buffer_complete_callback; bool gpu_memory_manager; }; diff --git a/gpu/command_buffer/service/gpu_control_service.cc b/gpu/command_buffer/service/gpu_control_service.cc index abb8e91..7c0eb8c 100644 --- a/gpu/command_buffer/service/gpu_control_service.cc +++ b/gpu/command_buffer/service/gpu_control_service.cc @@ -101,6 +101,10 @@ void GpuControlService::SendManagedMemoryStats( NOTREACHED(); } +void GpuControlService::Echo(const base::Closure& callback) { + NOTREACHED(); +} + bool GpuControlService::RegisterGpuMemoryBuffer( int32 id, gfx::GpuMemoryBufferHandle buffer, diff --git a/gpu/command_buffer/service/gpu_control_service.h b/gpu/command_buffer/service/gpu_control_service.h index 13bb3c0..3764ad4 100644 --- a/gpu/command_buffer/service/gpu_control_service.h +++ b/gpu/command_buffer/service/gpu_control_service.h @@ -29,10 +29,9 @@ class GPU_EXPORT GpuControlService : public GpuControl { const gpu::Capabilities& decoder_capabilities); virtual ~GpuControlService(); - // Overridden from GpuControl: + // GpuControl implementation. virtual gpu::Capabilities GetCapabilities() OVERRIDE; - virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer( size_t width, size_t height, @@ -49,6 +48,7 @@ class GPU_EXPORT GpuControlService : public GpuControl { virtual void SetSurfaceVisible(bool visible) OVERRIDE; virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) OVERRIDE; + virtual void Echo(const base::Closure& callback) OVERRIDE; // Register an existing gpu memory buffer and get an ID that can be used // to identify it in the command buffer. diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc index 4de4531..af14778 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.cc +++ b/gpu/command_buffer/service/in_process_command_buffer.cc @@ -464,7 +464,6 @@ bool InProcessCommandBuffer::InitializeOnGpuThread( } gles2::DisallowedFeatures disallowed_features; - disallowed_features.swap_buffer_complete_callback = true; disallowed_features.gpu_memory_manager = true; if (!decoder_->Initialize(surface_, context_, @@ -735,6 +734,10 @@ void InProcessCommandBuffer::SendManagedMemoryStats( const gpu::ManagedMemoryStats& stats) { } +void InProcessCommandBuffer::Echo(const base::Closure& callback) { + QueueTask(WrapCallback(callback)); +} + gpu::error::Error InProcessCommandBuffer::GetLastError() { CheckSequencedThread(); return last_state_.error; diff --git a/gpu/command_buffer/service/in_process_command_buffer.h b/gpu/command_buffer/service/in_process_command_buffer.h index 6665b9f..b00f25b 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.h +++ b/gpu/command_buffer/service/in_process_command_buffer.h @@ -125,6 +125,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, virtual void SetSurfaceVisible(bool visible) OVERRIDE; virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats) OVERRIDE; + virtual void Echo(const base::Closure& callback) OVERRIDE; // The serializer interface to the GPU service (i.e. thread). class SchedulerClient { diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index fdb2372..f809c1f 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -46,6 +46,7 @@ '../base/base.gyp:base', '../third_party/khronos/khronos.gyp:khronos_headers', '../ui/gl/gl.gyp:gl', + '../ui/gfx/gfx.gyp:gfx', 'command_buffer/command_buffer.gyp:gles2_utils', 'gles2_cmd_helper', ], @@ -67,6 +68,7 @@ 'dependencies': [ '../base/base.gyp:base', '../third_party/khronos/khronos.gyp:khronos_headers', + '../ui/gfx/gfx.gyp:gfx', 'command_buffer/command_buffer.gyp:gles2_utils', 'gles2_cmd_helper', ], |