| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | 5 #ifndef MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ |
| 6 #define MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | 6 #define MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "gpu/command_buffer/client/gpu_control.h" | 12 #include "gpu/command_buffer/client/gpu_control.h" |
| 13 #include "gpu/command_buffer/common/command_buffer.h" | 13 #include "gpu/command_buffer/common/command_buffer.h" |
| 14 #include "gpu/command_buffer/common/command_buffer_shared.h" | 14 #include "gpu/command_buffer/common/command_buffer_shared.h" |
| 15 #include "mojo/public/cpp/bindings/error_handler.h" | 15 #include "mojo/public/cpp/bindings/error_handler.h" |
| 16 #include "mojo/services/gles2/command_buffer.mojom.h" | 16 #include "mojo/services/gles2/command_buffer.mojom.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class RunLoop; | 19 class RunLoop; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace mojo { | 22 namespace mojo { |
| 23 template <typename S> | |
| 24 class SyncDispatcher; | |
| 25 | |
| 26 namespace gles2 { | 23 namespace gles2 { |
| 27 class CommandBufferClientImpl; | 24 class CommandBufferClientImpl; |
| 28 | 25 |
| 29 class CommandBufferDelegate { | 26 class CommandBufferDelegate { |
| 30 public: | 27 public: |
| 31 virtual ~CommandBufferDelegate(); | 28 virtual ~CommandBufferDelegate(); |
| 32 virtual void ContextLost(); | 29 virtual void ContextLost(); |
| 33 virtual void DrawAnimationFrame(); | 30 virtual void DrawAnimationFrame(); |
| 34 }; | 31 }; |
| 35 | 32 |
| 36 class CommandBufferClientImpl : public CommandBufferClient, | 33 class CommandBufferClientImpl : public CommandBufferClient, |
| 37 public CommandBufferSyncClient, | |
| 38 public ErrorHandler, | 34 public ErrorHandler, |
| 39 public gpu::CommandBuffer, | 35 public gpu::CommandBuffer, |
| 40 public gpu::GpuControl { | 36 public gpu::GpuControl { |
| 41 public: | 37 public: |
| 42 explicit CommandBufferClientImpl( | 38 explicit CommandBufferClientImpl( |
| 43 CommandBufferDelegate* delegate, | 39 CommandBufferDelegate* delegate, |
| 44 const MojoAsyncWaiter* async_waiter, | 40 const MojoAsyncWaiter* async_waiter, |
| 45 ScopedMessagePipeHandle command_buffer_handle); | 41 ScopedMessagePipeHandle command_buffer_handle); |
| 46 virtual ~CommandBufferClientImpl(); | 42 virtual ~CommandBufferClientImpl(); |
| 47 | 43 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 73 virtual void SignalQuery(uint32 query, | 69 virtual void SignalQuery(uint32 query, |
| 74 const base::Closure& callback) OVERRIDE; | 70 const base::Closure& callback) OVERRIDE; |
| 75 virtual void SetSurfaceVisible(bool visible) OVERRIDE; | 71 virtual void SetSurfaceVisible(bool visible) OVERRIDE; |
| 76 virtual void Echo(const base::Closure& callback) OVERRIDE; | 72 virtual void Echo(const base::Closure& callback) OVERRIDE; |
| 77 virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE; | 73 virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE; |
| 78 | 74 |
| 79 void RequestAnimationFrames(); | 75 void RequestAnimationFrames(); |
| 80 void CancelAnimationFrames(); | 76 void CancelAnimationFrames(); |
| 81 | 77 |
| 82 private: | 78 private: |
| 79 class SyncClientImpl; |
| 80 |
| 83 // CommandBufferClient implementation: | 81 // CommandBufferClient implementation: |
| 84 virtual void DidInitialize(bool success) OVERRIDE; | |
| 85 virtual void DidMakeProgress(CommandBufferStatePtr state) OVERRIDE; | |
| 86 virtual void DidDestroy() OVERRIDE; | 82 virtual void DidDestroy() OVERRIDE; |
| 87 virtual void LostContext(int32_t lost_reason) OVERRIDE; | 83 virtual void LostContext(int32_t lost_reason) OVERRIDE; |
| 84 virtual void DrawAnimationFrame() OVERRIDE; |
| 88 | 85 |
| 89 // ErrorHandler implementation: | 86 // ErrorHandler implementation: |
| 90 virtual void OnConnectionError() OVERRIDE; | 87 virtual void OnConnectionError() OVERRIDE; |
| 91 | 88 |
| 92 virtual void DrawAnimationFrame() OVERRIDE; | |
| 93 | |
| 94 void TryUpdateState(); | 89 void TryUpdateState(); |
| 95 void MakeProgressAndUpdateState(); | 90 void MakeProgressAndUpdateState(); |
| 96 | 91 |
| 97 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; } | 92 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; } |
| 98 | 93 |
| 99 CommandBufferDelegate* delegate_; | 94 CommandBufferDelegate* delegate_; |
| 100 CommandBufferPtr command_buffer_; | 95 CommandBufferPtr command_buffer_; |
| 101 scoped_ptr<SyncDispatcher<CommandBufferSyncClient> > sync_dispatcher_; | 96 scoped_ptr<SyncClientImpl> sync_client_impl_; |
| 102 | 97 |
| 103 State last_state_; | 98 State last_state_; |
| 104 mojo::ScopedSharedBufferHandle shared_state_handle_; | 99 mojo::ScopedSharedBufferHandle shared_state_handle_; |
| 105 gpu::CommandBufferSharedState* shared_state_; | 100 gpu::CommandBufferSharedState* shared_state_; |
| 106 int32 last_put_offset_; | 101 int32 last_put_offset_; |
| 107 int32 next_transfer_buffer_id_; | 102 int32 next_transfer_buffer_id_; |
| 108 | 103 |
| 109 bool initialize_result_; | |
| 110 const MojoAsyncWaiter* async_waiter_; | 104 const MojoAsyncWaiter* async_waiter_; |
| 111 }; | 105 }; |
| 112 | 106 |
| 113 } // gles2 | 107 } // gles2 |
| 114 } // mojo | 108 } // mojo |
| 115 | 109 |
| 116 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | 110 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ |
| OLD | NEW |