Chromium Code Reviews| Index: ui/gfx/canvas.h |
| diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h |
| index 8baa45c11e32f7a9b8a167bf5dd9268b7169beb5..be17344e368d765174154adf6430e549e77c5fbe 100644 |
| --- a/ui/gfx/canvas.h |
| +++ b/ui/gfx/canvas.h |
| @@ -20,6 +20,7 @@ namespace gfx { |
| class Rect; |
| class Font; |
| +class FontList; |
| class Point; |
| class Size; |
| class Transform; |
| @@ -121,19 +122,30 @@ class UI_EXPORT Canvas { |
| ui::ScaleFactor scale_factor, |
| bool is_opaque); |
| - // Compute the size required to draw some text with the provided font. |
| + // Compute the size required to draw some text with the provided fonts. |
| // Attempts to fit the text with the provided width and height. Increases |
| // height and then width as needed to make the text fit. This method |
| // supports multiple lines. On Skia only a line_height can be specified and |
| // specifying a 0 value for it will cause the default height to be used. |
| static void SizeStringInt(const base::string16& text, |
| + const gfx::FontList& font_list, |
| + int* width, |
| + int* height, |
| + int line_height, |
| + int flags); |
| + // Obsolete version. Use the above version which takes gfx::FontList. |
| + static void SizeStringInt(const base::string16& text, |
|
msw
2013/08/13 17:39:22
Ditto to my overloading comment throughout this fi
Yuki
2013/08/14 15:42:16
Please allow me to overload for a while.
As I'll r
|
| const gfx::Font& font, |
| - int* width, int* height, |
| + int* width, |
| + int* height, |
| int line_height, |
| int flags); |
| // Returns the number of horizontal pixels needed to display the specified |
| - // |text| with |font|. |
| + // |text| with |font_list|. |
| + static int GetStringWidth(const base::string16& text, |
| + const gfx::FontList& font_list); |
| + // Obsolete version. Use the above version which takes gfx::FontList. |
| static int GetStringWidth(const base::string16& text, const gfx::Font& font); |
| // Returns the default text alignment to be used when drawing text on a |
| @@ -146,7 +158,7 @@ class UI_EXPORT Canvas { |
| static int DefaultCanvasTextAlignment(); |
| // Draws text with a 1-pixel halo around it of the given color. |
| - // On Windows, it allows ClearType to be drawn to an otherwise transparenct |
| + // On Windows, it allows ClearType to be drawn to an otherwise transparent |
| // bitmap for drag images. Drag images have only 1-bit of transparency, so |
| // we don't do any fancy blurring. |
| // On Linux, text with halo is created by stroking it with 2px |halo_color| |
| @@ -155,10 +167,20 @@ class UI_EXPORT Canvas { |
| // TODO(dhollowa): Skia-native implementation is underway. Cut over to |
| // that when ready. http::/crbug.com/109946 |
| void DrawStringWithHalo(const base::string16& text, |
| + const gfx::FontList& font_list, |
| + SkColor text_color, |
| + SkColor halo_color, |
| + const gfx::Rect& display_rect, |
| + int flags); |
| + // Obsolete version. Use the above version which takes gfx::FontList. |
| + void DrawStringWithHalo(const base::string16& text, |
| const gfx::Font& font, |
| SkColor text_color, |
| SkColor halo_color, |
| - int x, int y, int w, int h, |
| + int x, |
| + int y, |
| + int w, |
| + int h, |
| int flags); |
| // Extracts an ImageSkiaRep from the contents of this canvas. |
| @@ -267,7 +289,8 @@ class UI_EXPORT Canvas { |
| // Parameters are specified relative to current canvas scale not in pixels. |
| // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. |
| void DrawImageInt(const gfx::ImageSkia& image, |
| - int x, int y, |
| + int x, |
| + int y, |
| const SkPaint& paint); |
| // Draws a portion of an image in the specified location. The src parameters |
| @@ -283,12 +306,24 @@ class UI_EXPORT Canvas { |
| // Parameters are specified relative to current canvas scale not in pixels. |
| // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. |
| void DrawImageInt(const gfx::ImageSkia& image, |
| - int src_x, int src_y, int src_w, int src_h, |
| - int dest_x, int dest_y, int dest_w, int dest_h, |
| + int src_x, |
| + int src_y, |
| + int src_w, |
| + int src_h, |
| + int dest_x, |
| + int dest_y, |
| + int dest_w, |
| + int dest_h, |
| bool filter); |
| void DrawImageInt(const gfx::ImageSkia& image, |
| - int src_x, int src_y, int src_w, int src_h, |
| - int dest_x, int dest_y, int dest_w, int dest_h, |
| + int src_x, |
| + int src_y, |
| + int src_w, |
| + int src_h, |
| + int dest_x, |
| + int dest_y, |
| + int dest_w, |
| + int dest_h, |
| bool filter, |
| const SkPaint& paint); |
| @@ -302,31 +337,56 @@ class UI_EXPORT Canvas { |
| const SkPath& path, |
| const SkPaint& paint); |
| - // Draws text with the specified color, font and location. The text is |
| + // Draws text with the specified color, fonts and location. The text is |
| // aligned to the left, vertically centered, clipped to the region. If the |
| // text is too big, it is truncated and '...' is added to the end. |
| + void DrawString(const base::string16& text, |
| + const gfx::FontList& font_list, |
| + SkColor color, |
| + const gfx::Rect& display_rect); |
| + // Obsolete versions. Use the above versions which take gfx::FontList. |
| void DrawStringInt(const base::string16& text, |
| const gfx::Font& font, |
| SkColor color, |
| - int x, int y, int w, int h); |
| + int x, |
| + int y, |
| + int w, |
| + int h); |
| void DrawStringInt(const base::string16& text, |
| const gfx::Font& font, |
| SkColor color, |
| const gfx::Rect& display_rect); |
| - // Draws text with the specified color, font and location. The last argument |
| + // Draws text with the specified color, fonts and location. The last argument |
| // specifies flags for how the text should be rendered. It can be one of |
| // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT. |
| + void DrawStringWithFlags(const base::string16& text, |
| + const gfx::FontList& font_list, |
| + SkColor color, |
| + const gfx::Rect& display_rect, |
| + int flags); |
| + // Obsolete version. Use the above version which takes gfx::FontList. |
| void DrawStringInt(const base::string16& text, |
| const gfx::Font& font, |
| SkColor color, |
| - int x, int y, int w, int h, |
| + int x, |
| + int y, |
| + int w, |
| + int h, |
| int flags); |
| // Similar to above DrawStringInt method but with text shadows support. |
| // Currently it's only implemented for canvas skia. Specifying a 0 line_height |
| // will cause the default height to be used. |
| void DrawStringWithShadows(const base::string16& text, |
| + const gfx::FontList& font_list, |
| + SkColor color, |
| + const gfx::Rect& text_bounds, |
| + int line_height, |
| + int flags, |
| + const ShadowValues& shadows); |
| + // Obsolete version. Use the above version which takes gfx::FontList. |
| + void DrawStringWithShadows(const base::string16& text, |
| const gfx::Font& font, |
| SkColor color, |
| const gfx::Rect& text_bounds, |
| @@ -341,14 +401,26 @@ class UI_EXPORT Canvas { |
| // Parameters are specified relative to current canvas scale not in pixels. |
| // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. |
| void TileImageInt(const gfx::ImageSkia& image, |
| - int x, int y, int w, int h); |
| + int x, |
| + int y, |
| + int w, |
| + int h); |
| void TileImageInt(const gfx::ImageSkia& image, |
| - int src_x, int src_y, |
| - int dest_x, int dest_y, int w, int h); |
| + int src_x, |
| + int src_y, |
| + int dest_x, |
| + int dest_y, |
| + int w, |
| + int h); |
| void TileImageInt(const gfx::ImageSkia& image, |
| - int src_x, int src_y, |
| - float tile_scale_x, float tile_scale_y, |
| - int dest_x, int dest_y, int w, int h); |
| + int src_x, |
| + int src_y, |
| + float tile_scale_x, |
| + float tile_scale_y, |
| + int dest_x, |
| + int dest_y, |
| + int w, |
| + int h); |
| // Returns a native drawing context for platform specific drawing routines to |
| // use. Must be balanced by a call to EndPlatformPaint(). |
| @@ -369,6 +441,14 @@ class UI_EXPORT Canvas { |
| const base::string16& text, |
| TruncateFadeMode truncate_mode, |
| size_t desired_characters_to_truncate_from_head, |
| + const gfx::FontList& font_list, |
| + SkColor color, |
| + const gfx::Rect& display_rect); |
| + // Obsolete version. Use the above version which takes gfx::FontList. |
| + void DrawFadeTruncatingString( |
| + const base::string16& text, |
| + TruncateFadeMode truncate_mode, |
| + size_t desired_characters_to_truncate_from_head, |
| const gfx::Font& font, |
| SkColor color, |
| const gfx::Rect& display_rect); |