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. 4 5 #ifndef GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_ALLOCATION_H_ 6 #define GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_ALLOCATION_H_ 7 8 #include "base/basictypes.h" 9 10 namespace gpu { 11 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 29 }; 30 31 // Limits when this renderer is visible. 32 uint64 bytes_limit_when_visible; 33 PriorityCutoff priority_cutoff_when_visible; 34 35 MemoryAllocation() 36 : bytes_limit_when_visible(0), 37 priority_cutoff_when_visible(CUTOFF_ALLOW_NOTHING) { 38 } 39 40 MemoryAllocation(uint64 bytes_limit_when_visible) 41 : bytes_limit_when_visible(bytes_limit_when_visible), 42 priority_cutoff_when_visible(CUTOFF_ALLOW_EVERYTHING) { 43 } 44 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; 49 } 50 }; 51 52 } // namespace content 53 54 #endif // GPU_COMMAND_BUFFER_COMMON_GPU_MEMORY_ALLOCATION_H_ 55