aboutsummaryrefslogtreecommitdiffhomepage
path: root/libs/graphics/sgl/SkRefCnt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/graphics/sgl/SkRefCnt.cpp')
-rw-r--r--libs/graphics/sgl/SkRefCnt.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/libs/graphics/sgl/SkRefCnt.cpp b/libs/graphics/sgl/SkRefCnt.cpp
new file mode 100644
index 0000000000..7c3d59c430
--- /dev/null
+++ b/libs/graphics/sgl/SkRefCnt.cpp
@@ -0,0 +1,36 @@
+#include "SkRefCnt.h"
+
+SkAutoUnref::~SkAutoUnref()
+{
+ if (fObj)
+ fObj->unref();
+}
+
+bool SkAutoUnref::ref()
+{
+ if (fObj)
+ {
+ fObj->ref();
+ return true;
+ }
+ return false;
+}
+
+bool SkAutoUnref::unref()
+{
+ if (fObj)
+ {
+ fObj->unref();
+ fObj = nil;
+ return true;
+ }
+ return false;
+}
+
+SkRefCnt* SkAutoUnref::detach()
+{
+ SkRefCnt* obj = fObj;
+
+ fObj = nil;
+ return obj;
+}