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