OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 11 matching lines...) Expand all Loading... |
22 class CommandBufferService : public CommandBuffer { | 22 class CommandBufferService : public CommandBuffer { |
23 public: | 23 public: |
24 CommandBufferService(); | 24 CommandBufferService(); |
25 virtual ~CommandBufferService(); | 25 virtual ~CommandBufferService(); |
26 | 26 |
27 // CommandBuffer implementation: | 27 // CommandBuffer implementation: |
28 virtual bool Initialize(int32 size); | 28 virtual bool Initialize(int32 size); |
29 virtual bool Initialize(base::SharedMemory* buffer, int32 size); | 29 virtual bool Initialize(base::SharedMemory* buffer, int32 size); |
30 virtual Buffer GetRingBuffer(); | 30 virtual Buffer GetRingBuffer(); |
31 virtual State GetState(); | 31 virtual State GetState(); |
32 virtual State GetLastState(); | |
33 virtual void Flush(int32 put_offset); | 32 virtual void Flush(int32 put_offset); |
34 virtual State FlushSync(int32 put_offset, int32 last_known_get); | 33 virtual State FlushSync(int32 put_offset, int32 last_known_get); |
35 virtual void SetGetOffset(int32 get_offset); | 34 virtual void SetGetOffset(int32 get_offset); |
36 virtual int32 CreateTransferBuffer(size_t size, int32 id_request); | 35 virtual int32 CreateTransferBuffer(size_t size, int32 id_request); |
37 virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, | 36 virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, |
38 size_t size, | 37 size_t size, |
39 int32 id_request); | 38 int32 id_request); |
40 virtual void DestroyTransferBuffer(int32 id); | 39 virtual void DestroyTransferBuffer(int32 id); |
41 virtual Buffer GetTransferBuffer(int32 handle); | 40 virtual Buffer GetTransferBuffer(int32 handle); |
42 virtual void SetToken(int32 token); | 41 virtual void SetToken(int32 token); |
43 virtual void SetParseError(error::Error error); | 42 virtual void SetParseError(error::Error error); |
44 virtual void SetContextLostReason(error::ContextLostReason); | 43 virtual void SetContextLostReason(error::ContextLostReason); |
45 | 44 |
46 // Sets a callback that is called whenever the put offset is changed. When | 45 // Sets a callback that is called whenever the put offset is changed. When |
47 // called with sync==true, the callback must not return until some progress | 46 // called with sync==true, the callback must not return until some progress |
48 // has been made (unless the command buffer is empty), i.e. the get offset | 47 // has been made (unless the command buffer is empty), i.e. the get offset |
49 // must have changed. It need not process the entire command buffer though. | 48 // must have changed. It need not process the entire command buffer though. |
50 // This allows concurrency between the writer and the reader while giving the | 49 // This allows concurrency between the writer and the reader while giving the |
51 // writer a means of waiting for the reader to make some progress before | 50 // writer a means of waiting for the reader to make some progress before |
52 // attempting to write more to the command buffer. Takes ownership of | 51 // attempting to write more to the command buffer. Takes ownership of |
53 // callback. | 52 // callback. |
54 virtual void SetPutOffsetChangeCallback(Callback0::Type* callback); | 53 virtual void SetPutOffsetChangeCallback(Callback1<bool>::Type* callback); |
55 virtual void SetParseErrorCallback(Callback0::Type* callback); | 54 virtual void SetParseErrorCallback(Callback0::Type* callback); |
56 | 55 |
57 private: | 56 private: |
58 Buffer ring_buffer_; | 57 Buffer ring_buffer_; |
59 int32 num_entries_; | 58 int32 num_entries_; |
60 int32 get_offset_; | 59 int32 get_offset_; |
61 int32 put_offset_; | 60 int32 put_offset_; |
62 scoped_ptr<Callback0::Type> put_offset_change_callback_; | 61 scoped_ptr<Callback1<bool>::Type> put_offset_change_callback_; |
63 scoped_ptr<Callback0::Type> parse_error_callback_; | 62 scoped_ptr<Callback0::Type> parse_error_callback_; |
64 std::vector<Buffer> registered_objects_; | 63 std::vector<Buffer> registered_objects_; |
65 std::set<int32> unused_registered_object_elements_; | 64 std::set<int32> unused_registered_object_elements_; |
66 int32 token_; | 65 int32 token_; |
67 uint32 generation_; | 66 uint32 generation_; |
68 error::Error error_; | 67 error::Error error_; |
69 error::ContextLostReason context_lost_reason_; | 68 error::ContextLostReason context_lost_reason_; |
70 }; | 69 }; |
71 | 70 |
72 } // namespace gpu | 71 } // namespace gpu |
73 | 72 |
74 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ | 73 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ |
OLD | NEW |