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

Side by Side Diff: ui/base/layout_mac.mm

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
« no previous file with comments | « ui/base/layout.cc ('k') | ui/snapshot/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base/layout.h" 5 #include "ui/base/layout.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/sdk_forward_declarations.h" 9 #include "base/mac/sdk_forward_declarations.h"
10 #include "ui/display/display.h"
10 11
11 namespace { 12 namespace {
12 13
13 float GetScaleFactorScaleForNativeView(gfx::NativeView view) { 14 float GetScaleFactorScaleForNativeView(gfx::NativeView view) {
14 if (NSWindow* window = [view window]) { 15 if (NSWindow* window = [view window]) {
15 return [window backingScaleFactor]; 16 return [window backingScaleFactor];
16 } 17 }
17 18
18 NSArray* screens = [NSScreen screens]; 19 NSArray* screens = [NSScreen screens];
19 if (![screens count]) 20 if (![screens count])
20 return 1.0f; 21 return 1.0f;
21 22
22 NSScreen* screen = [screens objectAtIndex:0]; 23 NSScreen* screen = [screens objectAtIndex:0];
23 return [screen backingScaleFactor]; 24 return [screen backingScaleFactor];
24 } 25 }
25 26
26 } // namespace 27 } // namespace
27 28
28 namespace ui { 29 namespace ui {
29 30
30 float GetScaleFactorForNativeView(gfx::NativeView view) { 31 float GetScaleFactorForNativeView(gfx::NativeView view) {
32 if (display::Display::HasForceDeviceScaleFactor())
33 return display::Display::GetForcedDeviceScaleFactor();
31 return GetScaleFactorScaleForNativeView(view); 34 return GetScaleFactorScaleForNativeView(view);
32 } 35 }
33 36
34 } // namespace ui 37 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/layout.cc ('k') | ui/snapshot/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698