| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <map> | 11 #include <map> |
| 9 #include <stack> | 12 #include <stack> |
| 10 #include <string> | 13 #include <string> |
| 14 #include "base/macros.h" |
| 11 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
| 12 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 13 #include "gpu/command_buffer/common/buffer.h" | 17 #include "gpu/command_buffer/common/buffer.h" |
| 14 #include "gpu/command_buffer/service/cmd_parser.h" | 18 #include "gpu/command_buffer/service/cmd_parser.h" |
| 15 #include "gpu/gpu_export.h" | 19 #include "gpu/gpu_export.h" |
| 16 | 20 |
| 17 // Forwardly declare a few GL types to avoid including GL header files. | 21 // Forwardly declare a few GL types to avoid including GL header files. |
| 18 typedef int GLsizei; | 22 typedef int GLsizei; |
| 19 typedef int GLint; | 23 typedef int GLint; |
| 20 | 24 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 std::vector<char*>* _string, | 97 std::vector<char*>* _string, |
| 94 std::vector<GLint>* _length); | 98 std::vector<GLint>* _length); |
| 95 | 99 |
| 96 private: | 100 private: |
| 97 bool OffsetSizeValid(size_t offset, size_t size) const { | 101 bool OffsetSizeValid(size_t offset, size_t size) const { |
| 98 size_t temp = offset + size; | 102 size_t temp = offset + size; |
| 99 return temp <= size_ && temp >= offset; | 103 return temp <= size_ && temp >= offset; |
| 100 } | 104 } |
| 101 | 105 |
| 102 size_t size_; | 106 size_t size_; |
| 103 ::scoped_ptr<int8[]> data_; | 107 ::scoped_ptr<int8_t[]> data_; |
| 104 | 108 |
| 105 DISALLOW_COPY_AND_ASSIGN(Bucket); | 109 DISALLOW_COPY_AND_ASSIGN(Bucket); |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 CommonDecoder(); | 112 CommonDecoder(); |
| 109 ~CommonDecoder() override; | 113 ~CommonDecoder() override; |
| 110 | 114 |
| 111 // Sets the engine, to get shared memory buffers from, and to set the token | 115 // Sets the engine, to get shared memory buffers from, and to set the token |
| 112 // to. | 116 // to. |
| 113 void set_engine(CommandBufferEngine* engine) { | 117 void set_engine(CommandBufferEngine* engine) { |
| 114 engine_ = engine; | 118 engine_ = engine; |
| 115 } | 119 } |
| 116 CommandBufferEngine* engine() const { return engine_; } | 120 CommandBufferEngine* engine() const { return engine_; } |
| 117 | 121 |
| 118 // Creates a bucket. If the bucket already exists returns that bucket. | 122 // Creates a bucket. If the bucket already exists returns that bucket. |
| 119 Bucket* CreateBucket(uint32 bucket_id); | 123 Bucket* CreateBucket(uint32_t bucket_id); |
| 120 | 124 |
| 121 // Gets a bucket. Returns NULL if the bucket does not exist. | 125 // Gets a bucket. Returns NULL if the bucket does not exist. |
| 122 Bucket* GetBucket(uint32 bucket_id) const; | 126 Bucket* GetBucket(uint32_t bucket_id) const; |
| 123 | 127 |
| 124 // Gets the address of shared memory data, given a shared memory ID and an | 128 // Gets the address of shared memory data, given a shared memory ID and an |
| 125 // offset. Also checks that the size is consistent with the shared memory | 129 // offset. Also checks that the size is consistent with the shared memory |
| 126 // size. | 130 // size. |
| 127 // Parameters: | 131 // Parameters: |
| 128 // shm_id: the id of the shared memory buffer. | 132 // shm_id: the id of the shared memory buffer. |
| 129 // offset: the offset of the data in the shared memory buffer. | 133 // offset: the offset of the data in the shared memory buffer. |
| 130 // size: the size of the data. | 134 // size: the size of the data. |
| 131 // Returns: | 135 // Returns: |
| 132 // NULL if shm_id isn't a valid shared memory buffer ID or if the size | 136 // NULL if shm_id isn't a valid shared memory buffer ID or if the size |
| (...skipping 25 matching lines...) Expand all Loading... |
| 158 unsigned int command, | 162 unsigned int command, |
| 159 unsigned int arg_count, | 163 unsigned int arg_count, |
| 160 const void* cmd_data); | 164 const void* cmd_data); |
| 161 | 165 |
| 162 // Gets an name for a common command. | 166 // Gets an name for a common command. |
| 163 const char* GetCommonCommandName(cmd::CommandId command_id) const; | 167 const char* GetCommonCommandName(cmd::CommandId command_id) const; |
| 164 | 168 |
| 165 private: | 169 private: |
| 166 // Generate a member function prototype for each command in an automated and | 170 // Generate a member function prototype for each command in an automated and |
| 167 // typesafe way. | 171 // typesafe way. |
| 168 #define COMMON_COMMAND_BUFFER_CMD_OP(name) \ | 172 #define COMMON_COMMAND_BUFFER_CMD_OP(name) \ |
| 169 error::Error Handle##name(uint32 immediate_data_size, const void* data); | 173 error::Error Handle##name(uint32_t immediate_data_size, const void* data); |
| 170 | 174 |
| 171 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) | 175 COMMON_COMMAND_BUFFER_CMDS(COMMON_COMMAND_BUFFER_CMD_OP) |
| 172 | 176 |
| 173 #undef COMMON_COMMAND_BUFFER_CMD_OP | 177 #undef COMMON_COMMAND_BUFFER_CMD_OP |
| 174 | 178 |
| 175 CommandBufferEngine* engine_; | 179 CommandBufferEngine* engine_; |
| 176 | 180 |
| 177 typedef std::map<uint32, linked_ptr<Bucket> > BucketMap; | 181 typedef std::map<uint32_t, linked_ptr<Bucket>> BucketMap; |
| 178 BucketMap buckets_; | 182 BucketMap buckets_; |
| 179 | 183 |
| 180 typedef Error (CommonDecoder::*CmdHandler)( | 184 typedef Error (CommonDecoder::*CmdHandler)(uint32_t immediate_data_size, |
| 181 uint32 immediate_data_size, | 185 const void* data); |
| 182 const void* data); | |
| 183 | 186 |
| 184 // A struct to hold info about each command. | 187 // A struct to hold info about each command. |
| 185 struct CommandInfo { | 188 struct CommandInfo { |
| 186 CmdHandler cmd_handler; | 189 CmdHandler cmd_handler; |
| 187 uint8 arg_flags; // How to handle the arguments for this command | 190 uint8_t arg_flags; // How to handle the arguments for this command |
| 188 uint8 cmd_flags; // How to handle this command | 191 uint8_t cmd_flags; // How to handle this command |
| 189 uint16 arg_count; // How many arguments are expected for this command. | 192 uint16_t arg_count; // How many arguments are expected for this command. |
| 190 }; | 193 }; |
| 191 | 194 |
| 192 // A table of CommandInfo for all the commands. | 195 // A table of CommandInfo for all the commands. |
| 193 static const CommandInfo command_info[]; | 196 static const CommandInfo command_info[]; |
| 194 | 197 |
| 195 }; | 198 }; |
| 196 | 199 |
| 197 } // namespace gpu | 200 } // namespace gpu |
| 198 | 201 |
| 199 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 202 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
| 200 | 203 |
| OLD | NEW |