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

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: Just the bug fixes first. Created 4 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
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 /**
herb_g 2016/02/29 18:37:10 Do you want *'s aligned vertically?
bungeman-skia 2016/02/29 19:21:20 So while we have a vertical bit on paint and we ki
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 */
258 SkAxisAlignment computeAxisAlignmentForHText();
259
260
248 protected: 261 protected:
249 Rec fRec; 262 Rec fRec;
250 263
251 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY. 264 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY.
252 * May call getMetrics if that would be just as fast. 265 * May call getMetrics if that would be just as fast.
253 */ 266 */
254 virtual void generateAdvance(SkGlyph* glyph) = 0; 267 virtual void generateAdvance(SkGlyph* glyph) = 0;
255 268
256 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft, 269 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft,
257 * as well as fAdvanceX and fAdvanceY if not already set. 270 * 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; 346 const SkMaskGamma::PreBlend fPreBlendForFilter;
334 }; 347 };
335 348
336 #define kRec_SkDescriptorTag SkSetFourByteTag('s', 'r', 'e', 'c') 349 #define kRec_SkDescriptorTag SkSetFourByteTag('s', 'r', 'e', 'c')
337 #define kPathEffect_SkDescriptorTag SkSetFourByteTag('p', 't', 'h', 'e') 350 #define kPathEffect_SkDescriptorTag SkSetFourByteTag('p', 't', 'h', 'e')
338 #define kMaskFilter_SkDescriptorTag SkSetFourByteTag('m', 's', 'k', 'f') 351 #define kMaskFilter_SkDescriptorTag SkSetFourByteTag('m', 's', 'k', 'f')
339 #define kRasterizer_SkDescriptorTag SkSetFourByteTag('r', 'a', 's', 't') 352 #define kRasterizer_SkDescriptorTag SkSetFourByteTag('r', 'a', 's', 't')
340 353
341 /////////////////////////////////////////////////////////////////////////////// 354 ///////////////////////////////////////////////////////////////////////////////
342 355
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 { 356 SkPaint::Hinting SkScalerContextRec::getHinting() const {
360 unsigned hint = (fFlags & SkScalerContext::kHinting_Mask) >> 357 unsigned hint = (fFlags & SkScalerContext::kHinting_Mask) >>
361 SkScalerContext::kHinting_Shift; 358 SkScalerContext::kHinting_Shift;
362 return static_cast<SkPaint::Hinting>(hint); 359 return static_cast<SkPaint::Hinting>(hint);
363 } 360 }
364 361
365 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { 362 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) {
366 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | 363 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) |
367 (hinting << SkScalerContext::kHinting_Shift); 364 (hinting << SkScalerContext::kHinting_Shift);
368 } 365 }
369 366
370 367
371 #endif 368 #endif
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | src/core/SkScalerContext.cpp » ('j') | src/core/SkScalerContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698