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; |
}; |