Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 #ifdef SK_BUILD_FOR_MAC | 10 #ifdef SK_BUILD_FOR_MAC |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 /** Acts like a CFRef, but calls CFSafeRelease when it goes out of scope. */ | 78 /** Acts like a CFRef, but calls CFSafeRelease when it goes out of scope. */ |
| 79 template<typename CFRef> class AutoCFRelease : private SkNoncopyable { | 79 template<typename CFRef> class AutoCFRelease : private SkNoncopyable { |
| 80 public: | 80 public: |
| 81 explicit AutoCFRelease(CFRef cfRef = NULL) : fCFRef(cfRef) { } | 81 explicit AutoCFRelease(CFRef cfRef = NULL) : fCFRef(cfRef) { } |
| 82 ~AutoCFRelease() { CFSafeRelease(fCFRef); } | 82 ~AutoCFRelease() { CFSafeRelease(fCFRef); } |
| 83 | 83 |
| 84 void reset(CFRef that = NULL) { | 84 void reset(CFRef that = NULL) { |
| 85 CFSafeRetain(that); | 85 if (that != fCFRef) { |
| 86 CFSafeRelease(fCFRef); | 86 CFSafeRelease(fCFRef); |
| 87 fCFRef = that; | 87 fCFRef = that; |
| 88 } | |
| 88 } | 89 } |
| 89 | 90 |
| 90 AutoCFRelease& operator =(CFRef that) { | 91 AutoCFRelease& operator =(CFRef that) { |
|
bungeman-skia
2014/07/14 17:38:30
I think I actually wrote this, but now I hate this
| |
| 91 reset(that); | 92 reset(that); |
| 92 return *this; | 93 return *this; |
| 93 } | 94 } |
| 94 | 95 |
| 95 operator CFRef() const { return fCFRef; } | 96 operator CFRef() const { return fCFRef; } |
| 96 CFRef get() const { return fCFRef; } | 97 CFRef get() const { return fCFRef; } |
| 97 | 98 |
| 98 CFRef* operator&() { SkASSERT(fCFRef == NULL); return &fCFRef; } | 99 CFRef* operator&() { SkASSERT(fCFRef == NULL); return &fCFRef; } |
| 99 private: | 100 private: |
| 100 CFRef fCFRef; | 101 CFRef fCFRef; |
| (...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2308 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); | 2309 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); |
| 2309 } | 2310 } |
| 2310 }; | 2311 }; |
| 2311 | 2312 |
| 2312 /////////////////////////////////////////////////////////////////////////////// | 2313 /////////////////////////////////////////////////////////////////////////////// |
| 2313 | 2314 |
| 2314 SkFontMgr* SkFontMgr::Factory() { | 2315 SkFontMgr* SkFontMgr::Factory() { |
| 2315 return SkNEW(SkFontMgr_Mac); | 2316 return SkNEW(SkFontMgr_Mac); |
| 2316 } | 2317 } |
| 2317 #endif | 2318 #endif |
| OLD | NEW |