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

Side by Side Diff: src/core/SkScalerContext.h

Issue 1740163002: Improve horizontal baseline detection. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
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
11 #include "SkMask.h" 11 #include "SkMask.h"
12 #include "SkMaskGamma.h" 12 #include "SkMaskGamma.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15 #include "SkTypeface.h" 15 #include "SkTypeface.h"
16 16
17 class SkGlyph; 17 class SkGlyph;
18 class SkDescriptor; 18 class SkDescriptor;
19 class SkMaskFilter; 19 class SkMaskFilter;
20 class SkPathEffect; 20 class SkPathEffect;
21 class SkRasterizer; 21 class SkRasterizer;
22 22
23 enum SkAxisAlignment {
24 kNone_SkAxisAlignment,
25 kX_SkAxisAlignment,
26 kY_SkAxisAlignment
27 };
28
23 /* 29 /*
24 * To allow this to be forward-declared, it must be its own typename, rather 30 * To allow this to be forward-declared, it must be its own typename, rather
25 * than a nested struct inside SkScalerContext (where it started). 31 * than a nested struct inside SkScalerContext (where it started).
26 */ 32 */
27 struct SkScalerContextRec { 33 struct SkScalerContextRec {
28 uint32_t fFontID; 34 uint32_t fFontID;
29 SkScalar fTextSize, fPreScaleX, fPreSkewX; 35 SkScalar fTextSize, fPreScaleX, fPreSkewX;
30 SkScalar fPost2x2[2][2]; 36 SkScalar fPost2x2[2][2];
31 SkScalar fFrameWidth, fMiterLimit; 37 SkScalar fFrameWidth, fMiterLimit;
32 38
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 void* data); 244 void* data);
239 245
240 static void MakeRec(const SkPaint&, const SkSurfaceProps* surfaceProps, 246 static void MakeRec(const SkPaint&, const SkSurfaceProps* surfaceProps,
241 const SkMatrix*, Rec* rec); 247 const SkMatrix*, Rec* rec);
242 static inline void PostMakeRec(const SkPaint&, Rec*); 248 static inline void PostMakeRec(const SkPaint&, Rec*);
243 249
244 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); 250 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec);
245 251
246 const Rec& getRec() const { return fRec; } 252 const Rec& getRec() const { return fRec; }
247 253
254 /**
255 * Return the axis (if any) that the baseline for horizontal text should lan d on.
256 * As an example, the identity matrix will return kX_SkAxisAlignment
257 * If glyphs landing on the baseline is not significant (no hinting), return s
258 * kNone_SkAxisAlignment.
259 */
260 SkAxisAlignment computeAxisAlignmentForHText();
261
262
248 protected: 263 protected:
249 Rec fRec; 264 Rec fRec;
250 265
251 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY. 266 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY.
252 * May call getMetrics if that would be just as fast. 267 * May call getMetrics if that would be just as fast.
253 */ 268 */
254 virtual void generateAdvance(SkGlyph* glyph) = 0; 269 virtual void generateAdvance(SkGlyph* glyph) = 0;
255 270
256 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft, 271 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft,
257 * as well as fAdvanceX and fAdvanceY if not already set. 272 * as well as fAdvanceX and fAdvanceY if not already set.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 const SkMaskGamma::PreBlend fPreBlendForFilter; 348 const SkMaskGamma::PreBlend fPreBlendForFilter;
334 }; 349 };
335 350
336 #define kRec_SkDescriptorTag SkSetFourByteTag('s', 'r', 'e', 'c') 351 #define kRec_SkDescriptorTag SkSetFourByteTag('s', 'r', 'e', 'c')
337 #define kPathEffect_SkDescriptorTag SkSetFourByteTag('p', 't', 'h', 'e') 352 #define kPathEffect_SkDescriptorTag SkSetFourByteTag('p', 't', 'h', 'e')
338 #define kMaskFilter_SkDescriptorTag SkSetFourByteTag('m', 's', 'k', 'f') 353 #define kMaskFilter_SkDescriptorTag SkSetFourByteTag('m', 's', 'k', 'f')
339 #define kRasterizer_SkDescriptorTag SkSetFourByteTag('r', 'a', 's', 't') 354 #define kRasterizer_SkDescriptorTag SkSetFourByteTag('r', 'a', 's', 't')
340 355
341 /////////////////////////////////////////////////////////////////////////////// 356 ///////////////////////////////////////////////////////////////////////////////
342 357
343 enum SkAxisAlignment {
344 kNone_SkAxisAlignment,
345 kX_SkAxisAlignment,
346 kY_SkAxisAlignment
347 };
348
349 /**
350 * Return the axis (if any) that the baseline for horizontal text will land on
351 * after running through the specified matrix.
352 *
353 * As an example, the identity matrix will return kX_SkAxisAlignment
354 */
355 SkAxisAlignment SkComputeAxisAlignmentForHText(const SkMatrix& matrix);
356
357 ///////////////////////////////////////////////////////////////////////////////
358
359 SkPaint::Hinting SkScalerContextRec::getHinting() const { 358 SkPaint::Hinting SkScalerContextRec::getHinting() const {
360 unsigned hint = (fFlags & SkScalerContext::kHinting_Mask) >> 359 unsigned hint = (fFlags & SkScalerContext::kHinting_Mask) >>
361 SkScalerContext::kHinting_Shift; 360 SkScalerContext::kHinting_Shift;
362 return static_cast<SkPaint::Hinting>(hint); 361 return static_cast<SkPaint::Hinting>(hint);
363 } 362 }
364 363
365 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { 364 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) {
366 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | 365 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) |
367 (hinting << SkScalerContext::kHinting_Shift); 366 (hinting << SkScalerContext::kHinting_Shift);
368 } 367 }
369 368
370 369
371 #endif 370 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698