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

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

Issue 14081016: Remove static effects from the effect memory pool. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | include/gpu/GrEffect.h » ('j') | include/gpu/GrEffect.h » ('J')
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 T* detach() { 112 T* detach() {
113 T* obj = fObj; 113 T* obj = fObj;
114 fObj = NULL; 114 fObj = NULL;
115 return obj; 115 return obj;
116 } 116 }
117 117
118 private: 118 private:
119 T* fObj; 119 T* fObj;
120 }; 120 };
121 121
122 // Calls ~T() in the destructor.
123 template <typename T> class SkAutoTDestroy : SkNoncopyable {
124 public:
125 SkAutoTDestroy(T* obj = NULL) : fObj(obj) {}
126 ~SkAutoTDestroy() {
robertphillips 2013/04/22 22:05:13 NULL !=
127 if (fObj) {
128 fObj->~T();
129 }
130 }
131
132 T* get() const { return fObj; }
133 T& operator*() const { SkASSERT(fObj); return *fObj; }
134 T* operator->() const { SkASSERT(fObj); return fObj; }
135
136 private:
137 T* fObj;
138 };
139
122 template <typename T> class SkAutoTDeleteArray : SkNoncopyable { 140 template <typename T> class SkAutoTDeleteArray : SkNoncopyable {
123 public: 141 public:
124 SkAutoTDeleteArray(T array[]) : fArray(array) {} 142 SkAutoTDeleteArray(T array[]) : fArray(array) {}
125 ~SkAutoTDeleteArray() { SkDELETE_ARRAY(fArray); } 143 ~SkAutoTDeleteArray() { SkDELETE_ARRAY(fArray); }
126 144
127 T* get() const { return fArray; } 145 T* get() const { return fArray; }
128 void free() { SkDELETE_ARRAY(fArray); fArray = NULL; } 146 void free() { SkDELETE_ARRAY(fArray); fArray = NULL; }
129 T* detach() { T* array = fArray; fArray = NULL; return array; } 147 T* detach() { T* array = fArray; fArray = NULL; return array; }
130 148
131 private: 149 private:
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 /** 373 /**
356 * Returns void* because this object does not initialize the 374 * Returns void* because this object does not initialize the
357 * memory. Use placement new for types that require a cons. 375 * memory. Use placement new for types that require a cons.
358 */ 376 */
359 void* get() { return fStorage.get(); } 377 void* get() { return fStorage.get(); }
360 private: 378 private:
361 SkAlignedSStorage<sizeof(T)*N> fStorage; 379 SkAlignedSStorage<sizeof(T)*N> fStorage;
362 }; 380 };
363 381
364 #endif 382 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrEffect.h » ('j') | include/gpu/GrEffect.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698