| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "components/mus/public/interfaces/command_buffer.mojom.h" | 16 #include "components/mus/public/interfaces/command_buffer.mojom.h" |
| 17 #include "gpu/command_buffer/client/gpu_control.h" | 17 #include "gpu/command_buffer/client/gpu_control.h" |
| 18 #include "gpu/command_buffer/common/command_buffer.h" | 18 #include "gpu/command_buffer/common/command_buffer.h" |
| 19 #include "gpu/command_buffer/common/command_buffer_id.h" | 19 #include "gpu/command_buffer/common/command_buffer_id.h" |
| 20 #include "gpu/command_buffer/common/command_buffer_shared.h" | 20 #include "gpu/command_buffer/common/command_buffer_shared.h" |
| 21 #include "mojo/public/cpp/bindings/binding.h" | 21 #include "mojo/public/cpp/bindings/binding.h" |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class RunLoop; | 24 class RunLoop; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace gles2 { | 27 namespace gles2 { |
| 28 class CommandBufferClientImpl; | 28 class CommandBufferClientImpl; |
| 29 | 29 |
| 30 class CommandBufferDelegate { |
| 31 public: |
| 32 virtual ~CommandBufferDelegate(); |
| 33 virtual void ContextLost(); |
| 34 }; |
| 35 |
| 30 class CommandBufferClientImpl | 36 class CommandBufferClientImpl |
| 31 : public mus::mojom::CommandBufferClient, | 37 : public mus::mojom::CommandBufferClient, |
| 32 public gpu::CommandBuffer, | 38 public gpu::CommandBuffer, |
| 33 public gpu::GpuControl { | 39 public gpu::GpuControl { |
| 34 public: | 40 public: |
| 35 explicit CommandBufferClientImpl( | 41 explicit CommandBufferClientImpl( |
| 42 CommandBufferDelegate* delegate, |
| 36 const std::vector<int32_t>& attribs, | 43 const std::vector<int32_t>& attribs, |
| 37 mojo::ScopedMessagePipeHandle command_buffer_handle); | 44 mojo::ScopedMessagePipeHandle command_buffer_handle); |
| 38 ~CommandBufferClientImpl() override; | 45 ~CommandBufferClientImpl() override; |
| 39 | 46 |
| 40 // CommandBuffer implementation: | 47 // CommandBuffer implementation: |
| 41 bool Initialize() override; | 48 bool Initialize() override; |
| 42 State GetLastState() override; | 49 State GetLastState() override; |
| 43 int32_t GetLastToken() override; | 50 int32_t GetLastToken() override; |
| 44 void Flush(int32_t put_offset) override; | 51 void Flush(int32_t put_offset) override; |
| 45 void OrderingBarrier(int32_t put_offset) override; | 52 void OrderingBarrier(int32_t put_offset) override; |
| 46 void WaitForTokenInRange(int32_t start, int32_t end) override; | 53 void WaitForTokenInRange(int32_t start, int32_t end) override; |
| 47 void WaitForGetOffsetInRange(int32_t start, int32_t end) override; | 54 void WaitForGetOffsetInRange(int32_t start, int32_t end) override; |
| 48 void SetGetBuffer(int32_t shm_id) override; | 55 void SetGetBuffer(int32_t shm_id) override; |
| 49 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, | 56 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, |
| 50 int32_t* id) override; | 57 int32_t* id) override; |
| 51 void DestroyTransferBuffer(int32_t id) override; | 58 void DestroyTransferBuffer(int32_t id) override; |
| 52 | 59 |
| 53 // gpu::GpuControl implementation: | 60 // gpu::GpuControl implementation: |
| 54 void SetGpuControlClient(gpu::GpuControlClient*) override; | |
| 55 gpu::Capabilities GetCapabilities() override; | 61 gpu::Capabilities GetCapabilities() override; |
| 56 int32_t CreateImage(ClientBuffer buffer, | 62 int32_t CreateImage(ClientBuffer buffer, |
| 57 size_t width, | 63 size_t width, |
| 58 size_t height, | 64 size_t height, |
| 59 unsigned internalformat) override; | 65 unsigned internalformat) override; |
| 60 void DestroyImage(int32_t id) override; | 66 void DestroyImage(int32_t id) override; |
| 61 int32_t CreateGpuMemoryBufferImage(size_t width, | 67 int32_t CreateGpuMemoryBufferImage(size_t width, |
| 62 size_t height, | 68 size_t height, |
| 63 unsigned internalformat, | 69 unsigned internalformat, |
| 64 unsigned usage) override; | 70 unsigned usage) override; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 83 void SignalAck(uint32_t id) override; | 89 void SignalAck(uint32_t id) override; |
| 84 void SwapBuffersCompleted(int32_t result) override; | 90 void SwapBuffersCompleted(int32_t result) override; |
| 85 void UpdateState(const gpu::CommandBuffer::State& state) override; | 91 void UpdateState(const gpu::CommandBuffer::State& state) override; |
| 86 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override; | 92 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override; |
| 87 | 93 |
| 88 void TryUpdateState(); | 94 void TryUpdateState(); |
| 89 void MakeProgressAndUpdateState(); | 95 void MakeProgressAndUpdateState(); |
| 90 | 96 |
| 91 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; } | 97 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; } |
| 92 | 98 |
| 93 gpu::GpuControlClient* gpu_control_client_; | 99 CommandBufferDelegate* delegate_; |
| 94 bool destroyed_; | |
| 95 std::vector<int32_t> attribs_; | 100 std::vector<int32_t> attribs_; |
| 96 mojo::Binding<mus::mojom::CommandBufferClient> client_binding_; | 101 mojo::Binding<mus::mojom::CommandBufferClient> client_binding_; |
| 97 mus::mojom::CommandBufferPtr command_buffer_; | 102 mus::mojom::CommandBufferPtr command_buffer_; |
| 98 | 103 |
| 99 gpu::CommandBufferId command_buffer_id_; | 104 gpu::CommandBufferId command_buffer_id_; |
| 100 gpu::Capabilities capabilities_; | 105 gpu::Capabilities capabilities_; |
| 101 State last_state_; | 106 State last_state_; |
| 102 mojo::ScopedSharedBufferHandle shared_state_handle_; | 107 mojo::ScopedSharedBufferHandle shared_state_handle_; |
| 103 gpu::CommandBufferSharedState* shared_state_; | 108 gpu::CommandBufferSharedState* shared_state_; |
| 104 int32_t last_put_offset_; | 109 int32_t last_put_offset_; |
| 105 int32_t next_transfer_buffer_id_; | 110 int32_t next_transfer_buffer_id_; |
| 106 | 111 |
| 107 // Image IDs are allocated in sequence. | 112 // Image IDs are allocated in sequence. |
| 108 int next_image_id_; | 113 int next_image_id_; |
| 109 | 114 |
| 110 uint64_t next_fence_sync_release_; | 115 uint64_t next_fence_sync_release_; |
| 111 uint64_t flushed_fence_sync_release_; | 116 uint64_t flushed_fence_sync_release_; |
| 112 }; | 117 }; |
| 113 | 118 |
| 114 } // gles2 | 119 } // gles2 |
| 115 | 120 |
| 116 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | 121 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ |
| OLD | NEW |