| 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 |
| 31 GpuMemoryManager(GpuMemoryManagerClient* client, | 48 GpuMemoryManager(GpuMemoryManagerClient* client, |
| 32 size_t max_surfaces_with_frontbuffer_soft_limit); | 49 size_t max_surfaces_with_frontbuffer_soft_limit); |
| 33 ~GpuMemoryManager(); | 50 ~GpuMemoryManager(); |
| 34 | 51 |
| 35 void ScheduleManage(); | 52 void ScheduleManage(); |
| 36 | 53 |
| 37 private: | 54 private: |
| 38 friend class GpuMemoryManagerTest; | 55 friend class GpuMemoryManagerTest; |
| 39 void Manage(); | 56 void Manage(); |
| 40 | 57 |
| 41 class CONTENT_EXPORT StubWithSurfaceComparator { | 58 class CONTENT_EXPORT StubWithSurfaceComparator { |
| 42 public: | 59 public: |
| 43 bool operator()(GpuCommandBufferStubBase* lhs, | 60 bool operator()(GpuCommandBufferStubBase* lhs, |
| 44 GpuCommandBufferStubBase* rhs); | 61 GpuCommandBufferStubBase* rhs); |
| 45 }; | 62 }; |
| 46 | 63 |
| 47 GpuMemoryManagerClient* client_; | 64 GpuMemoryManagerClient* client_; |
| 48 bool manage_scheduled_; | 65 bool manage_scheduled_; |
| 49 size_t max_surfaces_with_frontbuffer_soft_limit_; | 66 size_t max_surfaces_with_frontbuffer_soft_limit_; |
| 50 base::WeakPtrFactory<GpuMemoryManager> weak_factory_; | 67 base::WeakPtrFactory<GpuMemoryManager> weak_factory_; |
| 51 | 68 |
| 52 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); | 69 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); |
| 53 }; | 70 }; |
| 54 | 71 |
| 55 #endif | 72 #endif |
| 56 | 73 |
| 57 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ | 74 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ |
| OLD | NEW |