| 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/gfx/dpi_win.h" | 5 #include "ui/gfx/win/dpi.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/win/scoped_hdc.h" | 9 #include "base/win/scoped_hdc.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| 11 #include "ui/base/layout.h" | 11 #include "ui/base/layout.h" |
| 12 #include "base/win/registry.h" | 12 #include "base/win/registry.h" |
| 13 #include "ui/gfx/display.h" | 13 #include "ui/gfx/display.h" |
| 14 #include "ui/gfx/switches.h" | 14 #include "ui/gfx/switches.h" |
| 15 #include "ui/gfx/point_conversions.h" | 15 #include "ui/gfx/point_conversions.h" |
| 16 #include "ui/gfx/rect_conversions.h" | 16 #include "ui/gfx/rect_conversions.h" |
| 17 #include "ui/gfx/size_conversions.h" | 17 #include "ui/gfx/size_conversions.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 int kDefaultDPIX = 96; | 21 int kDefaultDPIX = 96; |
| 22 int kDefaultDPIY = 96; | 22 int kDefaultDPIY = 96; |
| 23 | 23 |
| 24 // Tests to see if the command line flag "--high-dpi-support" is set. | 24 // Tests to see if the command line flag "--high-dpi-support" is set. |
| 25 bool IsHighDPIEnabled() { | 25 bool IsHighDPIEnabled() { |
| 26 // Default is disabled. | 26 // Default is disabled. |
| 27 if (CommandLine::ForCurrentProcess()->HasSwitch( | 27 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 28 gfx::switches::kHighDPISupport)) { | 28 switches::kHighDPISupport)) { |
| 29 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 29 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 30 gfx::switches::kHighDPISupport).compare("1") == 0; | 30 switches::kHighDPISupport).compare("1") == 0; |
| 31 } | 31 } |
| 32 return false; | 32 return false; |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Gets the device scale factor. If support is enabled, this will return the | 35 // Gets the device scale factor. If support is enabled, this will return the |
| 36 // best available scale based on the screen's pixel density. This can be | 36 // best available scale based on the screen's pixel density. This can be |
| 37 // affected (overridden) by --force-device-scale-factor=x | 37 // affected (overridden) by --force-device-scale-factor=x |
| 38 float GetDeviceScaleFactorImpl() { | 38 float GetDeviceScaleFactorImpl() { |
| 39 if (IsHighDPIEnabled()) { | 39 if (IsHighDPIEnabled()) { |
| 40 float scale = gfx::Display::HasForceDeviceScaleFactor() ? | 40 float scale = gfx::Display::HasForceDeviceScaleFactor() ? |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 double GetUndocumentedDPITouchScale() { | 166 double GetUndocumentedDPITouchScale() { |
| 167 static double scale = | 167 static double scale = |
| 168 (base::win::GetVersion() < base::win::VERSION_WIN8_1) ? | 168 (base::win::GetVersion() < base::win::VERSION_WIN8_1) ? |
| 169 GetUndocumentedDPIScale() : 1.0; | 169 GetUndocumentedDPIScale() : 1.0; |
| 170 return scale; | 170 return scale; |
| 171 } | 171 } |
| 172 | 172 |
| 173 | 173 |
| 174 } // namespace win | 174 } // namespace win |
| 175 } // namespace gfx | 175 } // namespace gfx |
| OLD | NEW |