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

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

Issue 9309086: Removing more static initializers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set> 9 #include <set>
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "content/common/gpu/gpu_command_buffer_stub.h" 14 #include "content/common/gpu/gpu_command_buffer_stub.h"
15 #include "content/common/gpu/gpu_memory_allocation.h" 15 #include "content/common/gpu/gpu_memory_allocation.h"
16 16
17 namespace { 17 namespace {
18 18
19 // These are predefined values (in bytes) for 19 // These are predefined values (in bytes) for
20 // GpuMemoryAllocation::gpuResourceSizeInBytes. Currently, the value is only 20 // GpuMemoryAllocation::gpuResourceSizeInBytes. Currently, the value is only
21 // used to check if it is 0 or non-0. In the future, these values will not 21 // used to check if it is 0 or non-0. In the future, these values will not
22 // come from constants, but rather will be distributed dynamically. 22 // come from constants, but rather will be distributed dynamically.
23 const uint32 kResourceSizeNonHibernatedTab = 1; 23 enum {
24 const uint32 kResourceSizeHibernatedTab = 0; 24 kResourceSizeNonHibernatedTab = 1,
25 25 kResourceSizeHibernatedTab = 0
26 // Set up three allocation values for the three possible stub states 26 };
27 const GpuMemoryAllocation all_buffers_allocation(
28 kResourceSizeNonHibernatedTab, true, true);
29 const GpuMemoryAllocation front_buffers_allocation(
30 kResourceSizeNonHibernatedTab, true, false);
31 const GpuMemoryAllocation no_buffers_allocation(
32 kResourceSizeHibernatedTab, false, false);
33 27
34 } 28 }
35 29
36 GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client, 30 GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client,
37 size_t max_surfaces_with_frontbuffer_soft_limit) 31 size_t max_surfaces_with_frontbuffer_soft_limit)
38 : client_(client), 32 : client_(client),
39 manage_scheduled_(false), 33 manage_scheduled_(false),
40 max_surfaces_with_frontbuffer_soft_limit_( 34 max_surfaces_with_frontbuffer_soft_limit_(
41 max_surfaces_with_frontbuffer_soft_limit), 35 max_surfaces_with_frontbuffer_soft_limit),
42 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 36 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // * Must have both front and back buffer. 72 // * Must have both front and back buffer.
79 // 73 //
80 // 2. Background: Non visible surfaces, which have not surpassed the 74 // 2. Background: Non visible surfaces, which have not surpassed the
81 // max_surfaces_with_frontbuffer_soft_limit_ limit. 75 // max_surfaces_with_frontbuffer_soft_limit_ limit.
82 // * Will have only a frontbuffer. 76 // * Will have only a frontbuffer.
83 // 77 //
84 // 3. Hibernated: Non visible surfaces, which have surpassed the 78 // 3. Hibernated: Non visible surfaces, which have surpassed the
85 // max_surfaces_with_frontbuffer_soft_limit_ limit. 79 // max_surfaces_with_frontbuffer_soft_limit_ limit.
86 // * Will not have either buffer. 80 // * Will not have either buffer.
87 void GpuMemoryManager::Manage() { 81 void GpuMemoryManager::Manage() {
82 // Set up three allocation values for the three possible stub states
83 const GpuMemoryAllocation all_buffers_allocation(
84 kResourceSizeNonHibernatedTab, true, true);
85 const GpuMemoryAllocation front_buffers_allocation(
86 kResourceSizeNonHibernatedTab, true, false);
87 const GpuMemoryAllocation no_buffers_allocation(
88 kResourceSizeHibernatedTab, false, false);
89
88 manage_scheduled_ = false; 90 manage_scheduled_ = false;
89 91
90 // Create stub lists by separating out the two types received from client 92 // Create stub lists by separating out the two types received from client
91 std::vector<GpuCommandBufferStubBase*> stubs_with_surface; 93 std::vector<GpuCommandBufferStubBase*> stubs_with_surface;
92 { 94 {
93 std::vector<GpuCommandBufferStubBase*> stubs; 95 std::vector<GpuCommandBufferStubBase*> stubs;
94 client_->AppendAllCommandBufferStubs(stubs); 96 client_->AppendAllCommandBufferStubs(stubs);
95 97
96 for (std::vector<GpuCommandBufferStubBase*>::iterator it = stubs.begin(); 98 for (std::vector<GpuCommandBufferStubBase*>::iterator it = stubs.begin();
97 it != stubs.end(); ++it) { 99 it != stubs.end(); ++it) {
(...skipping 21 matching lines...) Expand all
119 front_buffers.insert(stub->surface_state().surface_id); 121 front_buffers.insert(stub->surface_state().surface_id);
120 stub->SendMemoryAllocationToProxy(front_buffers_allocation); 122 stub->SendMemoryAllocationToProxy(front_buffers_allocation);
121 } else { 123 } else {
122 no_buffers.insert(stub->surface_state().surface_id); 124 no_buffers.insert(stub->surface_state().surface_id);
123 stub->SendMemoryAllocationToProxy(no_buffers_allocation); 125 stub->SendMemoryAllocationToProxy(no_buffers_allocation);
124 } 126 }
125 } 127 }
126 } 128 }
127 129
128 #endif 130 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698