| 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_RENDERBUFFER_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "gpu/command_buffer/service/gl_utils.h" | 13 #include "gpu/command_buffer/service/gl_utils.h" |
| 14 #include "gpu/command_buffer/service/memory_tracking.h" |
| 14 #include "gpu/gpu_export.h" | 15 #include "gpu/gpu_export.h" |
| 15 | 16 |
| 16 namespace gpu { | 17 namespace gpu { |
| 17 namespace gles2 { | 18 namespace gles2 { |
| 18 | 19 |
| 19 class MemoryTracker; | |
| 20 class MemoryTypeTracker; | |
| 21 | |
| 22 // This class keeps track of the renderbuffers and whether or not they have | 20 // This class keeps track of the renderbuffers and whether or not they have |
| 23 // been cleared. | 21 // been cleared. |
| 24 class GPU_EXPORT RenderbufferManager { | 22 class GPU_EXPORT RenderbufferManager { |
| 25 public: | 23 public: |
| 26 // Info about Renderbuffers currently in the system. | 24 // Info about Renderbuffers currently in the system. |
| 27 class GPU_EXPORT RenderbufferInfo | 25 class GPU_EXPORT RenderbufferInfo |
| 28 : public base::RefCounted<RenderbufferInfo> { | 26 : public base::RefCounted<RenderbufferInfo> { |
| 29 public: | 27 public: |
| 30 typedef scoped_refptr<RenderbufferInfo> Ref; | 28 typedef scoped_refptr<RenderbufferInfo> Ref; |
| 31 | 29 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Gets the renderbuffer info for the given renderbuffer. | 160 // Gets the renderbuffer info for the given renderbuffer. |
| 163 RenderbufferInfo* GetRenderbufferInfo(GLuint client_id); | 161 RenderbufferInfo* GetRenderbufferInfo(GLuint client_id); |
| 164 | 162 |
| 165 // Removes a renderbuffer info for the given renderbuffer. | 163 // Removes a renderbuffer info for the given renderbuffer. |
| 166 void RemoveRenderbufferInfo(GLuint client_id); | 164 void RemoveRenderbufferInfo(GLuint client_id); |
| 167 | 165 |
| 168 // Gets a client id for a given service id. | 166 // Gets a client id for a given service id. |
| 169 bool GetClientId(GLuint service_id, GLuint* client_id) const; | 167 bool GetClientId(GLuint service_id, GLuint* client_id) const; |
| 170 | 168 |
| 171 size_t mem_represented() const { | 169 size_t mem_represented() const { |
| 172 return mem_represented_; | 170 return memory_tracker_->GetMemRepresented(); |
| 173 } | 171 } |
| 174 | 172 |
| 175 private: | 173 private: |
| 176 void UpdateMemRepresented(); | |
| 177 | |
| 178 void StartTracking(RenderbufferInfo* renderbuffer); | 174 void StartTracking(RenderbufferInfo* renderbuffer); |
| 179 void StopTracking(RenderbufferInfo* renderbuffer); | 175 void StopTracking(RenderbufferInfo* renderbuffer); |
| 180 | 176 |
| 181 scoped_ptr<MemoryTypeTracker> renderbuffer_memory_tracker_; | 177 scoped_ptr<MemoryTypeTracker> memory_tracker_; |
| 182 | 178 |
| 183 GLint max_renderbuffer_size_; | 179 GLint max_renderbuffer_size_; |
| 184 GLint max_samples_; | 180 GLint max_samples_; |
| 185 | 181 |
| 186 int num_uncleared_renderbuffers_; | 182 int num_uncleared_renderbuffers_; |
| 187 | 183 |
| 188 size_t mem_represented_; | |
| 189 | |
| 190 // Counts the number of RenderbufferInfo allocated with 'this' as its manager. | 184 // Counts the number of RenderbufferInfo allocated with 'this' as its manager. |
| 191 // Allows to check no RenderbufferInfo will outlive this. | 185 // Allows to check no RenderbufferInfo will outlive this. |
| 192 unsigned renderbuffer_info_count_; | 186 unsigned renderbuffer_info_count_; |
| 193 | 187 |
| 194 bool have_context_; | 188 bool have_context_; |
| 195 | 189 |
| 196 // Info for each renderbuffer in the system. | 190 // Info for each renderbuffer in the system. |
| 197 typedef base::hash_map<GLuint, RenderbufferInfo::Ref> RenderbufferInfoMap; | 191 typedef base::hash_map<GLuint, RenderbufferInfo::Ref> RenderbufferInfoMap; |
| 198 RenderbufferInfoMap renderbuffer_infos_; | 192 RenderbufferInfoMap renderbuffer_infos_; |
| 199 | 193 |
| 200 DISALLOW_COPY_AND_ASSIGN(RenderbufferManager); | 194 DISALLOW_COPY_AND_ASSIGN(RenderbufferManager); |
| 201 }; | 195 }; |
| 202 | 196 |
| 203 } // namespace gles2 | 197 } // namespace gles2 |
| 204 } // namespace gpu | 198 } // namespace gpu |
| 205 | 199 |
| 206 #endif // GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_ | 200 #endif // GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_ |
| OLD | NEW |