Added unit test for DevTools' ephemeral port support.
[chromium-blink-merge.git] / gpu / command_buffer / common / gpu_memory_allocation.h
blob2d23298ffc60311b823efeb3a5762b017471b12d
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_ALLOCATION_H_
6 #define GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_ALLOCATION_H_
8 #include "base/basictypes.h"
10 namespace gpu {
12 // These are per context memory allocation limits set by the GpuMemoryManager
13 // and assigned to the browser and renderer context.
14 // They will change over time, given memory availability, and browser state.
15 struct MemoryAllocation {
16 enum PriorityCutoff {
17 // Allow no allocations.
18 CUTOFF_ALLOW_NOTHING,
19 // Allow only allocations that are strictly required for correct rendering.
20 // For compositors, this is what is visible.
21 CUTOFF_ALLOW_REQUIRED_ONLY,
22 // Allow allocations that are not strictly needed for correct rendering, but
23 // are nice to have for performance. For compositors, this includes textures
24 // that are a few screens away from being visible.
25 CUTOFF_ALLOW_NICE_TO_HAVE,
26 // Allow all allocations.
27 CUTOFF_ALLOW_EVERYTHING,
28 CUTOFF_LAST = CUTOFF_ALLOW_EVERYTHING
31 // Limits when this renderer is visible.
32 uint64 bytes_limit_when_visible;
33 PriorityCutoff priority_cutoff_when_visible;
35 MemoryAllocation()
36 : bytes_limit_when_visible(0),
37 priority_cutoff_when_visible(CUTOFF_ALLOW_NOTHING) {
40 MemoryAllocation(uint64 bytes_limit_when_visible)
41 : bytes_limit_when_visible(bytes_limit_when_visible),
42 priority_cutoff_when_visible(CUTOFF_ALLOW_EVERYTHING) {
45 bool Equals(const MemoryAllocation& other) const {
46 return bytes_limit_when_visible ==
47 other.bytes_limit_when_visible &&
48 priority_cutoff_when_visible == other.priority_cutoff_when_visible;
52 // Memory Allocation request which is sent by a client, to help GpuMemoryManager
53 // more ideally split memory allocations across clients.
54 struct ManagedMemoryStats {
55 // Bytes required for correct rendering.
56 uint64 bytes_required;
58 // Bytes that are not strictly required for correctness, but, if allocated,
59 // will provide good performance.
60 uint64 bytes_nice_to_have;
62 // The number of bytes currently allocated.
63 uint64 bytes_allocated;
65 // Whether or not a backbuffer is currently requested (the memory usage
66 // of the buffer is known by the GPU process).
67 bool backbuffer_requested;
69 ManagedMemoryStats()
70 : bytes_required(0),
71 bytes_nice_to_have(0),
72 bytes_allocated(0),
73 backbuffer_requested(false) {
76 ManagedMemoryStats(uint64 bytes_required,
77 uint64 bytes_nice_to_have,
78 uint64 bytes_allocated,
79 bool backbuffer_requested)
80 : bytes_required(bytes_required),
81 bytes_nice_to_have(bytes_nice_to_have),
82 bytes_allocated(bytes_allocated),
83 backbuffer_requested(backbuffer_requested) {
86 bool Equals(const ManagedMemoryStats& other) const {
87 return bytes_required == other.bytes_required &&
88 bytes_nice_to_have == other.bytes_nice_to_have &&
89 bytes_allocated == other.bytes_allocated &&
90 backbuffer_requested == other.backbuffer_requested;
94 } // namespace content
96 #endif // GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_ALLOCATION_H_