Chromium Code Reviews| 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 GLuint* max_value); | 66 bool primitive_restart_enabled, 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) | |
| 105 : offset_(offset), | 106 : offset_(offset), |
| 106 count_(count), | 107 count_(count), |
| 107 type_(type) { | 108 type_(type), |
| 109 primitive_restart_enabled_( | |
| 110 primitive_restart_enabled ? GL_TRUE : GL_FALSE) { | |
|
piman
2016/03/19 00:56:11
nit: keep primitive_restart_enabled_ as a bool to
Ken Russell (switch to Gerrit)
2016/03/19 04:06:53
It was more straightforward in my opinion to turn
piman
2016/03/21 19:14:41
I don't care all that much, but FYI you can compar
Ken Russell (switch to Gerrit)
2016/03/21 22:22:29
Thanks, I didn't know that and should have tested
| |
| 108 } | 111 } |
| 109 | 112 |
| 110 // A less functor provided for std::map so it can find ranges. | 113 // A less functor provided for std::map so it can find ranges. |
| 111 struct Less { | 114 struct Less { |
| 112 bool operator() (const Range& lhs, const Range& rhs) const { | 115 bool operator() (const Range& lhs, const Range& rhs) const { |
| 113 if (lhs.offset_ != rhs.offset_) { | 116 if (lhs.offset_ != rhs.offset_) { |
| 114 return lhs.offset_ < rhs.offset_; | 117 return lhs.offset_ < rhs.offset_; |
| 115 } | 118 } |
| 116 if (lhs.count_ != rhs.count_) { | 119 if (lhs.count_ != rhs.count_) { |
| 117 return lhs.count_ < rhs.count_; | 120 return lhs.count_ < rhs.count_; |
| 118 } | 121 } |
| 119 return lhs.type_ < rhs.type_; | 122 if (lhs.type_ != rhs.type_) { |
| 123 return lhs.type_ < rhs.type_; | |
| 124 } | |
| 125 return lhs.primitive_restart_enabled_ < rhs.primitive_restart_enabled_; | |
| 120 } | 126 } |
| 121 }; | 127 }; |
| 122 | 128 |
| 123 private: | 129 private: |
| 124 GLuint offset_; | 130 GLuint offset_; |
| 125 GLsizei count_; | 131 GLsizei count_; |
| 126 GLenum type_; | 132 GLenum type_; |
| 133 GLboolean primitive_restart_enabled_; | |
| 127 }; | 134 }; |
| 128 | 135 |
| 129 ~Buffer(); | 136 ~Buffer(); |
| 130 | 137 |
| 131 GLenum initial_target() const { | 138 GLenum initial_target() const { |
| 132 return initial_target_; | 139 return initial_target_; |
| 133 } | 140 } |
| 134 | 141 |
| 135 void set_initial_target(GLenum target) { | 142 void set_initial_target(GLenum target) { |
| 136 DCHECK_EQ(0u, initial_target_); | 143 DCHECK_EQ(0u, initial_target_); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 bool have_context_; | 336 bool have_context_; |
| 330 bool use_client_side_arrays_for_stream_buffers_; | 337 bool use_client_side_arrays_for_stream_buffers_; |
| 331 | 338 |
| 332 DISALLOW_COPY_AND_ASSIGN(BufferManager); | 339 DISALLOW_COPY_AND_ASSIGN(BufferManager); |
| 333 }; | 340 }; |
| 334 | 341 |
| 335 } // namespace gles2 | 342 } // namespace gles2 |
| 336 } // namespace gpu | 343 } // namespace gpu |
| 337 | 344 |
| 338 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 345 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
| OLD | NEW |