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

Side by Side Diff: content/browser/renderer_host/dip_util.cc

Issue 750173002: Move dip utils to gfx/geometry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missed android change Created 6 years 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 "content/browser/renderer_host/dip_util.h" 5 #include "content/browser/renderer_host/dip_util.h"
6 6
7 #include "content/public/browser/render_widget_host_view.h" 7 #include "content/public/browser/render_widget_host_view.h"
8 #include "ui/base/layout.h" 8 #include "ui/base/layout.h"
9 #include "ui/gfx/display.h" 9 #include "ui/gfx/display.h"
10 #include "ui/gfx/geometry/dip_util.h"
10 #include "ui/gfx/point.h" 11 #include "ui/gfx/point.h"
11 #include "ui/gfx/point_conversions.h" 12 #include "ui/gfx/point_conversions.h"
12 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
13 #include "ui/gfx/rect_conversions.h" 14 #include "ui/gfx/rect_conversions.h"
14 #include "ui/gfx/screen.h" 15 #include "ui/gfx/screen.h"
15 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
16 #include "ui/gfx/size_conversions.h" 17 #include "ui/gfx/size_conversions.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 float GetScaleFactorForView(const RenderWidgetHostView* view) { 21 float GetScaleFactorForView(const RenderWidgetHostView* view) {
21 return ui::GetScaleFactorForNativeView(view ? view->GetNativeView() : NULL); 22 return ui::GetScaleFactorForNativeView(view ? view->GetNativeView() : NULL);
22 } 23 }
23 24
24 gfx::Point ConvertViewPointToDIP(const RenderWidgetHostView* view, 25 gfx::Point ConvertViewPointToDIP(const RenderWidgetHostView* view,
25 const gfx::Point& point_in_pixel) { 26 const gfx::Point& point_in_pixel) {
26 return gfx::ToFlooredPoint( 27 return gfx::ConvertPointToDIP(GetScaleFactorForView(view), point_in_pixel);
27 gfx::ScalePoint(point_in_pixel, 1.0f / GetScaleFactorForView(view)));
28 } 28 }
29 29
30 gfx::Size ConvertViewSizeToPixel(const RenderWidgetHostView* view, 30 gfx::Size ConvertViewSizeToPixel(const RenderWidgetHostView* view,
31 const gfx::Size& size_in_dip) { 31 const gfx::Size& size_in_dip) {
32 return ConvertSizeToPixel(GetScaleFactorForView(view), size_in_dip); 32 return gfx::ConvertSizeToPixel(GetScaleFactorForView(view), size_in_dip);
33 } 33 }
34 34
35 gfx::Rect ConvertViewRectToPixel(const RenderWidgetHostView* view, 35 gfx::Rect ConvertViewRectToPixel(const RenderWidgetHostView* view,
36 const gfx::Rect& rect_in_dip) { 36 const gfx::Rect& rect_in_dip) {
37 return ConvertRectToPixel(GetScaleFactorForView(view), rect_in_dip); 37 return gfx::ConvertRectToPixel(GetScaleFactorForView(view), rect_in_dip);
38 }
39
40 gfx::Size ConvertSizeToDIP(float scale_factor,
41 const gfx::Size& size_in_pixel) {
42 return gfx::ToFlooredSize(
43 gfx::ScaleSize(size_in_pixel, 1.0f / scale_factor));
44 }
45
46 gfx::Rect ConvertRectToDIP(float scale_factor,
47 const gfx::Rect& rect_in_pixel) {
48 return gfx::ToFlooredRectDeprecated(
49 gfx::ScaleRect(rect_in_pixel, 1.0f / scale_factor));
50 }
51
52 gfx::Size ConvertSizeToPixel(float scale_factor,
53 const gfx::Size& size_in_dip) {
54 return gfx::ToFlooredSize(gfx::ScaleSize(size_in_dip, scale_factor));
55 }
56
57 gfx::Rect ConvertRectToPixel(float scale_factor,
58 const gfx::Rect& rect_in_dip) {
59 return gfx::ToFlooredRectDeprecated(
60 gfx::ScaleRect(rect_in_dip, scale_factor));
61 } 38 }
62 39
63 } // namespace content 40 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/dip_util.h ('k') | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698