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

Side by Side Diff: skia/config/sk_ref_cnt_ext_debug.h

Issue 40973002: Enable reference adoption checks for Blink+skia in Debug builds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Just the Chromium changes for sanity. Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | skia/config/sk_ref_cnt_ext_release.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef SK_REF_CNT_EXT_DEBUG_H_
6 #define SK_REF_CNT_EXT_DEBUG_H_
7
8 #ifdef SK_REF_CNT_EXT_RELEASE_H_
9 #error Only one SkRefCnt should be used.
10 #endif
11
12 // Alternate implementation of SkRefCnt for Chromium debug builds
13 class SK_API SkRefCnt : public SkRefCntBase {
14 public:
15 SkRefCnt() : flags_(0) {}
16 void ref() const { SkASSERT(flags_ != AdoptionRequired_Flag); SkRefCntBase::re f(); }
17 void adopted() const { flags_ |= Adopted_Flag; }
18 void requireAdoption() const { flags_ |= AdoptionRequired_Flag; }
19 void deref() const { SkRefCntBase::unref(); }
20 private:
21 enum {
22 Adopted_Flag = 0x1,
23 AdoptionRequired_Flag = 0x2,
24 };
25
26 mutable int flags_;
27 };
28
29 // Bootstrap for Blink's WTF::RefPtr
30
31 namespace WTF {
32 inline void adopted(const SkRefCnt* object) {
33 if (!object)
34 return;
35 object->adopted();
36 }
37 inline void requireAdoption(const SkRefCnt* object) {
38 if (!object)
39 return;
40 object->requireAdoption();
41 }
42 };
43
44 using WTF::adopted;
45 using WTF::requireAdoption;
46
47 #endif
48
OLDNEW
« no previous file with comments | « skia/config/SkUserConfig.h ('k') | skia/config/sk_ref_cnt_ext_release.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698