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

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: removing needless includes 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
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..ddd6a566d9f3dd870e9c42087f011f5ad2f01f09 100644
--- a/content/common/gpu/gpu_memory_allocation.h
+++ b/content/common/gpu/gpu_memory_allocation.h
@@ -8,45 +8,100 @@
#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 {
+// 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.
+class GpuMemoryAllocationForRenderer {
piman 2012/03/15 20:14:32 style nit: if it has public fields, and essentiall
mmocny 2012/03/15 20:39:27 Fair, this is meant to act as a struct. On 2012/0
public:
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) {
+ }
+
+ friend inline bool operator==(const GpuMemoryAllocationForRenderer& lhs,
piman 2012/03/15 20:14:32 No need for friend or inline. Also, if it's a non-
mmocny 2012/03/15 20:39:27 Since this is the global non-member version of op=
+ const GpuMemoryAllocationForRenderer& rhs) {
+ return lhs.gpu_resource_size_in_bytes == rhs.gpu_resource_size_in_bytes &&
+ lhs.suggest_have_backbuffer == rhs.suggest_have_backbuffer;
+ }
+
+ friend inline bool operator!=(const GpuMemoryAllocationForRenderer& lhs,
+ const GpuMemoryAllocationForRenderer& rhs) {
+ return !(lhs == rhs);
+ }
+};
+
+// Memory Allocation which will be assigned to the browser.
+class GpuMemoryAllocationForBrowser {
piman 2012/03/15 20:14:32 class->struct.
+ public:
+ bool suggest_have_frontbuffer;
+
+ GpuMemoryAllocationForBrowser()
+ : suggest_have_frontbuffer(false) {
+ }
+
+ GpuMemoryAllocationForBrowser(bool suggest_have_frontbuffer)
+ : suggest_have_frontbuffer(suggest_have_frontbuffer) {
+ }
+
+ friend inline bool operator==(const GpuMemoryAllocationForBrowser& lhs,
+ const GpuMemoryAllocationForBrowser& rhs) {
+ return lhs.suggest_have_frontbuffer == rhs.suggest_have_frontbuffer;
+ }
+
+ friend inline bool operator!=(const GpuMemoryAllocationForBrowser& lhs,
+ const GpuMemoryAllocationForBrowser& rhs) {
+ return !(lhs == rhs);
}
};
-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);
-}
+// Combination of the above two Memory Allocations which will be created by the
+// GpuMemoryManager.
+class GpuMemoryAllocation : public GpuMemoryAllocationForRenderer,
+ public GpuMemoryAllocationForBrowser {
+ public:
+ 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) {
+ }
+
+ friend inline bool operator==(const GpuMemoryAllocation& lhs,
+ const GpuMemoryAllocation& rhs) {
+ return static_cast<const GpuMemoryAllocationForRenderer&>(lhs) ==
+ static_cast<const GpuMemoryAllocationForRenderer&>(rhs) &&
+ static_cast<const GpuMemoryAllocationForBrowser&>(lhs) ==
+ static_cast<const GpuMemoryAllocationForBrowser&>(rhs);
+ }
+
+ friend inline bool operator!=(const GpuMemoryAllocation& lhs,
+ const GpuMemoryAllocation& rhs) {
+ return !(lhs == rhs);
+ }
+};
#endif // CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_

Powered by Google App Engine
This is Rietveld 408576698