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

Side by Side Diff: Source/platform/fonts/shaping/Shaper.h

Issue 986493002: Simplify text emphasis painting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 24 matching lines...) Expand all
35 #include "platform/fonts/Font.h" 35 #include "platform/fonts/Font.h"
36 #include "wtf/HashSet.h" 36 #include "wtf/HashSet.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 class FloatRect; 40 class FloatRect;
41 class GlyphBuffer; 41 class GlyphBuffer;
42 class SimpleFontData; 42 class SimpleFontData;
43 class TextRun; 43 class TextRun;
44 44
45 struct GlyphData;
46
45 class PLATFORM_EXPORT Shaper { 47 class PLATFORM_EXPORT Shaper {
46 public:
47 enum ForTextEmphasisOrNot {
48 NotForTextEmphasis,
49 ForTextEmphasis
50 };
51
52 protected: 48 protected:
53 Shaper(const Font*, const TextRun&, ForTextEmphasisOrNot = NotForTextEmphasi s, HashSet<const SimpleFontData*>* fallbackFonts = nullptr, FloatRect* = nullptr ); 49 Shaper(const Font*, const TextRun&, const GlyphData* emphasisData = nullptr,
50 HashSet<const SimpleFontData*>* fallbackFonts = nullptr, FloatRect* = nu llptr);
54 51
55 void trackNonPrimaryFallbackFont(const SimpleFontData*); 52 void trackNonPrimaryFallbackFont(const SimpleFontData*);
56 53
57 protected: 54 bool forTextEmphasis() const { return m_emphasisSubstitutionData; }
55 void addEmphasisMark(GlyphBuffer*, float midGlyphOffset) const;
56
58 const Font* m_font; 57 const Font* m_font;
59 const TextRun& m_run; 58 const TextRun& m_run;
60 HashSet<const SimpleFontData*>* m_fallbackFonts; 59 HashSet<const SimpleFontData*>* m_fallbackFonts;
61 FloatRect* m_glyphBoundingBox; 60 FloatRect* m_glyphBoundingBox;
62 61
63 float m_expansion; // Pixels to be distributed over the line at word breaks. 62 float m_expansion; // Pixels to be distributed over the line at word breaks.
64 float m_expansionPerOpportunity; // Pixels to be added to each expansion opp ortunity. 63 float m_expansionPerOpportunity; // Pixels to be added to each expansion opp ortunity.
65 bool m_isAfterExpansion; 64 bool m_isAfterExpansion;
66 65
67 ForTextEmphasisOrNot m_forTextEmphasis; 66 private:
67 // Emphasis substitution info. If specified, this will be used to replace al l glyphs which
68 // can receive text emphasis with center-aligned emphasis glyphs.
69 const GlyphData* m_emphasisSubstitutionData;
70 FloatPoint m_emphasisGlyphCenter;
68 }; 71 };
69 72
70 inline void Shaper::trackNonPrimaryFallbackFont(const SimpleFontData* fontData) 73 inline void Shaper::trackNonPrimaryFallbackFont(const SimpleFontData* fontData)
71 { 74 {
72 ASSERT(m_fallbackFonts); 75 ASSERT(m_fallbackFonts);
73 76
74 if (fontData == m_font->primaryFont()) 77 if (fontData == m_font->primaryFont())
75 return; 78 return;
76 79
77 m_fallbackFonts->add(fontData); 80 m_fallbackFonts->add(fontData);
78 } 81 }
79 82
80 } // namespace blink 83 } // namespace blink
81 84
82 #endif // Shaper_h 85 #endif // Shaper_h
OLDNEW
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.cpp ('k') | Source/platform/fonts/shaping/Shaper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698