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

Side by Side Diff: command_buffer/service/cross/common_decoder.h

Issue 329046: Splits the command buffers into common commands... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 1 month 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
(Empty)
1 /*
2 * Copyright 2009, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef O3D_COMMAND_BUFFER_SERVICE_CROSS_COMMON_DECODER_H_
33 #define O3D_COMMAND_BUFFER_SERVICE_CROSS_COMMON_DECODER_H_
34
35 #include "core/cross/types.h"
36 #include "command_buffer/service/cross/cmd_parser.h"
37
38 namespace o3d {
39 namespace command_buffer {
40
41 class CommandBufferEngine;
42
43 // This class is a helper base class for implementing the common parts of the
44 // o3d/gl2 command buffer decoder.
45 class CommonDecoder : public AsyncAPIInterface {
46 public:
47 typedef parse_error::ParseError ParseError;
48
49 CommonDecoder() : engine_(NULL) {
50 }
51 virtual ~CommonDecoder() {
52 }
53
54 // Sets the engine, to get shared memory buffers from, and to set the token
55 // to.
56 void set_engine(CommandBufferEngine* engine) {
57 engine_ = engine;
58 }
59
60 protected:
61 // Executes a common command.
62 // Parameters:
63 // command: the command index.
64 // arg_count: the number of CommandBufferEntry arguments.
65 // cmd_data: the command data.
66 // Returns:
67 // parse_error::NO_ERROR if no error was found, one of
68 // parse_error::ParseError otherwise.
69 parse_error::ParseError DoCommonCommand(
70 unsigned int command,
71 unsigned int arg_count,
72 const void* cmd_data);
73
74 // Gets the address of shared memory data, given a shared memory ID and an
75 // offset. Also checks that the size is consistent with the shared memory
76 // size.
77 // Parameters:
78 // shm_id: the id of the shared memory buffer.
79 // offset: the offset of the data in the shared memory buffer.
80 // size: the size of the data.
81 // Returns:
82 // NULL if shm_id isn't a valid shared memory buffer ID or if the size
83 // check fails. Return a pointer to the data otherwise.
84 void* GetAddressAndCheckSize(unsigned int shm_id,
85 unsigned int offset,
86 unsigned int size);
87
88 // Gets an name for a common command.
89 const char* GetCommonCommandName(cmd::CommandId command_id) const;
90
91 private:
92 // Generate a member function prototype for each command in an automated and
93 // typesafe way.
94 #define COMMON_COMMAND_BUFFER_CMD_OP(name) \
95 parse_error::ParseError Handle ## name( \
96 unsigned int arg_count, \
97 const cmd::name& args); \
98
99 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP)
100
101 #undef COMMON_COMMAND_BUFFER_CMD_OP
102
103 CommandBufferEngine* engine_;
104 };
105
106 } // namespace command_buffer
107 } // namespace o3d
108
109 #endif // O3D_COMMAND_BUFFER_SERVICE_CROSS_COMMON_DECODER_H_
110
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698