| 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/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
| 8 #include "ui/gfx/display.h" | 8 #include "ui/gfx/display.h" |
| 9 #include "ui/gfx/geometry/size.h" | 9 #include "ui/gfx/geometry/size.h" |
| 10 #include "ui/gfx/screen.h" | 10 #include "ui/gfx/screen.h" |
| 11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 float GetDeviceScaleForNativeView(views::Widget* widget) { | 15 float GetDeviceScaleForNativeView(views::Widget* widget) { |
| 16 float device_scale = 1.0f; | 16 float device_scale = 1.0f; |
| 17 if (widget && widget->GetNativeView()) { | 17 if (widget && widget->GetNativeView()) { |
| 18 gfx::NativeView view = widget->GetNativeView(); | 18 gfx::NativeView view = widget->GetNativeView(); |
| 19 gfx::Display display = gfx::Screen::GetScreenFor(view)-> | 19 gfx::Display display = |
| 20 GetDisplayNearestWindow(view); | 20 gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); |
| 21 device_scale = display.device_scale_factor(); | 21 device_scale = display.device_scale_factor(); |
| 22 } | 22 } |
| 23 return device_scale; | 23 return device_scale; |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 namespace views { | 28 namespace views { |
| 29 | 29 |
| 30 gfx::Canvas* GetCanvasForDragImage(views::Widget* widget, | 30 gfx::Canvas* GetCanvasForDragImage(views::Widget* widget, |
| 31 const gfx::Size& canvas_size) { | 31 const gfx::Size& canvas_size) { |
| 32 float device_scale = GetDeviceScaleForNativeView(widget); | 32 float device_scale = GetDeviceScaleForNativeView(widget); |
| 33 return new gfx::Canvas(canvas_size, device_scale, false); | 33 return new gfx::Canvas(canvas_size, device_scale, false); |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace views | 36 } // namespace views |
| OLD | NEW |