OLD | NEW |
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/views/drag_utils.h" | 5 #include "ui/views/drag_utils.h" |
6 | 6 |
7 #include "ui/base/layout.h" | 7 #include "ui/base/layout.h" |
8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
9 #include "ui/gfx/geometry/size.h" | 9 #include "ui/gfx/geometry/size.h" |
10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
11 | 11 |
12 namespace views { | 12 namespace views { |
13 | 13 |
14 float ScaleFactorForDragFromWidget(Widget* widget) { | 14 float ScaleFactorForDragFromWidget(const Widget* widget) { |
15 float device_scale = 1.0f; | 15 float device_scale = 1.0f; |
16 if (widget && widget->GetNativeView()) { | 16 if (widget && widget->GetNativeView()) { |
17 gfx::NativeView view = widget->GetNativeView(); | 17 gfx::NativeView view = widget->GetNativeView(); |
18 device_scale = ui::GetScaleFactorForNativeView(view); | 18 device_scale = ui::GetScaleFactorForNativeView(view); |
19 } | 19 } |
20 return device_scale; | 20 return device_scale; |
21 } | 21 } |
22 | 22 |
23 gfx::Canvas* GetCanvasForDragImage(Widget* widget, | 23 gfx::Canvas* GetCanvasForDragImage(const Widget* widget, |
24 const gfx::Size& canvas_size) { | 24 const gfx::Size& canvas_size) { |
25 float device_scale = ScaleFactorForDragFromWidget(widget); | 25 float device_scale = ScaleFactorForDragFromWidget(widget); |
26 return new gfx::Canvas(canvas_size, device_scale, false); | 26 return new gfx::Canvas(canvas_size, device_scale, false); |
27 } | 27 } |
28 | 28 |
29 } // namespace views | 29 } // namespace views |
OLD | NEW |