| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "gpu/command_buffer/common/command_buffer.h" | 9 #include "gpu/command_buffer/common/command_buffer.h" |
| 10 #include "gpu/command_buffer/common/command_buffer_shared.h" | 10 #include "gpu/command_buffer/common/command_buffer_shared.h" |
| 11 | 11 |
| 12 namespace gpu { | 12 namespace gpu { |
| 13 | 13 |
| 14 class TransferBufferManagerInterface; | 14 class TransferBufferManagerInterface; |
| 15 | 15 |
| 16 class GPU_EXPORT CommandBufferServiceBase : public CommandBuffer { | 16 class GPU_EXPORT CommandBufferServiceBase : public CommandBuffer { |
| 17 public: | 17 public: |
| 18 CommandBufferServiceBase(CommandBufferNamespace namespace_id, |
| 19 uint64_t command_buffer_id) |
| 20 : CommandBuffer(namespace_id, command_buffer_id) {} |
| 21 |
| 18 // Sets the current get offset. This can be called from any thread. | 22 // Sets the current get offset. This can be called from any thread. |
| 19 virtual void SetGetOffset(int32 get_offset) = 0; | 23 virtual void SetGetOffset(int32 get_offset) = 0; |
| 20 | 24 |
| 21 // Get the transfer buffer associated with an ID. Returns a null buffer for | 25 // Get the transfer buffer associated with an ID. Returns a null buffer for |
| 22 // ID 0. | 26 // ID 0. |
| 23 virtual scoped_refptr<gpu::Buffer> GetTransferBuffer(int32 id) = 0; | 27 virtual scoped_refptr<gpu::Buffer> GetTransferBuffer(int32 id) = 0; |
| 24 | 28 |
| 25 // Allows the reader to update the current token value. | 29 // Allows the reader to update the current token value. |
| 26 virtual void SetToken(int32 token) = 0; | 30 virtual void SetToken(int32 token) = 0; |
| 27 | 31 |
| 28 // Allows the reader to set the current parse error. | 32 // Allows the reader to set the current parse error. |
| 29 virtual void SetParseError(error::Error) = 0; | 33 virtual void SetParseError(error::Error) = 0; |
| 30 | 34 |
| 31 // Allows the reader to set the current context lost reason. | 35 // Allows the reader to set the current context lost reason. |
| 32 // NOTE: if calling this in conjunction with SetParseError, | 36 // NOTE: if calling this in conjunction with SetParseError, |
| 33 // call this first. | 37 // call this first. |
| 34 virtual void SetContextLostReason(error::ContextLostReason) = 0; | 38 virtual void SetContextLostReason(error::ContextLostReason) = 0; |
| 35 | 39 |
| 36 // Allows the reader to obtain the current put offset. | 40 // Allows the reader to obtain the current put offset. |
| 37 virtual int32 GetPutOffset() = 0; | 41 virtual int32 GetPutOffset() = 0; |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 // An object that implements a shared memory command buffer and a synchronous | 44 // An object that implements a shared memory command buffer and a synchronous |
| 41 // API to manage the put and get pointers. | 45 // API to manage the put and get pointers. |
| 42 class GPU_EXPORT CommandBufferService : public CommandBufferServiceBase { | 46 class GPU_EXPORT CommandBufferService : public CommandBufferServiceBase { |
| 43 public: | 47 public: |
| 44 typedef base::Callback<bool(int32)> GetBufferChangedCallback; | 48 typedef base::Callback<bool(int32)> GetBufferChangedCallback; |
| 45 explicit CommandBufferService( | 49 explicit CommandBufferService( |
| 46 TransferBufferManagerInterface* transfer_buffer_manager); | 50 TransferBufferManagerInterface* transfer_buffer_manager, |
| 51 CommandBufferNamespace namespace_id, uint64_t command_buffer_id); |
| 47 ~CommandBufferService() override; | 52 ~CommandBufferService() override; |
| 48 | 53 |
| 49 // CommandBuffer implementation: | 54 // CommandBuffer implementation: |
| 50 bool Initialize() override; | 55 bool Initialize() override; |
| 51 State GetLastState() override; | 56 State GetLastState() override; |
| 52 int32 GetLastToken() override; | 57 int32 GetLastToken() override; |
| 53 void Flush(int32 put_offset) override; | 58 void Flush(int32 put_offset) override; |
| 54 void OrderingBarrier(int32 put_offset) override; | 59 void OrderingBarrier(int32 put_offset) override; |
| 55 void WaitForTokenInRange(int32 start, int32 end) override; | 60 void WaitForTokenInRange(int32 start, int32 end) override; |
| 56 void WaitForGetOffsetInRange(int32 start, int32 end) override; | 61 void WaitForGetOffsetInRange(int32 start, int32 end) override; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 uint32 generation_; | 111 uint32 generation_; |
| 107 error::Error error_; | 112 error::Error error_; |
| 108 error::ContextLostReason context_lost_reason_; | 113 error::ContextLostReason context_lost_reason_; |
| 109 | 114 |
| 110 DISALLOW_COPY_AND_ASSIGN(CommandBufferService); | 115 DISALLOW_COPY_AND_ASSIGN(CommandBufferService); |
| 111 }; | 116 }; |
| 112 | 117 |
| 113 } // namespace gpu | 118 } // namespace gpu |
| 114 | 119 |
| 115 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ | 120 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ |
| OLD | NEW |