Chromium Code Reviews| 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/display/display.h" | 7 #include "ui/display/display.h" |
| 8 #include "ui/display/screen.h" | 8 #include "ui/display/screen.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
| 11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace views { |
| 14 | 14 |
| 15 float GetDeviceScaleForNativeView(views::Widget* widget) { | 15 float GetDeviceScaleForNativeView(views::Widget* widget) { |
|
tapted
2017/02/14 23:34:07
nit: reorder to match .h (and remove views:: pref
enne (OOO)
2017/02/15 00:02:05
You might want to consider a presubmit like https:
tapted
2017/02/15 00:41:23
ooh - indeed :) also for gfx::.. just came up in a
| |
| 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 display::Display display = | 19 display::Display display = |
| 20 display::Screen::GetScreen()->GetDisplayNearestWindow(view); | 20 display::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 } |
|
tapted
2017/02/14 23:34:07
random orthogonal thought: I wonder if we should h
enne (OOO)
2017/02/15 00:02:05
Yeah, that would make a lot of sense. You could s
| |
| 25 | 25 |
| 26 } // namespace | |
| 27 | |
| 28 namespace views { | |
| 29 | |
| 30 gfx::Canvas* GetCanvasForDragImage(views::Widget* widget, | 26 gfx::Canvas* GetCanvasForDragImage(views::Widget* widget, |
| 31 const gfx::Size& canvas_size) { | 27 const gfx::Size& canvas_size) { |
| 32 float device_scale = GetDeviceScaleForNativeView(widget); | 28 float device_scale = GetDeviceScaleForNativeView(widget); |
| 33 return new gfx::Canvas(canvas_size, device_scale, false); | 29 return new gfx::Canvas(canvas_size, device_scale, false); |
| 34 } | 30 } |
| 35 | 31 |
| 36 } // namespace views | 32 } // namespace views |
| OLD | NEW |