| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // Internal helper class used by derived classes to draw text through Skia. | 42 // Internal helper class used by derived classes to draw text through Skia. |
| 43 class SkiaTextRenderer { | 43 class SkiaTextRenderer { |
| 44 public: | 44 public: |
| 45 explicit SkiaTextRenderer(Canvas* canvas); | 45 explicit SkiaTextRenderer(Canvas* canvas); |
| 46 ~SkiaTextRenderer(); | 46 ~SkiaTextRenderer(); |
| 47 | 47 |
| 48 void SetDrawLooper(SkDrawLooper* draw_looper); | 48 void SetDrawLooper(SkDrawLooper* draw_looper); |
| 49 void SetFontSmoothingSettings(bool enable_smoothing, bool enable_lcd_text); | 49 void SetFontSmoothingSettings(bool enable_smoothing, bool enable_lcd_text); |
| 50 void SetTypeface(SkTypeface* typeface); | 50 void SetTypeface(SkTypeface* typeface); |
| 51 void SetTextSize(int size); | 51 void SetTextSize(SkScalar size); |
| 52 void SetFontFamilyWithStyle(const std::string& family, int font_style); | 52 void SetFontFamilyWithStyle(const std::string& family, int font_style); |
| 53 void SetForegroundColor(SkColor foreground); | 53 void SetForegroundColor(SkColor foreground); |
| 54 void SetShader(SkShader* shader, const Rect& bounds); | 54 void SetShader(SkShader* shader, const Rect& bounds); |
| 55 // Sets underline metrics to use if the text will be drawn with an underline. |
| 56 // If not set, default values based on the size of the text will be used. The |
| 57 // two metrics must be set together. |
| 58 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); |
| 55 void DrawSelection(const std::vector<Rect>& selection, SkColor color); | 59 void DrawSelection(const std::vector<Rect>& selection, SkColor color); |
| 56 void DrawPosText(const SkPoint* pos, | 60 void DrawPosText(const SkPoint* pos, |
| 57 const uint16* glyphs, | 61 const uint16* glyphs, |
| 58 size_t glyph_count); | 62 size_t glyph_count); |
| 59 void DrawDecorations(int x, int y, int width, const StyleRange& style); | 63 void DrawDecorations(int x, int y, int width, const StyleRange& style); |
| 60 | 64 |
| 61 private: | 65 private: |
| 62 SkCanvas* canvas_skia_; | 66 SkCanvas* canvas_skia_; |
| 63 bool started_drawing_; | 67 bool started_drawing_; |
| 64 SkPaint paint_; | 68 SkPaint paint_; |
| 65 SkRect bounds_; | 69 SkRect bounds_; |
| 66 SkRefPtr<SkShader> deferred_fade_shader_; | 70 SkRefPtr<SkShader> deferred_fade_shader_; |
| 71 SkScalar underline_thickness_; |
| 72 SkScalar underline_position_; |
| 67 | 73 |
| 68 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); | 74 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); |
| 69 }; | 75 }; |
| 70 | 76 |
| 71 } // namespace internal | 77 } // namespace internal |
| 72 | 78 |
| 73 // A visual style applicable to a range of text. | 79 // A visual style applicable to a range of text. |
| 74 struct UI_EXPORT StyleRange { | 80 struct UI_EXPORT StyleRange { |
| 75 StyleRange(); | 81 StyleRange(); |
| 76 | 82 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 490 |
| 485 // Text shadows to be drawn. | 491 // Text shadows to be drawn. |
| 486 ShadowValues text_shadows_; | 492 ShadowValues text_shadows_; |
| 487 | 493 |
| 488 DISALLOW_COPY_AND_ASSIGN(RenderText); | 494 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 489 }; | 495 }; |
| 490 | 496 |
| 491 } // namespace gfx | 497 } // namespace gfx |
| 492 | 498 |
| 493 #endif // UI_GFX_RENDER_TEXT_H_ | 499 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |