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

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

Issue 11369144: ui: Make gfx::Point::Scale() mutate the class, similar to gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for aura Created 8 years, 1 month 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
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/point_conversions.h"
15 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
16 #include "ui/gfx/rect_conversions.h"
16 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
17 #include "ui/gfx/size_conversions.h" 18 #include "ui/gfx/size_conversions.h"
18 19
19 namespace ui { 20 namespace ui {
20 21
21 float GetDeviceScaleFactor(const Layer* layer) { 22 float GetDeviceScaleFactor(const Layer* layer) {
22 return layer->device_scale_factor(); 23 return layer->device_scale_factor();
23 } 24 }
24 25
25 gfx::Point ConvertPointToDIP(const Layer* layer, 26 gfx::Point ConvertPointToDIP(const Layer* layer,
26 const gfx::Point& point_in_pixel) { 27 const gfx::Point& point_in_pixel) {
27 return gfx::ToFlooredPoint( 28 return gfx::ToFlooredPoint(
28 point_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer))); 29 gfx::ScalePoint(point_in_pixel, 1.0f / GetDeviceScaleFactor(layer)));
29 } 30 }
30 31
31 gfx::Size ConvertSizeToDIP(const Layer* layer, 32 gfx::Size ConvertSizeToDIP(const Layer* layer,
32 const gfx::Size& size_in_pixel) { 33 const gfx::Size& size_in_pixel) {
33 return gfx::ToFlooredSize( 34 return gfx::ToFlooredSize(
34 size_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer))); 35 size_in_pixel.Scale(1.0f / GetDeviceScaleFactor(layer)));
35 } 36 }
36 37
37 gfx::Rect ConvertRectToDIP(const Layer* layer, 38 gfx::Rect ConvertRectToDIP(const Layer* layer,
38 const gfx::Rect& rect_in_pixel) { 39 const gfx::Rect& rect_in_pixel) {
39 float scale = 1.0f / GetDeviceScaleFactor(layer); 40 float scale = 1.0f / GetDeviceScaleFactor(layer);
40 return gfx::Rect(gfx::ToFlooredPoint(rect_in_pixel.origin().Scale(scale)), 41 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_pixel, scale));
41 gfx::ToFlooredSize(rect_in_pixel.size().Scale(scale)));
42 } 42 }
43 43
44 gfx::Point ConvertPointToPixel(const Layer* layer, 44 gfx::Point ConvertPointToPixel(const Layer* layer,
45 const gfx::Point& point_in_dip) { 45 const gfx::Point& point_in_dip) {
46 return gfx::ToFlooredPoint( 46 return gfx::ToFlooredPoint(
47 point_in_dip.Scale(GetDeviceScaleFactor(layer))); 47 gfx::ScalePoint(point_in_dip, GetDeviceScaleFactor(layer)));
48 } 48 }
49 49
50 gfx::Size ConvertSizeToPixel(const Layer* layer, 50 gfx::Size ConvertSizeToPixel(const Layer* layer,
51 const gfx::Size& size_in_dip) { 51 const gfx::Size& size_in_dip) {
52 return gfx::ToFlooredSize(size_in_dip.Scale(GetDeviceScaleFactor(layer))); 52 return gfx::ToFlooredSize(size_in_dip.Scale(GetDeviceScaleFactor(layer)));
53 } 53 }
54 54
55 gfx::Rect ConvertRectToPixel(const Layer* layer, 55 gfx::Rect ConvertRectToPixel(const Layer* layer,
56 const gfx::Rect& rect_in_dip) { 56 const gfx::Rect& rect_in_dip) {
57 float scale = GetDeviceScaleFactor(layer); 57 float scale = GetDeviceScaleFactor(layer);
58 return gfx::Rect(gfx::ToFlooredPoint(rect_in_dip.origin().Scale(scale)), 58 return gfx::ToFlooredRectDeprecated(gfx::ScaleRect(rect_in_dip, scale));
59 gfx::ToFlooredSize(rect_in_dip.size().Scale(scale)));
60 } 59 }
61 } // namespace ui 60 } // namespace ui
OLDNEW
« cc/layer_impl.cc ('K') | « ui/base/x/x11_util.cc ('k') | ui/gfx/point.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698