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/base/layout.h" | 5 #include "ui/base/layout.h" |
| 6 | 6 |
| 7 #include "base/mac/sdk_forward_declarations.h" | |
| 8 #include "ui/display/display.h" | |
| 9 | |
| 7 #include <Cocoa/Cocoa.h> | 10 #include <Cocoa/Cocoa.h> |
|
tapted
2017/03/13 01:47:01
nit: this should appear between layout.h and sdk_f
Jinsuk Kim
2017/03/13 01:58:21
Done.
| |
| 8 | 11 |
| 9 #include "base/mac/sdk_forward_declarations.h" | |
| 10 | |
| 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 |
| OLD | NEW |