OLD | NEW |
1 // Copyright (c) 2012 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 #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 <map> | 8 #include <map> |
9 #include <stack> | 9 #include <stack> |
10 #include <string> | 10 #include <string> |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "gpu/command_buffer/service/cmd_parser.h" | 13 #include "gpu/command_buffer/service/cmd_parser.h" |
14 #include "gpu/gpu_export.h" | |
15 | 14 |
16 namespace gpu { | 15 namespace gpu { |
17 | 16 |
18 class CommandBufferEngine; | 17 class CommandBufferEngine; |
19 | 18 |
20 // This class is a helper base class for implementing the common parts of the | 19 // This class is a helper base class for implementing the common parts of the |
21 // o3d/gl2 command buffer decoder. | 20 // o3d/gl2 command buffer decoder. |
22 class GPU_EXPORT CommonDecoder : NON_EXPORTED_BASE(public AsyncAPIInterface) { | 21 class CommonDecoder : public AsyncAPIInterface { |
23 public: | 22 public: |
24 typedef error::Error Error; | 23 typedef error::Error Error; |
25 | 24 |
26 static const unsigned int kMaxStackDepth = 32; | 25 static const unsigned int kMaxStackDepth = 32; |
27 | 26 |
28 // A bucket is a buffer to help collect memory across a command buffer. When | 27 // A bucket is a buffer to help collect memory across a command buffer. When |
29 // creating a command buffer implementation of an existing API, sometimes that | 28 // creating a command buffer implementation of an existing API, sometimes that |
30 // API has functions that take a pointer to data. A good example is OpenGL's | 29 // API has functions that take a pointer to data. A good example is OpenGL's |
31 // glBufferData. Because the data is separated between client and service, | 30 // glBufferData. Because the data is separated between client and service, |
32 // there are 2 ways to get this data across. 1 is to put all the data in | 31 // there are 2 ways to get this data across. 1 is to put all the data in |
33 // shared memory. The problem with this is the data can be arbitarily large | 32 // shared memory. The problem with this is the data can be arbitarily large |
34 // and the host OS may not support that much shared memory. Another solution | 33 // and the host OS may not support that much shared memory. Another solution |
35 // is to shuffle memory across a little bit at a time, collecting it on the | 34 // is to shuffle memory across a little bit at a time, collecting it on the |
36 // service side and when it is all there then call glBufferData. Buckets | 35 // service side and when it is all there then call glBufferData. Buckets |
37 // implement this second solution. Using the common commands, SetBucketSize, | 36 // implement this second solution. Using the common commands, SetBucketSize, |
38 // SetBucketData, SetBucketDataImmediate the client can fill a bucket. It can | 37 // SetBucketData, SetBucketDataImmediate the client can fill a bucket. It can |
39 // then call a command that uses that bucket (like BufferDataBucket in the | 38 // then call a command that uses that bucket (like BufferDataBucket in the |
40 // GLES2 command buffer implementation). | 39 // GLES2 command buffer implementation). |
41 // | 40 // |
42 // If you are designing an API from scratch you can avoid this need for | 41 // If you are designing an API from scratch you can avoid this need for |
43 // Buckets by making your API always take an offset and a size | 42 // Buckets by making your API always take an offset and a size |
44 // similar to glBufferSubData. | 43 // similar to glBufferSubData. |
45 // | 44 // |
46 // Buckets also help pass strings to/from the service. To return a string of | 45 // Buckets also help pass strings to/from the service. To return a string of |
47 // arbitary size, the service puts the string in a bucket. The client can | 46 // arbitary size, the service puts the string in a bucket. The client can |
48 // then query the size of a bucket and request sections of the bucket to | 47 // then query the size of a bucket and request sections of the bucket to |
49 // be passed across shared memory. | 48 // be passed across shared memory. |
50 class GPU_EXPORT Bucket { | 49 class Bucket { |
51 public: | 50 public: |
52 Bucket(); | 51 Bucket(); |
53 ~Bucket(); | 52 ~Bucket(); |
54 | 53 |
55 size_t size() const { | 54 size_t size() const { |
56 return size_; | 55 return size_; |
57 } | 56 } |
58 | 57 |
59 // Gets a pointer to a section the bucket. Returns NULL if offset or size is | 58 // Gets a pointer to a section the bucket. Returns NULL if offset or size is |
60 // out of range. | 59 // out of range. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 173 |
175 uint32 offset; | 174 uint32 offset; |
176 }; | 175 }; |
177 std::stack<CommandAddress> call_stack_; | 176 std::stack<CommandAddress> call_stack_; |
178 }; | 177 }; |
179 | 178 |
180 } // namespace gpu | 179 } // namespace gpu |
181 | 180 |
182 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ | 181 #endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ |
183 | 182 |
OLD | NEW |