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/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
19 #include "base/i18n/rtl.h" | 19 #include "base/i18n/rtl.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
22 #include "third_party/skia/include/core/SkColor.h" | 22 #include "third_party/skia/include/core/SkColor.h" |
23 #include "third_party/skia/include/core/SkPaint.h" | 23 #include "third_party/skia/include/core/SkPaint.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" |
(...skipping 18 matching lines...) Expand all Loading... |
52 | 53 |
53 // Internal helper class used by derived classes to draw text through Skia. | 54 // Internal helper class used by derived classes to draw text through Skia. |
54 class GFX_EXPORT SkiaTextRenderer { | 55 class GFX_EXPORT SkiaTextRenderer { |
55 public: | 56 public: |
56 explicit SkiaTextRenderer(Canvas* canvas); | 57 explicit SkiaTextRenderer(Canvas* canvas); |
57 virtual ~SkiaTextRenderer(); | 58 virtual ~SkiaTextRenderer(); |
58 | 59 |
59 void SetDrawLooper(sk_sp<SkDrawLooper> draw_looper); | 60 void SetDrawLooper(sk_sp<SkDrawLooper> draw_looper); |
60 void SetFontRenderParams(const FontRenderParams& params, | 61 void SetFontRenderParams(const FontRenderParams& params, |
61 bool subpixel_rendering_suppressed); | 62 bool subpixel_rendering_suppressed); |
62 void SetTypeface(SkTypeface* typeface); | 63 void SetTypeface(sk_sp<SkTypeface> typeface); |
63 void SetTextSize(SkScalar size); | 64 void SetTextSize(SkScalar size); |
64 void SetForegroundColor(SkColor foreground); | 65 void SetForegroundColor(SkColor foreground); |
65 void SetShader(sk_sp<SkShader> shader); | 66 void SetShader(sk_sp<SkShader> shader); |
66 // Sets underline metrics to use if the text will be drawn with an underline. | 67 // Sets underline metrics to use if the text will be drawn with an underline. |
67 // If not set, default values based on the size of the text will be used. The | 68 // If not set, default values based on the size of the text will be used. The |
68 // two metrics must be set together. | 69 // two metrics must be set together. |
69 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); | 70 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); |
70 void DrawSelection(const std::vector<Rect>& selection, SkColor color); | 71 void DrawSelection(const std::vector<Rect>& selection, SkColor color); |
71 virtual void DrawPosText(const SkPoint* pos, | 72 virtual void DrawPosText(const SkPoint* pos, |
72 const uint16_t* glyphs, | 73 const uint16_t* glyphs, |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 // Lines computed by EnsureLayout. These should be invalidated upon | 846 // Lines computed by EnsureLayout. These should be invalidated upon |
846 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 847 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
847 std::vector<internal::Line> lines_; | 848 std::vector<internal::Line> lines_; |
848 | 849 |
849 DISALLOW_COPY_AND_ASSIGN(RenderText); | 850 DISALLOW_COPY_AND_ASSIGN(RenderText); |
850 }; | 851 }; |
851 | 852 |
852 } // namespace gfx | 853 } // namespace gfx |
853 | 854 |
854 #endif // UI_GFX_RENDER_TEXT_H_ | 855 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |