| 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_COMMON_DECODER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 template <typename T> | 71 template <typename T> |
| 72 T GetDataAs(size_t offset, size_t size) const { | 72 T GetDataAs(size_t offset, size_t size) const { |
| 73 return reinterpret_cast<T>(GetData(offset, size)); | 73 return reinterpret_cast<T>(GetData(offset, size)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Sets the size of the bucket. | 76 // Sets the size of the bucket. |
| 77 void SetSize(size_t size); | 77 void SetSize(size_t size); |
| 78 | 78 |
| 79 // Sets a part of the bucket. | 79 // Sets a part of the bucket. |
| 80 // Returns false if offset or size is out of range. | 80 // Returns false if offset or size is out of range. |
| 81 bool SetData(const void* src, size_t offset, size_t size); | 81 bool SetData(const volatile void* src, size_t offset, size_t size); |
| 82 | 82 |
| 83 // Sets the bucket data from a string. Strings are passed NULL terminated to | 83 // Sets the bucket data from a string. Strings are passed NULL terminated to |
| 84 // distinguish between empty string and no string. | 84 // distinguish between empty string and no string. |
| 85 void SetFromString(const char* str); | 85 void SetFromString(const char* str); |
| 86 | 86 |
| 87 // Gets the bucket data as a string. Strings are passed NULL terminated to | 87 // Gets the bucket data as a string. Strings are passed NULL terminated to |
| 88 // distrinquish between empty string and no string. Returns False if there | 88 // distrinquish between empty string and no string. Returns False if there |
| 89 // is no string. | 89 // is no string. |
| 90 bool GetAsString(std::string* str); | 90 bool GetAsString(std::string* str); |
| 91 | 91 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 protected: | 169 protected: |
| 170 // Executes a common command. | 170 // Executes a common command. |
| 171 // Parameters: | 171 // Parameters: |
| 172 // command: the command index. | 172 // command: the command index. |
| 173 // arg_count: the number of CommandBufferEntry arguments. | 173 // arg_count: the number of CommandBufferEntry arguments. |
| 174 // cmd_data: the command data. | 174 // cmd_data: the command data. |
| 175 // Returns: | 175 // Returns: |
| 176 // error::kNoError if no error was found, one of | 176 // error::kNoError if no error was found, one of |
| 177 // error::Error otherwise. | 177 // error::Error otherwise. |
| 178 error::Error DoCommonCommand( | 178 error::Error DoCommonCommand(unsigned int command, |
| 179 unsigned int command, | 179 unsigned int arg_count, |
| 180 unsigned int arg_count, | 180 const volatile void* cmd_data); |
| 181 const void* cmd_data); | |
| 182 | 181 |
| 183 // Gets an name for a common command. | 182 // Gets an name for a common command. |
| 184 const char* GetCommonCommandName(cmd::CommandId command_id) const; | 183 const char* GetCommonCommandName(cmd::CommandId command_id) const; |
| 185 | 184 |
| 186 private: | 185 private: |
| 187 // Generate a member function prototype for each command in an automated and | 186 // Generate a member function prototype for each command in an automated and |
| 188 // typesafe way. | 187 // typesafe way. |
| 189 #define COMMON_COMMAND_BUFFER_CMD_OP(name) \ | 188 #define COMMON_COMMAND_BUFFER_CMD_OP(name) \ |
| 190 error::Error Handle##name(uint32_t immediate_data_size, const void* data); | 189 error::Error Handle##name(uint32_t immediate_data_size, \ |
| 190 const volatile void* data); |
| 191 | 191 |
| 192 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) | 192 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) |
| 193 | 193 |
| 194 #undef COMMON_COMMAND_BUFFER_CMD_OP | 194 #undef COMMON_COMMAND_BUFFER_CMD_OP |
| 195 | 195 |
| 196 CommandBufferEngine* engine_; | 196 CommandBufferEngine* engine_; |
| 197 size_t max_bucket_size_; | 197 size_t max_bucket_size_; |
| 198 | 198 |
| 199 typedef std::map<uint32_t, std::unique_ptr<Bucket>> BucketMap; | 199 typedef std::map<uint32_t, std::unique_ptr<Bucket>> BucketMap; |
| 200 BucketMap buckets_; | 200 BucketMap buckets_; |
| 201 | 201 |
| 202 typedef Error (CommonDecoder::*CmdHandler)(uint32_t immediate_data_size, | 202 typedef Error (CommonDecoder::*CmdHandler)(uint32_t immediate_data_size, |
| 203 const void* data); | 203 const volatile void* data); |
| 204 | 204 |
| 205 // A struct to hold info about each command. | 205 // A struct to hold info about each command. |
| 206 struct CommandInfo { | 206 struct CommandInfo { |
| 207 CmdHandler cmd_handler; | 207 CmdHandler cmd_handler; |
| 208 uint8_t arg_flags; // How to handle the arguments for this command | 208 uint8_t arg_flags; // How to handle the arguments for this command |
| 209 uint8_t cmd_flags; // How to handle this command | 209 uint8_t cmd_flags; // How to handle this command |
| 210 uint16_t arg_count; // How many arguments are expected for this command. | 210 uint16_t arg_count; // How many arguments are expected for this command. |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 // A table of CommandInfo for all the commands. | 213 // A table of CommandInfo for all the commands. |
| 214 static const CommandInfo command_info[]; | 214 static const CommandInfo command_info[]; |
| 215 | 215 |
| 216 DISALLOW_COPY_AND_ASSIGN(CommonDecoder); | 216 DISALLOW_COPY_AND_ASSIGN(CommonDecoder); |
| 217 }; | 217 }; |
| 218 | 218 |
| 219 } // namespace gpu | 219 } // namespace gpu |
| 220 | 220 |
| 221 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 221 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
| 222 | 222 |
| OLD | NEW |