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

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

Issue 479008: Implements bucket commands and adds unit tests to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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/common_decoder_unittest.cc ('k') | gpu/gpu.gyp » ('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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 #include <vector> 5 #include <vector>
6 #include <string> 6 #include <string>
7 #include <map> 7 #include <map>
8 #include <build/build_config.h> 8 #include <build/build_config.h>
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #define GLES2_GPU_SERVICE 1 10 #define GLES2_GPU_SERVICE 1
(...skipping 13 matching lines...) Expand all
24 const void* AddressAfterStruct(const T& pod) { 24 const void* AddressAfterStruct(const T& pod) {
25 return reinterpret_cast<const uint8*>(&pod) + sizeof(pod); 25 return reinterpret_cast<const uint8*>(&pod) + sizeof(pod);
26 } 26 }
27 27
28 // Returns the address of the frst byte after the struct. 28 // Returns the address of the frst byte after the struct.
29 template <typename RETURN_TYPE, typename COMMAND_TYPE> 29 template <typename RETURN_TYPE, typename COMMAND_TYPE>
30 RETURN_TYPE GetImmediateDataAs(const COMMAND_TYPE& pod) { 30 RETURN_TYPE GetImmediateDataAs(const COMMAND_TYPE& pod) {
31 return static_cast<RETURN_TYPE>(const_cast<void*>(AddressAfterStruct(pod))); 31 return static_cast<RETURN_TYPE>(const_cast<void*>(AddressAfterStruct(pod)));
32 } 32 }
33 33
34 // Returns the size in bytes of the data of an Immediate command, a command with
35 // its data inline in the command buffer.
36 template <typename T>
37 unsigned int ImmediateDataSize(uint32 arg_count) {
38 return static_cast<unsigned int>(
39 (arg_count + 1 - ComputeNumEntries(sizeof(T))) *
40 sizeof(CommandBufferEntry)); // NOLINT
41 }
42
43 // Checks if there is enough immediate data. 34 // Checks if there is enough immediate data.
44 template<typename T> 35 template<typename T>
45 bool CheckImmediateDataSize( 36 bool CheckImmediateDataSize(
46 uint32 immediate_data_size, 37 uint32 immediate_data_size,
47 GLuint count, 38 GLuint count,
48 size_t size, 39 size_t size,
49 unsigned int elements_per_unit) { 40 unsigned int elements_per_unit) {
50 return immediate_data_size == count * size * elements_per_unit; 41 return immediate_data_size == count * size * elements_per_unit;
51 } 42 }
52 43
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // Overridden from GLES2Decoder. 233 // Overridden from GLES2Decoder.
243 virtual bool Initialize(); 234 virtual bool Initialize();
244 235
245 // Overridden from GLES2Decoder. 236 // Overridden from GLES2Decoder.
246 virtual void Destroy(); 237 virtual void Destroy();
247 238
248 private: 239 private:
249 bool InitPlatformSpecific(); 240 bool InitPlatformSpecific();
250 bool InitGlew(); 241 bool InitGlew();
251 242
252 // Typed version of GetAddressAndCheckSize.
253 template <typename T>
254 T GetSharedMemoryAs(unsigned int shm_id, unsigned int offset,
255 unsigned int size) {
256 return static_cast<T>(GetAddressAndCheckSize(shm_id, offset, size));
257 }
258
259 // Template to help call glGenXXX functions. 243 // Template to help call glGenXXX functions.
260 template <void gl_gen_function(GLsizei, GLuint*)> 244 template <void gl_gen_function(GLsizei, GLuint*)>
261 bool GenGLObjects(GLsizei n, const GLuint* client_ids) { 245 bool GenGLObjects(GLsizei n, const GLuint* client_ids) {
262 // TODO(gman): Verify client ids are unused. 246 // TODO(gman): Verify client ids are unused.
263 scoped_array<GLuint>temp(new GLuint[n]); 247 scoped_array<GLuint>temp(new GLuint[n]);
264 gl_gen_function(n, temp.get()); 248 gl_gen_function(n, temp.get());
265 // TODO(gman): check for success before copying results. 249 // TODO(gman): check for success before copying results.
266 for (GLsizei ii = 0; ii < n; ++ii) { 250 for (GLsizei ii = 0; ii < n; ++ii) {
267 if (!id_map_.AddMapping(client_ids[ii], temp[ii])) { 251 if (!id_map_.AddMapping(client_ids[ii], temp[ii])) {
268 // TODO(gman): fail. 252 // TODO(gman): fail.
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1226 }
1243 1227
1244 // Include the auto-generated part of this file. We split this because it means 1228 // Include the auto-generated part of this file. We split this because it means
1245 // we can easily edit the non-auto generated parts right here in this file 1229 // we can easily edit the non-auto generated parts right here in this file
1246 // instead of having to edit some template or the code generator. 1230 // instead of having to edit some template or the code generator.
1247 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 1231 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
1248 1232
1249 } // namespace gles2 1233 } // namespace gles2
1250 } // namespace command_buffer 1234 } // namespace command_buffer
1251 1235
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/common_decoder_unittest.cc ('k') | gpu/gpu.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698