1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
// 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_ALLOCATION_H_
#define CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_
#include "base/basictypes.h"
namespace content {
// 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 suggest_have_backbuffer;
GpuMemoryAllocationForRenderer()
: gpu_resource_size_in_bytes(0),
suggest_have_backbuffer(false) {
}
GpuMemoryAllocationForRenderer(size_t gpu_resource_size_in_bytes,
bool suggest_have_backbuffer)
: gpu_resource_size_in_bytes(gpu_resource_size_in_bytes),
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);
}
};
// 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 {
// Bitmap
enum BufferAllocation {
kHasNoBuffers = 0,
kHasFrontbuffer = 1,
kHasBackbuffer = 2
};
GpuMemoryAllocation()
: GpuMemoryAllocationForRenderer(),
GpuMemoryAllocationForBrowser() {
}
GpuMemoryAllocation(size_t gpu_resource_size_in_bytes,
int allocationBitmap)
: GpuMemoryAllocationForRenderer(gpu_resource_size_in_bytes,
(allocationBitmap & kHasBackbuffer) == kHasBackbuffer),
GpuMemoryAllocationForBrowser(
(allocationBitmap & kHasFrontbuffer) == kHasFrontbuffer) {
}
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);
}
};
// Memory Allocation request which is sent by a client, to help GpuMemoryManager
// more ideally split memory allocations across clients.
struct GpuMemoryAllocationRequest {
size_t min_allocation_bytes;
size_t ideal_allocation_bytes;
GpuMemoryAllocationRequest()
: min_allocation_bytes(0),
ideal_allocation_bytes(0) {
}
GpuMemoryAllocationRequest(size_t min_bytes, size_t ideal_bytes)
: min_allocation_bytes(min_bytes),
ideal_allocation_bytes(ideal_bytes) {
}
bool operator==(const GpuMemoryAllocationRequest& other) const {
return min_allocation_bytes == other.min_allocation_bytes &&
ideal_allocation_bytes == other.ideal_allocation_bytes;
}
bool operator!=(const GpuMemoryAllocationRequest& other) const {
return !(*this == other);
}
};
} // namespace content
#endif // CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_
|