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

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

Issue 660953002: Type conversion fixes, text rendering edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 6 years, 2 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_skia.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 #include "ui/gfx/canvas.h" 5 #include "ui/gfx/canvas.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 canvas_->scale(scale_scalar, scale_scalar); 85 canvas_->scale(scale_scalar, scale_scalar);
86 } 86 }
87 87
88 // static 88 // static
89 void Canvas::SizeStringInt(const base::string16& text, 89 void Canvas::SizeStringInt(const base::string16& text,
90 const FontList& font_list, 90 const FontList& font_list,
91 int* width, 91 int* width,
92 int* height, 92 int* height,
93 int line_height, 93 int line_height,
94 int flags) { 94 int flags) {
95 float fractional_width = *width; 95 float fractional_width = static_cast<float>(*width);
96 float factional_height = *height; 96 float factional_height = static_cast<float>(*height);
97 SizeStringFloat(text, font_list, &fractional_width, 97 SizeStringFloat(text, font_list, &fractional_width,
98 &factional_height, line_height, flags); 98 &factional_height, line_height, flags);
99 *width = std::ceil(fractional_width); 99 *width = ToCeiledInt(fractional_width);
100 *height = std::ceil(factional_height); 100 *height = ToCeiledInt(factional_height);
101 } 101 }
102 102
103 // static 103 // static
104 int Canvas::GetStringWidth(const base::string16& text, 104 int Canvas::GetStringWidth(const base::string16& text,
105 const FontList& font_list) { 105 const FontList& font_list) {
106 int width = 0, height = 0; 106 int width = 0, height = 0;
107 SizeStringInt(text, font_list, &width, &height, 0, NO_ELLIPSIS); 107 SizeStringInt(text, font_list, &width, &height, 0, NO_ELLIPSIS);
108 return width; 108 return width;
109 } 109 }
110 110
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 SkPaint p(paint); 634 SkPaint p(paint);
635 p.setFilterLevel(filter ? SkPaint::kLow_FilterLevel 635 p.setFilterLevel(filter ? SkPaint::kLow_FilterLevel
636 : SkPaint::kNone_FilterLevel); 636 : SkPaint::kNone_FilterLevel);
637 p.setShader(shader.get()); 637 p.setShader(shader.get());
638 638
639 // The rect will be filled by the bitmap. 639 // The rect will be filled by the bitmap.
640 canvas_->drawRect(dest_rect, p); 640 canvas_->drawRect(dest_rect, p);
641 } 641 }
642 642
643 } // namespace gfx 643 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/canvas_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698