| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void DrawUnderline(int x, int y, int width); | 83 void DrawUnderline(int x, int y, int width); |
| 84 void DrawStrike(int x, int y, int width) const; | 84 void DrawStrike(int x, int y, int width) const; |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 friend class test::RenderTextTestApi; | 87 friend class test::RenderTextTestApi; |
| 88 | 88 |
| 89 // Helper class to draw a diagonal line with multiple pieces of different | 89 // Helper class to draw a diagonal line with multiple pieces of different |
| 90 // lengths and colors; to support text selection appearances. | 90 // lengths and colors; to support text selection appearances. |
| 91 class DiagonalStrike { | 91 class DiagonalStrike { |
| 92 public: | 92 public: |
| 93 DiagonalStrike(Canvas* canvas, Point start, const cc::PaintFlags& paint); | 93 DiagonalStrike(Canvas* canvas, Point start, const cc::PaintFlags& flags); |
| 94 ~DiagonalStrike(); | 94 ~DiagonalStrike(); |
| 95 | 95 |
| 96 void AddPiece(int length, SkColor color); | 96 void AddPiece(int length, SkColor color); |
| 97 void Draw(); | 97 void Draw(); |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 typedef std::pair<int, SkColor> Piece; | 100 typedef std::pair<int, SkColor> Piece; |
| 101 | 101 |
| 102 Canvas* canvas_; | 102 Canvas* canvas_; |
| 103 const Point start_; | 103 const Point start_; |
| 104 cc::PaintFlags paint_; | 104 cc::PaintFlags flags_; |
| 105 int total_length_; | 105 int total_length_; |
| 106 std::vector<Piece> pieces_; | 106 std::vector<Piece> pieces_; |
| 107 | 107 |
| 108 DISALLOW_COPY_AND_ASSIGN(DiagonalStrike); | 108 DISALLOW_COPY_AND_ASSIGN(DiagonalStrike); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 Canvas* canvas_; | 111 Canvas* canvas_; |
| 112 cc::PaintCanvas* canvas_skia_; | 112 cc::PaintCanvas* canvas_skia_; |
| 113 cc::PaintFlags paint_; | 113 cc::PaintFlags flags_; |
| 114 SkScalar underline_thickness_; | 114 SkScalar underline_thickness_; |
| 115 SkScalar underline_position_; | 115 SkScalar underline_position_; |
| 116 std::unique_ptr<DiagonalStrike> diagonal_; | 116 std::unique_ptr<DiagonalStrike> diagonal_; |
| 117 | 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); | 118 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 // Internal helper class used to iterate colors, baselines, and styles. | 121 // Internal helper class used to iterate colors, baselines, and styles. |
| 122 class StyleIterator { | 122 class StyleIterator { |
| 123 public: | 123 public: |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Maximum baseline of all segments on this line. | 189 // Maximum baseline of all segments on this line. |
| 190 int baseline; | 190 int baseline; |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 // Creates an SkTypeface from a font, |italic| and a desired |weight|. | 193 // Creates an SkTypeface from a font, |italic| and a desired |weight|. |
| 194 // May return null. | 194 // May return null. |
| 195 sk_sp<SkTypeface> CreateSkiaTypeface(const Font& font, | 195 sk_sp<SkTypeface> CreateSkiaTypeface(const Font& font, |
| 196 bool italic, | 196 bool italic, |
| 197 Font::Weight weight); | 197 Font::Weight weight); |
| 198 | 198 |
| 199 // Applies the given FontRenderParams to a Skia |paint|. | 199 // Applies the given FontRenderParams to the PaintFlags. |
| 200 void ApplyRenderParams(const FontRenderParams& params, | 200 void ApplyRenderParams(const FontRenderParams& params, |
| 201 bool subpixel_rendering_suppressed, | 201 bool subpixel_rendering_suppressed, |
| 202 cc::PaintFlags* paint); | 202 cc::PaintFlags* flags); |
| 203 | 203 |
| 204 } // namespace internal | 204 } // namespace internal |
| 205 | 205 |
| 206 // RenderText represents an abstract model of styled text and its corresponding | 206 // RenderText represents an abstract model of styled text and its corresponding |
| 207 // visual layout. Support is built in for a cursor, a selection, simple styling, | 207 // visual layout. Support is built in for a cursor, a selection, simple styling, |
| 208 // complex scripts, and bi-directional text. Implementations provide mechanisms | 208 // complex scripts, and bi-directional text. Implementations provide mechanisms |
| 209 // for rendering and translation between logical and visual data. | 209 // for rendering and translation between logical and visual data. |
| 210 class GFX_EXPORT RenderText { | 210 class GFX_EXPORT RenderText { |
| 211 public: | 211 public: |
| 212 #if defined(OS_MACOSX) | 212 #if defined(OS_MACOSX) |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 // Lines computed by EnsureLayout. These should be invalidated upon | 883 // Lines computed by EnsureLayout. These should be invalidated upon |
| 884 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 884 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
| 885 std::vector<internal::Line> lines_; | 885 std::vector<internal::Line> lines_; |
| 886 | 886 |
| 887 DISALLOW_COPY_AND_ASSIGN(RenderText); | 887 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 888 }; | 888 }; |
| 889 | 889 |
| 890 } // namespace gfx | 890 } // namespace gfx |
| 891 | 891 |
| 892 #endif // UI_GFX_RENDER_TEXT_H_ | 892 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |