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 69 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) | 90 ReportError(header.command, result); |
91 << "Error: " << result << " for Command " | |
92 << o3d::GetCommandName(static_cast<o3d::CommandId>(header.command)); | |
93 } | 91 } |
94 get_ = (get + header.size) % entry_count_; | 92 get_ = (get + header.size) % entry_count_; |
95 return result; | 93 return result; |
96 } | 94 } |
97 | 95 |
| 96 void CommandParser::ReportError(unsigned int command_id, |
| 97 parse_error::ParseError result) { |
| 98 DLOG(INFO) << "Error: " << result << " for Command " |
| 99 << handler_->GetCommandName(command_id); |
| 100 } |
| 101 |
98 // Processes all the commands, while the buffer is not empty. Stop if an error | 102 // Processes all the commands, while the buffer is not empty. Stop if an error |
99 // is encountered. | 103 // is encountered. |
100 parse_error::ParseError CommandParser::ProcessAllCommands() { | 104 parse_error::ParseError CommandParser::ProcessAllCommands() { |
101 while (!IsEmpty()) { | 105 while (!IsEmpty()) { |
102 parse_error::ParseError error = ProcessCommand(); | 106 parse_error::ParseError error = ProcessCommand(); |
103 if (error) return error; | 107 if (error) return error; |
104 } | 108 } |
105 return parse_error::kParseNoError; | 109 return parse_error::kParseNoError; |
106 } | 110 } |
107 | 111 |
108 } // namespace command_buffer | 112 } // namespace command_buffer |
109 } // namespace o3d | 113 } // namespace o3d |
OLD | NEW |