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

Unified Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResultBuffer.h

Issue 1561633002: Relocate ShapeResult's GlyphBuffer helpers to ShapeResultBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/fonts/shaping/ShapeResultBuffer.h
diff --git a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResultBuffer.h b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResultBuffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..a0394e46b20be605130220c58135b2871cd0dd48
--- /dev/null
+++ b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResultBuffer.h
@@ -0,0 +1,57 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ShapeResultBuffer_h
+#define ShapeResultBuffer_h
+
+#include "platform/fonts/shaping/ShapeResult.h"
+#include "wtf/Allocator.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
+
+namespace blink {
+
+class GlyphBuffer;
+class TextRun;
+
+class ShapeResultBuffer {
+ WTF_MAKE_NONCOPYABLE(ShapeResultBuffer);
+ STACK_ALLOCATED();
+public:
+ ShapeResultBuffer()
+ : m_hasVerticalOffsets(false) { }
+
+ void appendResult(PassRefPtr<ShapeResult> result)
+ {
+ m_hasVerticalOffsets |= result->hasVerticalOffsets();
+ m_results.append(result);
+ }
+
+ bool hasVerticalOffsets() const { return m_hasVerticalOffsets; }
+
+ float fillGlyphBuffer(GlyphBuffer*, const TextRun&, unsigned from, unsigned to) const;
+ float fillGlyphBufferForTextEmphasis(GlyphBuffer*, const TextRun&,
+ const GlyphData* emphasisData, unsigned from, unsigned to) const;
+ int offsetForPosition(const TextRun&, float targetX) const;
+ FloatRect selectionRect(TextDirection, float totalWidth, const FloatPoint&, int height,
+ unsigned from, unsigned to) const;
+
+private:
+ float fillFastHorizontalGlyphBuffer(GlyphBuffer*, TextDirection) const;
+
+ template<TextDirection>
+ static float fillGlyphBufferForRun(GlyphBuffer*, const ShapeResult::RunInfo*,
+ float initialAdvance, unsigned from, unsigned to, unsigned runOffset);
+ static float fillGlyphBufferForTextEmphasisRun(GlyphBuffer*, const ShapeResult::RunInfo*,
+ const TextRun&, const GlyphData*, float initialAdvance, unsigned from, unsigned to,
+ unsigned runOffset);
+
+ // Empirically, cases where we get more than 50 ShapeResults are extremely rare.
+ Vector<RefPtr<ShapeResult>, 64>m_results;
+ bool m_hasVerticalOffsets;
+};
+
+} // namespace blink
+
+#endif // ShapeResultBuffer_h

Powered by Google App Engine
This is Rietveld 408576698