| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 explicit SkiaTextRenderer(Canvas* canvas); | 57 explicit SkiaTextRenderer(Canvas* canvas); |
| 58 virtual ~SkiaTextRenderer(); | 58 virtual ~SkiaTextRenderer(); |
| 59 | 59 |
| 60 void SetDrawLooper(sk_sp<SkDrawLooper> draw_looper); | 60 void SetDrawLooper(sk_sp<SkDrawLooper> draw_looper); |
| 61 void SetFontRenderParams(const FontRenderParams& params, | 61 void SetFontRenderParams(const FontRenderParams& params, |
| 62 bool subpixel_rendering_suppressed); | 62 bool subpixel_rendering_suppressed); |
| 63 void SetTypeface(sk_sp<SkTypeface> typeface); | 63 void SetTypeface(sk_sp<SkTypeface> typeface); |
| 64 void SetTextSize(SkScalar size); | 64 void SetTextSize(SkScalar size); |
| 65 void SetForegroundColor(SkColor foreground); | 65 void SetForegroundColor(SkColor foreground); |
| 66 void SetShader(sk_sp<SkShader> shader); | 66 void SetShader(sk_sp<SkShader> shader); |
| 67 void SetHaloEffect(); | |
| 68 // 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. |
| 69 // 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 |
| 70 // two metrics must be set together. | 69 // two metrics must be set together. |
| 71 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); | 70 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); |
| 72 void DrawSelection(const std::vector<Rect>& selection, SkColor color); | 71 void DrawSelection(const std::vector<Rect>& selection, SkColor color); |
| 73 virtual void DrawPosText(const SkPoint* pos, | 72 virtual void DrawPosText(const SkPoint* pos, |
| 74 const uint16_t* glyphs, | 73 const uint16_t* glyphs, |
| 75 size_t glyph_count); | 74 size_t glyph_count); |
| 76 // Draw underline and strike-through text decorations. | 75 // Draw underline and strike-through text decorations. |
| 77 // Based on |SkCanvas::DrawTextDecorations()| and constants from: | 76 // Based on |SkCanvas::DrawTextDecorations()| and constants from: |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 const Rect& display_rect() const { return display_rect_; } | 321 const Rect& display_rect() const { return display_rect_; } |
| 323 void SetDisplayRect(const Rect& r); | 322 void SetDisplayRect(const Rect& r); |
| 324 | 323 |
| 325 bool subpixel_rendering_suppressed() const { | 324 bool subpixel_rendering_suppressed() const { |
| 326 return subpixel_rendering_suppressed_; | 325 return subpixel_rendering_suppressed_; |
| 327 } | 326 } |
| 328 void set_subpixel_rendering_suppressed(bool suppressed) { | 327 void set_subpixel_rendering_suppressed(bool suppressed) { |
| 329 subpixel_rendering_suppressed_ = suppressed; | 328 subpixel_rendering_suppressed_ = suppressed; |
| 330 } | 329 } |
| 331 | 330 |
| 332 bool halo_effect() const { return halo_effect_; } | |
| 333 void set_halo_effect(bool halo_effect) { halo_effect_ = halo_effect; } | |
| 334 | |
| 335 const SelectionModel& selection_model() const { return selection_model_; } | 331 const SelectionModel& selection_model() const { return selection_model_; } |
| 336 | 332 |
| 337 const Range& selection() const { return selection_model_.selection(); } | 333 const Range& selection() const { return selection_model_.selection(); } |
| 338 | 334 |
| 339 size_t cursor_position() const { return selection_model_.caret_pos(); } | 335 size_t cursor_position() const { return selection_model_.caret_pos(); } |
| 340 void SetCursorPosition(size_t position); | 336 void SetCursorPosition(size_t position); |
| 341 | 337 |
| 342 // Moves the cursor left or right. Cursor movement is visual, meaning that | 338 // Moves the cursor left or right. Cursor movement is visual, meaning that |
| 343 // left and right are relative to screen, not the directionality of the text. | 339 // left and right are relative to screen, not the directionality of the text. |
| 344 // |selection_behavior| determines whether a selection is to be made and it's | 340 // |selection_behavior| determines whether a selection is to be made and it's |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 // The cached bounds and offset are invalidated by changes to the cursor, | 858 // The cached bounds and offset are invalidated by changes to the cursor, |
| 863 // selection, font, and other operations that adjust the visible text bounds. | 859 // selection, font, and other operations that adjust the visible text bounds. |
| 864 bool cached_bounds_and_offset_valid_; | 860 bool cached_bounds_and_offset_valid_; |
| 865 | 861 |
| 866 // Text shadows to be drawn. | 862 // Text shadows to be drawn. |
| 867 ShadowValues shadows_; | 863 ShadowValues shadows_; |
| 868 | 864 |
| 869 // A list of valid display text line break positions. | 865 // A list of valid display text line break positions. |
| 870 BreakList<size_t> line_breaks_; | 866 BreakList<size_t> line_breaks_; |
| 871 | 867 |
| 872 // Draw text with 1px border. | |
| 873 bool halo_effect_ = false; | |
| 874 | |
| 875 // Lines computed by EnsureLayout. These should be invalidated upon | 868 // Lines computed by EnsureLayout. These should be invalidated upon |
| 876 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 869 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
| 877 std::vector<internal::Line> lines_; | 870 std::vector<internal::Line> lines_; |
| 878 | 871 |
| 879 DISALLOW_COPY_AND_ASSIGN(RenderText); | 872 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 880 }; | 873 }; |
| 881 | 874 |
| 882 } // namespace gfx | 875 } // namespace gfx |
| 883 | 876 |
| 884 #endif // UI_GFX_RENDER_TEXT_H_ | 877 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |