| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. |
| 128 static void SizeStringInt(const string16& text, | 128 static void SizeStringInt(const string16& text, |
| 129 const gfx::Font& font, | 129 const gfx::Font& font, |
| 130 int* width, int* height, | 130 int* width, int* height, |
| 131 int line_height, // Only on SKIA and -1 = default. |
| 131 int flags); | 132 int flags); |
| 132 | 133 |
| 133 // Returns the number of horizontal pixels needed to display the specified | 134 // Returns the number of horizontal pixels needed to display the specified |
| 134 // |text| with |font|. | 135 // |text| with |font|. |
| 135 static int GetStringWidth(const string16& text, const gfx::Font& font); | 136 static int GetStringWidth(const string16& text, const gfx::Font& font); |
| 136 | 137 |
| 137 // Returns the default text alignment to be used when drawing text on a | 138 // 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. | 139 // gfx::Canvas based on the directionality of the system locale language. |
| 139 // This function is used by gfx::Canvas::DrawStringInt when the text alignment | 140 // This function is used by gfx::Canvas::DrawStringInt when the text alignment |
| 140 // is not specified. | 141 // is not specified. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 SkColor color, | 321 SkColor color, |
| 321 int x, int y, int w, int h, | 322 int x, int y, int w, int h, |
| 322 int flags); | 323 int flags); |
| 323 | 324 |
| 324 // Similar to above DrawStringInt method but with text shadows support. | 325 // Similar to above DrawStringInt method but with text shadows support. |
| 325 // Currently it's only implemented for canvas skia. | 326 // Currently it's only implemented for canvas skia. |
| 326 void DrawStringWithShadows(const string16& text, | 327 void DrawStringWithShadows(const string16& text, |
| 327 const gfx::Font& font, | 328 const gfx::Font& font, |
| 328 SkColor color, | 329 SkColor color, |
| 329 const gfx::Rect& text_bounds, | 330 const gfx::Rect& text_bounds, |
| 331 int line_height, // Only on SKIA and -1 = default. |
| 330 int flags, | 332 int flags, |
| 331 const ShadowValues& shadows); | 333 const ShadowValues& shadows); |
| 332 | 334 |
| 333 // Draws a dotted gray rectangle used for focus purposes. | 335 // Draws a dotted gray rectangle used for focus purposes. |
| 334 void DrawFocusRect(const gfx::Rect& rect); | 336 void DrawFocusRect(const gfx::Rect& rect); |
| 335 | 337 |
| 336 // Tiles the image in the specified region. | 338 // Tiles the image in the specified region. |
| 337 // Parameters are specified relative to current canvas scale not in pixels. | 339 // Parameters are specified relative to current canvas scale not in pixels. |
| 338 // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. | 340 // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. |
| 339 void TileImageInt(const gfx::ImageSkia& image, | 341 void TileImageInt(const gfx::ImageSkia& image, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 401 |
| 400 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; | 402 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; |
| 401 SkCanvas* canvas_; | 403 SkCanvas* canvas_; |
| 402 | 404 |
| 403 DISALLOW_COPY_AND_ASSIGN(Canvas); | 405 DISALLOW_COPY_AND_ASSIGN(Canvas); |
| 404 }; | 406 }; |
| 405 | 407 |
| 406 } // namespace gfx | 408 } // namespace gfx |
| 407 | 409 |
| 408 #endif // UI_GFX_CANVAS_H_ | 410 #endif // UI_GFX_CANVAS_H_ |
| OLD | NEW |