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

Side by Side Diff: ui/views/drag_utils.cc

Issue 2739113002: Simplify calls for scale factor (Closed)
Patch Set: nit Created 3 years, 9 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
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 "ui/views/drag_utils.h" 5 #include "ui/views/drag_utils.h"
6 6
7 #include "ui/display/display.h" 7 #include "ui/base/layout.h"
8 #include "ui/display/screen.h"
9 #include "ui/gfx/canvas.h" 8 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/geometry/size.h" 9 #include "ui/gfx/geometry/size.h"
11 #include "ui/views/widget/widget.h" 10 #include "ui/views/widget/widget.h"
12 11
13 namespace views { 12 namespace views {
14 13
15 float ScaleFactorForDragFromWidget(Widget* widget) { 14 float ScaleFactorForDragFromWidget(Widget* widget) {
16 float device_scale = 1.0f; 15 float device_scale = 1.0f;
17 if (widget && widget->GetNativeView()) { 16 if (widget && widget->GetNativeView()) {
18 gfx::NativeView view = widget->GetNativeView(); 17 gfx::NativeView view = widget->GetNativeView();
19 display::Display display = 18 device_scale = ui::GetScaleFactorForNativeView(view);
20 display::Screen::GetScreen()->GetDisplayNearestWindow(view);
21 device_scale = display.device_scale_factor();
22 } 19 }
23 return device_scale; 20 return device_scale;
24 } 21 }
25 22
26 gfx::Canvas* GetCanvasForDragImage(Widget* widget, 23 gfx::Canvas* GetCanvasForDragImage(Widget* widget,
27 const gfx::Size& canvas_size) { 24 const gfx::Size& canvas_size) {
28 float device_scale = ScaleFactorForDragFromWidget(widget); 25 float device_scale = ScaleFactorForDragFromWidget(widget);
29 return new gfx::Canvas(canvas_size, device_scale, false); 26 return new gfx::Canvas(canvas_size, device_scale, false);
30 } 27 }
31 28
32 } // namespace views 29 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.mm ('k') | ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698