| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_RENDER_TEXT_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_H_ |
| 6 #define UI_GFX_RENDER_TEXT_H_ | 6 #define UI_GFX_RENDER_TEXT_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // If not set, default values based on the size of the text will be used. The | 67 // If not set, default values based on the size of the text will be used. The |
| 68 // two metrics must be set together. | 68 // two metrics must be set together. |
| 69 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); | 69 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); |
| 70 void DrawSelection(const std::vector<Rect>& selection, SkColor color); | 70 void DrawSelection(const std::vector<Rect>& selection, SkColor color); |
| 71 virtual void DrawPosText(const SkPoint* pos, | 71 virtual void DrawPosText(const SkPoint* pos, |
| 72 const uint16_t* glyphs, | 72 const uint16_t* glyphs, |
| 73 size_t glyph_count); | 73 size_t glyph_count); |
| 74 // Draw underline and strike-through text decorations. | 74 // Draw underline and strike-through text decorations. |
| 75 // Based on |SkCanvas::DrawTextDecorations()| and constants from: | 75 // Based on |SkCanvas::DrawTextDecorations()| and constants from: |
| 76 // third_party/skia/src/core/SkTextFormatParams.h | 76 // third_party/skia/src/core/SkTextFormatParams.h |
| 77 virtual void DrawDecorations(int x, int y, int width, bool underline, | 77 virtual void DrawDecorations(int x, |
| 78 bool strike, bool diagonal_strike); | 78 int y, |
| 79 // Finishes any ongoing diagonal strike run. | 79 int width, |
| 80 void EndDiagonalStrike(); | 80 bool underline, |
| 81 bool strike); |
| 81 void DrawUnderline(int x, int y, int width); | 82 void DrawUnderline(int x, int y, int width); |
| 82 void DrawStrike(int x, int y, int width) const; | 83 void DrawStrike(int x, int y, int width) const; |
| 83 | 84 |
| 84 private: | 85 private: |
| 85 friend class test::RenderTextTestApi; | 86 friend class test::RenderTextTestApi; |
| 86 | 87 |
| 87 // Helper class to draw a diagonal line with multiple pieces of different | |
| 88 // lengths and colors; to support text selection appearances. | |
| 89 class DiagonalStrike { | |
| 90 public: | |
| 91 DiagonalStrike(Canvas* canvas, Point start, const cc::PaintFlags& flags); | |
| 92 ~DiagonalStrike(); | |
| 93 | |
| 94 void AddPiece(int length, SkColor color); | |
| 95 void Draw(); | |
| 96 | |
| 97 private: | |
| 98 typedef std::pair<int, SkColor> Piece; | |
| 99 | |
| 100 Canvas* canvas_; | |
| 101 const Point start_; | |
| 102 cc::PaintFlags flags_; | |
| 103 int total_length_; | |
| 104 std::vector<Piece> pieces_; | |
| 105 | |
| 106 DISALLOW_COPY_AND_ASSIGN(DiagonalStrike); | |
| 107 }; | |
| 108 | |
| 109 Canvas* canvas_; | 88 Canvas* canvas_; |
| 110 cc::PaintCanvas* canvas_skia_; | 89 cc::PaintCanvas* canvas_skia_; |
| 111 cc::PaintFlags flags_; | 90 cc::PaintFlags flags_; |
| 112 SkScalar underline_thickness_; | 91 SkScalar underline_thickness_; |
| 113 SkScalar underline_position_; | 92 SkScalar underline_position_; |
| 114 std::unique_ptr<DiagonalStrike> diagonal_; | |
| 115 | 93 |
| 116 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); | 94 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); |
| 117 }; | 95 }; |
| 118 | 96 |
| 119 // Internal helper class used to iterate colors, baselines, and styles. | 97 // Internal helper class used to iterate colors, baselines, and styles. |
| 120 class StyleIterator { | 98 class StyleIterator { |
| 121 public: | 99 public: |
| 122 StyleIterator(const BreakList<SkColor>& colors, | 100 StyleIterator(const BreakList<SkColor>& colors, |
| 123 const BreakList<BaselineStyle>& baselines, | 101 const BreakList<BaselineStyle>& baselines, |
| 124 const BreakList<Font::Weight>& weights, | 102 const BreakList<Font::Weight>& weights, |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 // Lines computed by EnsureLayout. These should be invalidated upon | 834 // Lines computed by EnsureLayout. These should be invalidated upon |
| 857 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 835 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
| 858 std::vector<internal::Line> lines_; | 836 std::vector<internal::Line> lines_; |
| 859 | 837 |
| 860 DISALLOW_COPY_AND_ASSIGN(RenderText); | 838 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 861 }; | 839 }; |
| 862 | 840 |
| 863 } // namespace gfx | 841 } // namespace gfx |
| 864 | 842 |
| 865 #endif // UI_GFX_RENDER_TEXT_H_ | 843 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |