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

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

Issue 1907833002: RenderTextMac: Cache the SkTypeface on the TextRun (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: skia::RefPtr<>(Adopt(..)) -> sk_sp<>(..) Created 4 years, 8 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 | « no previous file | 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 class GFX_EXPORT SkiaTextRenderer { 55 class GFX_EXPORT SkiaTextRenderer {
56 public: 56 public:
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(SkTypeface* typeface); 63 void SetTypeface(SkTypeface* typeface);
64 void SetTextSize(SkScalar size); 64 void SetTextSize(SkScalar size);
65 void SetFontWithStyle(const Font& font, int font_style);
66 void SetForegroundColor(SkColor foreground); 65 void SetForegroundColor(SkColor foreground);
67 void SetShader(sk_sp<SkShader> shader); 66 void SetShader(sk_sp<SkShader> shader);
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);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // The sum of segment widths and the maximum of segment heights. 178 // The sum of segment widths and the maximum of segment heights.
180 SizeF size; 179 SizeF size;
181 180
182 // Sum of preceding lines' heights. 181 // Sum of preceding lines' heights.
183 int preceding_heights; 182 int preceding_heights;
184 183
185 // Maximum baseline of all segments on this line. 184 // Maximum baseline of all segments on this line.
186 int baseline; 185 int baseline;
187 }; 186 };
188 187
189 // Creates an SkTypeface from a font and a |gfx::Font::FontStyle|.
190 // May return NULL.
191 skia::RefPtr<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, int style);
192
193 // Applies the given FontRenderParams to a Skia |paint|. 188 // Applies the given FontRenderParams to a Skia |paint|.
194 void ApplyRenderParams(const FontRenderParams& params, 189 void ApplyRenderParams(const FontRenderParams& params,
195 bool subpixel_rendering_suppressed, 190 bool subpixel_rendering_suppressed,
196 SkPaint* paint); 191 SkPaint* paint);
197 192
198 } // namespace internal 193 } // namespace internal
199 194
200 // RenderText represents an abstract model of styled text and its corresponding 195 // RenderText represents an abstract model of styled text and its corresponding
201 // visual layout. Support is built in for a cursor, a selection, simple styling, 196 // visual layout. Support is built in for a cursor, a selection, simple styling,
202 // complex scripts, and bi-directional text. Implementations provide mechanisms 197 // complex scripts, and bi-directional text. Implementations provide mechanisms
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 // Lines computed by EnsureLayout. These should be invalidated upon 816 // Lines computed by EnsureLayout. These should be invalidated upon
822 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. 817 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls.
823 std::vector<internal::Line> lines_; 818 std::vector<internal::Line> lines_;
824 819
825 DISALLOW_COPY_AND_ASSIGN(RenderText); 820 DISALLOW_COPY_AND_ASSIGN(RenderText);
826 }; 821 };
827 822
828 } // namespace gfx 823 } // namespace gfx
829 824
830 #endif // UI_GFX_RENDER_TEXT_H_ 825 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698