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

Side by Side Diff: include/core/SkTDArray.h

Issue 639823005: Use BBH reserve hook to preallocate space for tiles. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: assert -> early check Created 6 years, 2 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 | « no previous file | src/core/SkTileGrid.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 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
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 9
10 #ifndef SkTDArray_DEFINED 10 #ifndef SkTDArray_DEFINED
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 #ifdef SK_DEBUG 341 #ifdef SK_DEBUG
342 void validate() const { 342 void validate() const {
343 SkASSERT((fReserve == 0 && fArray == NULL) || 343 SkASSERT((fReserve == 0 && fArray == NULL) ||
344 (fReserve > 0 && fArray != NULL)); 344 (fReserve > 0 && fArray != NULL));
345 SkASSERT(fCount <= fReserve); 345 SkASSERT(fCount <= fReserve);
346 SkASSERT(fData == (ArrayT*)fArray); 346 SkASSERT(fData == (ArrayT*)fArray);
347 } 347 }
348 #endif 348 #endif
349 349
350 void shrinkToFit() {
351 fReserve = fCount;
352 fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T));
353 }
354
350 private: 355 private:
351 #ifdef SK_DEBUG 356 #ifdef SK_DEBUG
352 enum { 357 enum {
353 kDebugArraySize = 16 358 kDebugArraySize = 16
354 }; 359 };
355 typedef T ArrayT[kDebugArraySize]; 360 typedef T ArrayT[kDebugArraySize];
356 ArrayT* fData; 361 ArrayT* fData;
357 #endif 362 #endif
358 T* fArray; 363 T* fArray;
359 int fReserve; 364 int fReserve;
(...skipping 20 matching lines...) Expand all
380 fReserve = count + 4; 385 fReserve = count + 4;
381 fReserve += fReserve / 4; 386 fReserve += fReserve / 4;
382 fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T)); 387 fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T));
383 #ifdef SK_DEBUG 388 #ifdef SK_DEBUG
384 fData = (ArrayT*)fArray; 389 fData = (ArrayT*)fArray;
385 #endif 390 #endif
386 } 391 }
387 }; 392 };
388 393
389 #endif 394 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkTileGrid.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698