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

Side by Side Diff: include/ports/SkFontConfigInterface.h

Issue 1933393002: Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Restore deleted Android code. Created 4 years, 7 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 | « include/core/SkTypeface.h ('k') | public.bzl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 * if the FontRef's data is not available. The caller is responsible for 90 * if the FontRef's data is not available. The caller is responsible for
91 * deleting the stream when it is done accessing the data. 91 * deleting the stream when it is done accessing the data.
92 */ 92 */
93 virtual SkStreamAsset* openStream(const FontIdentity&) = 0; 93 virtual SkStreamAsset* openStream(const FontIdentity&) = 0;
94 94
95 /** 95 /**
96 * Return an SkTypeface for the given FontIdentity. 96 * Return an SkTypeface for the given FontIdentity.
97 * 97 *
98 * The default implementation simply returns a new typeface built using dat a obtained from 98 * 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. 99 * openStream(), but derived classes may implement more complex caching sch emes.
100 *
101 * Callers are responsible for unref-ing the result.
102 */ 100 */
101 virtual sk_sp<SkTypeface> makeTypeface(const FontIdentity& identity) {
102 return SkTypeface::MakeFromStream(this->openStream(identity), identity.f TTCIndex);
103 }
104 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
103 virtual SkTypeface* createTypeface(const FontIdentity& identity) { 105 virtual SkTypeface* createTypeface(const FontIdentity& identity) {
104 return SkTypeface::CreateFromStream(this->openStream(identity), identity .fTTCIndex); 106 return this->makeTypeface(identity).release();
105 } 107 }
108 #endif
106 109
107 /** 110 /**
108 * Return a singleton instance of a direct subclass that calls into 111 * Return a singleton instance of a direct subclass that calls into
109 * libfontconfig. This does not affect the refcnt of the returned instance. 112 * libfontconfig. This does not affect the refcnt of the returned instance.
110 * The mutex may be used to guarantee the singleton is only constructed onc e. 113 * The mutex may be used to guarantee the singleton is only constructed onc e.
111 */ 114 */
112 static SkFontConfigInterface* GetSingletonDirectInterface(); 115 static SkFontConfigInterface* GetSingletonDirectInterface();
113 116
114 // New APIS, which have default impls for now (which do nothing) 117 // New APIS, which have default impls for now (which do nothing)
115 118
116 virtual SkDataTable* getFamilyNames() { return SkDataTable::NewEmpty(); } 119 virtual SkDataTable* getFamilyNames() { return SkDataTable::NewEmpty(); }
117 typedef SkRefCnt INHERITED; 120 typedef SkRefCnt INHERITED;
118 }; 121 };
119 122
120 /** Creates a SkFontMgr which wraps a SkFontConfigInterface. */ 123 /** Creates a SkFontMgr which wraps a SkFontConfigInterface. */
121 SK_API SkFontMgr* SkFontMgr_New_FCI(SkFontConfigInterface* fci); 124 SK_API SkFontMgr* SkFontMgr_New_FCI(SkFontConfigInterface* fci);
122 125
123 #endif 126 #endif
OLDNEW
« no previous file with comments | « include/core/SkTypeface.h ('k') | public.bzl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698