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_BUFFER_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 GLenum usage() const { | 57 GLenum usage() const { |
58 return usage_; | 58 return usage_; |
59 } | 59 } |
60 | 60 |
61 // Gets the maximum value in the buffer for the given range interpreted as | 61 // Gets the maximum value in the buffer for the given range interpreted as |
62 // the given type. Returns false if offset and count are out of range. | 62 // the given type. Returns false if offset and count are out of range. |
63 // offset is in bytes. | 63 // offset is in bytes. |
64 // count is in elements of type. | 64 // count is in elements of type. |
65 bool GetMaxValueForRange(GLuint offset, GLsizei count, GLenum type, | 65 bool GetMaxValueForRange(GLuint offset, GLsizei count, GLenum type, |
66 bool primitive_restart_enabled, GLuint* max_value); | 66 GLuint* max_value); |
67 | 67 |
68 // Returns a pointer to shadowed data. | 68 // Returns a pointer to shadowed data. |
69 const void* GetRange(GLintptr offset, GLsizeiptr size) const; | 69 const void* GetRange(GLintptr offset, GLsizeiptr size) const; |
70 | 70 |
71 bool IsDeleted() const { | 71 bool IsDeleted() const { |
72 return deleted_; | 72 return deleted_; |
73 } | 73 } |
74 | 74 |
75 bool IsValid() const { | 75 bool IsValid() const { |
76 return initial_target() && !IsDeleted(); | 76 return initial_target() && !IsDeleted(); |
(...skipping 17 matching lines...) Expand all Loading... |
94 } | 94 } |
95 | 95 |
96 private: | 96 private: |
97 friend class BufferManager; | 97 friend class BufferManager; |
98 friend class BufferManagerTestBase; | 98 friend class BufferManagerTestBase; |
99 friend class base::RefCounted<Buffer>; | 99 friend class base::RefCounted<Buffer>; |
100 | 100 |
101 // Represents a range in a buffer. | 101 // Represents a range in a buffer. |
102 class Range { | 102 class Range { |
103 public: | 103 public: |
104 Range(GLuint offset, GLsizei count, GLenum type, | 104 Range(GLuint offset, GLsizei count, GLenum type) |
105 bool primitive_restart_enabled) | |
106 : offset_(offset), | 105 : offset_(offset), |
107 count_(count), | 106 count_(count), |
108 type_(type), | 107 type_(type) { |
109 primitive_restart_enabled_(primitive_restart_enabled) { | |
110 } | 108 } |
111 | 109 |
112 // A less functor provided for std::map so it can find ranges. | 110 // A less functor provided for std::map so it can find ranges. |
113 struct Less { | 111 struct Less { |
114 bool operator() (const Range& lhs, const Range& rhs) const { | 112 bool operator() (const Range& lhs, const Range& rhs) const { |
115 if (lhs.offset_ != rhs.offset_) { | 113 if (lhs.offset_ != rhs.offset_) { |
116 return lhs.offset_ < rhs.offset_; | 114 return lhs.offset_ < rhs.offset_; |
117 } | 115 } |
118 if (lhs.count_ != rhs.count_) { | 116 if (lhs.count_ != rhs.count_) { |
119 return lhs.count_ < rhs.count_; | 117 return lhs.count_ < rhs.count_; |
120 } | 118 } |
121 if (lhs.type_ != rhs.type_) { | 119 return lhs.type_ < rhs.type_; |
122 return lhs.type_ < rhs.type_; | |
123 } | |
124 return lhs.primitive_restart_enabled_ < rhs.primitive_restart_enabled_; | |
125 } | 120 } |
126 }; | 121 }; |
127 | 122 |
128 private: | 123 private: |
129 GLuint offset_; | 124 GLuint offset_; |
130 GLsizei count_; | 125 GLsizei count_; |
131 GLenum type_; | 126 GLenum type_; |
132 bool primitive_restart_enabled_; | |
133 }; | 127 }; |
134 | 128 |
135 ~Buffer(); | 129 ~Buffer(); |
136 | 130 |
137 GLenum initial_target() const { | 131 GLenum initial_target() const { |
138 return initial_target_; | 132 return initial_target_; |
139 } | 133 } |
140 | 134 |
141 void set_initial_target(GLenum target) { | 135 void set_initial_target(GLenum target) { |
142 DCHECK_EQ(0u, initial_target_); | 136 DCHECK_EQ(0u, initial_target_); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 bool have_context_; | 329 bool have_context_; |
336 bool use_client_side_arrays_for_stream_buffers_; | 330 bool use_client_side_arrays_for_stream_buffers_; |
337 | 331 |
338 DISALLOW_COPY_AND_ASSIGN(BufferManager); | 332 DISALLOW_COPY_AND_ASSIGN(BufferManager); |
339 }; | 333 }; |
340 | 334 |
341 } // namespace gles2 | 335 } // namespace gles2 |
342 } // namespace gpu | 336 } // namespace gpu |
343 | 337 |
344 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 338 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
OLD | NEW |