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

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

Issue 148593003: fix auto-delete bug that crept in with new fast blur path; is causing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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/effects/SkBlurMaskFilter.cpp » ('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 SkTemplates_DEFINED 10 #ifndef SkTemplates_DEFINED
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 template <typename T> class SkAutoTDeleteArray : SkNoncopyable { 172 template <typename T> class SkAutoTDeleteArray : SkNoncopyable {
173 public: 173 public:
174 SkAutoTDeleteArray(T array[]) : fArray(array) {} 174 SkAutoTDeleteArray(T array[]) : fArray(array) {}
175 ~SkAutoTDeleteArray() { SkDELETE_ARRAY(fArray); } 175 ~SkAutoTDeleteArray() { SkDELETE_ARRAY(fArray); }
176 176
177 T* get() const { return fArray; } 177 T* get() const { return fArray; }
178 void free() { SkDELETE_ARRAY(fArray); fArray = NULL; } 178 void free() { SkDELETE_ARRAY(fArray); fArray = NULL; }
179 T* detach() { T* array = fArray; fArray = NULL; return array; } 179 T* detach() { T* array = fArray; fArray = NULL; return array; }
180 180
181 void reset(T array[]) {
182 if (fArray != array) {
183 SkDELETE_ARRAY(fArray);
robertphillips 2014/01/31 00:23:13 Move the assignment outside of the if block?
184 fArray = array;
185 }
186 }
187
181 private: 188 private:
182 T* fArray; 189 T* fArray;
183 }; 190 };
184 191
185 /** Allocate an array of T elements, and free the array in the destructor 192 /** Allocate an array of T elements, and free the array in the destructor
186 */ 193 */
187 template <typename T> class SkAutoTArray : SkNoncopyable { 194 template <typename T> class SkAutoTArray : SkNoncopyable {
188 public: 195 public:
189 SkAutoTArray() { 196 SkAutoTArray() {
190 fArray = NULL; 197 fArray = NULL;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 /** 469 /**
463 * Returns void* because this object does not initialize the 470 * Returns void* because this object does not initialize the
464 * memory. Use placement new for types that require a cons. 471 * memory. Use placement new for types that require a cons.
465 */ 472 */
466 void* get() { return fStorage.get(); } 473 void* get() { return fStorage.get(); }
467 private: 474 private:
468 SkAlignedSStorage<sizeof(T)*N> fStorage; 475 SkAlignedSStorage<sizeof(T)*N> fStorage;
469 }; 476 };
470 477
471 #endif 478 #endif
OLDNEW
« no previous file with comments | « no previous file | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698