blob: 4919b975e855cde11860034d2c849c63e3bdeb19 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
2 Copyright 2010 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#ifndef GrRefCnt_DEFINED
19#define GrRefCnt_DEFINED
20
21#include "GrTypes.h"
reed@google.com970cb552011-07-15 15:52:28 +000022#include "SkRefCnt.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000023
reed@google.com970cb552011-07-15 15:52:28 +000024typedef SkRefCnt GrRefCnt;
25typedef SkAutoRef GrAutoRef;
26typedef SkAutoUnref GrAutoUnref;
reed@google.comac10a2d2010-12-22 21:39:39 +000027
reed@google.com970cb552011-07-15 15:52:28 +000028static void GrSafeRef(const SkRefCnt* obj) { SkSafeRef(obj); }
29static void GrSafeUnref(const SkRefCnt* obj) { SkSafeUnref(obj); }
30#define GrSafeAssign(a, b) SkRefCnt_SafeAssign(a, b)
reed@google.comac10a2d2010-12-22 21:39:39 +000031
bsalomon@google.com8fe72472011-03-30 21:26:44 +000032template<typename T>
33static inline void GrSafeSetNull(T*& obj) {
34 if (NULL != obj) {
35 obj->unref();
36 obj = NULL;
37 }
38}
39
reed@google.comac10a2d2010-12-22 21:39:39 +000040#endif
41