| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <map> | 8 #include <map> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "gpu/command_buffer/service/gl_utils.h" | 13 #include "gpu/command_buffer/service/gl_utils.h" |
| 14 | 14 |
| 15 namespace gpu { | 15 namespace gpu { |
| 16 namespace gles2 { | 16 namespace gles2 { |
| 17 | 17 |
| 18 // This class keeps track of the buffers and their sizes so we can do | 18 // This class keeps track of the buffers and their sizes so we can do |
| 19 // bounds checking. | 19 // bounds checking. |
| 20 // | 20 // |
| 21 // NOTE: To support shared resources an instance of this class will need to be | 21 // NOTE: To support shared resources an instance of this class will need to be |
| 22 // shared by multiple GLES2Decoders. | 22 // shared by multiple GLES2Decoders. |
| 23 class BufferManager { | 23 class BufferManager { |
| 24 public: | 24 public: |
| 25 // Info about Buffers currently in the system. | 25 // Info about Buffers currently in the system. |
| 26 class BufferInfo : public base::RefCounted<BufferInfo> { | 26 class BufferInfo : public base::RefCounted<BufferInfo> { |
| 27 public: | 27 public: |
| 28 typedef scoped_refptr<BufferInfo> Ref; | 28 typedef scoped_refptr<BufferInfo> Ref; |
| 29 | 29 |
| 30 explicit BufferInfo(GLuint service_id) | 30 explicit BufferInfo(GLuint service_id); |
| 31 : service_id_(service_id), | |
| 32 target_(0), | |
| 33 size_(0), | |
| 34 shadowed_(false) { | |
| 35 } | |
| 36 | 31 |
| 37 GLuint service_id() const { | 32 GLuint service_id() const { |
| 38 return service_id_; | 33 return service_id_; |
| 39 } | 34 } |
| 40 | 35 |
| 41 GLsizeiptr size() const { | 36 GLsizeiptr size() const { |
| 42 return size_; | 37 return size_; |
| 43 } | 38 } |
| 44 | 39 |
| 45 // Sets a range of data for this buffer. Returns false if the offset or size | 40 // Sets a range of data for this buffer. Returns false if the offset or size |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return lhs.type_ < rhs.type_; | 79 return lhs.type_ < rhs.type_; |
| 85 } | 80 } |
| 86 }; | 81 }; |
| 87 | 82 |
| 88 private: | 83 private: |
| 89 GLuint offset_; | 84 GLuint offset_; |
| 90 GLsizei count_; | 85 GLsizei count_; |
| 91 GLenum type_; | 86 GLenum type_; |
| 92 }; | 87 }; |
| 93 | 88 |
| 94 ~BufferInfo() { } | 89 ~BufferInfo(); |
| 95 | 90 |
| 96 GLenum target() const { | 91 GLenum target() const { |
| 97 return target_; | 92 return target_; |
| 98 } | 93 } |
| 99 | 94 |
| 100 void set_target(GLenum target) { | 95 void set_target(GLenum target) { |
| 101 DCHECK_EQ(target_, 0u); // you can only set this once. | 96 DCHECK_EQ(target_, 0u); // you can only set this once. |
| 102 target_ = target; | 97 target_ = target; |
| 103 } | 98 } |
| 104 | 99 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 133 | 128 |
| 134 // A copy of the data in the buffer. This data is only kept if the target | 129 // A copy of the data in the buffer. This data is only kept if the target |
| 135 // is backed_ = true. | 130 // is backed_ = true. |
| 136 scoped_array<int8> shadow_; | 131 scoped_array<int8> shadow_; |
| 137 | 132 |
| 138 // A map of ranges to the highest value in that range of a certain type. | 133 // A map of ranges to the highest value in that range of a certain type. |
| 139 typedef std::map<Range, GLuint, Range::Less> RangeToMaxValueMap; | 134 typedef std::map<Range, GLuint, Range::Less> RangeToMaxValueMap; |
| 140 RangeToMaxValueMap range_set_; | 135 RangeToMaxValueMap range_set_; |
| 141 }; | 136 }; |
| 142 | 137 |
| 143 BufferManager() | 138 BufferManager(); |
| 144 : allow_buffers_on_multiple_targets_(false) { | |
| 145 } | |
| 146 ~BufferManager(); | 139 ~BufferManager(); |
| 147 | 140 |
| 148 // Must call before destruction. | 141 // Must call before destruction. |
| 149 void Destroy(bool have_context); | 142 void Destroy(bool have_context); |
| 150 | 143 |
| 151 // Creates a BufferInfo for the given buffer. | 144 // Creates a BufferInfo for the given buffer. |
| 152 void CreateBufferInfo(GLuint client_id, GLuint service_id); | 145 void CreateBufferInfo(GLuint client_id, GLuint service_id); |
| 153 | 146 |
| 154 // Gets the buffer info for the given buffer. | 147 // Gets the buffer info for the given buffer. |
| 155 BufferInfo* GetBufferInfo(GLuint client_id); | 148 BufferInfo* GetBufferInfo(GLuint client_id); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 181 | 174 |
| 182 DISALLOW_COPY_AND_ASSIGN(BufferManager); | 175 DISALLOW_COPY_AND_ASSIGN(BufferManager); |
| 183 }; | 176 }; |
| 184 | 177 |
| 185 } // namespace gles2 | 178 } // namespace gles2 |
| 186 } // namespace gpu | 179 } // namespace gpu |
| 187 | 180 |
| 188 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 181 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
| 189 | 182 |
| 190 | 183 |
| OLD | NEW |