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

Side by Side Diff: trunk/include/core/SkFontHost.h

Issue 12739006: move most of SkFontHost to private (preceeding making it all private) (Closed) Base URL: http://skia.googlecode.com/svn/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | trunk/include/core/SkTypeface.h » ('j') | trunk/tests/FontHostStreamTest.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9
10 #ifndef SkFontHost_DEFINED 10 #ifndef SkFontHost_DEFINED
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 2) Given the data for a font (either in a stream or a file name), return 42 2) Given the data for a font (either in a stream or a file name), return
43 a typeface that allows access to that data. 43 a typeface that allows access to that data.
44 3) Each typeface instance carries a 32bit ID for its corresponding font. 44 3) Each typeface instance carries a 32bit ID for its corresponding font.
45 SkFontHost turns that ID into a stream to access the font's data. 45 SkFontHost turns that ID into a stream to access the font's data.
46 4) Given a font ID, return a subclass of SkScalerContext, which connects a 46 4) Given a font ID, return a subclass of SkScalerContext, which connects a
47 font scaler (e.g. freetype or other) to the font's data. 47 font scaler (e.g. freetype or other) to the font's data.
48 5) Utilites to manage the font cache (budgeting) and gamma correction 48 5) Utilites to manage the font cache (budgeting) and gamma correction
49 */ 49 */
50 class SK_API SkFontHost { 50 class SK_API SkFontHost {
51 public: 51 public:
52 /** LCDs either have their color elements arranged horizontally or
53 vertically. When rendering subpixel glyphs we need to know which way
54 round they are.
55
56 Note, if you change this after startup, you'll need to flush the glyph
57 cache because it'll have the wrong type of masks cached.
58
59 @deprecated use SkPixelGeometry instead.
60 */
61 enum LCDOrientation {
62 kHorizontal_LCDOrientation = 0, //!< this is the default
63 kVertical_LCDOrientation = 1
64 };
65
66 /** @deprecated set on Device creation. */
67 static void SetSubpixelOrientation(LCDOrientation orientation);
68 /** @deprecated get from Device. */
69 static LCDOrientation GetSubpixelOrientation();
70
71 /** LCD color elements can vary in order. For subpixel text we need to know
72 the order which the LCDs uses so that the color fringes are in the
73 correct place.
74
75 Note, if you change this after startup, you'll need to flush the glyph
76 cache because it'll have the wrong type of masks cached.
77
78 kNONE_LCDOrder means that the subpixel elements are not spatially
79 separated in any usable fashion.
80
81 @deprecated use SkPixelGeometry instead.
82 */
83 enum LCDOrder {
84 kRGB_LCDOrder = 0, //!< this is the default
85 kBGR_LCDOrder = 1,
86 kNONE_LCDOrder = 2
87 };
88
89 /** @deprecated set on Device creation. */
90 static void SetSubpixelOrder(LCDOrder order);
91 /** @deprecated get from Device. */
92 static LCDOrder GetSubpixelOrder();
93
94 #ifdef SK_BUILD_FOR_ANDROID
95 /**
96 * Return the number of font units per em.
97 *
98 * @param fontID the font to query.
99 * @return the number of font units per em or 0 on error.
100 */
101 static uint32_t GetUnitsPerEm(SkFontID fontID);
102 #endif
103
104 /** If Skia is running in a constrained environment and the typeface
105 implementation is handle based, the typeface data may become
106 unavailable asynchronously. If a font host or scaler context method is
107 unable to access font data, it may call this function as a request to
108 make the handle contained in the typeface useable.
109 */
110 static void EnsureTypefaceAccessible(const SkTypeface& typeface);
111
112 /**
113 * Return a subclass of SkScalarContext
114 * DEPRECATED -- will be moved to SkTypeface
115 */
116 static SkScalerContext* CreateScalerContext(const SkDescriptor* desc);
117
118 /**
119 * DEPRECATED -- will be DESTROYED
120 *
121 * Given a "current" fontID, return the next logical fontID to use
122 * when searching fonts for a given unicode value. Typically the caller
123 * will query a given font, and if a unicode value is not supported, they
124 * will call this, and if 0 is not returned, will search that font, and so
125 * on. This process must be finite, and when the fonthost sees a
126 * font with no logical successor, it must return 0.
127 *
128 * The original fontID is also provided. This is the initial font that was
129 * stored in the typeface of the caller. It is provided as an aid to choose
130 * the best next logical font. e.g. If the original font was bold or serif,
131 * but the 2nd in the logical chain was plain, then a subsequent call to
132 * get the 3rd can still inspect the original, and try to match its
133 * stylistic attributes.
134 */
135 static SkFontID NextLogicalFont(SkFontID currFontID, SkFontID origFontID);
136
137 private:
52 /** Return a new, closest matching typeface given either an existing family 138 /** Return a new, closest matching typeface given either an existing family
53 (specified by a typeface in that family) or by a familyName and a 139 (specified by a typeface in that family) or by a familyName and a
54 requested style. 140 requested style.
55 1) If familyFace is null, use familyName. 141 1) If familyFace is null, use familyName.
56 2) If familyName is null, use data (UTF-16 to cover). 142 2) If familyName is null, use data (UTF-16 to cover).
57 3) If all are null, return the default font that best matches style 143 3) If all are null, return the default font that best matches style
58 */ 144 */
59 static SkTypeface* CreateTypeface(const SkTypeface* familyFace, 145 static SkTypeface* CreateTypeface(const SkTypeface* familyFace,
60 const char familyName[], 146 const char familyName[],
61 SkTypeface::Style style); 147 SkTypeface::Style style);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 214
129 /** Given a stream created by Serialize(), return a new typeface (like 215 /** Given a stream created by Serialize(), return a new typeface (like
130 CreateTypeface) which is either an exact match to the one serialized 216 CreateTypeface) which is either an exact match to the one serialized
131 or the best available typeface based on the data in the deserialized 217 or the best available typeface based on the data in the deserialized
132 SkFontDescriptor. 218 SkFontDescriptor.
133 */ 219 */
134 static SkTypeface* Deserialize(SkStream*); 220 static SkTypeface* Deserialize(SkStream*);
135 221
136 /////////////////////////////////////////////////////////////////////////// 222 ///////////////////////////////////////////////////////////////////////////
137 223
138 /** Return a subclass of SkScalarContext
139 */
140 static SkScalerContext* CreateScalerContext(const SkDescriptor* desc);
141
142 /**
143 * Given a "current" fontID, return the next logical fontID to use
144 * when searching fonts for a given unicode value. Typically the caller
145 * will query a given font, and if a unicode value is not supported, they
146 * will call this, and if 0 is not returned, will search that font, and so
147 * on. This process must be finite, and when the fonthost sees a
148 * font with no logical successor, it must return 0.
149 *
150 * The original fontID is also provided. This is the initial font that was
151 * stored in the typeface of the caller. It is provided as an aid to choose
152 * the best next logical font. e.g. If the original font was bold or serif,
153 * but the 2nd in the logical chain was plain, then a subsequent call to
154 * get the 3rd can still inspect the original, and try to match its
155 * stylistic attributes.
156 */
157 static SkFontID NextLogicalFont(SkFontID currFontID, SkFontID origFontID);
158
159 ///////////////////////////////////////////////////////////////////////////
160
161 /** Given a filled-out rec, the fonthost may decide to modify it to reflect 224 /** Given a filled-out rec, the fonthost may decide to modify it to reflect
162 what the host is actually capable of fulfilling. For example, if the 225 what the host is actually capable of fulfilling. For example, if the
163 rec is requesting a level of hinting that, for this host, maps some 226 rec is requesting a level of hinting that, for this host, maps some
164 other level (e.g. kFull -> kNormal), it should update the rec to reflect 227 other level (e.g. kFull -> kNormal), it should update the rec to reflect
165 what will actually be done. This is an optimization so that the font 228 what will actually be done. This is an optimization so that the font
166 cache does not contain different recs (i.e. keys) that in reality map to 229 cache does not contain different recs (i.e. keys) that in reality map to
167 the same output. 230 the same output.
168 231
169 A lazy (but valid) fonthost can do nothing in its FilterRec routine. 232 A lazy (but valid) fonthost can do nothing in its FilterRec routine.
170 233
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 exceeds the table's size, then only the bytes up to the table's 286 exceeds the table's size, then only the bytes up to the table's
224 size are actually copied, and this is the value returned. If 287 size are actually copied, and this is the value returned. If
225 offset > the table's size, or tag is not a valid table, 288 offset > the table's size, or tag is not a valid table,
226 then 0 is returned. 289 then 0 is returned.
227 */ 290 */
228 static size_t GetTableData(SkFontID fontID, SkFontTableTag tag, 291 static size_t GetTableData(SkFontID fontID, SkFontTableTag tag,
229 size_t offset, size_t length, void* data); 292 size_t offset, size_t length, void* data);
230 293
231 /////////////////////////////////////////////////////////////////////////// 294 ///////////////////////////////////////////////////////////////////////////
232 295
233 /** LCDs either have their color elements arranged horizontally or 296 friend class SkTypeface;
234 vertically. When rendering subpixel glyphs we need to know which way
235 round they are.
236
237 Note, if you change this after startup, you'll need to flush the glyph
238 cache because it'll have the wrong type of masks cached.
239
240 @deprecated use SkPixelGeometry instead.
241 */
242 enum LCDOrientation {
243 kHorizontal_LCDOrientation = 0, //!< this is the default
244 kVertical_LCDOrientation = 1
245 };
246
247 /** @deprecated set on Device creation. */
248 static void SetSubpixelOrientation(LCDOrientation orientation);
249 /** @deprecated get from Device. */
250 static LCDOrientation GetSubpixelOrientation();
251
252 /** LCD color elements can vary in order. For subpixel text we need to know
253 the order which the LCDs uses so that the color fringes are in the
254 correct place.
255
256 Note, if you change this after startup, you'll need to flush the glyph
257 cache because it'll have the wrong type of masks cached.
258
259 kNONE_LCDOrder means that the subpixel elements are not spatially
260 separated in any usable fashion.
261
262 @deprecated use SkPixelGeometry instead.
263 */
264 enum LCDOrder {
265 kRGB_LCDOrder = 0, //!< this is the default
266 kBGR_LCDOrder = 1,
267 kNONE_LCDOrder = 2
268 };
269
270 /** @deprecated set on Device creation. */
271 static void SetSubpixelOrder(LCDOrder order);
272 /** @deprecated get from Device. */
273 static LCDOrder GetSubpixelOrder();
274
275 #ifdef SK_BUILD_FOR_ANDROID
276 ///////////////////////////////////////////////////////////////////////////
277
278 /**
279 * Return the number of font units per em.
280 *
281 * @param fontID the font to query.
282 * @return the number of font units per em or 0 on error.
283 */
284 static uint32_t GetUnitsPerEm(SkFontID fontID);
285 #endif
286
287 /** If Skia is running in a constrained environment and the typeface
288 implementation is handle based, the typeface data may become
289 unavailable asynchronously. If a font host or scaler context method is
290 unable to access font data, it may call this function as a request to
291 make the handle contained in the typeface useable.
292 */
293 static void EnsureTypefaceAccessible(const SkTypeface& typeface);
294 }; 297 };
295 298
296 #endif 299 #endif
OLDNEW
« no previous file with comments | « no previous file | trunk/include/core/SkTypeface.h » ('j') | trunk/tests/FontHostStreamTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698