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

Unified Diff: ui/gfx/render_text_harfbuzz.h

Issue 152473008: More or less implement RenderTextHarfBuzz (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased; decorations Created 6 years, 9 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: ui/gfx/render_text_harfbuzz.h
diff --git a/ui/gfx/render_text_harfbuzz.h b/ui/gfx/render_text_harfbuzz.h
new file mode 100644
index 0000000000000000000000000000000000000000..05dc732ef03940b322e9ed52b0a7ed667f1c7684
--- /dev/null
+++ b/ui/gfx/render_text_harfbuzz.h
@@ -0,0 +1,99 @@
+// Copyright (c) 2014 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 UI_GFX_RENDER_TEXT_HARFBUZZ_H_
+#define UI_GFX_RENDER_TEXT_HARFBUZZ_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
+#include "third_party/harfbuzz-ng/src/hb.h"
+#include "third_party/icu/source/common/unicode/ubidi.h"
+#include "ui/gfx/render_text.h"
+
+namespace gfx {
+
+namespace internal {
+
+struct TextRunHarfBuzz {
+ TextRunHarfBuzz();
+ ~TextRunHarfBuzz();
+
+ int width;
+ Range range;
+ UBiDiDirection direction;
+ UBiDiLevel level;
+
+ scoped_ptr<uint16[]> glyphs;
+ scoped_ptr<SkPoint[]> positions;
+ scoped_ptr<uint32[]> glyph_to_char;
+ size_t glyph_count;
+
+ skia::RefPtr<SkTypeface> skia_face;
+ int font_size;
+ int font_style;
+ bool strike;
+ bool diagonal_strike;
+ bool underline;
+};
+
+} // namespace internal
+
+class RenderTextHarfBuzz : public RenderText {
+ public:
+ RenderTextHarfBuzz();
+ virtual ~RenderTextHarfBuzz();
+
+ // Overridden from RenderText.
+ virtual Size GetStringSize() OVERRIDE;
+ virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE;
+ virtual bool IsCursorablePosition(size_t position) OVERRIDE;
+ virtual std::vector<FontSpan> GetFontSpansForTesting() OVERRIDE;
+
+ protected:
+ // Overridden from RenderText.
+ virtual int GetLayoutTextBaseline() OVERRIDE;
+ virtual SelectionModel AdjacentCharSelectionModel(
+ const SelectionModel& selection,
+ VisualCursorDirection direction) OVERRIDE;
+ virtual SelectionModel AdjacentWordSelectionModel(
+ const SelectionModel& selection,
+ VisualCursorDirection direction) OVERRIDE;
+ virtual Range GetGlyphBounds(size_t index) OVERRIDE;
+ virtual std::vector<Rect> GetSubstringBounds(const Range& range) OVERRIDE;
+ virtual size_t TextIndexToLayoutIndex(size_t index) const OVERRIDE;
+ virtual size_t LayoutIndexToTextIndex(size_t index) const OVERRIDE;
+ virtual void ResetLayout() OVERRIDE;
+ virtual void EnsureLayout() OVERRIDE;
+ virtual void DrawVisualText(Canvas* canvas) OVERRIDE;
+
+ void ShapeRun(internal::TextRunHarfBuzz* run);
msw 2014/04/29 06:24:45 nit: comment like "Shape the glyphs needed for the
ckocagil 2014/05/01 22:02:01 Done.
+
+ size_t GetRunContainingCaret(const SelectionModel& caret) const;
msw 2014/04/29 06:24:45 nit: copy/adapt the comments from RenderTextWin fo
ckocagil 2014/05/01 22:02:01 Done.
+
+ // Returns the X coordinate of the leading or |trailing| edge of the glyph
+ // starting at |index|, relative to the left of the text (not the view).
+ int GetGlyphXBoundary(size_t run_index, size_t text_index, bool trailing);
+
+ SelectionModel RenderTextHarfBuzz::FirstSelectionModelInsideRun(
+ const internal::TextRunHarfBuzz* run);
+
+ SelectionModel RenderTextHarfBuzz::LastSelectionModelInsideRun(
+ const internal::TextRunHarfBuzz* run);
+
+ size_t GetRunContainingXCoord(int x, int* offset) const;
+
+ private:
+ // Text runs in logical order.
+ ScopedVector<internal::TextRunHarfBuzz> runs_;
+
+ // Maps visual run indices to logical run indices and vice versa.
+ std::vector<int32_t> visual_to_logical_;
+ std::vector<int32_t> logical_to_visual_;
+
+ bool needs_layout_;
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_

Powered by Google App Engine
This is Rietveld 408576698