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_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 "../common/buffer.h" | 8 #include "../common/buffer.h" |
9 #include "../common/constants.h" | 9 #include "../common/constants.h" |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Allows the reader to update the current token value. | 116 // Allows the reader to update the current token value. |
117 virtual void SetToken(int32 token) = 0; | 117 virtual void SetToken(int32 token) = 0; |
118 | 118 |
119 // Allows the reader to set the current parse error. | 119 // Allows the reader to set the current parse error. |
120 virtual void SetParseError(error::Error) = 0; | 120 virtual void SetParseError(error::Error) = 0; |
121 | 121 |
122 private: | 122 private: |
123 DISALLOW_COPY_AND_ASSIGN(CommandBuffer); | 123 DISALLOW_COPY_AND_ASSIGN(CommandBuffer); |
124 }; | 124 }; |
125 | 125 |
| 126 // Synchronizing other mechanisms (such as IPC) with the CommandBuffer requires |
| 127 // inserting (writing) a token into the buffer and knowing what the last token |
| 128 // read at that point was. ReadWriteTokens is a convenience struct for passing |
| 129 // these pairs around. Expected usage is to compare a current token to |
| 130 // [last_token_read,last_token_written). |
| 131 class ReadWriteTokens { |
| 132 public: |
| 133 ReadWriteTokens(int32 read, int32 written); |
| 134 // Required to support pickling. Use by anything else will DCHECK in InRange. |
| 135 ReadWriteTokens(); |
| 136 |
| 137 // Return true iff |value| is in the range described by |tokens|, accounting |
| 138 // for (up to) one wrap-around. |
| 139 bool InRange(int32 token) const; |
| 140 |
| 141 // These want to be private (and const) but can't in order to support |
| 142 // pickling. |
| 143 int32 last_token_read; |
| 144 int32 last_token_written; |
| 145 }; |
| 146 |
126 } // namespace gpu | 147 } // namespace gpu |
127 | 148 |
128 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ | 149 #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ |
OLD | NEW |