1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SK_REF_CNT_EXT_DEBUG_H_
6 #define SK_REF_CNT_EXT_DEBUG_H_
8 #ifdef SK_REF_CNT_EXT_RELEASE_H_
9 #error Only one SkRefCnt should be used.
12 // Alternate implementation of SkRefCnt for Chromium debug builds
13 class SK_API SkRefCnt
: public SkRefCntBase
{
15 SkRefCnt() : flags_(0) {}
16 void ref() const { SkASSERT(flags_
!= AdoptionRequired_Flag
); SkRefCntBase::ref(); }
17 void adopted() const { flags_
|= Adopted_Flag
; }
18 void requireAdoption() const { flags_
|= AdoptionRequired_Flag
; }
19 void deref() const { SkRefCntBase::unref(); }
23 AdoptionRequired_Flag
= 0x2,
29 // Bootstrap for Blink's WTF::RefPtr
32 inline void adopted(const SkRefCnt
* object
) {
37 inline void requireAdoption(const SkRefCnt
* object
) {
40 object
->requireAdoption();
45 using WTF::requireAdoption
;