| Index: ui/gfx/display.cc
|
| diff --git a/ui/gfx/display.cc b/ui/gfx/display.cc
|
| index 5b375891ad0fa271aae4cc990c0f116a724eabc7..f7227a40e86423f794c50317efb8cdbfe9bc2d92 100644
|
| --- a/ui/gfx/display.cc
|
| +++ b/ui/gfx/display.cc
|
| @@ -9,25 +9,33 @@
|
| #include "base/string_number_conversions.h"
|
| #include "base/stringprintf.h"
|
| #include "ui/base/ui_base_switches.h"
|
| +#include "ui/base/win/dpi.h"
|
| #include "ui/gfx/insets.h"
|
| #include "ui/gfx/size_conversions.h"
|
|
|
| namespace gfx {
|
| namespace {
|
|
|
| -bool HasForceDeviceScaleFactor() {
|
| +bool HasForceDeviceScaleFactorImpl() {
|
| return CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kForceDeviceScaleFactor);
|
| }
|
|
|
| float GetForcedDeviceScaleFactorImpl() {
|
| double scale_in_double = 1.0;
|
| - if (HasForceDeviceScaleFactor()) {
|
| + if (HasForceDeviceScaleFactorImpl()) {
|
| std::string value = CommandLine::ForCurrentProcess()->
|
| GetSwitchValueASCII(switches::kForceDeviceScaleFactor);
|
| if (!base::StringToDouble(value, &scale_in_double))
|
| LOG(ERROR) << "Failed to parse the deafult device scale factor:" << value;
|
| }
|
| +#if defined(OS_WIN)
|
| + else {
|
| + static double os_scale = ui::GetDPIScale();
|
| + scale_in_double = os_scale;
|
| + }
|
| +#endif
|
| +
|
| return static_cast<float>(scale_in_double);
|
| }
|
|
|
| @@ -41,6 +49,10 @@ float Display::GetForcedDeviceScaleFactor() {
|
| GetForcedDeviceScaleFactorImpl();
|
| return kForcedDeviceScaleFactor;
|
| }
|
| +//static
|
| +bool Display::HasForceDeviceScaleFactor() {
|
| + return HasForceDeviceScaleFactorImpl();
|
| +}
|
|
|
| // static
|
| int64 Display::GetID(uint16 manufacturer_id, uint32 serial_number) {
|
| @@ -64,7 +76,7 @@ Display::Display(int64 id, const gfx::Rect& bounds)
|
| bounds_(bounds),
|
| work_area_(bounds),
|
| device_scale_factor_(GetForcedDeviceScaleFactor()) {
|
| -#if defined(USE_AURA)
|
| +#if defined(USE_AURA) || defined(OS_WIN)
|
| SetScaleAndBounds(device_scale_factor_, bounds);
|
| #endif
|
| }
|
| @@ -92,7 +104,7 @@ void Display::SetScaleAndBounds(
|
| device_scale_factor_ = device_scale_factor;
|
| }
|
| device_scale_factor_ = std::max(1.0f, device_scale_factor_);
|
| -#if defined(USE_AURA)
|
| +#if defined(USE_AURA) || defined(OS_WIN)
|
| bounds_in_pixel_ = bounds_in_pixel;
|
| #endif
|
| bounds_ = gfx::Rect(gfx::ToFlooredSize(
|
| @@ -103,7 +115,7 @@ void Display::SetScaleAndBounds(
|
| void Display::SetSize(const gfx::Size& size_in_pixel) {
|
| SetScaleAndBounds(
|
| device_scale_factor_,
|
| -#if defined(USE_AURA)
|
| +#if defined(USE_AURA) || defined(OS_WIN)
|
| gfx::Rect(bounds_in_pixel_.origin(), size_in_pixel));
|
| #else
|
| gfx::Rect(bounds_.origin(), size_in_pixel));
|
|
|