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 <algorithm> | 8 #include <algorithm> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <string> | 10 #include <string> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 namespace internal { | 46 namespace internal { |
47 | 47 |
48 // Internal helper class used by derived classes to draw text through Skia. | 48 // Internal helper class used by derived classes to draw text through Skia. |
49 class SkiaTextRenderer { | 49 class SkiaTextRenderer { |
50 public: | 50 public: |
51 explicit SkiaTextRenderer(Canvas* canvas); | 51 explicit SkiaTextRenderer(Canvas* canvas); |
52 ~SkiaTextRenderer(); | 52 ~SkiaTextRenderer(); |
53 | 53 |
54 void SetDrawLooper(SkDrawLooper* draw_looper); | 54 void SetDrawLooper(SkDrawLooper* draw_looper); |
55 void SetFontRenderParams(const FontRenderParams& params, | 55 void SetFontRenderParams(FontRenderParams params, |
56 bool background_is_transparent); | 56 bool background_is_transparent); |
57 void SetTypeface(SkTypeface* typeface); | 57 void SetTypeface(SkTypeface* typeface); |
58 void SetTextSize(SkScalar size); | 58 void SetTextSize(SkScalar size); |
59 void SetFontFamilyWithStyle(const std::string& family, int font_style); | 59 void SetFontFamilyWithStyle(const std::string& family, int font_style); |
60 void SetForegroundColor(SkColor foreground); | 60 void SetForegroundColor(SkColor foreground); |
61 void SetShader(SkShader* shader, const Rect& bounds); | 61 void SetShader(SkShader* shader, const Rect& bounds); |
62 // Sets underline metrics to use if the text will be drawn with an underline. | 62 // Sets underline metrics to use if the text will be drawn with an underline. |
63 // If not set, default values based on the size of the text will be used. The | 63 // If not set, default values based on the size of the text will be used. The |
64 // two metrics must be set together. | 64 // two metrics must be set together. |
65 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); | 65 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 // Maximum baseline of all segments on this line. | 172 // Maximum baseline of all segments on this line. |
173 int baseline; | 173 int baseline; |
174 }; | 174 }; |
175 | 175 |
176 // Creates an SkTypeface from a font |family| name and a |gfx::Font::FontStyle|. | 176 // Creates an SkTypeface from a font |family| name and a |gfx::Font::FontStyle|. |
177 // May return NULL. | 177 // May return NULL. |
178 skia::RefPtr<SkTypeface> CreateSkiaTypeface(const std::string& family, | 178 skia::RefPtr<SkTypeface> CreateSkiaTypeface(const std::string& family, |
179 int style); | 179 int style); |
180 | 180 |
| 181 // Applies the given FontRenderParams to a Skia |paint|. |
| 182 void ApplyRenderParams(const FontRenderParams& params, SkPaint* paint); |
| 183 |
181 } // namespace internal | 184 } // namespace internal |
182 | 185 |
183 // RenderText represents an abstract model of styled text and its corresponding | 186 // RenderText represents an abstract model of styled text and its corresponding |
184 // visual layout. Support is built in for a cursor, a selection, simple styling, | 187 // visual layout. Support is built in for a cursor, a selection, simple styling, |
185 // complex scripts, and bi-directional text. Implementations provide mechanisms | 188 // complex scripts, and bi-directional text. Implementations provide mechanisms |
186 // for rendering and translation between logical and visual data. | 189 // for rendering and translation between logical and visual data. |
187 class GFX_EXPORT RenderText { | 190 class GFX_EXPORT RenderText { |
188 public: | 191 public: |
189 virtual ~RenderText(); | 192 virtual ~RenderText(); |
190 | 193 |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 // Lines computed by EnsureLayout. These should be invalidated with | 724 // Lines computed by EnsureLayout. These should be invalidated with |
722 // ResetLayout and on |display_rect_| changes. | 725 // ResetLayout and on |display_rect_| changes. |
723 std::vector<internal::Line> lines_; | 726 std::vector<internal::Line> lines_; |
724 | 727 |
725 DISALLOW_COPY_AND_ASSIGN(RenderText); | 728 DISALLOW_COPY_AND_ASSIGN(RenderText); |
726 }; | 729 }; |
727 | 730 |
728 } // namespace gfx | 731 } // namespace gfx |
729 | 732 |
730 #endif // UI_GFX_RENDER_TEXT_H_ | 733 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |