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_MANAGER_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ |
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ | 6 #define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #if defined(ENABLE_GPU) | 9 #if defined(ENABLE_GPU) |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 virtual ~GpuMemoryManagerClient() {} | 21 virtual ~GpuMemoryManagerClient() {} |
22 | 22 |
23 virtual void AppendAllCommandBufferStubs( | 23 virtual void AppendAllCommandBufferStubs( |
24 std::vector<GpuCommandBufferStubBase*>& stubs) = 0; | 24 std::vector<GpuCommandBufferStubBase*>& stubs) = 0; |
25 }; | 25 }; |
26 | 26 |
27 class CONTENT_EXPORT GpuMemoryManager { | 27 class CONTENT_EXPORT GpuMemoryManager { |
28 public: | 28 public: |
29 enum { kDefaultMaxSurfacesWithFrontbufferSoftLimit = 8 }; | 29 enum { kDefaultMaxSurfacesWithFrontbufferSoftLimit = 8 }; |
30 | 30 |
31 // These are predefined values (in bytes) for | |
32 // GpuMemoryAllocation::gpuResourceSizeInBytes. | |
33 // Maximum Allocation for all tabs is a soft limit that can be exceeded | |
34 // during the time it takes for renderers to respect new allocations, | |
35 // including when switching tabs or opening a new window. | |
36 // To alleviate some pressure, we decrease our desired limit by "one tabs' | |
37 // worth" of memory. | |
38 enum { | |
39 #if defined(OS_ANDROID) | |
40 kMinimumAllocationForTab = 32 * 1024 * 1024, | |
41 kMaximumAllocationForTabs = 64 * 1024 * 1024, | |
42 #else | |
43 kMinimumAllocationForTab = 64 * 1024 * 1024, | |
44 kMaximumAllocationForTabs = 512 * 1024 * 1024 - kMinimumAllocationForTab, | |
45 #endif | |
46 }; | |
47 | |
48 GpuMemoryManager(GpuMemoryManagerClient* client, | 31 GpuMemoryManager(GpuMemoryManagerClient* client, |
49 size_t max_surfaces_with_frontbuffer_soft_limit); | 32 size_t max_surfaces_with_frontbuffer_soft_limit); |
50 ~GpuMemoryManager(); | 33 ~GpuMemoryManager(); |
51 | 34 |
52 void ScheduleManage(); | 35 void ScheduleManage(); |
53 | 36 |
54 private: | 37 private: |
55 friend class GpuMemoryManagerTest; | 38 friend class GpuMemoryManagerTest; |
56 void Manage(); | 39 void Manage(); |
57 | 40 |
58 class CONTENT_EXPORT StubWithSurfaceComparator { | 41 class CONTENT_EXPORT StubWithSurfaceComparator { |
59 public: | 42 public: |
60 bool operator()(GpuCommandBufferStubBase* lhs, | 43 bool operator()(GpuCommandBufferStubBase* lhs, |
61 GpuCommandBufferStubBase* rhs); | 44 GpuCommandBufferStubBase* rhs); |
62 }; | 45 }; |
63 | 46 |
64 GpuMemoryManagerClient* client_; | 47 GpuMemoryManagerClient* client_; |
65 bool manage_scheduled_; | 48 bool manage_scheduled_; |
66 size_t max_surfaces_with_frontbuffer_soft_limit_; | 49 size_t max_surfaces_with_frontbuffer_soft_limit_; |
67 base::WeakPtrFactory<GpuMemoryManager> weak_factory_; | 50 base::WeakPtrFactory<GpuMemoryManager> weak_factory_; |
68 | 51 |
69 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); | 52 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); |
70 }; | 53 }; |
71 | 54 |
72 #endif | 55 #endif |
73 | 56 |
74 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ | 57 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ |
OLD | NEW |