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

Side by Side Diff: src/gpu/gl/GrGLNameAllocator.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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
« no previous file with comments | « src/gpu/gl/GrGLIndexBuffer.h ('k') | src/gpu/gl/GrGLPath.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrGLNameAllocator.h" 9 #include "GrGLNameAllocator.h"
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 class GrGLNameAllocator::SparseNameTree : public SparseNameRange { 126 class GrGLNameAllocator::SparseNameTree : public SparseNameRange {
127 public: 127 public:
128 SparseNameTree(SparseNameRange* left, SparseNameRange* right) 128 SparseNameTree(SparseNameRange* left, SparseNameRange* right)
129 : fLeft(left), 129 : fLeft(left),
130 fRight(right) { 130 fRight(right) {
131 SkASSERT(fLeft.get()); 131 SkASSERT(fLeft.get());
132 SkASSERT(fRight.get()); 132 SkASSERT(fRight.get());
133 this->updateStats(); 133 this->updateStats();
134 } 134 }
135 135
136 virtual SparseNameRange* SK_WARN_UNUSED_RESULT internalAllocate(GrGLuint* ou tName) SK_OVERRIDE { 136 SparseNameRange* SK_WARN_UNUSED_RESULT internalAllocate(GrGLuint* outName) S K_OVERRIDE {
137 // Try allocating the range inside fLeft's internal gaps. 137 // Try allocating the range inside fLeft's internal gaps.
138 fLeft.reset(fLeft->internalAllocate(outName)); 138 fLeft.reset(fLeft->internalAllocate(outName));
139 if (0 != *outName) { 139 if (0 != *outName) {
140 this->updateStats(); 140 this->updateStats();
141 return this->rebalance(); 141 return this->rebalance();
142 } 142 }
143 143
144 if (fLeft->end() + 1 == fRight->first()) { 144 if (fLeft->end() + 1 == fRight->first()) {
145 // It closed the gap between fLeft and fRight; merge. 145 // It closed the gap between fLeft and fRight; merge.
146 GrGLuint removedCount; 146 GrGLuint removedCount;
147 fRight.reset(fRight->removeLeftmostContiguousRange(&removedCount)); 147 fRight.reset(fRight->removeLeftmostContiguousRange(&removedCount));
148 *outName = fLeft->appendNames(1 + removedCount); 148 *outName = fLeft->appendNames(1 + removedCount);
149 if (NULL == fRight.get()) { 149 if (NULL == fRight.get()) {
150 return fLeft.detach(); 150 return fLeft.detach();
151 } 151 }
152 this->updateStats(); 152 this->updateStats();
153 return this->rebalance(); 153 return this->rebalance();
154 } 154 }
155 155
156 // There is guaranteed to be a gap between fLeft and fRight, and the 156 // There is guaranteed to be a gap between fLeft and fRight, and the
157 // "size 1" case has already been covered. 157 // "size 1" case has already been covered.
158 SkASSERT(fLeft->end() + 1 < fRight->first()); 158 SkASSERT(fLeft->end() + 1 < fRight->first());
159 *outName = fLeft->appendNames(1); 159 *outName = fLeft->appendNames(1);
160 return this->takeRef(); 160 return this->takeRef();
161 } 161 }
162 162
163 virtual SparseNameRange* SK_WARN_UNUSED_RESULT removeLeftmostContiguousRange (GrGLuint* removedCount) SK_OVERRIDE { 163 SparseNameRange* SK_WARN_UNUSED_RESULT removeLeftmostContiguousRange(GrGLuin t* removedCount) SK_OVERRIDE {
164 fLeft.reset(fLeft->removeLeftmostContiguousRange(removedCount)); 164 fLeft.reset(fLeft->removeLeftmostContiguousRange(removedCount));
165 if (NULL == fLeft) { 165 if (NULL == fLeft) {
166 return fRight.detach(); 166 return fRight.detach();
167 } 167 }
168 this->updateStats(); 168 this->updateStats();
169 return this->rebalance(); 169 return this->rebalance();
170 } 170 }
171 171
172 virtual GrGLuint appendNames(GrGLuint count) SK_OVERRIDE { 172 GrGLuint appendNames(GrGLuint count) SK_OVERRIDE {
173 SkASSERT(fEnd + count > fEnd); // Check for integer wrap. 173 SkASSERT(fEnd + count > fEnd); // Check for integer wrap.
174 GrGLuint name = fRight->appendNames(count); 174 GrGLuint name = fRight->appendNames(count);
175 SkASSERT(fRight->end() == fEnd + count); 175 SkASSERT(fRight->end() == fEnd + count);
176 this->updateStats(); 176 this->updateStats();
177 return name; 177 return name;
178 } 178 }
179 179
180 virtual GrGLuint prependNames(GrGLuint count) SK_OVERRIDE { 180 GrGLuint prependNames(GrGLuint count) SK_OVERRIDE {
181 SkASSERT(fFirst > count); // We can't allocate at or below 0. 181 SkASSERT(fFirst > count); // We can't allocate at or below 0.
182 GrGLuint name = fLeft->prependNames(count); 182 GrGLuint name = fLeft->prependNames(count);
183 SkASSERT(fLeft->first() == fFirst - count); 183 SkASSERT(fLeft->first() == fFirst - count);
184 this->updateStats(); 184 this->updateStats();
185 return name; 185 return name;
186 } 186 }
187 187
188 virtual SparseNameRange* SK_WARN_UNUSED_RESULT free(GrGLuint name) SK_OVERRI DE { 188 SparseNameRange* SK_WARN_UNUSED_RESULT free(GrGLuint name) SK_OVERRIDE {
189 if (name < fLeft->end()) { 189 if (name < fLeft->end()) {
190 fLeft.reset(fLeft->free(name)); 190 fLeft.reset(fLeft->free(name));
191 if (NULL == fLeft) { 191 if (NULL == fLeft) {
192 // fLeft became empty after the free. 192 // fLeft became empty after the free.
193 return fRight.detach(); 193 return fRight.detach();
194 } 194 }
195 this->updateStats(); 195 this->updateStats();
196 return this->rebalance(); 196 return this->rebalance();
197 } else { 197 } else {
198 fRight.reset(fRight->free(name)); 198 fRight.reset(fRight->free(name));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 */ 273 */
274 class GrGLNameAllocator::ContiguousNameRange : public SparseNameRange { 274 class GrGLNameAllocator::ContiguousNameRange : public SparseNameRange {
275 public: 275 public:
276 ContiguousNameRange(GrGLuint first, GrGLuint end) { 276 ContiguousNameRange(GrGLuint first, GrGLuint end) {
277 SkASSERT(first < end); 277 SkASSERT(first < end);
278 fFirst = first; 278 fFirst = first;
279 fEnd = end; 279 fEnd = end;
280 fHeight = 0; 280 fHeight = 0;
281 } 281 }
282 282
283 virtual SparseNameRange* SK_WARN_UNUSED_RESULT internalAllocate(GrGLuint* ou tName) SK_OVERRIDE { 283 SparseNameRange* SK_WARN_UNUSED_RESULT internalAllocate(GrGLuint* outName) S K_OVERRIDE {
284 *outName = 0; // No internal gaps, we are contiguous. 284 *outName = 0; // No internal gaps, we are contiguous.
285 return this->takeRef(); 285 return this->takeRef();
286 } 286 }
287 287
288 virtual SparseNameRange* SK_WARN_UNUSED_RESULT removeLeftmostContiguousRange (GrGLuint* removedCount) SK_OVERRIDE { 288 SparseNameRange* SK_WARN_UNUSED_RESULT removeLeftmostContiguousRange(GrGLuin t* removedCount) SK_OVERRIDE {
289 *removedCount = fEnd - fFirst; 289 *removedCount = fEnd - fFirst;
290 return NULL; 290 return NULL;
291 } 291 }
292 292
293 virtual GrGLuint appendNames(GrGLuint count) SK_OVERRIDE { 293 GrGLuint appendNames(GrGLuint count) SK_OVERRIDE {
294 SkASSERT(fEnd + count > fEnd); // Check for integer wrap. 294 SkASSERT(fEnd + count > fEnd); // Check for integer wrap.
295 GrGLuint name = fEnd; 295 GrGLuint name = fEnd;
296 fEnd += count; 296 fEnd += count;
297 return name; 297 return name;
298 } 298 }
299 299
300 virtual GrGLuint prependNames(GrGLuint count) SK_OVERRIDE { 300 GrGLuint prependNames(GrGLuint count) SK_OVERRIDE {
301 SkASSERT(fFirst > count); // We can't allocate at or below 0. 301 SkASSERT(fFirst > count); // We can't allocate at or below 0.
302 fFirst -= count; 302 fFirst -= count;
303 return fFirst; 303 return fFirst;
304 } 304 }
305 305
306 virtual SparseNameRange* SK_WARN_UNUSED_RESULT free(GrGLuint name) SK_OVERRI DE { 306 SparseNameRange* SK_WARN_UNUSED_RESULT free(GrGLuint name) SK_OVERRIDE {
307 if (name < fFirst || name >= fEnd) { 307 if (name < fFirst || name >= fEnd) {
308 // Not-allocated names are silently ignored. 308 // Not-allocated names are silently ignored.
309 return this->takeRef(); 309 return this->takeRef();
310 } 310 }
311 311
312 if (fFirst == name) { 312 if (fFirst == name) {
313 ++fFirst; 313 ++fFirst;
314 return (fEnd == fFirst) ? NULL : this->takeRef(); 314 return (fEnd == fFirst) ? NULL : this->takeRef();
315 } 315 }
316 316
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 361 }
362 362
363 void GrGLNameAllocator::free(GrGLuint name) { 363 void GrGLNameAllocator::free(GrGLuint name) {
364 if (!fAllocatedNames.get()) { 364 if (!fAllocatedNames.get()) {
365 // Not-allocated names are silently ignored. 365 // Not-allocated names are silently ignored.
366 return; 366 return;
367 } 367 }
368 368
369 fAllocatedNames.reset(fAllocatedNames->free(name)); 369 fAllocatedNames.reset(fAllocatedNames->free(name));
370 } 370 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLIndexBuffer.h ('k') | src/gpu/gl/GrGLPath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698