OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
7 | 7 |
8 #include <map> | |
9 #include <string> | 8 #include <string> |
10 #include <vector> | 9 #include <vector> |
11 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 11 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
13 #include "gpu/command_buffer/client/id_allocator.h" | 12 #include "gpu/command_buffer/client/id_allocator.h" |
14 #include "gpu/command_buffer/client/fenced_allocator.h" | 13 #include "gpu/command_buffer/client/fenced_allocator.h" |
15 | 14 |
16 namespace gpu { | 15 namespace gpu { |
17 namespace gles2 { | 16 namespace gles2 { |
18 | 17 |
(...skipping 37 matching lines...) Loading... |
56 } | 55 } |
57 | 56 |
58 // Gets the shared memory offset for the result buffer. | 57 // Gets the shared memory offset for the result buffer. |
59 uint32 result_shm_offset() const { | 58 uint32 result_shm_offset() const { |
60 return result_shm_offset_; | 59 return result_shm_offset_; |
61 } | 60 } |
62 | 61 |
63 // Gets the value of the result. | 62 // Gets the value of the result. |
64 template <typename T> | 63 template <typename T> |
65 T GetResultAs() const { | 64 T GetResultAs() const { |
66 return static_cast<T>(result_buffer_); | 65 return *static_cast<T*>(result_buffer_); |
67 } | 66 } |
68 | 67 |
69 // Gets the GLError through our wrapper. | |
70 GLenum GetGLError(); | |
71 | |
72 // Sets our wrapper for the GLError. | |
73 void SetGLError(GLenum error); | |
74 | |
75 // Waits for all commands to execute. | 68 // Waits for all commands to execute. |
76 void WaitForCmd(); | 69 void WaitForCmd(); |
77 | 70 |
78 // TODO(gman): These bucket functions really seem like they belong in | 71 // TODO(gman): These bucket functions really seem like they belong in |
79 // CommandBufferHelper (or maybe BucketHelper?). Unfortunately they need | 72 // CommandBufferHelper (or maybe BucketHelper?). Unfortunately they need |
80 // a transfer buffer to function which is currently managed by this class. | 73 // a transfer buffer to function which is currently managed by this class. |
81 | 74 |
82 // Gets the contents of a bucket. | 75 // Gets the contents of a bucket. |
83 void GetBucketContents(uint32 bucket_id, std::vector<int8>* data); | 76 void GetBucketContents(uint32 bucket_id, std::vector<int8>* data); |
84 | 77 |
85 // Sets the contents of a bucket. | 78 // Sets the contents of a bucket. |
86 void SetBucketContents(uint32 bucket_id, const void* data, size_t size); | 79 void SetBucketContents(uint32 bucket_id, const void* data, size_t size); |
87 | 80 |
88 // Gets the contents of a bucket as a string. Returns false if there is no | 81 // Gets the contents of a bucket as a string. |
89 // string available which is a separate case from the empty string. | 82 std::string GetBucketAsString(uint32 bucket_id); |
90 bool GetBucketAsString(uint32 bucket_id, std::string* str); | |
91 | 83 |
92 // Sets the contents of a bucket as a string. | 84 // Sets the contents of a bucket as a string. |
93 void SetBucketAsString(uint32 bucket_id, const std::string& str); | 85 void SetBucketAsString(uint32 bucket_id, const std::string& str); |
94 | 86 |
95 // The maxiumum result size from simple GL get commands. | 87 // The maxiumum result size from simple GL get commands. |
96 static const size_t kMaxSizeOfSimpleResult = 16 * sizeof(uint32); // NOLINT. | 88 static const size_t kMaxSizeOfSimpleResult = 16 * sizeof(uint32); // NOLINT. |
97 static const uint32 kResultBucketId = 1; | 89 static const uint32 kResultBucketId = 1; |
98 | 90 |
99 GLES2Util util_; | 91 GLES2Util util_; |
100 GLES2CmdHelper* helper_; | 92 GLES2CmdHelper* helper_; |
101 IdAllocator id_allocator_; | 93 IdAllocator id_allocator_; |
102 FencedAllocatorWrapper transfer_buffer_; | 94 FencedAllocatorWrapper transfer_buffer_; |
103 int transfer_buffer_id_; | 95 int transfer_buffer_id_; |
104 void* result_buffer_; | 96 void* result_buffer_; |
105 uint32 result_shm_offset_; | 97 uint32 result_shm_offset_; |
106 | 98 |
107 // pack alignment as last set by glPixelStorei | 99 // pack alignment as last set by glPixelStorei |
108 GLint pack_alignment_; | 100 GLint pack_alignment_; |
109 | 101 |
110 // unpack alignment as last set by glPixelStorei | 102 // unpack alignment as last set by glPixelStorei |
111 GLint unpack_alignment_; | 103 GLint unpack_alignment_; |
112 | 104 |
113 // Current GL error bits. | |
114 uint32 error_bits_; | |
115 | |
116 // Map of GLenum to Strings for glGetString. We need to cache these because | |
117 // the pointer passed back to the client has to remain valid for eternity. | |
118 typedef std::map<uint32, std::string> GLStringMap; | |
119 GLStringMap gl_strings_; | |
120 | |
121 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); | 105 DISALLOW_COPY_AND_ASSIGN(GLES2Implementation); |
122 }; | 106 }; |
123 | 107 |
| 108 |
124 } // namespace gles2 | 109 } // namespace gles2 |
125 } // namespace gpu | 110 } // namespace gpu |
126 | 111 |
127 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 112 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
128 | 113 |
OLD | NEW |