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

Unified Diff: cc/memory_history.cc

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/memory_history.h ('k') | cc/ring_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/memory_history.cc
diff --git a/cc/memory_history.cc b/cc/memory_history.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6934f7f086d75c514db8f612a1cbc9573d7ffcea
--- /dev/null
+++ b/cc/memory_history.cc
@@ -0,0 +1,50 @@
+// Copyright 2012 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.
+
+#include "cc/memory_history.h"
+
+namespace cc {
+
+// static
+scoped_ptr<MemoryHistory> MemoryHistory::create() {
+ return make_scoped_ptr(new MemoryHistory());
+}
+
+MemoryHistory::MemoryHistory() {
+}
+
+MemoryHistory::Entry MemoryHistory::GetEntry(const size_t& n) const {
+ DCHECK(n < ring_buffer_.BufferSize());
+
+ if (ring_buffer_.IsFilledIndex(n))
+ return ring_buffer_.ReadBuffer(n);
+
+ return MemoryHistory::Entry();
+}
+
+void MemoryHistory::SaveEntry(const MemoryHistory::Entry& entry) {
+ ring_buffer_.SaveToBuffer(entry);
+}
+
+void MemoryHistory::GetMinAndMax(size_t* min, size_t* max) const {
+ *min = std::numeric_limits<size_t>::max();
+ *max = 0;
+
+ for (size_t i = 0; i < ring_buffer_.BufferSize(); i++) {
+ if (!ring_buffer_.IsFilledIndex(i))
+ continue;
+ const Entry entry = ring_buffer_.ReadBuffer(i);
+ size_t bytes_total = entry.bytes_total();
+
+ if (bytes_total < *min)
+ *min = bytes_total;
+ if (bytes_total > *max)
+ *max = bytes_total;
+ }
+
+ if (*min > *max)
+ *min = *max;
+}
+
+} // namespace cc
« no previous file with comments | « cc/memory_history.h ('k') | cc/ring_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698