OLD | NEW |
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 |
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 | 10 |
11 // These are per context memory allocation limits set by the GpuMemoryManager | 11 // These are per context memory allocation limits set by the GpuMemoryManager |
12 // and assigned to the browser and renderer context. | 12 // and assigned to the browser and renderer context. |
13 // They will change over time, given memory availability, and browser state. | 13 // They will change over time, given memory availability, and browser state. |
14 | 14 |
15 | |
16 // Memory Allocation which will be assigned to the renderer context. | 15 // Memory Allocation which will be assigned to the renderer context. |
17 struct GpuMemoryAllocationForRenderer { | 16 struct GpuMemoryAllocationForRenderer { |
18 enum { | 17 enum { |
19 INVALID_RESOURCE_SIZE = -1 | 18 INVALID_RESOURCE_SIZE = -1 |
20 }; | 19 }; |
21 | 20 |
22 // Exceeding this limit for an unreasonable amount of time may cause context | 21 // Exceeding this limit for an unreasonable amount of time may cause context |
23 // to be lost. | 22 // to be lost. |
24 size_t gpu_resource_size_in_bytes; | 23 size_t gpu_resource_size_in_bytes; |
25 bool suggest_have_backbuffer; | 24 bool suggest_have_backbuffer; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 60 } |
62 bool operator!=(const GpuMemoryAllocationForBrowser& other) const { | 61 bool operator!=(const GpuMemoryAllocationForBrowser& other) const { |
63 return !(*this == other); | 62 return !(*this == other); |
64 } | 63 } |
65 }; | 64 }; |
66 | 65 |
67 // Combination of the above two Memory Allocations which will be created by the | 66 // Combination of the above two Memory Allocations which will be created by the |
68 // GpuMemoryManager. | 67 // GpuMemoryManager. |
69 struct GpuMemoryAllocation : public GpuMemoryAllocationForRenderer, | 68 struct GpuMemoryAllocation : public GpuMemoryAllocationForRenderer, |
70 public GpuMemoryAllocationForBrowser { | 69 public GpuMemoryAllocationForBrowser { |
| 70 // Bitmap |
| 71 enum BufferAllocation { |
| 72 kHasNoBuffers = 0, |
| 73 kHasFrontbuffer = 1, |
| 74 kHasBackbuffer = 2 |
| 75 }; |
| 76 |
71 GpuMemoryAllocation() | 77 GpuMemoryAllocation() |
72 : GpuMemoryAllocationForRenderer(), | 78 : GpuMemoryAllocationForRenderer(), |
73 GpuMemoryAllocationForBrowser() { | 79 GpuMemoryAllocationForBrowser() { |
74 } | 80 } |
75 | 81 |
76 GpuMemoryAllocation(size_t gpu_resource_size_in_bytes, | 82 GpuMemoryAllocation(size_t gpu_resource_size_in_bytes, |
77 bool suggest_have_backbuffer, | 83 int allocationBitmap) |
78 bool suggest_have_frontbuffer) | |
79 : GpuMemoryAllocationForRenderer(gpu_resource_size_in_bytes, | 84 : GpuMemoryAllocationForRenderer(gpu_resource_size_in_bytes, |
80 suggest_have_backbuffer), | 85 (allocationBitmap & kHasBackbuffer) == kHasBackbuffer), |
81 GpuMemoryAllocationForBrowser(suggest_have_frontbuffer) { | 86 GpuMemoryAllocationForBrowser( |
| 87 (allocationBitmap & kHasFrontbuffer) == kHasFrontbuffer) { |
82 } | 88 } |
83 | 89 |
84 bool operator==(const GpuMemoryAllocation& other) const { | 90 bool operator==(const GpuMemoryAllocation& other) const { |
85 return static_cast<const GpuMemoryAllocationForRenderer&>(*this) == | 91 return static_cast<const GpuMemoryAllocationForRenderer&>(*this) == |
86 static_cast<const GpuMemoryAllocationForRenderer&>(other) && | 92 static_cast<const GpuMemoryAllocationForRenderer&>(other) && |
87 static_cast<const GpuMemoryAllocationForBrowser&>(*this) == | 93 static_cast<const GpuMemoryAllocationForBrowser&>(*this) == |
88 static_cast<const GpuMemoryAllocationForBrowser&>(other); | 94 static_cast<const GpuMemoryAllocationForBrowser&>(other); |
89 } | 95 } |
90 bool operator!=(const GpuMemoryAllocation& other) const { | 96 bool operator!=(const GpuMemoryAllocation& other) const { |
91 return !(*this == other); | 97 return !(*this == other); |
92 } | 98 } |
93 }; | 99 }; |
94 | 100 |
95 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_ | 101 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_ |
OLD | NEW |