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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
mmocny 2012/03/15 19:11:43 I've separated out the two different "Allocations"
5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_ 5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_ 6 #define CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "ui/gfx/gl/gl_surface.h"
mmocny 2012/03/15 19:11:43 I dont need this, will remove..
10 11
11 // These are memory allocation limits assigned to a context. 12 // These are per context memory allocation limits set by the GpuMemoryManager
12 // They will change over time, given memory availability, and browser state 13 // and assigned to the browser and renderer context.
13 // Exceeding these limits for an unreasonable amount of time will cause context 14 // They will change over time, given memory availability, and browser state.
14 // to be lost. 15
15 class GpuMemoryAllocation { 16
17 // Memory Allocation which will be assigned to the renderer context.
18 class GpuMemoryAllocationForRenderer {
mmocny 2012/03/15 19:11:43 This name will need to change to something more ge
16 public: 19 public:
17 enum { 20 enum {
18 INVALID_RESOURCE_SIZE = -1 21 INVALID_RESOURCE_SIZE = -1
19 }; 22 };
20 23
24 // Exceeding this limit for an unreasonable amount of time may cause context
25 // to be lost.
21 size_t gpu_resource_size_in_bytes; 26 size_t gpu_resource_size_in_bytes;
22 bool has_frontbuffer; 27 bool suggest_have_backbuffer;
23 bool has_backbuffer;
24 28
29 GpuMemoryAllocationForRenderer()
30 : gpu_resource_size_in_bytes(0),
31 suggest_have_backbuffer(false) {
32 }
33
34 GpuMemoryAllocationForRenderer(size_t gpu_resource_size_in_bytes,
35 bool suggest_have_backbuffer)
36 : gpu_resource_size_in_bytes(gpu_resource_size_in_bytes),
37 suggest_have_backbuffer(suggest_have_backbuffer) {
38 }
39
40 friend inline bool operator==(const GpuMemoryAllocationForRenderer& lhs,
41 const GpuMemoryAllocationForRenderer& rhs) {
42 return lhs.gpu_resource_size_in_bytes == rhs.gpu_resource_size_in_bytes &&
43 lhs.suggest_have_backbuffer == rhs.suggest_have_backbuffer;
44 }
45
46 friend inline bool operator!=(const GpuMemoryAllocationForRenderer& lhs,
47 const GpuMemoryAllocationForRenderer& rhs) {
48 return !(lhs == rhs);
49 }
50 };
51
52 // Memory Allocation which will be assigned to the browser.
53 class GpuMemoryAllocationForBrowser {
mmocny 2012/03/15 19:11:43 ditto on naming here.
54 public:
55 bool suggest_have_frontbuffer;
56
57 GpuMemoryAllocationForBrowser()
58 : suggest_have_frontbuffer(false) {
59 }
60
61 GpuMemoryAllocationForBrowser(bool suggest_have_frontbuffer)
62 : suggest_have_frontbuffer(suggest_have_frontbuffer) {
63 }
64
65 friend inline bool operator==(const GpuMemoryAllocationForBrowser& lhs,
66 const GpuMemoryAllocationForBrowser& rhs) {
67 return lhs.suggest_have_frontbuffer == rhs.suggest_have_frontbuffer;
68 }
69
70 friend inline bool operator!=(const GpuMemoryAllocationForBrowser& lhs,
71 const GpuMemoryAllocationForBrowser& rhs) {
72 return !(lhs == rhs);
73 }
74 };
75
76 // Combination of the above two Memory Allocations which will be created by the
77 // GpuMemoryManager.
78 class GpuMemoryAllocation : public GpuMemoryAllocationForRenderer,
mmocny 2012/03/15 19:11:43 This could have been std::pair<..ForRenderer, ..Fo
79 public GpuMemoryAllocationForBrowser {
80 public:
25 GpuMemoryAllocation() 81 GpuMemoryAllocation()
26 : gpu_resource_size_in_bytes(0), 82 : GpuMemoryAllocationForRenderer(),
27 has_frontbuffer(false), 83 GpuMemoryAllocationForBrowser() {
28 has_backbuffer(false) {
29 } 84 }
30 85
31 GpuMemoryAllocation(size_t gpu_resource_size_in_bytes, 86 GpuMemoryAllocation(size_t gpu_resource_size_in_bytes,
32 bool has_frontbuffer, 87 bool suggest_have_backbuffer,
33 bool has_backbuffer) 88 bool suggest_have_frontbuffer)
34 : gpu_resource_size_in_bytes(gpu_resource_size_in_bytes), 89 : GpuMemoryAllocationForRenderer(gpu_resource_size_in_bytes,
35 has_frontbuffer(has_frontbuffer), 90 suggest_have_backbuffer),
36 has_backbuffer(has_backbuffer) { 91 GpuMemoryAllocationForBrowser(suggest_have_frontbuffer) {
92 }
93
94 friend inline bool operator==(const GpuMemoryAllocation& lhs,
95 const GpuMemoryAllocation& rhs) {
96 return static_cast<const GpuMemoryAllocationForRenderer&>(lhs) ==
97 static_cast<const GpuMemoryAllocationForRenderer&>(rhs) &&
98 static_cast<const GpuMemoryAllocationForBrowser&>(lhs) ==
99 static_cast<const GpuMemoryAllocationForBrowser&>(rhs);
100 }
101
102 friend inline bool operator!=(const GpuMemoryAllocation& lhs,
103 const GpuMemoryAllocation& rhs) {
104 return !(lhs == rhs);
37 } 105 }
38 }; 106 };
39 107
40 inline bool operator==(const GpuMemoryAllocation& lhs,
41 const GpuMemoryAllocation& rhs) {
42 return lhs.gpu_resource_size_in_bytes == rhs.gpu_resource_size_in_bytes &&
43 lhs.has_frontbuffer == rhs.has_frontbuffer &&
44 lhs.has_backbuffer == rhs.has_backbuffer;
45 }
46
47 inline bool operator!=(const GpuMemoryAllocation& lhs,
48 const GpuMemoryAllocation& rhs) {
49 return !(lhs == rhs);
50 }
51
52 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_ 108 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698