| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COMMON_COMMAND_BUFFER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ |
| 6 #define GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ | 6 #define GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ |
| 7 | 7 |
| 8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 | 10 |
| 11 namespace command_buffer { | 11 namespace gpu { |
| 12 | 12 |
| 13 // Common interface for CommandBuffer implementations. | 13 // Common interface for CommandBuffer implementations. |
| 14 class CommandBuffer { | 14 class CommandBuffer { |
| 15 public: | 15 public: |
| 16 CommandBuffer() { | 16 CommandBuffer() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 virtual ~CommandBuffer() { | 19 virtual ~CommandBuffer() { |
| 20 } | 20 } |
| 21 | 21 |
| 22 // Initialize the command buffer with the given ring buffer. Takes ownership | 22 // Initialize the command buffer with the given size (number of command |
| 23 // of ring buffer. | 23 // entries). |
| 24 virtual bool Initialize(::base::SharedMemory* ring_buffer) = 0; | 24 virtual base::SharedMemory* Initialize(int32 size) = 0; |
| 25 | 25 |
| 26 // Gets the shared memory ring buffer object for the command buffer. | 26 // Gets the shared memory ring buffer object for the command buffer. |
| 27 virtual ::base::SharedMemory* GetRingBuffer() = 0; | 27 virtual base::SharedMemory* GetRingBuffer() = 0; |
| 28 | 28 |
| 29 virtual int32 GetSize() = 0; | 29 virtual int32 GetSize() = 0; |
| 30 | 30 |
| 31 // The writer calls this to update its put offset. This function returns the | 31 // The writer calls this to update its put offset. This function returns the |
| 32 // reader's most recent get offset. Does not return until after the put offset | 32 // reader's most recent get offset. Does not return until after the put offset |
| 33 // change callback has been invoked. Returns -1 if the put offset is invalid. | 33 // change callback has been invoked. Returns -1 if the put offset is invalid. |
| 34 virtual int32 SyncOffsets(int32 put_offset) = 0; | 34 virtual int32 SyncOffsets(int32 put_offset) = 0; |
| 35 | 35 |
| 36 // Returns the current get offset. This can be called from any thread. | 36 // Returns the current get offset. This can be called from any thread. |
| 37 virtual int32 GetGetOffset() = 0; | 37 virtual int32 GetGetOffset() = 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 55 virtual void SetPutOffsetChangeCallback(Callback0::Type* callback) = 0; | 55 virtual void SetPutOffsetChangeCallback(Callback0::Type* callback) = 0; |
| 56 | 56 |
| 57 // Create a shared memory transfer buffer and return a handle that uniquely | 57 // Create a shared memory transfer buffer and return a handle that uniquely |
| 58 // identifies it or -1 on error. | 58 // identifies it or -1 on error. |
| 59 virtual int32 CreateTransferBuffer(size_t size) = 0; | 59 virtual int32 CreateTransferBuffer(size_t size) = 0; |
| 60 | 60 |
| 61 // Destroy a shared memory transfer buffer and recycle the handle. | 61 // Destroy a shared memory transfer buffer and recycle the handle. |
| 62 virtual void DestroyTransferBuffer(int32 id) = 0; | 62 virtual void DestroyTransferBuffer(int32 id) = 0; |
| 63 | 63 |
| 64 // Get the shared memory associated with a handle. | 64 // Get the shared memory associated with a handle. |
| 65 virtual ::base::SharedMemory* GetTransferBuffer(int32 handle) = 0; | 65 virtual base::SharedMemory* GetTransferBuffer(int32 handle) = 0; |
| 66 | 66 |
| 67 // Get the current token value. This is used for by the writer to defer | 67 // Get the current token value. This is used for by the writer to defer |
| 68 // changes to shared memory objects until the reader has reached a certain | 68 // changes to shared memory objects until the reader has reached a certain |
| 69 // point in the command buffer. The reader is responsible for updating the | 69 // point in the command buffer. The reader is responsible for updating the |
| 70 // token value, for example in response to an asynchronous set token command | 70 // token value, for example in response to an asynchronous set token command |
| 71 // embedded in the command buffer. The default token value is zero. | 71 // embedded in the command buffer. The default token value is zero. |
| 72 virtual int32 GetToken() = 0; | 72 virtual int32 GetToken() = 0; |
| 73 | 73 |
| 74 // Allows the reader to update the current token value. | 74 // Allows the reader to update the current token value. |
| 75 virtual void SetToken(int32 token) = 0; | 75 virtual void SetToken(int32 token) = 0; |
| 76 | 76 |
| 77 // Get the current parse error and reset it to zero. Zero means no error. Non- | 77 // Get the current parse error and reset it to zero. Zero means no error. Non- |
| 78 // zero means error. The default error status is zero. | 78 // zero means error. The default error status is zero. |
| 79 virtual int32 ResetParseError() = 0; | 79 virtual int32 ResetParseError() = 0; |
| 80 | 80 |
| 81 // Allows the reader to set the current parse error. | 81 // Allows the reader to set the current parse error. |
| 82 virtual void SetParseError(int32 parse_error) = 0; | 82 virtual void SetParseError(int32 parse_error) = 0; |
| 83 | 83 |
| 84 // Returns whether the command buffer is in the error state. | 84 // Returns whether the command buffer is in the error state. |
| 85 virtual bool GetErrorStatus() = 0; | 85 virtual bool GetErrorStatus() = 0; |
| 86 | 86 |
| 87 // Allows the reader to set the error status. Once in an error state, the | 87 // Allows the reader to set the error status. Once in an error state, the |
| 88 // command buffer cannot recover and ceases to process commands. | 88 // command buffer cannot recover and ceases to process commands. |
| 89 virtual void RaiseErrorStatus() = 0; | 89 virtual void RaiseErrorStatus() = 0; |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 DISALLOW_COPY_AND_ASSIGN(CommandBuffer); | 92 DISALLOW_COPY_AND_ASSIGN(CommandBuffer); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace command_buffer | 95 } // namespace gpu |
| 96 | 96 |
| 97 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ | 97 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ |
| OLD | NEW |