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

Side by Side Diff: ui/gfx/geometry/dip_util.cc

Issue 1302233006: aura: Stop converting Rect to RectF implicitly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rectfconvert-aura: . Created 5 years, 3 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 | « ui/base/touch/selection_bound.cc ('k') | ui/views/view.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/geometry/dip_util.h" 5 #include "ui/gfx/geometry/dip_util.h"
6 6
7 #include "ui/gfx/geometry/point.h" 7 #include "ui/gfx/geometry/point.h"
8 #include "ui/gfx/geometry/point_conversions.h" 8 #include "ui/gfx/geometry/point_conversions.h"
9 #include "ui/gfx/geometry/point_f.h" 9 #include "ui/gfx/geometry/point_f.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
(...skipping 13 matching lines...) Expand all
24 const gfx::PointF& point_in_pixel) { 24 const gfx::PointF& point_in_pixel) {
25 return gfx::ScalePoint(point_in_pixel, 1.0f / scale_factor); 25 return gfx::ScalePoint(point_in_pixel, 1.0f / scale_factor);
26 } 26 }
27 27
28 gfx::Size ConvertSizeToDIP(float scale_factor, const gfx::Size& size_in_pixel) { 28 gfx::Size ConvertSizeToDIP(float scale_factor, const gfx::Size& size_in_pixel) {
29 return gfx::ToFlooredSize(gfx::ScaleSize(size_in_pixel, 1.0f / scale_factor)); 29 return gfx::ToFlooredSize(gfx::ScaleSize(size_in_pixel, 1.0f / scale_factor));
30 } 30 }
31 31
32 gfx::Rect ConvertRectToDIP(float scale_factor, const gfx::Rect& rect_in_pixel) { 32 gfx::Rect ConvertRectToDIP(float scale_factor, const gfx::Rect& rect_in_pixel) {
33 return gfx::ToFlooredRectDeprecated( 33 return gfx::ToFlooredRectDeprecated(
34 gfx::ScaleRect(rect_in_pixel, 1.0f / scale_factor)); 34 gfx::ScaleRect(gfx::RectF(rect_in_pixel), 1.0f / scale_factor));
35 } 35 }
36 36
37 gfx::Point ConvertPointToPixel(float scale_factor, 37 gfx::Point ConvertPointToPixel(float scale_factor,
38 const gfx::Point& point_in_dip) { 38 const gfx::Point& point_in_dip) {
39 return gfx::ToFlooredPoint(gfx::ScalePoint(point_in_dip, scale_factor)); 39 return gfx::ToFlooredPoint(gfx::ScalePoint(point_in_dip, scale_factor));
40 } 40 }
41 41
42 gfx::Size ConvertSizeToPixel(float scale_factor, const gfx::Size& size_in_dip) { 42 gfx::Size ConvertSizeToPixel(float scale_factor, const gfx::Size& size_in_dip) {
43 return gfx::ToFlooredSize(gfx::ScaleSize(size_in_dip, scale_factor)); 43 return gfx::ToFlooredSize(gfx::ScaleSize(size_in_dip, scale_factor));
44 } 44 }
45 45
46 gfx::Rect ConvertRectToPixel(float scale_factor, const gfx::Rect& rect_in_dip) { 46 gfx::Rect ConvertRectToPixel(float scale_factor, const gfx::Rect& rect_in_dip) {
47 // Use ToEnclosingRect() to ensure we paint all the possible pixels 47 // Use ToEnclosingRect() to ensure we paint all the possible pixels
48 // touched. ToEnclosingRect() floors the origin, and ceils the max 48 // touched. ToEnclosingRect() floors the origin, and ceils the max
49 // coordinate. To do otherwise (such as flooring the size) potentially 49 // coordinate. To do otherwise (such as flooring the size) potentially
50 // results in rounding down and not drawing all the pixels that are 50 // results in rounding down and not drawing all the pixels that are
51 // touched. 51 // touched.
52 return gfx::ToEnclosingRect( 52 return gfx::ToEnclosingRect(
53 gfx::RectF(gfx::ScalePoint(rect_in_dip.origin(), scale_factor), 53 gfx::RectF(gfx::ScalePoint(rect_in_dip.origin(), scale_factor),
54 gfx::ScaleSize(rect_in_dip.size(), scale_factor))); 54 gfx::ScaleSize(rect_in_dip.size(), scale_factor)));
55 } 55 }
56 56
57 } // namespace gfx 57 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/base/touch/selection_bound.cc ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698