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

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

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
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 command parser class. 5 // This file contains the command parser class.
6 6
7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_ 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_
8 #define GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_ 8 #define GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_
9 9
10 #include "gpu/command_buffer/common/constants.h" 10 #include "gpu/command_buffer/common/constants.h"
11 #include "gpu/command_buffer/common/cmd_buffer_common.h" 11 #include "gpu/command_buffer/common/cmd_buffer_common.h"
12 12
13 namespace gpu { 13 namespace gpu {
14 14
15 class AsyncAPIInterface; 15 class AsyncAPIInterface;
16 16
17 // Command parser class. This class parses commands from a shared memory 17 // Command parser class. This class parses commands from a shared memory
18 // buffer, to implement some asynchronous RPC mechanism. 18 // buffer, to implement some asynchronous RPC mechanism.
19 class CommandParser { 19 class CommandParser {
20 public: 20 public:
21 explicit CommandParser(AsyncAPIInterface* handler); 21 CommandParser(void *shm_address,
22 22 size_t shm_size,
23 // Sets the buffer to read commands from. 23 ptrdiff_t offset,
24 void SetBuffer( 24 size_t size,
25 void* shm_address, 25 CommandBufferOffset start_get,
26 size_t shm_size, 26 AsyncAPIInterface *handler);
27 ptrdiff_t offset,
28 size_t size);
29 27
30 // Gets the "get" pointer. The get pointer is an index into the command 28 // Gets the "get" pointer. The get pointer is an index into the command
31 // buffer considered as an array of CommandBufferEntry. 29 // buffer considered as an array of CommandBufferEntry.
32 CommandBufferOffset get() const { return get_; } 30 CommandBufferOffset get() const { return get_; }
33 31
34 // Sets the "get" pointer. The get pointer is an index into the command buffer 32 // Sets the "get" pointer. The get pointer is an index into the command buffer
35 // considered as an array of CommandBufferEntry. 33 // considered as an array of CommandBufferEntry.
36 bool set_get(CommandBufferOffset get) { 34 bool set_get(CommandBufferOffset get) {
37 if (get >= 0 && get < entry_count_) { 35 if (get >= 0 && get < entry_count_) {
38 get_ = get; 36 get_ = get;
(...skipping 19 matching lines...) Expand all
58 56
59 // Processes all commands until get == put. 57 // Processes all commands until get == put.
60 error::Error ProcessAllCommands(); 58 error::Error ProcessAllCommands();
61 59
62 // Reports an error. 60 // Reports an error.
63 void ReportError(unsigned int command_id, error::Error result); 61 void ReportError(unsigned int command_id, error::Error result);
64 62
65 private: 63 private:
66 CommandBufferOffset get_; 64 CommandBufferOffset get_;
67 CommandBufferOffset put_; 65 CommandBufferOffset put_;
68 CommandBufferEntry* buffer_; 66 CommandBufferEntry *buffer_;
69 int32 entry_count_; 67 int32 entry_count_;
70 AsyncAPIInterface* handler_; 68 AsyncAPIInterface *handler_;
71 }; 69 };
72 70
73 // This class defines the interface for an asynchronous API handler, that 71 // This class defines the interface for an asynchronous API handler, that
74 // is responsible for de-multiplexing commands and their arguments. 72 // is responsible for de-multiplexing commands and their arguments.
75 class AsyncAPIInterface { 73 class AsyncAPIInterface {
76 public: 74 public:
77 AsyncAPIInterface() {} 75 AsyncAPIInterface() {}
78 virtual ~AsyncAPIInterface() {} 76 virtual ~AsyncAPIInterface() {}
79 77
80 // Executes a command. 78 // Executes a command.
81 // Parameters: 79 // Parameters:
82 // command: the command index. 80 // command: the command index.
83 // arg_count: the number of CommandBufferEntry arguments. 81 // arg_count: the number of CommandBufferEntry arguments.
84 // cmd_data: the command data. 82 // cmd_data: the command data.
85 // Returns: 83 // Returns:
86 // error::kNoError if no error was found, one of 84 // error::kNoError if no error was found, one of
87 // error::Error otherwise. 85 // error::Error otherwise.
88 virtual error::Error DoCommand( 86 virtual error::Error DoCommand(
89 unsigned int command, 87 unsigned int command,
90 unsigned int arg_count, 88 unsigned int arg_count,
91 const void* cmd_data) = 0; 89 const void* cmd_data) = 0;
92 90
93 // Returns a name for a command. Useful for logging / debuging. 91 // Returns a name for a command. Useful for logging / debuging.
94 virtual const char* GetCommandName(unsigned int command_id) const = 0; 92 virtual const char* GetCommandName(unsigned int command_id) const = 0;
95 }; 93 };
96 94
97 } // namespace gpu 95 } // namespace gpu
98 96
99 #endif // GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_ 97 #endif // GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/cmd_buffer_engine.h ('k') | gpu/command_buffer/service/cmd_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698