Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkFontConfigInterface_DEFINED | 8 #ifndef SkFontConfigInterface_DEFINED |
| 9 #define SkFontConfigInterface_DEFINED | 9 #define SkFontConfigInterface_DEFINED |
| 10 | 10 |
| 11 #include "SkDataTable.h" | 11 #include "SkDataTable.h" |
| 12 #include "SkFontStyle.h" | 12 #include "SkFontStyle.h" |
| 13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 #include "SkTypeface.h" | 14 #include "SkTypeface.h" |
| 15 | 15 |
| 16 class SkFontMgr; | 16 class SkFontMgr; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * \class SkFontConfigInterface | 19 * \class SkFontConfigInterface |
| 20 * | 20 * |
| 21 * A simple interface for remotable font management. | 21 * A simple interface for remotable font management. |
| 22 * The global instance can be found with RefGlobal(). | 22 * The global instance can be found with RefGlobal(). |
| 23 */ | 23 */ |
| 24 class SK_API SkFontConfigInterface : public SkRefCnt { | 24 class SK_API SkFontConfigInterface : public SkRefCnt { |
| 25 public: | 25 public: |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Returns the global SkFontConfigInterface instance, and if it is not | 28 * Returns the global SkFontConfigInterface instance. If it is not |
| 29 * NULL, calls ref() on it. The caller must balance this with a call to | 29 * nullptr, calls ref() on it. The caller must balance this with a call to |
| 30 * unref(). | 30 * unref(). The default SkFontConfigInterface is the result of calling |
| 31 * GetSingletonDirectInterface. | |
| 31 */ | 32 */ |
| 32 static SkFontConfigInterface* RefGlobal(); | 33 static SkFontConfigInterface* RefGlobal(); |
|
reed1
2016/09/19 19:10:08
sk_sp<...> ?
bungeman-skia
2016/09/19 19:11:27
Yeah, that needs to be done too.
| |
| 33 | 34 |
| 34 /** | 35 /** |
| 35 * Replace the current global instance with the specified one, safely | 36 * Replace the current global instance with the specified one, safely |
| 36 * ref'ing the new instance, and unref'ing the previous. Returns its | 37 * ref'ing the new instance, and unref'ing the previous. Returns its |
| 37 * parameter (the new global instance). | 38 * parameter (the new global instance). |
| 38 */ | 39 */ |
| 39 static SkFontConfigInterface* SetGlobal(SkFontConfigInterface*); | 40 static SkFontConfigInterface* SetGlobal(SkFontConfigInterface*); |
| 40 | 41 |
| 41 /** | 42 /** |
| 42 * This should be treated as private to the impl of SkFontConfigInterface. | 43 * This should be treated as private to the impl of SkFontConfigInterface. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 * The default implementation simply returns a new typeface built using dat a obtained from | 99 * The default implementation simply returns a new typeface built using dat a obtained from |
| 99 * openStream(), but derived classes may implement more complex caching sch emes. | 100 * openStream(), but derived classes may implement more complex caching sch emes. |
| 100 */ | 101 */ |
| 101 virtual sk_sp<SkTypeface> makeTypeface(const FontIdentity& identity) { | 102 virtual sk_sp<SkTypeface> makeTypeface(const FontIdentity& identity) { |
| 102 return SkTypeface::MakeFromStream(this->openStream(identity), identity.f TTCIndex); | 103 return SkTypeface::MakeFromStream(this->openStream(identity), identity.f TTCIndex); |
| 103 } | 104 } |
| 104 | 105 |
| 105 /** | 106 /** |
| 106 * Return a singleton instance of a direct subclass that calls into | 107 * Return a singleton instance of a direct subclass that calls into |
| 107 * libfontconfig. This does not affect the refcnt of the returned instance. | 108 * libfontconfig. This does not affect the refcnt of the returned instance. |
| 108 * The mutex may be used to guarantee the singleton is only constructed onc e. | |
| 109 */ | 109 */ |
| 110 static SkFontConfigInterface* GetSingletonDirectInterface(); | 110 static SkFontConfigInterface* GetSingletonDirectInterface(); |
| 111 | 111 |
| 112 // New APIS, which have default impls for now (which do nothing) | 112 // New APIS, which have default impls for now (which do nothing) |
| 113 | 113 |
| 114 virtual sk_sp<SkDataTable> getFamilyNames() { return SkDataTable::MakeEmpty( ); } | 114 virtual sk_sp<SkDataTable> getFamilyNames() { return SkDataTable::MakeEmpty( ); } |
| 115 typedef SkRefCnt INHERITED; | 115 typedef SkRefCnt INHERITED; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 /** Creates a SkFontMgr which wraps a SkFontConfigInterface. */ | |
| 119 SK_API SkFontMgr* SkFontMgr_New_FCI(SkFontConfigInterface* fci); | |
| 120 | |
| 121 #endif | 118 #endif |
| OLD | NEW |