| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 class Font; | 49 class Font; |
| 50 class GlyphBuffer; | 50 class GlyphBuffer; |
| 51 class SimpleFontData; | 51 class SimpleFontData; |
| 52 class HarfBuzzShaper; | 52 class HarfBuzzShaper; |
| 53 | 53 |
| 54 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> { | 54 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> { |
| 55 public: | 55 public: |
| 56 static PassRefPtr<ShapeResult> create(unsigned numCharacters, TextDirection
direction) | 56 static PassRefPtr<ShapeResult> create(const Font* font, |
| 57 unsigned numCharacters, TextDirection direction) |
| 57 { | 58 { |
| 58 return adoptRef(new ShapeResult(numCharacters, direction)); | 59 return adoptRef(new ShapeResult(font, numCharacters, direction)); |
| 59 } | 60 } |
| 60 ~ShapeResult(); | 61 ~ShapeResult(); |
| 61 | 62 |
| 62 float width() { return m_width; } | 63 float width() { return m_width; } |
| 63 FloatRect bounds() { return m_glyphBoundingBox; } | 64 FloatRect bounds() { return m_glyphBoundingBox; } |
| 64 int offsetForPosition(float targetX); | 65 int offsetForPosition(float targetX); |
| 65 unsigned numCharacters() const { return m_numCharacters; } | 66 unsigned numCharacters() const { return m_numCharacters; } |
| 66 const HashSet<RefPtr<SimpleFontData>>* fallbackFonts() const | 67 void fallbackFonts(HashSet<const SimpleFontData*>*) const; |
| 67 { | |
| 68 return &m_fallbackFonts; | |
| 69 } | |
| 70 | 68 |
| 71 static float fillGlyphBuffer(Vector<RefPtr<ShapeResult>>&, | 69 static float fillGlyphBuffer(Vector<RefPtr<ShapeResult>>&, |
| 72 GlyphBuffer*, const TextRun&, unsigned from, unsigned to); | 70 GlyphBuffer*, const TextRun&, unsigned from, unsigned to); |
| 73 static float fillGlyphBufferForTextEmphasis(Vector<RefPtr<ShapeResult>>&, | 71 static float fillGlyphBufferForTextEmphasis(Vector<RefPtr<ShapeResult>>&, |
| 74 GlyphBuffer*, const TextRun&, const GlyphData* emphasisData, | 72 GlyphBuffer*, const TextRun&, const GlyphData* emphasisData, |
| 75 unsigned from, unsigned to); | 73 unsigned from, unsigned to); |
| 76 static FloatRect selectionRect(Vector<RefPtr<ShapeResult>>&, | 74 static FloatRect selectionRect(Vector<RefPtr<ShapeResult>>&, |
| 77 TextDirection, float totalWidth, const FloatPoint&, int height, | 75 TextDirection, float totalWidth, const FloatPoint&, int height, |
| 78 unsigned from, unsigned to); | 76 unsigned from, unsigned to); |
| 79 | 77 |
| 80 unsigned numberOfRunsForTesting() const; | 78 unsigned numberOfRunsForTesting() const; |
| 81 bool runInfoForTesting(unsigned runIndex, unsigned& startIndex, | 79 bool runInfoForTesting(unsigned runIndex, unsigned& startIndex, |
| 82 unsigned& numGlyphs, hb_script_t&); | 80 unsigned& numGlyphs, hb_script_t&); |
| 83 uint16_t glyphForTesting(unsigned runIndex, size_t glyphIndex); | 81 uint16_t glyphForTesting(unsigned runIndex, size_t glyphIndex); |
| 84 float advanceForTesting(unsigned runIndex, size_t glyphIndex); | 82 float advanceForTesting(unsigned runIndex, size_t glyphIndex); |
| 85 | 83 |
| 86 private: | 84 private: |
| 87 struct RunInfo; | 85 struct RunInfo; |
| 88 | 86 |
| 89 ShapeResult(unsigned numCharacters, TextDirection); | 87 ShapeResult(const Font*, unsigned numCharacters, TextDirection); |
| 90 | 88 |
| 91 template<TextDirection> | 89 template<TextDirection> |
| 92 float fillGlyphBufferForRun(GlyphBuffer*, const RunInfo*, | 90 float fillGlyphBufferForRun(GlyphBuffer*, const RunInfo*, |
| 93 float initialAdvance, unsigned from, unsigned to, unsigned runOffset); | 91 float initialAdvance, unsigned from, unsigned to, unsigned runOffset); |
| 94 | 92 |
| 95 float fillGlyphBufferForTextEmphasisRun(GlyphBuffer*, const RunInfo*, | 93 float fillGlyphBufferForTextEmphasisRun(GlyphBuffer*, const RunInfo*, |
| 96 const TextRun&, const GlyphData*, float initialAdvance, | 94 const TextRun&, const GlyphData*, float initialAdvance, |
| 97 unsigned from, unsigned to, unsigned runOffset); | 95 unsigned from, unsigned to, unsigned runOffset); |
| 98 | 96 |
| 99 float m_width; | 97 float m_width; |
| 100 FloatRect m_glyphBoundingBox; | 98 FloatRect m_glyphBoundingBox; |
| 101 Vector<OwnPtr<RunInfo>> m_runs; | 99 Vector<OwnPtr<RunInfo>> m_runs; |
| 102 HashSet<RefPtr<SimpleFontData>> m_fallbackFonts; | 100 RefPtr<SimpleFontData> m_primaryFont; |
| 103 | 101 |
| 104 unsigned m_numCharacters; | 102 unsigned m_numCharacters; |
| 105 unsigned m_numGlyphs : 31; | 103 unsigned m_numGlyphs : 31; |
| 106 | 104 |
| 107 // Overall direction for the TextRun, dictates which order each individual | 105 // Overall direction for the TextRun, dictates which order each individual |
| 108 // sub run (represented by RunInfo structs in the m_runs vector) can have a | 106 // sub run (represented by RunInfo structs in the m_runs vector) can have a |
| 109 // different text direction. | 107 // different text direction. |
| 110 unsigned m_direction : 1; | 108 unsigned m_direction : 1; |
| 111 | 109 |
| 112 friend class HarfBuzzShaper; | 110 friend class HarfBuzzShaper; |
| 113 }; | 111 }; |
| 114 | 112 |
| 115 class PLATFORM_EXPORT HarfBuzzShaper final : public Shaper { | 113 class PLATFORM_EXPORT HarfBuzzShaper final : public Shaper { |
| 116 public: | 114 public: |
| 117 HarfBuzzShaper(const Font*, const TextRun&, | 115 HarfBuzzShaper(const Font*, const TextRun&); |
| 118 HashSet<const SimpleFontData*>* fallbackFonts); | |
| 119 PassRefPtr<ShapeResult> shapeResult(); | 116 PassRefPtr<ShapeResult> shapeResult(); |
| 120 ~HarfBuzzShaper() { } | 117 ~HarfBuzzShaper() { } |
| 121 | 118 |
| 122 private: | 119 private: |
| 123 struct HarfBuzzRun { | 120 struct HarfBuzzRun { |
| 124 const SimpleFontData* m_fontData; | 121 const SimpleFontData* m_fontData; |
| 125 unsigned m_startIndex; | 122 unsigned m_startIndex; |
| 126 size_t m_numCharacters; | 123 size_t m_numCharacters; |
| 127 hb_direction_t m_direction; | 124 hb_direction_t m_direction; |
| 128 hb_script_t m_script; | 125 hb_script_t m_script; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 146 float m_letterSpacing; // Pixels to be added after each glyph. | 143 float m_letterSpacing; // Pixels to be added after each glyph. |
| 147 unsigned m_expansionOpportunityCount; | 144 unsigned m_expansionOpportunityCount; |
| 148 | 145 |
| 149 Vector<hb_feature_t, 4> m_features; | 146 Vector<hb_feature_t, 4> m_features; |
| 150 Vector<HarfBuzzRun, 16> m_harfBuzzRuns; | 147 Vector<HarfBuzzRun, 16> m_harfBuzzRuns; |
| 151 }; | 148 }; |
| 152 | 149 |
| 153 } // namespace blink | 150 } // namespace blink |
| 154 | 151 |
| 155 #endif // HarfBuzzShaper_h | 152 #endif // HarfBuzzShaper_h |
| OLD | NEW |