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

Side by Side Diff: gpu/command_buffer/common/id_allocator.cc

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This file contains the implementation of IdAllocator. 5 // This file contains the implementation of IdAllocator.
6 6
7 #include "gpu/command_buffer/common/id_allocator.h" 7 #include "gpu/command_buffer/common/id_allocator.h"
8 8
9 #include <stdint.h>
10
9 #include <limits> 11 #include <limits>
10 #include "base/logging.h" 12 #include "base/logging.h"
11 13
12 namespace gpu { 14 namespace gpu {
13 15
14 IdAllocator::IdAllocator() { 16 IdAllocator::IdAllocator() {
15 static_assert(kInvalidResource == 0u, "kInvalidResource must be 0"); 17 static_assert(kInvalidResource == 0u, "kInvalidResource must be 0");
16 // Simplify the code by making sure that lower_bound(id) never 18 // Simplify the code by making sure that lower_bound(id) never
17 // returns the beginning of the map, if id is valid (eg != 19 // returns the beginning of the map, if id is valid (eg !=
18 // kInvalidResource). 20 // kInvalidResource).
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 137 }
136 138
137 used_ids_.insert(std::make_pair(id, id)); 139 used_ids_.insert(std::make_pair(id, id));
138 return true; 140 return true;
139 } 141 }
140 142
141 void IdAllocator::FreeID(ResourceId id) { 143 void IdAllocator::FreeID(ResourceId id) {
142 FreeIDRange(id, 1u); 144 FreeIDRange(id, 1u);
143 } 145 }
144 146
145 void IdAllocator::FreeIDRange(ResourceId first_id, uint32 range) { 147 void IdAllocator::FreeIDRange(ResourceId first_id, uint32_t range) {
146 static_assert(kInvalidResource == 0u, "kInvalidResource must be 0"); 148 static_assert(kInvalidResource == 0u, "kInvalidResource must be 0");
147 149
148 if (range == 0u || (first_id == 0u && range == 1u)) { 150 if (range == 0u || (first_id == 0u && range == 1u)) {
149 return; 151 return;
150 } 152 }
151 153
152 if (first_id == 0u) { 154 if (first_id == 0u) {
153 first_id++; 155 first_id++;
154 range--; 156 range--;
155 } 157 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (current->first == id) { 198 if (current->first == id) {
197 return true; 199 return true;
198 } 200 }
199 } 201 }
200 202
201 --current; 203 --current;
202 return current->second >= id; 204 return current->second >= id;
203 } 205 }
204 206
205 } // namespace gpu 207 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gpu_memory_allocation.h ('k') | gpu/command_buffer/common/id_allocator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698