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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/gpu/GrEffect.h » ('j') | include/gpu/GrEffect.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTemplates.h
===================================================================
--- include/core/SkTemplates.h (revision 8808)
+++ include/core/SkTemplates.h (working copy)
@@ -119,6 +119,24 @@
T* fObj;
};
+// Calls ~T() in the destructor.
+template <typename T> class SkAutoTDestroy : SkNoncopyable {
+public:
+ SkAutoTDestroy(T* obj = NULL) : fObj(obj) {}
+ ~SkAutoTDestroy() {
robertphillips 2013/04/22 22:05:13 NULL !=
+ if (fObj) {
+ fObj->~T();
+ }
+ }
+
+ T* get() const { return fObj; }
+ T& operator*() const { SkASSERT(fObj); return *fObj; }
+ T* operator->() const { SkASSERT(fObj); return fObj; }
+
+private:
+ T* fObj;
+};
+
template <typename T> class SkAutoTDeleteArray : SkNoncopyable {
public:
SkAutoTDeleteArray(T array[]) : fArray(array) {}
« 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