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

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

Issue 16051006: ui/gfx: Use base::string16 now that string16 was moved into base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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/canvas.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_CANVAS_H_ 5 #ifndef UI_GFX_CANVAS_H_
6 #define UI_GFX_CANVAS_H_ 6 #define UI_GFX_CANVAS_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // this method can be private. 119 // this method can be private.
120 void RecreateBackingCanvas(const gfx::Size& size, 120 void RecreateBackingCanvas(const gfx::Size& size,
121 ui::ScaleFactor scale_factor, 121 ui::ScaleFactor scale_factor,
122 bool is_opaque); 122 bool is_opaque);
123 123
124 // Compute the size required to draw some text with the provided font. 124 // Compute the size required to draw some text with the provided font.
125 // Attempts to fit the text with the provided width and height. Increases 125 // Attempts to fit the text with the provided width and height. Increases
126 // height and then width as needed to make the text fit. This method 126 // height and then width as needed to make the text fit. This method
127 // supports multiple lines. On Skia only a line_height can be specified and 127 // supports multiple lines. On Skia only a line_height can be specified and
128 // specifying a 0 value for it will cause the default height to be used. 128 // specifying a 0 value for it will cause the default height to be used.
129 static void SizeStringInt(const string16& text, 129 static void SizeStringInt(const base::string16& text,
130 const gfx::Font& font, 130 const gfx::Font& font,
131 int* width, int* height, 131 int* width, int* height,
132 int line_height, 132 int line_height,
133 int flags); 133 int flags);
134 134
135 // Returns the number of horizontal pixels needed to display the specified 135 // Returns the number of horizontal pixels needed to display the specified
136 // |text| with |font|. 136 // |text| with |font|.
137 static int GetStringWidth(const string16& text, const gfx::Font& font); 137 static int GetStringWidth(const base::string16& text, const gfx::Font& font);
138 138
139 // Returns the default text alignment to be used when drawing text on a 139 // Returns the default text alignment to be used when drawing text on a
140 // gfx::Canvas based on the directionality of the system locale language. 140 // gfx::Canvas based on the directionality of the system locale language.
141 // This function is used by gfx::Canvas::DrawStringInt when the text alignment 141 // This function is used by gfx::Canvas::DrawStringInt when the text alignment
142 // is not specified. 142 // is not specified.
143 // 143 //
144 // This function returns either gfx::Canvas::TEXT_ALIGN_LEFT or 144 // This function returns either gfx::Canvas::TEXT_ALIGN_LEFT or
145 // gfx::Canvas::TEXT_ALIGN_RIGHT. 145 // gfx::Canvas::TEXT_ALIGN_RIGHT.
146 static int DefaultCanvasTextAlignment(); 146 static int DefaultCanvasTextAlignment();
147 147
148 // Draws text with a 1-pixel halo around it of the given color. 148 // Draws text with a 1-pixel halo around it of the given color.
149 // On Windows, it allows ClearType to be drawn to an otherwise transparenct 149 // On Windows, it allows ClearType to be drawn to an otherwise transparenct
150 // bitmap for drag images. Drag images have only 1-bit of transparency, so 150 // bitmap for drag images. Drag images have only 1-bit of transparency, so
151 // we don't do any fancy blurring. 151 // we don't do any fancy blurring.
152 // On Linux, text with halo is created by stroking it with 2px |halo_color| 152 // On Linux, text with halo is created by stroking it with 2px |halo_color|
153 // then filling it with |text_color|. 153 // then filling it with |text_color|.
154 // On Mac, NOTIMPLEMENTED. 154 // On Mac, NOTIMPLEMENTED.
155 // TODO(dhollowa): Skia-native implementation is underway. Cut over to 155 // TODO(dhollowa): Skia-native implementation is underway. Cut over to
156 // that when ready. http::/crbug.com/109946 156 // that when ready. http::/crbug.com/109946
157 void DrawStringWithHalo(const string16& text, 157 void DrawStringWithHalo(const base::string16& text,
158 const gfx::Font& font, 158 const gfx::Font& font,
159 SkColor text_color, 159 SkColor text_color,
160 SkColor halo_color, 160 SkColor halo_color,
161 int x, int y, int w, int h, 161 int x, int y, int w, int h,
162 int flags); 162 int flags);
163 163
164 // Extracts an ImageSkiaRep from the contents of this canvas. 164 // Extracts an ImageSkiaRep from the contents of this canvas.
165 gfx::ImageSkiaRep ExtractImageRep() const; 165 gfx::ImageSkiaRep ExtractImageRep() const;
166 166
167 // Draws a dashed rectangle of the specified color. 167 // Draws a dashed rectangle of the specified color.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // Thus, x is 2 pixels if canvas scale = 2 & |x| = 1. 298 // Thus, x is 2 pixels if canvas scale = 2 & |x| = 1.
299 void DrawImageInPath(const gfx::ImageSkia& image, 299 void DrawImageInPath(const gfx::ImageSkia& image,
300 int x, 300 int x,
301 int y, 301 int y,
302 const SkPath& path, 302 const SkPath& path,
303 const SkPaint& paint); 303 const SkPaint& paint);
304 304
305 // Draws text with the specified color, font and location. The text is 305 // Draws text with the specified color, font and location. The text is
306 // aligned to the left, vertically centered, clipped to the region. If the 306 // aligned to the left, vertically centered, clipped to the region. If the
307 // text is too big, it is truncated and '...' is added to the end. 307 // text is too big, it is truncated and '...' is added to the end.
308 void DrawStringInt(const string16& text, 308 void DrawStringInt(const base::string16& text,
309 const gfx::Font& font, 309 const gfx::Font& font,
310 SkColor color, 310 SkColor color,
311 int x, int y, int w, int h); 311 int x, int y, int w, int h);
312 void DrawStringInt(const string16& text, 312 void DrawStringInt(const base::string16& text,
313 const gfx::Font& font, 313 const gfx::Font& font,
314 SkColor color, 314 SkColor color,
315 const gfx::Rect& display_rect); 315 const gfx::Rect& display_rect);
316 316
317 // Draws text with the specified color, font and location. The last argument 317 // Draws text with the specified color, font and location. The last argument
318 // specifies flags for how the text should be rendered. It can be one of 318 // specifies flags for how the text should be rendered. It can be one of
319 // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT. 319 // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT.
320 void DrawStringInt(const string16& text, 320 void DrawStringInt(const base::string16& text,
321 const gfx::Font& font, 321 const gfx::Font& font,
322 SkColor color, 322 SkColor color,
323 int x, int y, int w, int h, 323 int x, int y, int w, int h,
324 int flags); 324 int flags);
325 325
326 // Similar to above DrawStringInt method but with text shadows support. 326 // Similar to above DrawStringInt method but with text shadows support.
327 // Currently it's only implemented for canvas skia. Specifying a 0 line_height 327 // Currently it's only implemented for canvas skia. Specifying a 0 line_height
328 // will cause the default height to be used. 328 // will cause the default height to be used.
329 void DrawStringWithShadows(const string16& text, 329 void DrawStringWithShadows(const base::string16& text,
330 const gfx::Font& font, 330 const gfx::Font& font,
331 SkColor color, 331 SkColor color,
332 const gfx::Rect& text_bounds, 332 const gfx::Rect& text_bounds,
333 int line_height, 333 int line_height,
334 int flags, 334 int flags,
335 const ShadowValues& shadows); 335 const ShadowValues& shadows);
336 336
337 // Draws a dotted gray rectangle used for focus purposes. 337 // Draws a dotted gray rectangle used for focus purposes.
338 void DrawFocusRect(const gfx::Rect& rect); 338 void DrawFocusRect(const gfx::Rect& rect);
339 339
(...skipping 19 matching lines...) Expand all
359 void EndPlatformPaint(); 359 void EndPlatformPaint();
360 360
361 // Apply transformation on the canvas. 361 // Apply transformation on the canvas.
362 void Transform(const gfx::Transform& transform); 362 void Transform(const gfx::Transform& transform);
363 363
364 // Draws the given string with the beginning and/or the end using a fade 364 // Draws the given string with the beginning and/or the end using a fade
365 // gradient. When truncating the head 365 // gradient. When truncating the head
366 // |desired_characters_to_truncate_from_head| specifies the maximum number of 366 // |desired_characters_to_truncate_from_head| specifies the maximum number of
367 // characters that can be truncated. 367 // characters that can be truncated.
368 void DrawFadeTruncatingString( 368 void DrawFadeTruncatingString(
369 const string16& text, 369 const base::string16& text,
370 TruncateFadeMode truncate_mode, 370 TruncateFadeMode truncate_mode,
371 size_t desired_characters_to_truncate_from_head, 371 size_t desired_characters_to_truncate_from_head,
372 const gfx::Font& font, 372 const gfx::Font& font,
373 SkColor color, 373 SkColor color,
374 const gfx::Rect& display_rect); 374 const gfx::Rect& display_rect);
375 375
376 skia::PlatformCanvas* platform_canvas() const { return owned_canvas_.get(); } 376 skia::PlatformCanvas* platform_canvas() const { return owned_canvas_.get(); }
377 SkCanvas* sk_canvas() const { return canvas_; } 377 SkCanvas* sk_canvas() const { return canvas_; }
378 ui::ScaleFactor scale_factor() const { return scale_factor_; } 378 ui::ScaleFactor scale_factor() const { return scale_factor_; }
379 379
(...skipping 23 matching lines...) Expand all
403 403
404 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; 404 skia::RefPtr<skia::PlatformCanvas> owned_canvas_;
405 SkCanvas* canvas_; 405 SkCanvas* canvas_;
406 406
407 DISALLOW_COPY_AND_ASSIGN(Canvas); 407 DISALLOW_COPY_AND_ASSIGN(Canvas);
408 }; 408 };
409 409
410 } // namespace gfx 410 } // namespace gfx
411 411
412 #endif // UI_GFX_CANVAS_H_ 412 #endif // UI_GFX_CANVAS_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698