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

Side by Side Diff: gpu/command_buffer/client/cmd_buffer_helper.h

Issue 555129: Add commands Jump, Call and Return... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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
« no previous file with comments | « no previous file | gpu/command_buffer/client/cmd_buffer_helper.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 command buffer helper class. 5 // This file contains the command buffer helper class.
6 6
7 #ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_
8 #define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ 8 #define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_
9 9
10 #include "gpu/command_buffer/common/logging.h" 10 #include "gpu/command_buffer/common/logging.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // was successful. The function will fail if the command buffer service has 48 // was successful. The function will fail if the command buffer service has
49 // disconnected. 49 // disconnected.
50 bool Finish(); 50 bool Finish();
51 51
52 // Waits until a given number of available entries are available. 52 // Waits until a given number of available entries are available.
53 // Parameters: 53 // Parameters:
54 // count: number of entries needed. This value must be at most 54 // count: number of entries needed. This value must be at most
55 // the size of the buffer minus one. 55 // the size of the buffer minus one.
56 void WaitForAvailableEntries(int32 count); 56 void WaitForAvailableEntries(int32 count);
57 57
58 // Adds a command data to the command buffer. This may wait until sufficient
59 // space is available.
60 // Parameters:
61 // entries: The command entries to add.
62 // count: The number of entries.
63 void AddCommandData(const CommandBufferEntry* entries, int32 count) {
64 WaitForAvailableEntries(count);
65 for (; count > 0; --count) {
66 entries_[put_++] = *entries++;
67 }
68 DCHECK_LE(put_, entry_count_);
69 if (put_ == entry_count_) put_ = 0;
70 }
71
72 // A typed version of AddCommandData.
73 template <typename T>
74 void AddTypedCmdData(const T& cmd) {
75 AddCommandData(reinterpret_cast<const CommandBufferEntry*>(&cmd),
76 ComputeNumEntries(sizeof(cmd)));
77 }
78
79 // Adds a command to the command buffer. This may wait until sufficient space
80 // is available.
81 // Parameters:
82 // command: the command index.
83 // arg_count: the number of arguments for the command.
84 // args: the arguments for the command (these are copied before the
85 // function returns).
86 void AddCommand(int32 command,
87 int32 arg_count,
88 const CommandBufferEntry *args) {
89 CommandHeader header;
90 header.size = arg_count + 1;
91 header.command = command;
92 WaitForAvailableEntries(header.size);
93 entries_[put_++].value_header = header;
94 for (int i = 0; i < arg_count; ++i) {
95 entries_[put_++] = args[i];
96 }
97 DCHECK_LE(put_, entry_count_);
98 if (put_ == entry_count_) put_ = 0;
99 }
100
101 // Inserts a new token into the command buffer. This token either has a value 58 // Inserts a new token into the command buffer. This token either has a value
102 // different from previously inserted tokens, or ensures that previously 59 // different from previously inserted tokens, or ensures that previously
103 // inserted tokens with that value have already passed through the command 60 // inserted tokens with that value have already passed through the command
104 // stream. 61 // stream.
105 // Returns: 62 // Returns:
106 // the value of the new token or -1 if the command buffer reader has 63 // the value of the new token or -1 if the command buffer reader has
107 // shutdown. 64 // shutdown.
108 int32 InsertToken(); 65 int32 InsertToken();
109 66
110 // Waits until the token of a particular value has passed through the command 67 // Waits until the token of a particular value has passed through the command
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 int32 get_; 136 int32 get_;
180 int32 put_; 137 int32 put_;
181 138
182 friend class CommandBufferHelperTest; 139 friend class CommandBufferHelperTest;
183 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); 140 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper);
184 }; 141 };
185 142
186 } // namespace gpu 143 } // namespace gpu
187 144
188 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ 145 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/client/cmd_buffer_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698