| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 SkScalerContext_DEFINED | 8 #ifndef SkScalerContext_DEFINED |
| 9 #define SkScalerContext_DEFINED | 9 #define SkScalerContext_DEFINED |
| 10 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool isSubpixel() const { | 159 bool isSubpixel() const { |
| 160 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag); | 160 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag); |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool isVertical() const { | 163 bool isVertical() const { |
| 164 return SkToBool(fRec.fFlags & kVertical_Flag); | 164 return SkToBool(fRec.fFlags & kVertical_Flag); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // remember our glyph offset/base | |
| 168 void setBaseGlyphCount(unsigned baseGlyphCount) { | |
| 169 fBaseGlyphCount = baseGlyphCount; | |
| 170 } | |
| 171 | |
| 172 /** Return the corresponding glyph for the specified unichar. Since contexts | 167 /** Return the corresponding glyph for the specified unichar. Since contexts |
| 173 may be chained (under the hood), the glyphID that is returned may in | 168 may be chained (under the hood), the glyphID that is returned may in |
| 174 fact correspond to a different font/context. In that case, we use the | 169 fact correspond to a different font/context. In that case, we use the |
| 175 base-glyph-count to know how to translate back into local glyph space. | 170 base-glyph-count to know how to translate back into local glyph space. |
| 176 */ | 171 */ |
| 177 uint16_t charToGlyphID(SkUnichar uni); | 172 uint16_t charToGlyphID(SkUnichar uni) { |
| 173 return generateCharToGlyph(uni); |
| 174 } |
| 178 | 175 |
| 179 /** Map the glyphID to its glyph index, and then to its char code. Unmapped | 176 /** Map the glyphID to its glyph index, and then to its char code. Unmapped |
| 180 glyphs return zero. | 177 glyphs return zero. |
| 181 */ | 178 */ |
| 182 SkUnichar glyphIDToChar(uint16_t glyphID); | 179 SkUnichar glyphIDToChar(uint16_t glyphID) { |
| 180 return (glyphID < getGlyphCount()) ? generateGlyphToChar(glyphID) : 0; |
| 181 } |
| 183 | 182 |
| 184 unsigned getGlyphCount() { return this->generateGlyphCount(); } | 183 unsigned getGlyphCount() { return this->generateGlyphCount(); } |
| 185 void getAdvance(SkGlyph*); | 184 void getAdvance(SkGlyph*); |
| 186 void getMetrics(SkGlyph*); | 185 void getMetrics(SkGlyph*); |
| 187 void getImage(const SkGlyph&); | 186 void getImage(const SkGlyph&); |
| 188 void getPath(const SkGlyph&, SkPath*); | 187 void getPath(const SkGlyph&, SkPath*); |
| 189 void getFontMetrics(SkPaint::FontMetrics*); | 188 void getFontMetrics(SkPaint::FontMetrics*); |
| 190 | 189 |
| 191 /** Return the size in bytes of the associated gamma lookup table | 190 /** Return the size in bytes of the associated gamma lookup table |
| 192 */ | 191 */ |
| 193 static size_t GetGammaLUTSize(SkScalar contrast, SkScalar paintGamma, SkScal
ar deviceGamma, | 192 static size_t GetGammaLUTSize(SkScalar contrast, SkScalar paintGamma, SkScal
ar deviceGamma, |
| 194 int* width, int* height); | 193 int* width, int* height); |
| 195 | 194 |
| 196 /** Get the associated gamma lookup table. The 'data' pointer must point to
pre-allocated | 195 /** Get the associated gamma lookup table. The 'data' pointer must point to
pre-allocated |
| 197 memory, with size in bytes greater than or equal to the return value of
getGammaLUTSize(). | 196 memory, with size in bytes greater than or equal to the return value of
getGammaLUTSize(). |
| 198 */ | 197 */ |
| 199 static void GetGammaLUTData(SkScalar contrast, SkScalar paintGamma, SkScal
ar deviceGamma, | 198 static void GetGammaLUTData(SkScalar contrast, SkScalar paintGamma, SkScal
ar deviceGamma, |
| 200 void* data); | 199 void* data); |
| 201 | 200 |
| 202 #ifdef SK_BUILD_FOR_ANDROID | |
| 203 unsigned getBaseGlyphCount(SkUnichar charCode); | |
| 204 | |
| 205 // This function must be public for SkTypeface_android.h, but should not be | |
| 206 // called by other callers | |
| 207 SkFontID findTypefaceIdForChar(SkUnichar uni); | |
| 208 #endif | |
| 209 | |
| 210 static void MakeRec(const SkPaint&, const SkDeviceProperties* deviceProperti
es, | 201 static void MakeRec(const SkPaint&, const SkDeviceProperties* deviceProperti
es, |
| 211 const SkMatrix*, Rec* rec); | 202 const SkMatrix*, Rec* rec); |
| 212 static inline void PostMakeRec(const SkPaint&, Rec*); | 203 static inline void PostMakeRec(const SkPaint&, Rec*); |
| 213 | 204 |
| 214 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); | 205 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); |
| 215 | 206 |
| 216 protected: | 207 protected: |
| 217 Rec fRec; | 208 Rec fRec; |
| 218 unsigned fBaseGlyphCount; | |
| 219 | 209 |
| 220 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY. | 210 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY. |
| 221 * May call getMetrics if that would be just as fast. | 211 * May call getMetrics if that would be just as fast. |
| 222 */ | 212 */ |
| 223 virtual void generateAdvance(SkGlyph* glyph) = 0; | 213 virtual void generateAdvance(SkGlyph* glyph) = 0; |
| 224 | 214 |
| 225 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft, | 215 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft, |
| 226 * as well as fAdvanceX and fAdvanceY if not already set. | 216 * as well as fAdvanceX and fAdvanceY if not already set. |
| 227 * | 217 * |
| 228 * TODO: fMaskFormat is set by getMetrics later; cannot be set here. | 218 * TODO: fMaskFormat is set by getMetrics later; cannot be set here. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 SkMaskFilter* fMaskFilter; | 271 SkMaskFilter* fMaskFilter; |
| 282 SkRasterizer* fRasterizer; | 272 SkRasterizer* fRasterizer; |
| 283 | 273 |
| 284 // if this is set, we draw the image from a path, rather than | 274 // if this is set, we draw the image from a path, rather than |
| 285 // calling generateImage. | 275 // calling generateImage. |
| 286 bool fGenerateImageFromPath; | 276 bool fGenerateImageFromPath; |
| 287 | 277 |
| 288 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, | 278 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, |
| 289 SkPath* devPath, SkMatrix* fillToDevMatrix); | 279 SkPath* devPath, SkMatrix* fillToDevMatrix); |
| 290 | 280 |
| 291 // Return the context associated with the next logical typeface, or NULL if | |
| 292 // there are no more entries in the fallback chain. | |
| 293 SkScalerContext* allocNextContext() const; | |
| 294 | |
| 295 // return the next context, treating fNextContext as a cache of the answer | |
| 296 SkScalerContext* getNextContext(); | |
| 297 | |
| 298 // returns the right context from our link-list for this glyph. If no match | |
| 299 // is found, just returns the original context (this) | |
| 300 SkScalerContext* getGlyphContext(const SkGlyph& glyph); | |
| 301 | |
| 302 // returns the right context from our link-list for this char. If no match | 281 // returns the right context from our link-list for this char. If no match |
| 303 // is found it returns NULL. If a match is found then the glyphID param is | 282 // is found it returns NULL. If a match is found then the glyphID param is |
| 304 // set to the glyphID that maps to the provided char. | 283 // set to the glyphID that maps to the provided char. |
| 305 SkScalerContext* getContextFromChar(SkUnichar uni, uint16_t* glyphID); | 284 SkScalerContext* getContextFromChar(SkUnichar uni, uint16_t* glyphID); |
| 306 | 285 |
| 307 // link-list of context, to handle missing chars. null-terminated. | |
| 308 SkScalerContext* fNextContext; | |
| 309 | |
| 310 // SkMaskGamma::PreBlend converts linear masks to gamma correcting masks. | 286 // SkMaskGamma::PreBlend converts linear masks to gamma correcting masks. |
| 311 protected: | 287 protected: |
| 312 // Visible to subclasses so that generateImage can apply the pre-blend direc
tly. | 288 // Visible to subclasses so that generateImage can apply the pre-blend direc
tly. |
| 313 const SkMaskGamma::PreBlend fPreBlend; | 289 const SkMaskGamma::PreBlend fPreBlend; |
| 314 private: | 290 private: |
| 315 // When there is a filter, previous steps must create a linear mask | 291 // When there is a filter, previous steps must create a linear mask |
| 316 // and the pre-blend applied as a final step. | 292 // and the pre-blend applied as a final step. |
| 317 const SkMaskGamma::PreBlend fPreBlendForFilter; | 293 const SkMaskGamma::PreBlend fPreBlendForFilter; |
| 318 }; | 294 }; |
| 319 | 295 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 349 return static_cast<SkPaint::Hinting>(hint); | 325 return static_cast<SkPaint::Hinting>(hint); |
| 350 } | 326 } |
| 351 | 327 |
| 352 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { | 328 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { |
| 353 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | | 329 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | |
| 354 (hinting << SkScalerContext::kHinting_Shift); | 330 (hinting << SkScalerContext::kHinting_Shift); |
| 355 } | 331 } |
| 356 | 332 |
| 357 | 333 |
| 358 #endif | 334 #endif |
| OLD | NEW |