| 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 // This file contains the command buffer helper class. | 5 // This file contains the command buffer helper class. |
| 6 | 6 |
| 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
| 8 #define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 8 #define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
| 9 | 9 |
| 10 #include "gpu/command_buffer/common/logging.h" | 10 #include "gpu/command_buffer/common/logging.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 // Typed version of GetSpace for immediate commands. | 140 // Typed version of GetSpace for immediate commands. |
| 141 template <typename T> | 141 template <typename T> |
| 142 T& GetImmediateCmdSpaceTotalSize(size_t total_space) { | 142 T& GetImmediateCmdSpaceTotalSize(size_t total_space) { |
| 143 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); | 143 COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); |
| 144 uint32 space_needed = ComputeNumEntries(total_space); | 144 uint32 space_needed = ComputeNumEntries(total_space); |
| 145 void* data = GetSpace(space_needed); | 145 void* data = GetSpace(space_needed); |
| 146 return *reinterpret_cast<T*>(data); | 146 return *reinterpret_cast<T*>(data); |
| 147 } | 147 } |
| 148 | 148 |
| 149 parse_error::ParseError GetParseError(); | 149 parse_error::ParseError GetError(); |
| 150 | 150 |
| 151 // Common Commands | 151 // Common Commands |
| 152 void Noop(uint32 skip_count) { | 152 void Noop(uint32 skip_count) { |
| 153 cmd::Noop& cmd = GetImmediateCmdSpace<cmd::Noop>( | 153 cmd::Noop& cmd = GetImmediateCmdSpace<cmd::Noop>( |
| 154 skip_count * sizeof(CommandBufferEntry)); | 154 skip_count * sizeof(CommandBufferEntry)); |
| 155 cmd.Init(skip_count); | 155 cmd.Init(skip_count); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void SetToken(uint32 token) { | 158 void SetToken(uint32 token) { |
| 159 cmd::SetToken& cmd = GetCmdSpace<cmd::SetToken>(); | 159 cmd::SetToken& cmd = GetCmdSpace<cmd::SetToken>(); |
| 160 cmd.Init(token); | 160 cmd.Init(token); |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 // Waits until get changes, updating the value of get_. | 165 // Waits until get changes, updating the value of get_. |
| 166 void WaitForGetChange(); | 166 void WaitForGetChange(); |
| 167 | 167 |
| 168 // Returns the number of available entries (they may not be contiguous). | 168 // Returns the number of available entries (they may not be contiguous). |
| 169 int32 AvailableEntries() { | 169 int32 AvailableEntries() { |
| 170 return (get_ - put_ - 1 + entry_count_) % entry_count_; | 170 return (get_ - put_ - 1 + entry_count_) % entry_count_; |
| 171 } | 171 } |
| 172 | 172 |
| 173 // Synchronize with current service state. |
| 174 void SynchronizeState(CommandBuffer::State state); |
| 175 |
| 173 CommandBuffer* command_buffer_; | 176 CommandBuffer* command_buffer_; |
| 174 Buffer ring_buffer_; | 177 Buffer ring_buffer_; |
| 175 CommandBufferEntry *entries_; | 178 CommandBufferEntry *entries_; |
| 176 int32 entry_count_; | 179 int32 entry_count_; |
| 177 int32 token_; | 180 int32 token_; |
| 178 int32 last_token_read_; | 181 int32 last_token_read_; |
| 179 int32 get_; | 182 int32 get_; |
| 180 int32 put_; | 183 int32 put_; |
| 181 | 184 |
| 182 friend class CommandBufferHelperTest; | 185 friend class CommandBufferHelperTest; |
| 183 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 186 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
| 184 }; | 187 }; |
| 185 | 188 |
| 186 } // namespace gpu | 189 } // namespace gpu |
| 187 | 190 |
| 188 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 191 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
| OLD | NEW |