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

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

Issue 9702081: Splitting GpuMemoryAllocation into two parts: for renderer and browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding unittests for GpuMemoryAllocation comparison functions since they have become not as trivial. Created 8 years, 9 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 | « content/common/gpu/gpu_command_buffer_stub.cc ('k') | content/common/gpu/gpu_memory_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/gpu_memory_allocation.h
diff --git a/content/common/gpu/gpu_memory_allocation.h b/content/common/gpu/gpu_memory_allocation.h
index a5acb1d86226e64d0bd72c6029440b3c9cd12ae7..b38fe8320403a9bd8327dc659963479e7914867a 100644
--- a/content/common/gpu/gpu_memory_allocation.h
+++ b/content/common/gpu/gpu_memory_allocation.h
@@ -8,45 +8,88 @@
#include "base/basictypes.h"
-// These are memory allocation limits assigned to a context.
-// They will change over time, given memory availability, and browser state
-// Exceeding these limits for an unreasonable amount of time will cause context
-// to be lost.
-class GpuMemoryAllocation {
- public:
+// These are per context memory allocation limits set by the GpuMemoryManager
+// and assigned to the browser and renderer context.
+// They will change over time, given memory availability, and browser state.
+
+
+// Memory Allocation which will be assigned to the renderer context.
+struct GpuMemoryAllocationForRenderer {
enum {
INVALID_RESOURCE_SIZE = -1
};
+ // Exceeding this limit for an unreasonable amount of time may cause context
+ // to be lost.
size_t gpu_resource_size_in_bytes;
- bool has_frontbuffer;
- bool has_backbuffer;
+ bool suggest_have_backbuffer;
- GpuMemoryAllocation()
+ GpuMemoryAllocationForRenderer()
: gpu_resource_size_in_bytes(0),
- has_frontbuffer(false),
- has_backbuffer(false) {
+ suggest_have_backbuffer(false) {
}
- GpuMemoryAllocation(size_t gpu_resource_size_in_bytes,
- bool has_frontbuffer,
- bool has_backbuffer)
+ GpuMemoryAllocationForRenderer(size_t gpu_resource_size_in_bytes,
+ bool suggest_have_backbuffer)
: gpu_resource_size_in_bytes(gpu_resource_size_in_bytes),
- has_frontbuffer(has_frontbuffer),
- has_backbuffer(has_backbuffer) {
+ suggest_have_backbuffer(suggest_have_backbuffer) {
+ }
+
+ bool operator==(const GpuMemoryAllocationForRenderer& other) const {
+ return gpu_resource_size_in_bytes == other.gpu_resource_size_in_bytes &&
+ suggest_have_backbuffer == other.suggest_have_backbuffer;
+ }
+ bool operator!=(const GpuMemoryAllocationForRenderer& other) const {
+ return !(*this == other);
}
};
-inline bool operator==(const GpuMemoryAllocation& lhs,
- const GpuMemoryAllocation& rhs) {
- return lhs.gpu_resource_size_in_bytes == rhs.gpu_resource_size_in_bytes &&
- lhs.has_frontbuffer == rhs.has_frontbuffer &&
- lhs.has_backbuffer == rhs.has_backbuffer;
-}
-
-inline bool operator!=(const GpuMemoryAllocation& lhs,
- const GpuMemoryAllocation& rhs) {
- return !(lhs == rhs);
-}
+// Memory Allocation which will be assigned to the browser.
+struct GpuMemoryAllocationForBrowser {
+ bool suggest_have_frontbuffer;
+
+ GpuMemoryAllocationForBrowser()
+ : suggest_have_frontbuffer(false) {
+ }
+
+ GpuMemoryAllocationForBrowser(bool suggest_have_frontbuffer)
+ : suggest_have_frontbuffer(suggest_have_frontbuffer) {
+ }
+
+ bool operator==(const GpuMemoryAllocationForBrowser& other) const {
+ return suggest_have_frontbuffer == other.suggest_have_frontbuffer;
+ }
+ bool operator!=(const GpuMemoryAllocationForBrowser& other) const {
+ return !(*this == other);
+ }
+};
+
+// Combination of the above two Memory Allocations which will be created by the
+// GpuMemoryManager.
+struct GpuMemoryAllocation : public GpuMemoryAllocationForRenderer,
+ public GpuMemoryAllocationForBrowser {
+ GpuMemoryAllocation()
+ : GpuMemoryAllocationForRenderer(),
+ GpuMemoryAllocationForBrowser() {
+ }
+
+ GpuMemoryAllocation(size_t gpu_resource_size_in_bytes,
+ bool suggest_have_backbuffer,
+ bool suggest_have_frontbuffer)
+ : GpuMemoryAllocationForRenderer(gpu_resource_size_in_bytes,
+ suggest_have_backbuffer),
+ GpuMemoryAllocationForBrowser(suggest_have_frontbuffer) {
+ }
+
+ bool operator==(const GpuMemoryAllocation& other) const {
+ return static_cast<const GpuMemoryAllocationForRenderer&>(*this) ==
+ static_cast<const GpuMemoryAllocationForRenderer&>(other) &&
+ static_cast<const GpuMemoryAllocationForBrowser&>(*this) ==
+ static_cast<const GpuMemoryAllocationForBrowser&>(other);
+ }
+ bool operator!=(const GpuMemoryAllocation& other) const {
+ return !(*this == other);
+ }
+};
#endif // CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.cc ('k') | content/common/gpu/gpu_memory_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698