OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 16 matching lines...) Expand all Loading... |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 | 32 |
33 // This file contains the implementation of the command parser. | 33 // This file contains the implementation of the command parser. |
34 | 34 |
35 #include "command_buffer/service/cross/cmd_parser.h" | 35 #include "command_buffer/service/cross/cmd_parser.h" |
36 // TODO(gman): remove this so we can use this code for different formats. | 36 // TODO(gman): remove this so we can use this code for different formats. |
37 #include "command_buffer/common/cross/cmd_buffer_format.h" | 37 #include "command_buffer/common/cross/o3d_cmd_format.h" |
38 | 38 |
39 namespace o3d { | 39 namespace o3d { |
40 namespace command_buffer { | 40 namespace command_buffer { |
41 | 41 |
42 CommandParser::CommandParser(void *shm_address, | 42 CommandParser::CommandParser(void *shm_address, |
43 size_t shm_size, | 43 size_t shm_size, |
44 ptrdiff_t offset, | 44 ptrdiff_t offset, |
45 size_t size, | 45 size_t size, |
46 CommandBufferOffset start_get, | 46 CommandBufferOffset start_get, |
47 AsyncAPIInterface *handler) | 47 AsyncAPIInterface *handler) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 DLOG(INFO) << "Error: get offset out of bounds"; | 80 DLOG(INFO) << "Error: get offset out of bounds"; |
81 return parse_error::kParseOutOfBounds; | 81 return parse_error::kParseOutOfBounds; |
82 } | 82 } |
83 | 83 |
84 parse_error::ParseError result = handler_->DoCommand( | 84 parse_error::ParseError result = handler_->DoCommand( |
85 header.command, header.size - 1, buffer_ + get); | 85 header.command, header.size - 1, buffer_ + get); |
86 // TODO(gman): If you want to log errors this is the best place to catch them. | 86 // TODO(gman): If you want to log errors this is the best place to catch them. |
87 // It seems like we need an official way to turn on a debug mode and | 87 // It seems like we need an official way to turn on a debug mode and |
88 // get these errors. | 88 // get these errors. |
89 if (result != parse_error::kParseNoError) { | 89 if (result != parse_error::kParseNoError) { |
90 DLOG(INFO) << "Error: " << result << " for Command " | 90 DLOG(INFO) |
91 << cmd::GetCommandName(static_cast<CommandId>(header.command)); | 91 << "Error: " << result << " for Command " |
| 92 << o3d::GetCommandName(static_cast<o3d::CommandId>(header.command)); |
92 } | 93 } |
93 get_ = (get + header.size) % entry_count_; | 94 get_ = (get + header.size) % entry_count_; |
94 return result; | 95 return result; |
95 } | 96 } |
96 | 97 |
97 // Processes all the commands, while the buffer is not empty. Stop if an error | 98 // Processes all the commands, while the buffer is not empty. Stop if an error |
98 // is encountered. | 99 // is encountered. |
99 parse_error::ParseError CommandParser::ProcessAllCommands() { | 100 parse_error::ParseError CommandParser::ProcessAllCommands() { |
100 while (!IsEmpty()) { | 101 while (!IsEmpty()) { |
101 parse_error::ParseError error = ProcessCommand(); | 102 parse_error::ParseError error = ProcessCommand(); |
102 if (error) return error; | 103 if (error) return error; |
103 } | 104 } |
104 return parse_error::kParseNoError; | 105 return parse_error::kParseNoError; |
105 } | 106 } |
106 | 107 |
107 } // namespace command_buffer | 108 } // namespace command_buffer |
108 } // namespace o3d | 109 } // namespace o3d |
OLD | NEW |