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

Side by Side Diff: ui/gfx/win/dpi.cc

Issue 1417023002: Remove some implicit Point to PointF conversions, add helpers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-views: extrachange Created 5 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
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/win/dpi.h" 5 #include "ui/gfx/win/dpi.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include "base/win/scoped_hdc.h" 8 #include "base/win/scoped_hdc.h"
9 #include "ui/gfx/display.h" 9 #include "ui/gfx/display.h"
10 #include "ui/gfx/geometry/point_conversions.h" 10 #include "ui/gfx/geometry/point_conversions.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // Force 125% and below to 100% scale. We do this to maintain previous 60 // Force 125% and below to 100% scale. We do this to maintain previous
61 // (non-DPI-aware) behavior where only the font size was boosted. 61 // (non-DPI-aware) behavior where only the font size was boosted.
62 dpi_scale = 1.0; 62 dpi_scale = 1.0;
63 } 63 }
64 return dpi_scale; 64 return dpi_scale;
65 } 65 }
66 66
67 namespace win { 67 namespace win {
68 68
69 Point ScreenToDIPPoint(const Point& pixel_point) { 69 Point ScreenToDIPPoint(const Point& pixel_point) {
70 return ToFlooredPoint(ScalePoint(pixel_point, 1.0f / GetDPIScale())); 70 return ScaleToFlooredPoint(pixel_point, 1.0f / GetDPIScale());
71 } 71 }
72 72
73 Point DIPToScreenPoint(const Point& dip_point) { 73 Point DIPToScreenPoint(const Point& dip_point) {
74 return ToFlooredPoint(ScalePoint(dip_point, GetDPIScale())); 74 return ScaleToFlooredPoint(dip_point, GetDPIScale());
75 } 75 }
76 76
77 Rect ScreenToDIPRect(const Rect& pixel_bounds) { 77 Rect ScreenToDIPRect(const Rect& pixel_bounds) {
78 // It's important we scale the origin and size separately. If we instead 78 // It's important we scale the origin and size separately. If we instead
79 // calculated the size from the floored origin and ceiled right the size could 79 // calculated the size from the floored origin and ceiled right the size could
80 // vary depending upon where the two points land. That would cause problems 80 // vary depending upon where the two points land. That would cause problems
81 // for the places this code is used (in particular mapping from native window 81 // for the places this code is used (in particular mapping from native window
82 // bounds to DIPs). 82 // bounds to DIPs).
83 return Rect(ScreenToDIPPoint(pixel_bounds.origin()), 83 return Rect(ScreenToDIPPoint(pixel_bounds.origin()),
84 ScreenToDIPSize(pixel_bounds.size())); 84 ScreenToDIPSize(pixel_bounds.size()));
(...skipping 14 matching lines...) Expand all
99 // Always ceil sizes. Otherwise we may be leaving off part of the bounds. 99 // Always ceil sizes. Otherwise we may be leaving off part of the bounds.
100 return ScaleToCeiledSize(dip_size, GetDPIScale()); 100 return ScaleToCeiledSize(dip_size, GetDPIScale());
101 } 101 }
102 102
103 int GetSystemMetricsInDIP(int metric) { 103 int GetSystemMetricsInDIP(int metric) {
104 return static_cast<int>(GetSystemMetrics(metric) / GetDPIScale() + 0.5); 104 return static_cast<int>(GetSystemMetrics(metric) / GetDPIScale() + 0.5);
105 } 105 }
106 106
107 } // namespace win 107 } // namespace win
108 } // namespace gfx 108 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698