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 "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "gpu/command_buffer/common/command_buffer.h" | 10 #include "gpu/command_buffer/common/command_buffer.h" |
11 #include "gpu/command_buffer/common/command_buffer_shared.h" | 11 #include "gpu/command_buffer/common/command_buffer_shared.h" |
12 | 12 |
13 namespace gpu { | 13 namespace gpu { |
14 | 14 |
15 class TransferBufferManagerInterface; | 15 class TransferBufferManagerInterface; |
16 | 16 |
| 17 class GPU_EXPORT CommandBufferServiceBase : public CommandBuffer { |
| 18 public: |
| 19 // Sets the current get offset. This can be called from any thread. |
| 20 virtual void SetGetOffset(int32 get_offset) = 0; |
| 21 |
| 22 // Get the transfer buffer associated with an ID. Returns a null buffer for |
| 23 // ID 0. |
| 24 virtual scoped_refptr<gpu::Buffer> GetTransferBuffer(int32 id) = 0; |
| 25 |
| 26 // Allows the reader to update the current token value. |
| 27 virtual void SetToken(int32 token) = 0; |
| 28 |
| 29 // Allows the reader to set the current parse error. |
| 30 virtual void SetParseError(error::Error) = 0; |
| 31 |
| 32 // Allows the reader to set the current context lost reason. |
| 33 // NOTE: if calling this in conjunction with SetParseError, |
| 34 // call this first. |
| 35 virtual void SetContextLostReason(error::ContextLostReason) = 0; |
| 36 }; |
| 37 |
17 // An object that implements a shared memory command buffer and a synchronous | 38 // An object that implements a shared memory command buffer and a synchronous |
18 // API to manage the put and get pointers. | 39 // API to manage the put and get pointers. |
19 class GPU_EXPORT CommandBufferService : public CommandBuffer { | 40 class GPU_EXPORT CommandBufferService : public CommandBufferServiceBase { |
20 public: | 41 public: |
21 typedef base::Callback<bool(int32)> GetBufferChangedCallback; | 42 typedef base::Callback<bool(int32)> GetBufferChangedCallback; |
22 explicit CommandBufferService( | 43 explicit CommandBufferService( |
23 TransferBufferManagerInterface* transfer_buffer_manager); | 44 TransferBufferManagerInterface* transfer_buffer_manager); |
24 virtual ~CommandBufferService(); | 45 virtual ~CommandBufferService(); |
25 | 46 |
26 // CommandBuffer implementation: | 47 // CommandBuffer implementation: |
27 virtual bool Initialize() OVERRIDE; | 48 virtual bool Initialize() OVERRIDE; |
28 virtual State GetState() OVERRIDE; | 49 virtual State GetState() OVERRIDE; |
29 virtual State GetLastState() OVERRIDE; | 50 virtual State GetLastState() OVERRIDE; |
30 virtual int32 GetLastToken() OVERRIDE; | 51 virtual int32 GetLastToken() OVERRIDE; |
31 virtual void Flush(int32 put_offset) OVERRIDE; | 52 virtual void Flush(int32 put_offset) OVERRIDE; |
32 virtual void WaitForTokenInRange(int32 start, int32 end) OVERRIDE; | 53 virtual void WaitForTokenInRange(int32 start, int32 end) OVERRIDE; |
33 virtual void WaitForGetOffsetInRange(int32 start, int32 end) OVERRIDE; | 54 virtual void WaitForGetOffsetInRange(int32 start, int32 end) OVERRIDE; |
34 virtual void SetGetBuffer(int32 transfer_buffer_id) OVERRIDE; | 55 virtual void SetGetBuffer(int32 transfer_buffer_id) OVERRIDE; |
35 virtual void SetGetOffset(int32 get_offset) OVERRIDE; | |
36 virtual scoped_refptr<Buffer> CreateTransferBuffer(size_t size, | 56 virtual scoped_refptr<Buffer> CreateTransferBuffer(size_t size, |
37 int32* id) OVERRIDE; | 57 int32* id) OVERRIDE; |
38 virtual void DestroyTransferBuffer(int32 id) OVERRIDE; | 58 virtual void DestroyTransferBuffer(int32 id) OVERRIDE; |
| 59 |
| 60 // CommandBufferServiceBase implementation: |
| 61 virtual void SetGetOffset(int32 get_offset) OVERRIDE; |
39 virtual scoped_refptr<Buffer> GetTransferBuffer(int32 id) OVERRIDE; | 62 virtual scoped_refptr<Buffer> GetTransferBuffer(int32 id) OVERRIDE; |
40 virtual void SetToken(int32 token) OVERRIDE; | 63 virtual void SetToken(int32 token) OVERRIDE; |
41 virtual void SetParseError(error::Error error) OVERRIDE; | 64 virtual void SetParseError(error::Error error) OVERRIDE; |
42 virtual void SetContextLostReason(error::ContextLostReason) OVERRIDE; | 65 virtual void SetContextLostReason(error::ContextLostReason) OVERRIDE; |
43 | 66 |
44 // Sets a callback that is called whenever the put offset is changed. When | 67 // Sets a callback that is called whenever the put offset is changed. When |
45 // called with sync==true, the callback must not return until some progress | 68 // called with sync==true, the callback must not return until some progress |
46 // has been made (unless the command buffer is empty), i.e. the get offset | 69 // has been made (unless the command buffer is empty), i.e. the get offset |
47 // must have changed. It need not process the entire command buffer though. | 70 // must have changed. It need not process the entire command buffer though. |
48 // This allows concurrency between the writer and the reader while giving the | 71 // This allows concurrency between the writer and the reader while giving the |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 uint32 generation_; | 107 uint32 generation_; |
85 error::Error error_; | 108 error::Error error_; |
86 error::ContextLostReason context_lost_reason_; | 109 error::ContextLostReason context_lost_reason_; |
87 | 110 |
88 DISALLOW_COPY_AND_ASSIGN(CommandBufferService); | 111 DISALLOW_COPY_AND_ASSIGN(CommandBufferService); |
89 }; | 112 }; |
90 | 113 |
91 } // namespace gpu | 114 } // namespace gpu |
92 | 115 |
93 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ | 116 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ |
OLD | NEW |