Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: command_buffer/service/cross/cmd_parser.cc

Issue 212018: Change command buffer client code to use structures.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // Process one command, reading the header from the command buffer, and 60 // Process one command, reading the header from the command buffer, and
61 // forwarding the command index and the arguments to the handler. 61 // forwarding the command index and the arguments to the handler.
62 // Note that: 62 // Note that:
63 // - validation needs to happen on a copy of the data (to avoid race 63 // - validation needs to happen on a copy of the data (to avoid race
64 // conditions). This function only validates the header, leaving the arguments 64 // conditions). This function only validates the header, leaving the arguments
65 // validation to the handler, so it can pass a reference to them. 65 // validation to the handler, so it can pass a reference to them.
66 // - get_ is modified *after* the command has been executed. 66 // - get_ is modified *after* the command has been executed.
67 BufferSyncInterface::ParseError CommandParser::ProcessCommand() { 67 BufferSyncInterface::ParseError CommandParser::ProcessCommand() {
68 CommandBufferOffset get = get_; 68 CommandBufferOffset get = get_;
69 if (get == put_) return BufferSyncInterface::PARSE_NO_ERROR; 69 if (get == put_) return BufferSyncInterface::kParseNoError;
70 70
71 CommandHeader header = buffer_[get].value_header; 71 CommandHeader header = buffer_[get].value_header;
72 if (header.size == 0) return BufferSyncInterface::PARSE_INVALID_SIZE; 72 if (header.size == 0) return BufferSyncInterface::kParseInvalidSize;
73 if (header.size + get > entry_count_) 73 if (header.size + get > entry_count_)
74 return BufferSyncInterface::PARSE_OUT_OF_BOUNDS; 74 return BufferSyncInterface::kParseOutOfBounds;
75 BufferSyncInterface::ParseError result = handler_->DoCommand( 75 BufferSyncInterface::ParseError result = handler_->DoCommand(
76 header.command, header.size - 1, buffer_ + get + 1); 76 header.command, header.size - 1, buffer_ + get);
77 get_ = (get + header.size) % entry_count_; 77 get_ = (get + header.size) % entry_count_;
78 return result; 78 return result;
79 } 79 }
80 80
81 // Processes all the commands, while the buffer is not empty. Stop if an error 81 // Processes all the commands, while the buffer is not empty. Stop if an error
82 // is encountered. 82 // is encountered.
83 BufferSyncInterface::ParseError CommandParser::ProcessAllCommands() { 83 BufferSyncInterface::ParseError CommandParser::ProcessAllCommands() {
84 while (!IsEmpty()) { 84 while (!IsEmpty()) {
85 BufferSyncInterface::ParseError error = ProcessCommand(); 85 BufferSyncInterface::ParseError error = ProcessCommand();
86 if (error) return error; 86 if (error) return error;
87 } 87 }
88 return BufferSyncInterface::PARSE_NO_ERROR; 88 return BufferSyncInterface::kParseNoError;
89 } 89 }
90 90
91 } // namespace command_buffer 91 } // namespace command_buffer
92 } // namespace o3d 92 } // namespace o3d
OLDNEW
« no previous file with comments | « command_buffer/service/cross/cmd_parser.h ('k') | command_buffer/service/cross/cmd_parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698