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

Unified Diff: content/common/gpu/gpu_memory_management.h

Issue 9289052: Adding GpuMemoryManager to track GpuCommandBufferStub visibility and last_used_time and dictate mem… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor updates, working on tests Created 8 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
Index: content/common/gpu/gpu_memory_management.h
diff --git a/content/common/gpu/gpu_memory_management.h b/content/common/gpu/gpu_memory_management.h
new file mode 100644
index 0000000000000000000000000000000000000000..4039cca1620bc8e24e6c95e40e1d3746f590c70a
--- /dev/null
+++ b/content/common/gpu/gpu_memory_management.h
@@ -0,0 +1,77 @@
+// Copyright (c) 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.
+
+#ifndef CONTENT_COMMON_GPU_GPU_MEMORY_MANAGEMENT_H_
+#define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGEMENT_H_
nduca 2012/01/31 06:53:47 OK , so this file shouldn't exist. These individua
mmocny 2012/01/31 18:54:57 Done.
+#pragma once
+
+#if defined(ENABLE_GPU)
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/time.h"
+
+#include "content/common/gpu/gpu_memory_allocation.h"
+
+////////////////////////////////////////////////////////////////////////////////
+
+struct GpuSurfaceState {
nduca 2012/01/31 06:53:47 This I think should be a public inner struct calle
mmocny 2012/01/31 18:54:57 Done.
+ int32 surface_id;
+ bool visible;
+ base::TimeTicks last_used_time;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+class GpuMemoryManageableCommandBufferStub {
nduca 2012/01/31 06:53:47 This should be a class in GpuCommandBufferStub and
mmocny 2012/01/31 18:54:57 Done.
+public:
+ virtual ~GpuMemoryManageableCommandBufferStub() {}
+
+ virtual const GpuSurfaceState& surface_state() = 0;
+ virtual const std::vector<int32>& affected_surface_ids() = 0;
+ virtual void SendMemoryAllocation(const GpuMemoryAllocation& allocation) = 0;
nduca 2012/01/31 06:53:47 SendMemoryAllocationToProxy?
mmocny 2012/01/31 18:54:57 Done.
+};
+
+class GpuMemoryManagerClient {
nduca 2012/01/31 06:53:47 This class should be defined in gpu_memory_manager
mmocny 2012/01/31 18:54:57 Done.
+public:
+ virtual ~GpuMemoryManagerClient() {}
+
+ virtual void AppendAllCommandBufferStubs(
+ std::vector<GpuMemoryManageableCommandBufferStub*>& stubs_with_surface,
+ std::vector<GpuMemoryManageableCommandBufferStub*>& stubs_without_surface)
+ = 0;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
jonathan.backer 2012/01/31 18:13:58 I have a feeling that these comparators are only u
mmocny 2012/01/31 18:54:57 Also used in tests, but they are moved to GpuMemor
+/*
+ * Returns true if lhs stub is more "important" than rhs stub
+ */
+inline bool IsMoreImportant(GpuMemoryManageableCommandBufferStub* lhs,
nduca 2012/01/31 06:53:47 Why both a comparator and a function? Pick one or
mmocny 2012/01/31 18:54:57 Done.
+ GpuMemoryManageableCommandBufferStub* rhs) {
+ const GpuSurfaceState& lhs_ss = lhs->surface_state();
+ const GpuSurfaceState& rhs_ss = rhs->surface_state();
+
+ if (lhs_ss.visible)
+ return !rhs_ss.visible || (lhs_ss.last_used_time > rhs_ss.last_used_time);
+ else
+ return !rhs_ss.visible && (lhs_ss.last_used_time > rhs_ss.last_used_time);
+}
+
+/*
+ * Comparator used to sort stubs into most-to-least "important" order
+ */
+struct StubComparator {
nduca 2012/01/31 06:53:47 class; struct feels awkward here.
nduca 2012/01/31 06:53:47 I think this should be an inner class in the GpuMe
mmocny 2012/01/31 18:54:57 Done.
mmocny 2012/01/31 18:54:57 Done.
+ bool operator()(GpuMemoryManageableCommandBufferStub* lhs,
+ GpuMemoryManageableCommandBufferStub* rhs) {
+ return IsMoreImportant(lhs, rhs);
+ }
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif
+
+#endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGEMENT_H_

Powered by Google App Engine
This is Rietveld 408576698