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 |
(...skipping 13 matching lines...) Expand all Loading... |
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 int32 GetSize(); |
30 virtual int32 SyncOffsets(int32 put_offset); | 30 virtual int32 SyncOffsets(int32 put_offset); |
31 virtual int32 GetGetOffset(); | 31 virtual int32 GetGetOffset(); |
32 virtual void SetGetOffset(int32 get_offset); | 32 virtual void SetGetOffset(int32 get_offset); |
33 virtual int32 GetPutOffset(); | 33 virtual int32 GetPutOffset(); |
34 virtual void SetPutOffsetChangeCallback(Callback0::Type* callback); | |
35 virtual int32 CreateTransferBuffer(size_t size); | 34 virtual int32 CreateTransferBuffer(size_t size); |
36 virtual void DestroyTransferBuffer(int32 id); | 35 virtual void DestroyTransferBuffer(int32 id); |
37 virtual Buffer GetTransferBuffer(int32 handle); | 36 virtual Buffer GetTransferBuffer(int32 handle); |
38 virtual int32 GetToken(); | 37 virtual int32 GetToken(); |
39 virtual void SetToken(int32 token); | 38 virtual void SetToken(int32 token); |
40 virtual int32 ResetParseError(); | 39 virtual int32 ResetParseError(); |
41 virtual void SetParseError(int32 parse_error); | 40 virtual void SetParseError(int32 parse_error); |
42 virtual bool GetErrorStatus(); | 41 virtual bool GetErrorStatus(); |
43 virtual void RaiseErrorStatus(); | 42 virtual void RaiseErrorStatus(); |
44 | 43 |
| 44 // 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 |
| 46 // been made (unless the command buffer is empty), i.e. the |
| 47 // get offset must have changed. It need not process the entire command |
| 48 // 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 |
| 50 // progress before attempting to write more to the command buffer. Avoiding |
| 51 // the use of a synchronization primitive like a condition variable to |
| 52 // synchronize reader and writer reduces the risk of deadlock. |
| 53 // Takes ownership of callback. The callback is invoked on the plugin thread. |
| 54 virtual void SetPutOffsetChangeCallback(Callback0::Type* callback); |
| 55 |
45 private: | 56 private: |
46 scoped_ptr< base::SharedMemory> ring_buffer_; | 57 scoped_ptr< base::SharedMemory> ring_buffer_; |
47 int32 size_; | 58 int32 size_; |
48 int32 get_offset_; | 59 int32 get_offset_; |
49 int32 put_offset_; | 60 int32 put_offset_; |
50 scoped_ptr<Callback0::Type> put_offset_change_callback_; | 61 scoped_ptr<Callback0::Type> put_offset_change_callback_; |
51 std::vector<linked_ptr< base::SharedMemory> > registered_objects_; | 62 std::vector<linked_ptr< base::SharedMemory> > registered_objects_; |
52 std::set<int32> unused_registered_object_elements_; | 63 std::set<int32> unused_registered_object_elements_; |
53 int32 token_; | 64 int32 token_; |
54 int32 parse_error_; | 65 int32 parse_error_; |
55 bool error_status_; | 66 bool error_status_; |
56 }; | 67 }; |
57 | 68 |
58 } // namespace gpu | 69 } // namespace gpu |
59 | 70 |
60 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ | 71 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ |
OLD | NEW |