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

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: fixes Created 4 years, 7 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 explicit SkiaTextRenderer(Canvas* canvas); 56 explicit SkiaTextRenderer(Canvas* canvas);
57 virtual ~SkiaTextRenderer(); 57 virtual ~SkiaTextRenderer();
58 58
59 void SetDrawLooper(sk_sp<SkDrawLooper> draw_looper); 59 void SetDrawLooper(sk_sp<SkDrawLooper> draw_looper);
60 void SetFontRenderParams(const FontRenderParams& params, 60 void SetFontRenderParams(const FontRenderParams& params,
61 bool subpixel_rendering_suppressed); 61 bool subpixel_rendering_suppressed);
62 void SetTypeface(SkTypeface* typeface); 62 void SetTypeface(SkTypeface* typeface);
63 void SetTextSize(SkScalar size); 63 void SetTextSize(SkScalar size);
64 void SetForegroundColor(SkColor foreground); 64 void SetForegroundColor(SkColor foreground);
65 void SetShader(sk_sp<SkShader> shader); 65 void SetShader(sk_sp<SkShader> shader);
66 void SetHaloEffect();
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,
73 size_t glyph_count); 74 size_t glyph_count);
74 // Draw underline and strike-through text decorations. 75 // Draw underline and strike-through text decorations.
75 // Based on |SkCanvas::DrawTextDecorations()| and constants from: 76 // Based on |SkCanvas::DrawTextDecorations()| and constants from:
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 const Rect& display_rect() const { return display_rect_; } 305 const Rect& display_rect() const { return display_rect_; }
305 void SetDisplayRect(const Rect& r); 306 void SetDisplayRect(const Rect& r);
306 307
307 bool subpixel_rendering_suppressed() const { 308 bool subpixel_rendering_suppressed() const {
308 return subpixel_rendering_suppressed_; 309 return subpixel_rendering_suppressed_;
309 } 310 }
310 void set_subpixel_rendering_suppressed(bool suppressed) { 311 void set_subpixel_rendering_suppressed(bool suppressed) {
311 subpixel_rendering_suppressed_ = suppressed; 312 subpixel_rendering_suppressed_ = suppressed;
312 } 313 }
313 314
315 bool halo_effect() const { return halo_effect_; }
316 void set_halo_effect(bool halo_effect) { halo_effect_ = halo_effect; }
317
314 const SelectionModel& selection_model() const { return selection_model_; } 318 const SelectionModel& selection_model() const { return selection_model_; }
315 319
316 const Range& selection() const { return selection_model_.selection(); } 320 const Range& selection() const { return selection_model_.selection(); }
317 321
318 size_t cursor_position() const { return selection_model_.caret_pos(); } 322 size_t cursor_position() const { return selection_model_.caret_pos(); }
319 void SetCursorPosition(size_t position); 323 void SetCursorPosition(size_t position);
320 324
321 // Moves the cursor left or right. Cursor movement is visual, meaning that 325 // Moves the cursor left or right. Cursor movement is visual, meaning that
322 // left and right are relative to screen, not the directionality of the text. 326 // left and right are relative to screen, not the directionality of the text.
323 // If |select| is false, the selection start is moved to the same position. 327 // If |select| is false, the selection start is moved to the same position.
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 // The cached bounds and offset are invalidated by changes to the cursor, 828 // The cached bounds and offset are invalidated by changes to the cursor,
825 // selection, font, and other operations that adjust the visible text bounds. 829 // selection, font, and other operations that adjust the visible text bounds.
826 bool cached_bounds_and_offset_valid_; 830 bool cached_bounds_and_offset_valid_;
827 831
828 // Text shadows to be drawn. 832 // Text shadows to be drawn.
829 ShadowValues shadows_; 833 ShadowValues shadows_;
830 834
831 // A list of valid display text line break positions. 835 // A list of valid display text line break positions.
832 BreakList<size_t> line_breaks_; 836 BreakList<size_t> line_breaks_;
833 837
838 // Draw text with 1px border.
839 bool halo_effect_ = false;
840
834 // Lines computed by EnsureLayout. These should be invalidated upon 841 // Lines computed by EnsureLayout. These should be invalidated upon
835 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. 842 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls.
836 std::vector<internal::Line> lines_; 843 std::vector<internal::Line> lines_;
837 844
838 DISALLOW_COPY_AND_ASSIGN(RenderText); 845 DISALLOW_COPY_AND_ASSIGN(RenderText);
839 }; 846 };
840 847
841 } // namespace gfx 848 } // namespace gfx
842 849
843 #endif // UI_GFX_RENDER_TEXT_H_ 850 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698