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

Unified Diff: include/core/SkTemplates.h

Issue 396143004: Add a working SkFontMgr_fontconfig. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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
Index: include/core/SkTemplates.h
diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h
index 5d3fa2d10cd2371c7dcebf2b45552e8922412884..bfcc785718f3f49b18402449a65017ea42ba8243 100644
--- a/include/core/SkTemplates.h
+++ b/include/core/SkTemplates.h
@@ -77,7 +77,19 @@ template <typename T, void (*P)(T*)> class SkAutoTCallVProc : SkNoncopyable {
public:
SkAutoTCallVProc(T* obj): fObj(obj) {}
~SkAutoTCallVProc() { if (fObj) P(fObj); }
+
+ operator T*() const { return fObj; }
+ T& operator*() const { SkASSERT(fObj); return *fObj; }
+ T* operator->() const { SkASSERT(fObj); return fObj; }
+ T** operator&() { return &fObj; }
+
T* detach() { T* obj = fObj; fObj = NULL; return obj; }
+ void reset(T* obj = NULL) {
+ if (fObj != obj) {
+ if (fObj) { P(fObj); }
+ fObj = obj;
reed1 2014/07/17 20:41:42 nitty nit: lets not keep the "if (fObj) { ... }" o
bungeman-skia 2014/07/17 22:08:27 Done.
+ }
+ }
private:
T* fObj;
};

Powered by Google App Engine
This is Rietveld 408576698