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

Side by Side Diff: include/private/SkTArray.h

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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 | « include/gpu/effects/GrXfermodeFragmentProcessor.h ('k') | src/core/SkBitmapProcShader.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 * 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // Set fCount to 0 before calling checkRealloc so that no elements are m oved. 114 // Set fCount to 0 before calling checkRealloc so that no elements are m oved.
115 fCount = 0; 115 fCount = 0;
116 this->checkRealloc(n); 116 this->checkRealloc(n);
117 fCount = n; 117 fCount = n;
118 for (int i = 0; i < fCount; ++i) { 118 for (int i = 0; i < fCount; ++i) {
119 new (fItemArray + i) T; 119 new (fItemArray + i) T;
120 } 120 }
121 } 121 }
122 122
123 /** 123 /**
124 * Ensures there is enough reserved space for n elements.
125 */
126 void reserve(int n) {
127 if (fCount < n) {
128 this->checkRealloc(n - fCount);
129 }
130 }
131
132 /**
124 * Resets to a copy of a C array. 133 * Resets to a copy of a C array.
125 */ 134 */
126 void reset(const T* array, int count) { 135 void reset(const T* array, int count) {
127 for (int i = 0; i < fCount; ++i) { 136 for (int i = 0; i < fCount; ++i) {
128 fItemArray[i].~T(); 137 fItemArray[i].~T();
129 } 138 }
130 fCount = 0; 139 fCount = 0;
131 this->checkRealloc(count); 140 this->checkRealloc(count);
132 fCount = count; 141 fCount = count;
133 this->copy(array); 142 this->copy(array);
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 SkSTArray& operator= (const INHERITED& array) { 538 SkSTArray& operator= (const INHERITED& array) {
530 INHERITED::operator=(array); 539 INHERITED::operator=(array);
531 return *this; 540 return *this;
532 } 541 }
533 542
534 private: 543 private:
535 SkAlignedSTStorage<N,T> fStorage; 544 SkAlignedSTStorage<N,T> fStorage;
536 }; 545 };
537 546
538 #endif 547 #endif
OLDNEW
« no previous file with comments | « include/gpu/effects/GrXfermodeFragmentProcessor.h ('k') | src/core/SkBitmapProcShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698