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 28 matching lines...) Expand all Loading... | |
| 39 #include "wtf/HashSet.h" | 39 #include "wtf/HashSet.h" |
| 40 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
| 41 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
| 42 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
| 43 #include "wtf/text/CharacterNames.h" | 43 #include "wtf/text/CharacterNames.h" |
| 44 | 44 |
| 45 #include <unicode/uscript.h> | 45 #include <unicode/uscript.h> |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 class CachingWordShapeIterator; | |
| 49 class Font; | 50 class Font; |
| 50 class GlyphBuffer; | 51 class GlyphBuffer; |
| 51 class SimpleFontData; | 52 class SimpleFontData; |
| 52 class HarfBuzzShaper; | 53 class HarfBuzzShaper; |
| 53 | 54 |
| 54 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> { | 55 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> { |
| 55 public: | 56 public: |
| 56 static PassRefPtr<ShapeResult> create(unsigned numCharacters, TextDirection direction) | 57 static PassRefPtr<ShapeResult> create(unsigned numCharacters, TextDirection direction) |
| 57 { | 58 { |
| 58 return adoptRef(new ShapeResult(numCharacters, direction)); | 59 return adoptRef(new ShapeResult(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 unsigned numCharacters() const { return m_numCharacters; } | 65 unsigned numCharacters() const { return m_numCharacters; } |
| 66 const HashSet<RefPtr<SimpleFontData>>* fallbackFonts() const | 66 const HashSet<RefPtr<SimpleFontData>>* fallbackFonts() const |
| 67 { | 67 { |
| 68 return &m_fallbackFonts; | 68 return &m_fallbackFonts; |
| 69 } | 69 } |
| 70 | 70 |
| 71 static int offsetForPosition(CachingWordShapeIterator&, | |
|
eae
2015/07/22 18:33:22
How about changing this to take a vector of shape
kojii
2015/07/23 05:06:12
Makes sense, done.
| |
| 72 const TextRun&, float targetX); | |
| 71 static float fillGlyphBuffer(Vector<RefPtr<ShapeResult>>&, | 73 static float fillGlyphBuffer(Vector<RefPtr<ShapeResult>>&, |
| 72 GlyphBuffer*, const TextRun&, unsigned from, unsigned to); | 74 GlyphBuffer*, const TextRun&, unsigned from, unsigned to); |
| 73 static float fillGlyphBufferForTextEmphasis(Vector<RefPtr<ShapeResult>>&, | 75 static float fillGlyphBufferForTextEmphasis(Vector<RefPtr<ShapeResult>>&, |
| 74 GlyphBuffer*, const TextRun&, const GlyphData* emphasisData, | 76 GlyphBuffer*, const TextRun&, const GlyphData* emphasisData, |
| 75 unsigned from, unsigned to); | 77 unsigned from, unsigned to); |
| 76 static FloatRect selectionRect(Vector<RefPtr<ShapeResult>>&, | 78 static FloatRect selectionRect(Vector<RefPtr<ShapeResult>>&, |
| 77 TextDirection, float totalWidth, const FloatPoint&, int height, | 79 TextDirection, float totalWidth, const FloatPoint&, int height, |
| 78 unsigned from, unsigned to); | 80 unsigned from, unsigned to); |
| 79 | 81 |
| 80 unsigned numberOfRunsForTesting() const; | 82 unsigned numberOfRunsForTesting() const; |
| 81 bool runInfoForTesting(unsigned runIndex, unsigned& startIndex, | 83 bool runInfoForTesting(unsigned runIndex, unsigned& startIndex, |
| 82 unsigned& numGlyphs, hb_script_t&); | 84 unsigned& numGlyphs, hb_script_t&); |
| 83 uint16_t glyphForTesting(unsigned runIndex, size_t glyphIndex); | 85 uint16_t glyphForTesting(unsigned runIndex, size_t glyphIndex); |
| 84 float advanceForTesting(unsigned runIndex, size_t glyphIndex); | 86 float advanceForTesting(unsigned runIndex, size_t glyphIndex); |
| 85 | 87 |
| 86 private: | 88 private: |
| 87 struct RunInfo; | 89 struct RunInfo; |
| 88 | 90 |
| 89 ShapeResult(unsigned numCharacters, TextDirection direction) | 91 ShapeResult(unsigned numCharacters, TextDirection direction) |
| 90 : m_width(0) | 92 : m_width(0) |
| 91 , m_numCharacters(numCharacters) | 93 , m_numCharacters(numCharacters) |
| 92 , m_numGlyphs(0) | 94 , m_numGlyphs(0) |
| 93 , m_direction(direction) { } | 95 , m_direction(direction) { } |
| 94 | 96 |
| 97 int offsetForPosition(float targetX); | |
| 95 template<TextDirection> | 98 template<TextDirection> |
| 96 float fillGlyphBufferForRun(GlyphBuffer*, const RunInfo*, | 99 float fillGlyphBufferForRun(GlyphBuffer*, const RunInfo*, |
| 97 float initialAdvance, unsigned from, unsigned to, unsigned runOffset); | 100 float initialAdvance, unsigned from, unsigned to, unsigned runOffset); |
| 98 | 101 |
| 99 float fillGlyphBufferForTextEmphasisRun(GlyphBuffer*, const RunInfo*, | 102 float fillGlyphBufferForTextEmphasisRun(GlyphBuffer*, const RunInfo*, |
| 100 const TextRun&, const GlyphData*, float initialAdvance, | 103 const TextRun&, const GlyphData*, float initialAdvance, |
| 101 unsigned from, unsigned to, unsigned runOffset); | 104 unsigned from, unsigned to, unsigned runOffset); |
| 102 | 105 |
| 103 float m_width; | 106 float m_width; |
| 104 FloatRect m_glyphBoundingBox; | 107 FloatRect m_glyphBoundingBox; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 float m_letterSpacing; // Pixels to be added after each glyph. | 153 float m_letterSpacing; // Pixels to be added after each glyph. |
| 151 unsigned m_expansionOpportunityCount; | 154 unsigned m_expansionOpportunityCount; |
| 152 | 155 |
| 153 Vector<hb_feature_t, 4> m_features; | 156 Vector<hb_feature_t, 4> m_features; |
| 154 Vector<HarfBuzzRun, 16> m_harfBuzzRuns; | 157 Vector<HarfBuzzRun, 16> m_harfBuzzRuns; |
| 155 }; | 158 }; |
| 156 | 159 |
| 157 } // namespace blink | 160 } // namespace blink |
| 158 | 161 |
| 159 #endif // HarfBuzzShaper_h | 162 #endif // HarfBuzzShaper_h |
| OLD | NEW |