| 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_MEMORY_TRACKING_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MEMORY_TRACKING_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_MEMORY_TRACKING_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_MEMORY_TRACKING_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 | 11 |
| 12 namespace gpu { | 12 namespace gpu { |
| 13 namespace gles2 { | 13 namespace gles2 { |
| 14 | 14 |
| 15 // A MemoryTracker is used to propagate per-ContextGroup memory usage | 15 // A MemoryTracker is used to propagate per-ContextGroup memory usage |
| 16 // statistics to the global GpuMemoryManager. | 16 // statistics to the global GpuMemoryManager. |
| 17 class MemoryTracker : public base::RefCounted<MemoryTracker> { | 17 class MemoryTracker : public base::RefCounted<MemoryTracker> { |
| 18 public: | 18 public: |
| 19 enum Pool { | 19 enum Pool { |
| 20 kUnmanaged, | 20 kUnmanaged, |
| 21 kManaged | 21 kManaged |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 virtual void TrackMemoryAllocatedChange(size_t old_size, | 24 virtual void TrackMemoryAllocatedChange(size_t old_size, |
| 25 size_t new_size, | 25 size_t new_size, |
| 26 Pool pool) = 0; | 26 Pool pool) = 0; |
| 27 | 27 |
| 28 // Ensure a certain amount of GPU memory is free. Returns true on success. |
| 29 virtual bool EnsureGPUMemoryAvailable(size_t size_needed) = 0; |
| 30 |
| 28 protected: | 31 protected: |
| 29 friend class base::RefCounted<MemoryTracker>; | 32 friend class base::RefCounted<MemoryTracker>; |
| 30 MemoryTracker() {} | 33 MemoryTracker() {} |
| 31 virtual ~MemoryTracker() {}; | 34 virtual ~MemoryTracker() {}; |
| 32 | 35 |
| 33 private: | 36 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(MemoryTracker); | 37 DISALLOW_COPY_AND_ASSIGN(MemoryTracker); |
| 35 }; | 38 }; |
| 36 | 39 |
| 37 // A MemoryTypeTracker tracks the use of a particular type of memory (buffer, | 40 // A MemoryTypeTracker tracks the use of a particular type of memory (buffer, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 size_t mem_represented_; | 93 size_t mem_represented_; |
| 91 size_t mem_represented_at_last_update_; | 94 size_t mem_represented_at_last_update_; |
| 92 | 95 |
| 93 DISALLOW_COPY_AND_ASSIGN(MemoryTypeTracker); | 96 DISALLOW_COPY_AND_ASSIGN(MemoryTypeTracker); |
| 94 }; | 97 }; |
| 95 | 98 |
| 96 } // namespace gles2 | 99 } // namespace gles2 |
| 97 } // namespace gpu | 100 } // namespace gpu |
| 98 | 101 |
| 99 #endif // GPU_COMMAND_BUFFER_SERVICE_MEMORY_TRACKING_H_ | 102 #endif // GPU_COMMAND_BUFFER_SERVICE_MEMORY_TRACKING_H_ |
| OLD | NEW |