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

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: Fix ttc index and descriptor. 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..f3b5f7434cc33b65b1a81b2d6d367a3d584ab2c1 100644
--- a/include/core/SkTemplates.h
+++ b/include/core/SkTemplates.h
@@ -77,7 +77,21 @@ 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; }
mtklein 2014/07/22 15:48:42 Is there any chance, given that we get to start fr
bungeman-skia 2014/07/22 22:09:57 Not sure what you mean here. If you create an SkAu
+ T& operator*() const { SkASSERT(fObj); return *fObj; }
+ T* operator->() const { SkASSERT(fObj); return fObj; }
+ T** operator&() { return &fObj; }
mtklein 2014/07/22 15:48:42 Can we avoid this one? Seems really easy to write
bungeman-skia 2014/07/22 22:09:57 It is, but it makes certain things easier when dea
+
T* detach() { T* obj = fObj; fObj = NULL; return obj; }
+ void reset(T* obj = NULL) {
+ if (fObj != obj) {
+ if (fObj) {
+ P(fObj);
+ }
+ fObj = obj;
+ }
+ }
private:
T* fObj;
};

Powered by Google App Engine
This is Rietveld 408576698