| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkTArray_DEFINED | 8 #ifndef SkTArray_DEFINED |
| 9 #define SkTArray_DEFINED | 9 #define SkTArray_DEFINED |
| 10 | 10 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 int fAllocCount; | 457 int fAllocCount; |
| 458 void* fPreAllocMemArray; | 458 void* fPreAllocMemArray; |
| 459 union { | 459 union { |
| 460 T* fItemArray; | 460 T* fItemArray; |
| 461 void* fMemArray; | 461 void* fMemArray; |
| 462 }; | 462 }; |
| 463 }; | 463 }; |
| 464 | 464 |
| 465 // Use the below macro (SkNEW_APPEND_TO_TARRAY) rather than calling this directl
y | 465 // Use the below macro (SkNEW_APPEND_TO_TARRAY) rather than calling this directl
y |
| 466 template <typename T, bool MEM_COPY> | 466 template <typename T, bool MEM_COPY> |
| 467 void* operator new(size_t, SkTArray<T, MEM_COPY>* array, int atIndex) { | 467 void* operator new(size_t, SkTArray<T, MEM_COPY>* array, int SkDEBUGCODE(atIndex
)) { |
| 468 // Currently, we only support adding to the end of the array. When the array
class itself | 468 // Currently, we only support adding to the end of the array. When the array
class itself |
| 469 // supports random insertion then this should be updated. | 469 // supports random insertion then this should be updated. |
| 470 // SkASSERT(atIndex >= 0 && atIndex <= array->count()); | 470 // SkASSERT(atIndex >= 0 && atIndex <= array->count()); |
| 471 SkASSERT(atIndex == array->count()); | 471 SkASSERT(atIndex == array->count()); |
| 472 return array->push_back_raw(1); | 472 return array->push_back_raw(1); |
| 473 } | 473 } |
| 474 | 474 |
| 475 // Skia doesn't use C++ exceptions but it may be compiled with them enabled. Hav
ing an op delete | 475 // Skia doesn't use C++ exceptions but it may be compiled with them enabled. Hav
ing an op delete |
| 476 // to match the op new silences warnings about missing op delete when a construc
tor throws an | 476 // to match the op new silences warnings about missing op delete when a construc
tor throws an |
| 477 // exception. | 477 // exception. |
| 478 template <typename T, bool MEM_COPY> | 478 template <typename T, bool MEM_COPY> |
| 479 void operator delete(void*, SkTArray<T, MEM_COPY>* array, int atIndex) { | 479 void operator delete(void*, SkTArray<T, MEM_COPY>* /*array*/, int /*atIndex*/) { |
| 480 SK_CRASH(); | 480 SK_CRASH(); |
| 481 } | 481 } |
| 482 | 482 |
| 483 // Constructs a new object as the last element of an SkTArray. | 483 // Constructs a new object as the last element of an SkTArray. |
| 484 #define SkNEW_APPEND_TO_TARRAY(array_ptr, type_name, args) \ | 484 #define SkNEW_APPEND_TO_TARRAY(array_ptr, type_name, args) \ |
| 485 (new ((array_ptr), (array_ptr)->count()) type_name args) | 485 (new ((array_ptr), (array_ptr)->count()) type_name args) |
| 486 | 486 |
| 487 | 487 |
| 488 /** | 488 /** |
| 489 * Subclass of SkTArray that contains a preallocated memory block for the array. | 489 * Subclass of SkTArray that contains a preallocated memory block for the array. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 520 SkSTArray& operator= (const INHERITED& array) { | 520 SkSTArray& operator= (const INHERITED& array) { |
| 521 INHERITED::operator=(array); | 521 INHERITED::operator=(array); |
| 522 return *this; | 522 return *this; |
| 523 } | 523 } |
| 524 | 524 |
| 525 private: | 525 private: |
| 526 SkAlignedSTStorage<N,T> fStorage; | 526 SkAlignedSTStorage<N,T> fStorage; |
| 527 }; | 527 }; |
| 528 | 528 |
| 529 #endif | 529 #endif |
| OLD | NEW |