| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 int line_height, | 132 int line_height, |
| 133 int flags); | 133 int flags); |
| 134 // Obsolete version. Use the above version which takes FontList. | 134 // Obsolete version. Use the above version which takes FontList. |
| 135 static void SizeStringInt(const base::string16& text, | 135 static void SizeStringInt(const base::string16& text, |
| 136 const Font& font, | 136 const Font& font, |
| 137 int* width, | 137 int* width, |
| 138 int* height, | 138 int* height, |
| 139 int line_height, | 139 int line_height, |
| 140 int flags); | 140 int flags); |
| 141 | 141 |
| 142 // This is same as SizeStringInt except that fractional size is returned. |
| 143 // See comment in GetStringWidthF for its usage. |
| 144 static void SizeStringFloat(const base::string16& text, |
| 145 const FontList& font_list, |
| 146 float* width, |
| 147 float* height, |
| 148 int line_height, |
| 149 int flags); |
| 150 |
| 142 // Returns the number of horizontal pixels needed to display the specified | 151 // Returns the number of horizontal pixels needed to display the specified |
| 143 // |text| with |font_list|. | 152 // |text| with |font_list|. |
| 144 static int GetStringWidth(const base::string16& text, | 153 static int GetStringWidth(const base::string16& text, |
| 145 const FontList& font_list); | 154 const FontList& font_list); |
| 146 // Obsolete version. Use the above version which takes FontList. | 155 // Obsolete version. Use the above version which takes FontList. |
| 147 static int GetStringWidth(const base::string16& text, const Font& font); | 156 static int GetStringWidth(const base::string16& text, const Font& font); |
| 148 | 157 |
| 158 // This is same as GetStringWidth except that fractional width is returned. |
| 159 // Use this method for the scenario that multiple string widths need to be |
| 160 // summed up. This is because GetStringWidth returns the ceiled width and |
| 161 // adding multiple ceiled widths could cause more precision loss for certain |
| 162 // platform like Mac where the fractioal width is used. |
| 163 static float GetStringWidthF(const base::string16& text, |
| 164 const FontList& font_list); |
| 165 |
| 149 // Returns the default text alignment to be used when drawing text on a | 166 // Returns the default text alignment to be used when drawing text on a |
| 150 // Canvas based on the directionality of the system locale language. | 167 // Canvas based on the directionality of the system locale language. |
| 151 // This function is used by Canvas::DrawStringInt when the text alignment | 168 // This function is used by Canvas::DrawStringInt when the text alignment |
| 152 // is not specified. | 169 // is not specified. |
| 153 // | 170 // |
| 154 // This function returns either Canvas::TEXT_ALIGN_LEFT or | 171 // This function returns either Canvas::TEXT_ALIGN_LEFT or |
| 155 // Canvas::TEXT_ALIGN_RIGHT. | 172 // Canvas::TEXT_ALIGN_RIGHT. |
| 156 static int DefaultCanvasTextAlignment(); | 173 static int DefaultCanvasTextAlignment(); |
| 157 | 174 |
| 158 // Draws text with a 1-pixel halo around it of the given color. | 175 // Draws text with a 1-pixel halo around it of the given color. |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 495 |
| 479 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; | 496 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; |
| 480 SkCanvas* canvas_; | 497 SkCanvas* canvas_; |
| 481 | 498 |
| 482 DISALLOW_COPY_AND_ASSIGN(Canvas); | 499 DISALLOW_COPY_AND_ASSIGN(Canvas); |
| 483 }; | 500 }; |
| 484 | 501 |
| 485 } // namespace gfx | 502 } // namespace gfx |
| 486 | 503 |
| 487 #endif // UI_GFX_CANVAS_H_ | 504 #endif // UI_GFX_CANVAS_H_ |
| OLD | NEW |