OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ShapeResultBuffer_h |
| 6 #define ShapeResultBuffer_h |
| 7 |
| 8 #include "platform/fonts/shaping/ShapeResult.h" |
| 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/RefPtr.h" |
| 11 #include "wtf/Vector.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 class GlyphBuffer; |
| 16 class TextRun; |
| 17 |
| 18 class ShapeResultBuffer { |
| 19 WTF_MAKE_NONCOPYABLE(ShapeResultBuffer); |
| 20 STACK_ALLOCATED(); |
| 21 public: |
| 22 ShapeResultBuffer() |
| 23 : m_hasVerticalOffsets(false) { } |
| 24 |
| 25 void appendResult(PassRefPtr<ShapeResult> result) |
| 26 { |
| 27 m_hasVerticalOffsets |= result->hasVerticalOffsets(); |
| 28 m_results.append(result); |
| 29 } |
| 30 |
| 31 bool hasVerticalOffsets() const { return m_hasVerticalOffsets; } |
| 32 |
| 33 float fillGlyphBuffer(GlyphBuffer*, const TextRun&, unsigned from, unsigned
to) const; |
| 34 float fillGlyphBufferForTextEmphasis(GlyphBuffer*, const TextRun&, |
| 35 const GlyphData* emphasisData, unsigned from, unsigned to) const; |
| 36 int offsetForPosition(const TextRun&, float targetX) const; |
| 37 FloatRect selectionRect(TextDirection, float totalWidth, const FloatPoint&,
int height, |
| 38 unsigned from, unsigned to) const; |
| 39 |
| 40 private: |
| 41 float fillFastHorizontalGlyphBuffer(GlyphBuffer*, TextDirection) const; |
| 42 |
| 43 template<TextDirection> |
| 44 static float fillGlyphBufferForRun(GlyphBuffer*, const ShapeResult::RunInfo*
, |
| 45 float initialAdvance, unsigned from, unsigned to, unsigned runOffset); |
| 46 static float fillGlyphBufferForTextEmphasisRun(GlyphBuffer*, const ShapeResu
lt::RunInfo*, |
| 47 const TextRun&, const GlyphData*, float initialAdvance, unsigned from, u
nsigned to, |
| 48 unsigned runOffset); |
| 49 |
| 50 // Empirically, cases where we get more than 50 ShapeResults are extremely r
are. |
| 51 Vector<RefPtr<ShapeResult>, 64>m_results; |
| 52 bool m_hasVerticalOffsets; |
| 53 }; |
| 54 |
| 55 } // namespace blink |
| 56 |
| 57 #endif // ShapeResultBuffer_h |
OLD | NEW |