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 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <cstring> | 12 #include <cstring> |
13 #include <memory> | 13 #include <memory> |
14 #include <string> | 14 #include <string> |
15 #include <utility> | 15 #include <utility> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/i18n/rtl.h" | 18 #include "base/i18n/rtl.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 21 #include "cc/paint/paint_canvas.h" |
| 22 #include "cc/paint/paint_flags.h" |
21 #include "third_party/skia/include/core/SkColor.h" | 23 #include "third_party/skia/include/core/SkColor.h" |
22 #include "third_party/skia/include/core/SkPaint.h" | |
23 #include "third_party/skia/include/core/SkRefCnt.h" | 24 #include "third_party/skia/include/core/SkRefCnt.h" |
24 #include "ui/gfx/break_list.h" | 25 #include "ui/gfx/break_list.h" |
25 #include "ui/gfx/font_list.h" | 26 #include "ui/gfx/font_list.h" |
26 #include "ui/gfx/font_render_params.h" | 27 #include "ui/gfx/font_render_params.h" |
27 #include "ui/gfx/geometry/point.h" | 28 #include "ui/gfx/geometry/point.h" |
28 #include "ui/gfx/geometry/rect.h" | 29 #include "ui/gfx/geometry/rect.h" |
29 #include "ui/gfx/geometry/size_f.h" | 30 #include "ui/gfx/geometry/size_f.h" |
30 #include "ui/gfx/geometry/vector2d.h" | 31 #include "ui/gfx/geometry/vector2d.h" |
31 #include "ui/gfx/range/range.h" | 32 #include "ui/gfx/range/range.h" |
32 #include "ui/gfx/range/range_f.h" | 33 #include "ui/gfx/range/range_f.h" |
33 #include "ui/gfx/selection_model.h" | 34 #include "ui/gfx/selection_model.h" |
34 #include "ui/gfx/shadow_value.h" | 35 #include "ui/gfx/shadow_value.h" |
35 #include "ui/gfx/text_constants.h" | 36 #include "ui/gfx/text_constants.h" |
36 | 37 |
37 class SkCanvas; | |
38 class SkDrawLooper; | 38 class SkDrawLooper; |
39 struct SkPoint; | 39 struct SkPoint; |
40 class SkShader; | 40 class SkShader; |
41 class SkTypeface; | 41 class SkTypeface; |
42 | 42 |
43 namespace gfx { | 43 namespace gfx { |
44 namespace test { | 44 namespace test { |
45 class RenderTextTestApi; | 45 class RenderTextTestApi; |
46 } | 46 } |
47 | 47 |
(...skipping 35 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 SkPaint& paint); | 93 DiagonalStrike(Canvas* canvas, Point start, const cc::PaintFlags& paint); |
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 SkPaint paint_; | 104 cc::PaintFlags paint_; |
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 SkCanvas* canvas_skia_; | 112 cc::PaintCanvas* canvas_skia_; |
113 SkPaint paint_; | 113 cc::PaintFlags paint_; |
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 a Skia |paint|. |
200 void ApplyRenderParams(const FontRenderParams& params, | 200 void ApplyRenderParams(const FontRenderParams& params, |
201 bool subpixel_rendering_suppressed, | 201 bool subpixel_rendering_suppressed, |
202 SkPaint* paint); | 202 cc::PaintFlags* paint); |
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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 // Lines computed by EnsureLayout. These should be invalidated upon | 875 // Lines computed by EnsureLayout. These should be invalidated upon |
876 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 876 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
877 std::vector<internal::Line> lines_; | 877 std::vector<internal::Line> lines_; |
878 | 878 |
879 DISALLOW_COPY_AND_ASSIGN(RenderText); | 879 DISALLOW_COPY_AND_ASSIGN(RenderText); |
880 }; | 880 }; |
881 | 881 |
882 } // namespace gfx | 882 } // namespace gfx |
883 | 883 |
884 #endif // UI_GFX_RENDER_TEXT_H_ | 884 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |