Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 | 53 |
| 54 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> { | 54 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> { |
| 55 public: | 55 public: |
| 56 ShapeResult(): m_width(0), m_numGlyphs(0) { } | 56 ShapeResult(): m_width(0), m_numGlyphs(0) { } |
| 57 ~ShapeResult(); | 57 ~ShapeResult(); |
| 58 | 58 |
| 59 float width() { return m_width; } | 59 float width() { return m_width; } |
| 60 FloatRect bounds() { return m_glyphBoundingBox; } | 60 FloatRect bounds() { return m_glyphBoundingBox; } |
| 61 int offsetForPosition(float targetX); | 61 int offsetForPosition(float targetX); |
| 62 unsigned numCharacters() const { return m_numCharacters; } | 62 unsigned numCharacters() const { return m_numCharacters; } |
| 63 const HashSet<const SimpleFontData*>* fallbackFonts() const | 63 void fallbackFonts(HashSet<const SimpleFontData*>*) const; |
| 64 { | |
| 65 return &m_fallbackFonts; | |
| 66 } | |
| 67 | 64 |
| 68 static float fillGlyphBuffer(Vector<RefPtr<ShapeResult>>&, | 65 static float fillGlyphBuffer(Vector<RefPtr<ShapeResult>>&, |
| 69 GlyphBuffer*, const TextRun&, unsigned from, unsigned to); | 66 GlyphBuffer*, const TextRun&, unsigned from, unsigned to); |
| 70 static float fillGlyphBufferForTextEmphasis(Vector<RefPtr<ShapeResult>>&, | 67 static float fillGlyphBufferForTextEmphasis(Vector<RefPtr<ShapeResult>>&, |
| 71 GlyphBuffer*, const TextRun&, const GlyphData* emphasisData, | 68 GlyphBuffer*, const TextRun&, const GlyphData* emphasisData, |
| 72 unsigned from, unsigned to); | 69 unsigned from, unsigned to); |
| 73 static FloatRect selectionRect(Vector<RefPtr<ShapeResult>>&, | 70 static FloatRect selectionRect(Vector<RefPtr<ShapeResult>>&, |
| 74 TextDirection, float totalWidth, const FloatPoint&, int height, | 71 TextDirection, float totalWidth, const FloatPoint&, int height, |
| 75 unsigned from, unsigned to); | 72 unsigned from, unsigned to); |
| 76 | 73 |
| 74 | |
|
leviw_travelin_and_unemployed
2015/07/13 20:47:24
Nit: extra newlines are the devil.
| |
| 77 unsigned numberOfRunsForTesting() const; | 75 unsigned numberOfRunsForTesting() const; |
| 78 bool runInfoForTesting(unsigned runIndex, unsigned& startIndex, | 76 bool runInfoForTesting(unsigned runIndex, unsigned& startIndex, |
| 79 unsigned& numGlyphs, hb_script_t&); | 77 unsigned& numGlyphs, hb_script_t&); |
| 80 uint16_t glyphForTesting(unsigned runIndex, size_t glyphIndex); | 78 uint16_t glyphForTesting(unsigned runIndex, size_t glyphIndex); |
| 81 float advanceForTesting(unsigned runIndex, size_t glyphIndex); | 79 float advanceForTesting(unsigned runIndex, size_t glyphIndex); |
| 82 | 80 |
| 83 private: | 81 private: |
| 84 struct RunInfo; | 82 struct RunInfo; |
| 85 | 83 |
| 86 template<TextDirection> | 84 template<TextDirection> |
| 87 float fillGlyphBufferForRun(GlyphBuffer*, const RunInfo*, | 85 float fillGlyphBufferForRun(GlyphBuffer*, const RunInfo*, |
| 88 float initialAdvance, unsigned from, unsigned to, unsigned runOffset); | 86 float initialAdvance, unsigned from, unsigned to, unsigned runOffset); |
| 89 | 87 |
| 90 float fillGlyphBufferForTextEmphasisRun(GlyphBuffer*, const RunInfo*, | 88 float fillGlyphBufferForTextEmphasisRun(GlyphBuffer*, const RunInfo*, |
| 91 const TextRun&, const GlyphData*, float initialAdvance, | 89 const TextRun&, const GlyphData*, float initialAdvance, |
| 92 unsigned from, unsigned to, unsigned runOffset); | 90 unsigned from, unsigned to, unsigned runOffset); |
| 93 | 91 |
| 94 float m_width; | 92 float m_width; |
| 95 FloatRect m_glyphBoundingBox; | 93 FloatRect m_glyphBoundingBox; |
| 96 Vector<RunInfo*> m_runs; | 94 Vector<RunInfo*> m_runs; |
| 97 HashSet<const SimpleFontData*> m_fallbackFonts; | 95 const SimpleFontData* m_primaryFont; |
| 98 | 96 |
| 99 unsigned m_numCharacters; | 97 unsigned m_numCharacters; |
| 100 unsigned m_numGlyphs : 31; | 98 unsigned m_numGlyphs : 31; |
| 101 | 99 |
| 102 // Overall direction for the TextRun, dictates which order each individual | 100 // Overall direction for the TextRun, dictates which order each individual |
| 103 // sub run (represented by RunInfo structs in the m_runs vector) can have a | 101 // sub run (represented by RunInfo structs in the m_runs vector) can have a |
| 104 // different text direction. | 102 // different text direction. |
| 105 unsigned m_direction : 1; | 103 unsigned m_direction : 1; |
| 106 | 104 |
| 107 friend class HarfBuzzShaper; | 105 friend class HarfBuzzShaper; |
| 108 }; | 106 }; |
| 109 | 107 |
| 110 class PLATFORM_EXPORT HarfBuzzShaper final : public Shaper { | 108 class PLATFORM_EXPORT HarfBuzzShaper final : public Shaper { |
| 111 public: | 109 public: |
| 112 HarfBuzzShaper(const Font*, const TextRun&, | 110 HarfBuzzShaper(const Font*, const TextRun&); |
| 113 HashSet<const SimpleFontData*>* fallbackFonts); | |
| 114 PassRefPtr<ShapeResult> shapeResult(); | 111 PassRefPtr<ShapeResult> shapeResult(); |
| 115 ~HarfBuzzShaper() { } | 112 ~HarfBuzzShaper() { } |
| 116 | 113 |
| 117 private: | 114 private: |
| 118 class PLATFORM_EXPORT HarfBuzzRun { | 115 class PLATFORM_EXPORT HarfBuzzRun { |
| 119 public: | 116 public: |
| 120 HarfBuzzRun(const HarfBuzzRun&); | 117 HarfBuzzRun(const HarfBuzzRun&); |
| 121 ~HarfBuzzRun(); | 118 ~HarfBuzzRun(); |
| 122 | 119 |
| 123 static PassOwnPtr<HarfBuzzRun> create(const SimpleFontData* fontData, un signed startIndex, unsigned numCharacters, hb_direction_t direction, hb_script_t script) | 120 static PassOwnPtr<HarfBuzzRun> create(const SimpleFontData* fontData, un signed startIndex, unsigned numCharacters, hb_direction_t direction, hb_script_t script) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 float m_letterSpacing; // Pixels to be added after each glyph. | 157 float m_letterSpacing; // Pixels to be added after each glyph. |
| 161 unsigned m_expansionOpportunityCount; | 158 unsigned m_expansionOpportunityCount; |
| 162 | 159 |
| 163 Vector<hb_feature_t, 4> m_features; | 160 Vector<hb_feature_t, 4> m_features; |
| 164 Vector<OwnPtr<HarfBuzzRun>, 16> m_harfBuzzRuns; | 161 Vector<OwnPtr<HarfBuzzRun>, 16> m_harfBuzzRuns; |
| 165 }; | 162 }; |
| 166 | 163 |
| 167 } // namespace blink | 164 } // namespace blink |
| 168 | 165 |
| 169 #endif // HarfBuzzShaper_h | 166 #endif // HarfBuzzShaper_h |
| OLD | NEW |