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

Side by Side Diff: ui/compositor/dip_util.cc

Issue 11081007: Remove implicit flooring Scale() method from Point and Size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/compositor/layer.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/compositor/dip_util.h" 5 #include "ui/compositor/dip_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "ui/base/ui_base_switches.h" 8 #include "ui/base/ui_base_switches.h"
9 #include "ui/compositor/compositor.h" 9 #include "ui/compositor/compositor.h"
10 #include "ui/compositor/compositor_switches.h" 10 #include "ui/compositor/compositor_switches.h"
11 #include "ui/compositor/layer.h" 11 #include "ui/compositor/layer.h"
12 #include "ui/gfx/display.h" 12 #include "ui/gfx/display.h"
13 #include "ui/gfx/point.h" 13 #include "ui/gfx/point.h"
14 #include "ui/gfx/point_conversions.h"
14 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
15 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
17 #include "ui/gfx/size_conversions.h"
16 18
17 namespace ui { 19 namespace ui {
18 20
19 float GetDeviceScaleFactor(const Layer* layer) { 21 float GetDeviceScaleFactor(const Layer* layer) {
20 return layer->device_scale_factor(); 22 return layer->device_scale_factor();
21 } 23 }
22 24
23 gfx::Point ConvertPointToDIP(const Layer* layer, 25 gfx::Point ConvertPointToDIP(const Layer* layer,
24 const gfx::Point& point_in_pixel) { 26 const gfx::Point& point_in_pixel) {
25 return point_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer)); 27 return gfx::ToFlooredPoint(
28 point_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer)));
26 } 29 }
27 30
28 gfx::Size ConvertSizeToDIP(const Layer* layer, 31 gfx::Size ConvertSizeToDIP(const Layer* layer,
29 const gfx::Size& size_in_pixel) { 32 const gfx::Size& size_in_pixel) {
30 return size_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer)); 33 return gfx::ToFlooredSize(
34 size_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer)));
31 } 35 }
32 36
33 gfx::Rect ConvertRectToDIP(const Layer* layer, 37 gfx::Rect ConvertRectToDIP(const Layer* layer,
34 const gfx::Rect& rect_in_pixel) { 38 const gfx::Rect& rect_in_pixel) {
35 float scale = 1.0f / GetDeviceScaleFactor(layer); 39 float scale = 1.0f / GetDeviceScaleFactor(layer);
36 return gfx::Rect(rect_in_pixel.origin().Scale(scale), 40 return gfx::Rect(gfx::ToFlooredPoint(rect_in_pixel.origin().Scale(scale)),
37 rect_in_pixel.size().Scale(scale)); 41 gfx::ToFlooredSize(rect_in_pixel.size().Scale(scale)));
38 } 42 }
39 43
40 gfx::Point ConvertPointToPixel(const Layer* layer, 44 gfx::Point ConvertPointToPixel(const Layer* layer,
41 const gfx::Point& point_in_dip) { 45 const gfx::Point& point_in_dip) {
42 return point_in_dip.Scale(GetDeviceScaleFactor(layer)); 46 return gfx::ToFlooredPoint(
47 point_in_dip.Scale(GetDeviceScaleFactor(layer)));
43 } 48 }
44 49
45 gfx::Size ConvertSizeToPixel(const Layer* layer, 50 gfx::Size ConvertSizeToPixel(const Layer* layer,
46 const gfx::Size& size_in_dip) { 51 const gfx::Size& size_in_dip) {
47 return size_in_dip.Scale(GetDeviceScaleFactor(layer)); 52 return gfx::ToFlooredSize(size_in_dip.Scale(GetDeviceScaleFactor(layer)));
48 } 53 }
49 54
50 gfx::Rect ConvertRectToPixel(const Layer* layer, 55 gfx::Rect ConvertRectToPixel(const Layer* layer,
51 const gfx::Rect& rect_in_dip) { 56 const gfx::Rect& rect_in_dip) {
52 float scale = GetDeviceScaleFactor(layer); 57 float scale = GetDeviceScaleFactor(layer);
53 return gfx::Rect(rect_in_dip.origin().Scale(scale), 58 return gfx::Rect(gfx::ToFlooredPoint(rect_in_dip.origin().Scale(scale)),
54 rect_in_dip.size().Scale(scale)); 59 gfx::ToFlooredSize(rect_in_dip.size().Scale(scale)));
55 } 60 }
56 } // namespace ui 61 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/compositor/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698