| OLD | NEW |
| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // canvas after having initialized the canvas. | 117 // canvas after having initialized the canvas. |
| 118 // TODO(pkotwicz): Push the scale factor into skia::PlatformCanvas such that | 118 // TODO(pkotwicz): Push the scale factor into skia::PlatformCanvas such that |
| 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. | 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 static void SizeStringInt(const string16& text, | 129 static void SizeStringInt(const string16& text, |
| 129 const gfx::Font& font, | 130 const gfx::Font& font, |
| 130 int* width, int* height, | 131 int* width, int* height, |
| 132 int line_height, |
| 131 int flags); | 133 int flags); |
| 132 | 134 |
| 133 // Returns the number of horizontal pixels needed to display the specified | 135 // Returns the number of horizontal pixels needed to display the specified |
| 134 // |text| with |font|. | 136 // |text| with |font|. |
| 135 static int GetStringWidth(const string16& text, const gfx::Font& font); | 137 static int GetStringWidth(const string16& text, const gfx::Font& font); |
| 136 | 138 |
| 137 // 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 |
| 138 // gfx::Canvas based on the directionality of the system locale language. | 140 // gfx::Canvas based on the directionality of the system locale language. |
| 139 // 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 |
| 140 // is not specified. | 142 // is not specified. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // 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 |
| 316 // 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 |
| 317 // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT. | 319 // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT. |
| 318 void DrawStringInt(const string16& text, | 320 void DrawStringInt(const string16& text, |
| 319 const gfx::Font& font, | 321 const gfx::Font& font, |
| 320 SkColor color, | 322 SkColor color, |
| 321 int x, int y, int w, int h, | 323 int x, int y, int w, int h, |
| 322 int flags); | 324 int flags); |
| 323 | 325 |
| 324 // Similar to above DrawStringInt method but with text shadows support. | 326 // Similar to above DrawStringInt method but with text shadows support. |
| 325 // Currently it's only implemented for canvas skia. | 327 // Currently it's only implemented for canvas skia. Specifying a 0 line_height |
| 328 // will cause the default height to be used. |
| 326 void DrawStringWithShadows(const string16& text, | 329 void DrawStringWithShadows(const string16& text, |
| 327 const gfx::Font& font, | 330 const gfx::Font& font, |
| 328 SkColor color, | 331 SkColor color, |
| 329 const gfx::Rect& text_bounds, | 332 const gfx::Rect& text_bounds, |
| 333 int line_height, |
| 330 int flags, | 334 int flags, |
| 331 const ShadowValues& shadows); | 335 const ShadowValues& shadows); |
| 332 | 336 |
| 333 // Draws a dotted gray rectangle used for focus purposes. | 337 // Draws a dotted gray rectangle used for focus purposes. |
| 334 void DrawFocusRect(const gfx::Rect& rect); | 338 void DrawFocusRect(const gfx::Rect& rect); |
| 335 | 339 |
| 336 // Tiles the image in the specified region. | 340 // Tiles the image in the specified region. |
| 337 // Parameters are specified relative to current canvas scale not in pixels. | 341 // Parameters are specified relative to current canvas scale not in pixels. |
| 338 // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. | 342 // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. |
| 339 void TileImageInt(const gfx::ImageSkia& image, | 343 void TileImageInt(const gfx::ImageSkia& image, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 403 |
| 400 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; | 404 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; |
| 401 SkCanvas* canvas_; | 405 SkCanvas* canvas_; |
| 402 | 406 |
| 403 DISALLOW_COPY_AND_ASSIGN(Canvas); | 407 DISALLOW_COPY_AND_ASSIGN(Canvas); |
| 404 }; | 408 }; |
| 405 | 409 |
| 406 } // namespace gfx | 410 } // namespace gfx |
| 407 | 411 |
| 408 #endif // UI_GFX_CANVAS_H_ | 412 #endif // UI_GFX_CANVAS_H_ |
| OLD | NEW |