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

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

Issue 8865008: Revert 113479 - Revert "Revert 113250 - Add CommandBuffer::SetGetBuffer" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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
« no previous file with comments | « gpu/command_buffer/service/cmd_parser.h ('k') | gpu/command_buffer/service/cmd_parser_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 implementation of the command parser. 5 // This file contains the implementation of the command parser.
6 6
7 #include "gpu/command_buffer/service/cmd_parser.h" 7 #include "gpu/command_buffer/service/cmd_parser.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 namespace gpu { 11 namespace gpu {
12 12
13 CommandParser::CommandParser(AsyncAPIInterface* handler) 13 CommandParser::CommandParser(void *shm_address,
14 : get_(0), 14 size_t shm_size,
15 put_(0), 15 ptrdiff_t offset,
16 buffer_(NULL), 16 size_t size,
17 entry_count_(0), 17 CommandBufferOffset start_get,
18 AsyncAPIInterface *handler)
19 : get_(start_get),
20 put_(start_get),
18 handler_(handler) { 21 handler_(handler) {
19 }
20
21 void CommandParser::SetBuffer(
22 void* shm_address,
23 size_t shm_size,
24 ptrdiff_t offset,
25 size_t size) {
26 // check proper alignments. 22 // check proper alignments.
27 DCHECK_EQ(0, (reinterpret_cast<intptr_t>(shm_address)) % 4); 23 DCHECK_EQ(0, (reinterpret_cast<intptr_t>(shm_address)) % 4);
28 DCHECK_EQ(0, offset % 4); 24 DCHECK_EQ(0, offset % 4);
29 DCHECK_EQ(0u, size % 4); 25 DCHECK_EQ(0u, size % 4);
30 // check that the command buffer fits into the memory buffer. 26 // check that the command buffer fits into the memory buffer.
31 DCHECK_GE(shm_size, offset + size); 27 DCHECK_GE(shm_size, offset + size);
32 get_ = 0; 28 char * buffer_begin = static_cast<char *>(shm_address) + offset;
33 put_ = 0; 29 buffer_ = reinterpret_cast<CommandBufferEntry *>(buffer_begin);
34 char* buffer_begin = static_cast<char*>(shm_address) + offset;
35 buffer_ = reinterpret_cast<CommandBufferEntry*>(buffer_begin);
36 entry_count_ = size / 4; 30 entry_count_ = size / 4;
37 } 31 }
38 32
39 // Process one command, reading the header from the command buffer, and 33 // Process one command, reading the header from the command buffer, and
40 // forwarding the command index and the arguments to the handler. 34 // forwarding the command index and the arguments to the handler.
41 // Note that: 35 // Note that:
42 // - validation needs to happen on a copy of the data (to avoid race 36 // - validation needs to happen on a copy of the data (to avoid race
43 // conditions). This function only validates the header, leaving the arguments 37 // conditions). This function only validates the header, leaving the arguments
44 // validation to the handler, so it can pass a reference to them. 38 // validation to the handler, so it can pass a reference to them.
45 // - get_ is modified *after* the command has been executed. 39 // - get_ is modified *after* the command has been executed.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 error::Error CommandParser::ProcessAllCommands() { 80 error::Error CommandParser::ProcessAllCommands() {
87 while (!IsEmpty()) { 81 while (!IsEmpty()) {
88 error::Error error = ProcessCommand(); 82 error::Error error = ProcessCommand();
89 if (error) 83 if (error)
90 return error; 84 return error;
91 } 85 }
92 return error::kNoError; 86 return error::kNoError;
93 } 87 }
94 88
95 } // namespace gpu 89 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/cmd_parser.h ('k') | gpu/command_buffer/service/cmd_parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698