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

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

Issue 293563002: GetScaleFactorForNativeView should return scale factor in float (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
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/gfx/display.h" 9 #include "ui/gfx/display.h"
9 #include "ui/gfx/point.h" 10 #include "ui/gfx/point.h"
10 #include "ui/gfx/point_conversions.h" 11 #include "ui/gfx/point_conversions.h"
11 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
12 #include "ui/gfx/rect_conversions.h" 13 #include "ui/gfx/rect_conversions.h"
13 #include "ui/gfx/screen.h" 14 #include "ui/gfx/screen.h"
14 #include "ui/gfx/size.h" 15 #include "ui/gfx/size.h"
15 #include "ui/gfx/size_conversions.h" 16 #include "ui/gfx/size_conversions.h"
16 17
17 namespace content { 18 namespace content {
18 namespace {
19 19
20 float GetScaleForView(const RenderWidgetHostView* view) { 20 float GetScaleFactorForView(const RenderWidgetHostView* view) {
21 return ui::GetImageScale(GetScaleFactorForView(view));
22 }
23
24 } // namespace
25
26 ui::ScaleFactor GetScaleFactorForView(const RenderWidgetHostView* view) {
27 return ui::GetScaleFactorForNativeView(view ? view->GetNativeView() : NULL); 21 return ui::GetScaleFactorForNativeView(view ? view->GetNativeView() : NULL);
28 } 22 }
29 23
30 gfx::Point ConvertViewPointToDIP(const RenderWidgetHostView* view, 24 gfx::Point ConvertViewPointToDIP(const RenderWidgetHostView* view,
31 const gfx::Point& point_in_pixel) { 25 const gfx::Point& point_in_pixel) {
32 return gfx::ToFlooredPoint( 26 return gfx::ToFlooredPoint(
33 gfx::ScalePoint(point_in_pixel, 1.0f / GetScaleForView(view))); 27 gfx::ScalePoint(point_in_pixel, 1.0f / GetScaleFactorForView(view)));
34 } 28 }
35 29
36 gfx::Size ConvertViewSizeToPixel(const RenderWidgetHostView* view, 30 gfx::Size ConvertViewSizeToPixel(const RenderWidgetHostView* view,
37 const gfx::Size& size_in_dip) { 31 const gfx::Size& size_in_dip) {
38 return ConvertSizeToPixel(GetScaleForView(view), size_in_dip); 32 return ConvertSizeToPixel(GetScaleFactorForView(view), size_in_dip);
39 } 33 }
40 34
41 gfx::Rect ConvertViewRectToPixel(const RenderWidgetHostView* view, 35 gfx::Rect ConvertViewRectToPixel(const RenderWidgetHostView* view,
42 const gfx::Rect& rect_in_dip) { 36 const gfx::Rect& rect_in_dip) {
43 return ConvertRectToPixel(GetScaleForView(view), rect_in_dip); 37 return ConvertRectToPixel(GetScaleFactorForView(view), rect_in_dip);
44 } 38 }
45 39
46 gfx::Size ConvertSizeToDIP(float scale_factor, 40 gfx::Size ConvertSizeToDIP(float scale_factor,
47 const gfx::Size& size_in_pixel) { 41 const gfx::Size& size_in_pixel) {
48 return gfx::ToFlooredSize( 42 return gfx::ToFlooredSize(
49 gfx::ScaleSize(size_in_pixel, 1.0f / scale_factor)); 43 gfx::ScaleSize(size_in_pixel, 1.0f / scale_factor));
50 } 44 }
51 45
52 gfx::Rect ConvertRectToDIP(float scale_factor, 46 gfx::Rect ConvertRectToDIP(float scale_factor,
53 const gfx::Rect& rect_in_pixel) { 47 const gfx::Rect& rect_in_pixel) {
54 return gfx::ToFlooredRectDeprecated( 48 return gfx::ToFlooredRectDeprecated(
55 gfx::ScaleRect(rect_in_pixel, 1.0f / scale_factor)); 49 gfx::ScaleRect(rect_in_pixel, 1.0f / scale_factor));
56 } 50 }
57 51
58 gfx::Size ConvertSizeToPixel(float scale_factor, 52 gfx::Size ConvertSizeToPixel(float scale_factor,
59 const gfx::Size& size_in_dip) { 53 const gfx::Size& size_in_dip) {
60 return gfx::ToFlooredSize(gfx::ScaleSize(size_in_dip, scale_factor)); 54 return gfx::ToFlooredSize(gfx::ScaleSize(size_in_dip, scale_factor));
61 } 55 }
62 56
63 gfx::Rect ConvertRectToPixel(float scale_factor, 57 gfx::Rect ConvertRectToPixel(float scale_factor,
64 const gfx::Rect& rect_in_dip) { 58 const gfx::Rect& rect_in_dip) {
65 return gfx::ToFlooredRectDeprecated( 59 return gfx::ToFlooredRectDeprecated(
66 gfx::ScaleRect(rect_in_dip, scale_factor)); 60 gfx::ScaleRect(rect_in_dip, scale_factor));
67 } 61 }
68 62
69 } // namespace content 63 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/dip_util.h ('k') | content/browser/renderer_host/render_view_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698