Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4226)

Unified Diff: cc/memory_history.h

Issue 12149004: [cc] Show GPU memory usage and overage below FPS counter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layer_tree_impl.cc ('k') | cc/memory_history.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/memory_history.h
diff --git a/cc/memory_history.h b/cc/memory_history.h
new file mode 100644
index 0000000000000000000000000000000000000000..eca0a79126422e2c6be36f57129f1543ca717de9
--- /dev/null
+++ b/cc/memory_history.h
@@ -0,0 +1,54 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_MEMORY_HISTORY_H_
+#define CC_MEMORY_HISTORY_H_
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time.h"
+#include "cc/ring_buffer.h"
+
+namespace cc {
+
+// Maintains a history of memory for each frame
+class MemoryHistory {
+ public:
+ static scoped_ptr<MemoryHistory> create();
+
+ size_t HistorySize() const { return ring_buffer_.BufferSize(); }
+
+ struct Entry {
+ Entry()
+ : bytes_allocated(0),
+ bytes_over(0) { }
+
+ size_t bytes_allocated;
+ size_t bytes_unreleasable;
+ size_t bytes_over;
+ size_t bytes_total() const {
+ return bytes_allocated +
+ bytes_unreleasable +
+ bytes_over;
+ }
+ };
+
+ // n = 0 returns the oldest and
+ // n = HistorySize() - 1 the most recent paint time.
+ Entry GetEntry(const size_t& n) const;
+
+ void SaveEntry(const Entry& entry);
+ void GetMinAndMax(size_t* min, size_t* max) const;
+
+ private:
+ MemoryHistory();
+
+ RingBuffer<Entry, 80> ring_buffer_;
+
+ DISALLOW_COPY_AND_ASSIGN(MemoryHistory);
+};
+
+} // namespace cc
+
+#endif // CC_MEMORY_HISTORY_H_
« no previous file with comments | « cc/layer_tree_impl.cc ('k') | cc/memory_history.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698