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

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

Issue 1691073002: Add plumbing in blink to allow overriding the skia font manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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
« no previous file with comments | « content/child/font_warmup_win.cc ('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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SK_REF_CNT_EXT_DEBUG_H_ 5 #ifndef SK_REF_CNT_EXT_DEBUG_H_
6 #define SK_REF_CNT_EXT_DEBUG_H_ 6 #define SK_REF_CNT_EXT_DEBUG_H_
7 7
8 #ifdef SK_REF_CNT_EXT_RELEASE_H_ 8 #ifdef SK_REF_CNT_EXT_RELEASE_H_
9 #error Only one SkRefCnt should be used. 9 #error Only one SkRefCnt should be used.
10 #endif 10 #endif
11 11
12 #include <atomic> 12 #include <atomic>
13 13
14 class SkRefCnt;
15
16 namespace WTF {
17 void adopted(const SkRefCnt*);
18 void requireAdoption(const SkRefCnt*);
19 }
20
14 // Alternate implementation of SkRefCnt for Chromium debug builds 21 // Alternate implementation of SkRefCnt for Chromium debug builds
15 class SK_API SkRefCnt : public SkRefCntBase { 22 class SK_API SkRefCnt : public SkRefCntBase {
16 public: 23 public:
17 SkRefCnt(); 24 SkRefCnt();
18 ~SkRefCnt() override; 25 ~SkRefCnt() override;
19 void ref() const { SkASSERT(flags_.load() != AdoptionRequired_Flag); SkRefCntB ase::ref(); } 26 void ref() const { SkASSERT(flags_.load() != AdoptionRequired_Flag); SkRefCntB ase::ref(); }
27 void deref() const { SkRefCntBase::unref(); }
28 private:
Ilya Kulshin 2016/02/11 20:40:18 Note: the actual change here is moving adopted() a
20 void adopted() const { flags_ |= Adopted_Flag; } 29 void adopted() const { flags_ |= Adopted_Flag; }
21 void requireAdoption() const { flags_ |= AdoptionRequired_Flag; } 30 void requireAdoption() const { flags_ |= AdoptionRequired_Flag; }
22 void deref() const { SkRefCntBase::unref(); }
23 private:
24 31
25 enum { 32 enum {
26 Adopted_Flag = 0x1, 33 Adopted_Flag = 0x1,
27 AdoptionRequired_Flag = 0x2, 34 AdoptionRequired_Flag = 0x2,
28 }; 35 };
29 36
30 mutable std::atomic<int> flags_; 37 mutable std::atomic<int> flags_;
38
39 friend void WTF::adopted(const SkRefCnt*);
40 friend void WTF::requireAdoption(const SkRefCnt*);
31 }; 41 };
32 42
33 inline SkRefCnt::SkRefCnt() : flags_(0) { } 43 inline SkRefCnt::SkRefCnt() : flags_(0) { }
34 44
35 inline SkRefCnt::~SkRefCnt() { } 45 inline SkRefCnt::~SkRefCnt() { }
36 46
37 // Bootstrap for Blink's WTF::RefPtr 47 // Bootstrap for Blink's WTF::RefPtr
38 48
39 namespace WTF { 49 namespace WTF {
40 inline void adopted(const SkRefCnt* object) { 50 inline void adopted(const SkRefCnt* object) {
41 if (!object) 51 if (!object)
42 return; 52 return;
43 object->adopted(); 53 object->adopted();
44 } 54 }
45 inline void requireAdoption(const SkRefCnt* object) { 55 inline void requireAdoption(const SkRefCnt* object) {
46 if (!object) 56 if (!object)
47 return; 57 return;
48 object->requireAdoption(); 58 object->requireAdoption();
49 } 59 }
50 }; 60 };
51 61
52 using WTF::adopted;
53 using WTF::requireAdoption;
54
55 #endif 62 #endif
56 63
OLDNEW
« no previous file with comments | « content/child/font_warmup_win.cc ('k') | skia/config/sk_ref_cnt_ext_release.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698