Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: content/common/gpu/gpu_memory_manager.cc

Issue 10801014: Add GetStubStats and related functions in GpuMemoryManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding comments, renaming some functions. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "content/common/gpu/gpu_memory_manager.h" 5 #include "content/common/gpu/gpu_memory_manager.h"
6 6
7 #if defined(ENABLE_GPU) 7 #if defined(ENABLE_GPU)
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 } 57 }
58 58
59 } 59 }
60 60
61 GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client, 61 GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client,
62 size_t max_surfaces_with_frontbuffer_soft_limit) 62 size_t max_surfaces_with_frontbuffer_soft_limit)
63 : client_(client), 63 : client_(client),
64 manage_immediate_scheduled_(false), 64 manage_immediate_scheduled_(false),
65 max_surfaces_with_frontbuffer_soft_limit_( 65 max_surfaces_with_frontbuffer_soft_limit_(
66 max_surfaces_with_frontbuffer_soft_limit) { 66 max_surfaces_with_frontbuffer_soft_limit),
67 peak_assigned_allocation_sum_(0) {
67 } 68 }
68 69
69 GpuMemoryManager::~GpuMemoryManager() { 70 GpuMemoryManager::~GpuMemoryManager() {
70 } 71 }
71 72
72 bool GpuMemoryManager::StubWithSurfaceComparator::operator()( 73 bool GpuMemoryManager::StubWithSurfaceComparator::operator()(
73 GpuCommandBufferStubBase* lhs, 74 GpuCommandBufferStubBase* lhs,
74 GpuCommandBufferStubBase* rhs) { 75 GpuCommandBufferStubBase* rhs) {
75 DCHECK(lhs->has_surface_state() && rhs->has_surface_state()); 76 DCHECK(lhs->has_surface_state() && rhs->has_surface_state());
76 const GpuCommandBufferStubBase::SurfaceState& lhs_ss = lhs->surface_state(); 77 const GpuCommandBufferStubBase::SurfaceState& lhs_ss = lhs->surface_state();
(...skipping 19 matching lines...) Expand all
96 return; 97 return;
97 delayed_manage_callback_.Reset(base::Bind(&GpuMemoryManager::Manage, 98 delayed_manage_callback_.Reset(base::Bind(&GpuMemoryManager::Manage,
98 AsWeakPtr())); 99 AsWeakPtr()));
99 MessageLoop::current()->PostDelayedTask( 100 MessageLoop::current()->PostDelayedTask(
100 FROM_HERE, 101 FROM_HERE,
101 delayed_manage_callback_.callback(), 102 delayed_manage_callback_.callback(),
102 base::TimeDelta::FromMilliseconds(kDelayedScheduleManageTimeoutMs)); 103 base::TimeDelta::FromMilliseconds(kDelayedScheduleManageTimeoutMs));
103 } 104 }
104 } 105 }
105 106
107 size_t GpuMemoryManager::GetAvailableGpuMemory() const {
108 // TODO(mmocny): Implement this with real system figures.
109 return kMaximumAllocationForTabs;
110 }
111
106 // The current Manage algorithm simply classifies contexts (stubs) into 112 // The current Manage algorithm simply classifies contexts (stubs) into
107 // "foreground", "background", or "hibernated" categories. 113 // "foreground", "background", or "hibernated" categories.
108 // For each of these three categories, there are predefined memory allocation 114 // For each of these three categories, there are predefined memory allocation
109 // limits and front/backbuffer states. 115 // limits and front/backbuffer states.
110 // 116 //
111 // Stubs may or may not have a surfaces, and the rules are different for each. 117 // Stubs may or may not have a surfaces, and the rules are different for each.
112 // 118 //
113 // The rules for categorizing contexts with a surface are: 119 // The rules for categorizing contexts with a surface are:
114 // 1. Foreground: All visible surfaces. 120 // 1. Foreground: All visible surfaces.
115 // * Must have both front and back buffer. 121 // * Must have both front and back buffer.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 240
235 AssignMemoryAllocations(stubs_without_surface_background, 241 AssignMemoryAllocations(stubs_without_surface_background,
236 GpuMemoryAllocation(kMinimumAllocationForTab, 242 GpuMemoryAllocation(kMinimumAllocationForTab,
237 GpuMemoryAllocation::kHasNoBuffers)); 243 GpuMemoryAllocation::kHasNoBuffers));
238 244
239 AssignMemoryAllocations(stubs_without_surface_hibernated, 245 AssignMemoryAllocations(stubs_without_surface_hibernated,
240 GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers)); 246 GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers));
241 } 247 }
242 248
243 #endif 249 #endif
OLDNEW
« content/common/gpu/gpu_memory_allocation.h ('K') | « content/common/gpu/gpu_memory_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698