| 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/display.h" | 5 #include "ui/gfx/display.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "ui/base/ui_base_switches.h" | 11 #include "ui/base/ui_base_switches.h" |
| 12 #include "ui/base/win/dpi.h" |
| 12 #include "ui/gfx/insets.h" | 13 #include "ui/gfx/insets.h" |
| 13 #include "ui/gfx/size_conversions.h" | 14 #include "ui/gfx/size_conversions.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 bool HasForceDeviceScaleFactor() { | 19 bool HasForceDeviceScaleFactorImpl() { |
| 19 return CommandLine::ForCurrentProcess()->HasSwitch( | 20 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 20 switches::kForceDeviceScaleFactor); | 21 switches::kForceDeviceScaleFactor); |
| 21 } | 22 } |
| 22 | 23 |
| 23 float GetForcedDeviceScaleFactorImpl() { | 24 float GetForcedDeviceScaleFactorImpl() { |
| 24 double scale_in_double = 1.0; | 25 double scale_in_double = 1.0; |
| 25 if (HasForceDeviceScaleFactor()) { | 26 if (HasForceDeviceScaleFactorImpl()) { |
| 26 std::string value = CommandLine::ForCurrentProcess()-> | 27 std::string value = CommandLine::ForCurrentProcess()-> |
| 27 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); | 28 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); |
| 28 if (!base::StringToDouble(value, &scale_in_double)) | 29 if (!base::StringToDouble(value, &scale_in_double)) |
| 29 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; | 30 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; |
| 30 } | 31 } |
| 31 return static_cast<float>(scale_in_double); | 32 return static_cast<float>(scale_in_double); |
| 32 } | 33 } |
| 33 | 34 |
| 34 } // namespace | 35 } // namespace |
| 35 | 36 |
| 36 const int64 Display::kInvalidDisplayID = -1; | 37 const int64 Display::kInvalidDisplayID = -1; |
| 37 | 38 |
| 38 // static | 39 // static |
| 39 float Display::GetForcedDeviceScaleFactor() { | 40 float Display::GetForcedDeviceScaleFactor() { |
| 40 static const float kForcedDeviceScaleFactor = | 41 static const float kForcedDeviceScaleFactor = |
| 41 GetForcedDeviceScaleFactorImpl(); | 42 GetForcedDeviceScaleFactorImpl(); |
| 42 return kForcedDeviceScaleFactor; | 43 return kForcedDeviceScaleFactor; |
| 43 } | 44 } |
| 44 | 45 |
| 46 //static |
| 47 bool Display::HasForceDeviceScaleFactor() { |
| 48 return HasForceDeviceScaleFactorImpl(); |
| 49 } |
| 50 |
| 45 // static | 51 // static |
| 46 int64 Display::GetID(uint16 manufacturer_id, | 52 int64 Display::GetID(uint16 manufacturer_id, |
| 47 uint16 product_code, | 53 uint16 product_code, |
| 48 uint8 output_index) { | 54 uint8 output_index) { |
| 49 int64 new_id = ((static_cast<int64>(manufacturer_id) << 24) | | 55 int64 new_id = ((static_cast<int64>(manufacturer_id) << 24) | |
| 50 (static_cast<int64>(product_code) << 8) | output_index); | 56 (static_cast<int64>(product_code) << 8) | output_index); |
| 51 DCHECK_NE(kInvalidDisplayID, new_id); | 57 DCHECK_NE(kInvalidDisplayID, new_id); |
| 52 return new_id; | 58 return new_id; |
| 53 } | 59 } |
| 54 | 60 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 130 |
| 125 std::string Display::ToString() const { | 131 std::string Display::ToString() const { |
| 126 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", | 132 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", |
| 127 static_cast<long long int>(id_), | 133 static_cast<long long int>(id_), |
| 128 bounds_.ToString().c_str(), | 134 bounds_.ToString().c_str(), |
| 129 work_area_.ToString().c_str(), | 135 work_area_.ToString().c_str(), |
| 130 device_scale_factor_); | 136 device_scale_factor_); |
| 131 } | 137 } |
| 132 | 138 |
| 133 } // namespace gfx | 139 } // namespace gfx |
| OLD | NEW |