Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: ui/gfx/render_text.h

Issue 1634103003: Fix gfx::Canvas::DrawStringRectWithHalo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small fixes Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/canvas_skia.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
67 // Sets underline metrics to use if the text will be drawn with an underline. 68 // Sets underline metrics to use if the text will be drawn with an underline.
68 // If not set, default values based on the size of the text will be used. The 69 // If not set, default values based on the size of the text will be used. The
69 // two metrics must be set together. 70 // two metrics must be set together.
70 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); 71 void SetUnderlineMetrics(SkScalar thickness, SkScalar position);
71 void DrawSelection(const std::vector<Rect>& selection, SkColor color); 72 void DrawSelection(const std::vector<Rect>& selection, SkColor color);
72 virtual void DrawPosText(const SkPoint* pos, 73 virtual void DrawPosText(const SkPoint* pos,
73 const uint16_t* glyphs, 74 const uint16_t* glyphs,
74 size_t glyph_count); 75 size_t glyph_count);
75 // Draw underline and strike-through text decorations. 76 // Draw underline and strike-through text decorations.
76 // Based on |SkCanvas::DrawTextDecorations()| and constants from: 77 // Based on |SkCanvas::DrawTextDecorations()| and constants from:
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 const Rect& display_rect() const { return display_rect_; } 309 const Rect& display_rect() const { return display_rect_; }
309 void SetDisplayRect(const Rect& r); 310 void SetDisplayRect(const Rect& r);
310 311
311 bool subpixel_rendering_suppressed() const { 312 bool subpixel_rendering_suppressed() const {
312 return subpixel_rendering_suppressed_; 313 return subpixel_rendering_suppressed_;
313 } 314 }
314 void set_subpixel_rendering_suppressed(bool suppressed) { 315 void set_subpixel_rendering_suppressed(bool suppressed) {
315 subpixel_rendering_suppressed_ = suppressed; 316 subpixel_rendering_suppressed_ = suppressed;
316 } 317 }
317 318
319 bool halo_effect() const { return halo_effect_; }
320 void set_halo_effect(bool halo_effect) { halo_effect_ = halo_effect; }
321
318 const SelectionModel& selection_model() const { return selection_model_; } 322 const SelectionModel& selection_model() const { return selection_model_; }
319 323
320 const Range& selection() const { return selection_model_.selection(); } 324 const Range& selection() const { return selection_model_.selection(); }
321 325
322 size_t cursor_position() const { return selection_model_.caret_pos(); } 326 size_t cursor_position() const { return selection_model_.caret_pos(); }
323 void SetCursorPosition(size_t position); 327 void SetCursorPosition(size_t position);
324 328
325 // Moves the cursor left or right. Cursor movement is visual, meaning that 329 // Moves the cursor left or right. Cursor movement is visual, meaning that
326 // left and right are relative to screen, not the directionality of the text. 330 // left and right are relative to screen, not the directionality of the text.
327 // If |select| is false, the selection start is moved to the same position. 331 // If |select| is false, the selection start is moved to the same position.
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 // The cached bounds and offset are invalidated by changes to the cursor, 836 // The cached bounds and offset are invalidated by changes to the cursor,
833 // selection, font, and other operations that adjust the visible text bounds. 837 // selection, font, and other operations that adjust the visible text bounds.
834 bool cached_bounds_and_offset_valid_; 838 bool cached_bounds_and_offset_valid_;
835 839
836 // Text shadows to be drawn. 840 // Text shadows to be drawn.
837 ShadowValues shadows_; 841 ShadowValues shadows_;
838 842
839 // A list of valid display text line break positions. 843 // A list of valid display text line break positions.
840 BreakList<size_t> line_breaks_; 844 BreakList<size_t> line_breaks_;
841 845
846 // Draw text with 1px border.
847 bool halo_effect_ = false;
848
842 // Lines computed by EnsureLayout. These should be invalidated upon 849 // Lines computed by EnsureLayout. These should be invalidated upon
843 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. 850 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls.
844 std::vector<internal::Line> lines_; 851 std::vector<internal::Line> lines_;
845 852
846 DISALLOW_COPY_AND_ASSIGN(RenderText); 853 DISALLOW_COPY_AND_ASSIGN(RenderText);
847 }; 854 };
848 855
849 } // namespace gfx 856 } // namespace gfx
850 857
851 #endif // UI_GFX_RENDER_TEXT_H_ 858 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « ui/gfx/canvas_skia.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698