| OLD | NEW |
| 1 // Copyright (c) 2009 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_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 <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/linked_ptr.h" | 11 #include "base/linked_ptr.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
| 14 #include "base/task.h" | 14 #include "base/task.h" |
| 15 #include "gpu/command_buffer/common/command_buffer.h" | 15 #include "gpu/command_buffer/common/command_buffer.h" |
| 16 | 16 |
| 17 namespace gpu { | 17 namespace gpu { |
| 18 | 18 |
| 19 // An object that implements a shared memory command buffer and a synchronous | 19 // An object that implements a shared memory command buffer and a synchronous |
| 20 // API to manage the put and get pointers. | 20 // API to manage the put and get pointers. |
| 21 class CommandBufferService : public CommandBuffer { | 21 class CommandBufferService : public CommandBuffer { |
| 22 public: | 22 public: |
| 23 CommandBufferService(); | 23 CommandBufferService(); |
| 24 virtual ~CommandBufferService(); | 24 virtual ~CommandBufferService(); |
| 25 | 25 |
| 26 // CommandBuffer implementation: | 26 // CommandBuffer implementation: |
| 27 virtual bool Initialize(int32 size); | 27 virtual bool Initialize(int32 size); |
| 28 virtual Buffer GetRingBuffer(); | 28 virtual Buffer GetRingBuffer(); |
| 29 virtual int32 GetSize(); | 29 virtual State GetState(); |
| 30 virtual int32 SyncOffsets(int32 put_offset); | 30 virtual State Flush(int32 put_offset); |
| 31 virtual int32 GetGetOffset(); | |
| 32 virtual void SetGetOffset(int32 get_offset); | 31 virtual void SetGetOffset(int32 get_offset); |
| 33 virtual int32 GetPutOffset(); | |
| 34 virtual int32 CreateTransferBuffer(size_t size); | 32 virtual int32 CreateTransferBuffer(size_t size); |
| 35 virtual void DestroyTransferBuffer(int32 id); | 33 virtual void DestroyTransferBuffer(int32 id); |
| 36 virtual Buffer GetTransferBuffer(int32 handle); | 34 virtual Buffer GetTransferBuffer(int32 handle); |
| 37 virtual int32 GetToken(); | |
| 38 virtual void SetToken(int32 token); | 35 virtual void SetToken(int32 token); |
| 39 virtual int32 ResetParseError(); | 36 virtual void SetParseError(parse_error::ParseError); |
| 40 virtual void SetParseError(int32 parse_error); | |
| 41 virtual bool GetErrorStatus(); | |
| 42 virtual void RaiseErrorStatus(); | |
| 43 | 37 |
| 44 // Sets a callback that should be posted on another thread whenever the put | 38 // Sets a callback that should be posted on another thread whenever the put |
| 45 // offset is changed. The callback must not return until some progress has | 39 // offset is changed. The callback must not return until some progress has |
| 46 // been made (unless the command buffer is empty), i.e. the | 40 // been made (unless the command buffer is empty), i.e. the |
| 47 // get offset must have changed. It need not process the entire command | 41 // get offset must have changed. It need not process the entire command |
| 48 // buffer though. This allows concurrency between the writer and the reader | 42 // buffer though. This allows concurrency between the writer and the reader |
| 49 // while giving the writer a means of waiting for the reader to make some | 43 // while giving the writer a means of waiting for the reader to make some |
| 50 // progress before attempting to write more to the command buffer. Avoiding | 44 // progress before attempting to write more to the command buffer. Avoiding |
| 51 // the use of a synchronization primitive like a condition variable to | 45 // the use of a synchronization primitive like a condition variable to |
| 52 // synchronize reader and writer reduces the risk of deadlock. | 46 // synchronize reader and writer reduces the risk of deadlock. |
| 53 // Takes ownership of callback. The callback is invoked on the plugin thread. | 47 // Takes ownership of callback. The callback is invoked on the plugin thread. |
| 54 virtual void SetPutOffsetChangeCallback(Callback0::Type* callback); | 48 virtual void SetPutOffsetChangeCallback(Callback0::Type* callback); |
| 55 | 49 |
| 56 private: | 50 private: |
| 57 scoped_ptr< base::SharedMemory> ring_buffer_; | 51 scoped_ptr< base::SharedMemory> ring_buffer_; |
| 58 int32 size_; | 52 int32 size_; |
| 59 int32 get_offset_; | 53 int32 get_offset_; |
| 60 int32 put_offset_; | 54 int32 put_offset_; |
| 61 scoped_ptr<Callback0::Type> put_offset_change_callback_; | 55 scoped_ptr<Callback0::Type> put_offset_change_callback_; |
| 62 std::vector<linked_ptr< base::SharedMemory> > registered_objects_; | 56 std::vector<linked_ptr< base::SharedMemory> > registered_objects_; |
| 63 std::set<int32> unused_registered_object_elements_; | 57 std::set<int32> unused_registered_object_elements_; |
| 64 int32 token_; | 58 int32 token_; |
| 65 int32 parse_error_; | 59 parse_error::ParseError error_; |
| 66 bool error_status_; | |
| 67 }; | 60 }; |
| 68 | 61 |
| 69 } // namespace gpu | 62 } // namespace gpu |
| 70 | 63 |
| 71 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ | 64 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ |
| OLD | NEW |