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/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" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 double scale_in_double = 1.0; | 25 double scale_in_double = 1.0; |
| 26 if (HasForceDeviceScaleFactorImpl()) { | 26 if (HasForceDeviceScaleFactorImpl()) { |
| 27 std::string value = CommandLine::ForCurrentProcess()-> | 27 std::string value = CommandLine::ForCurrentProcess()-> |
| 28 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); | 28 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); |
| 29 if (!base::StringToDouble(value, &scale_in_double)) | 29 if (!base::StringToDouble(value, &scale_in_double)) |
| 30 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; | 30 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; |
| 31 } | 31 } |
| 32 return static_cast<float>(scale_in_double); | 32 return static_cast<float>(scale_in_double); |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
|
oshima
2013/02/12 21:39:53
this is nor your fault, but could please fix this?
ynovikov
2013/02/13 13:48:37
Done.
| |
| 36 | 36 |
| 37 const int64 Display::kInvalidDisplayID = -1; | 37 const int64 Display::kInvalidDisplayID = -1; |
| 38 namespace { | |
| 39 int64 internal_display_id_ = Display::kInvalidDisplayID; | |
|
oshima
2013/02/12 21:39:53
indent
ynovikov
2013/02/13 13:48:37
Done.
| |
| 40 } // namespace | |
|
oshima
2013/02/12 21:39:53
move this into the anonymous namespace above.
ynovikov
2013/02/13 13:48:37
Done.
| |
| 38 | 41 |
| 39 // static | 42 // static |
| 40 float Display::GetForcedDeviceScaleFactor() { | 43 float Display::GetForcedDeviceScaleFactor() { |
| 41 static const float kForcedDeviceScaleFactor = | 44 static const float kForcedDeviceScaleFactor = |
| 42 GetForcedDeviceScaleFactorImpl(); | 45 GetForcedDeviceScaleFactorImpl(); |
| 43 return kForcedDeviceScaleFactor; | 46 return kForcedDeviceScaleFactor; |
| 44 } | 47 } |
| 45 | 48 |
| 46 //static | 49 //static |
| 47 bool Display::HasForceDeviceScaleFactor() { | 50 bool Display::HasForceDeviceScaleFactor() { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { | 125 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { |
| 123 work_area_ = bounds_; | 126 work_area_ = bounds_; |
| 124 work_area_.Inset(insets); | 127 work_area_.Inset(insets); |
| 125 } | 128 } |
| 126 | 129 |
| 127 gfx::Size Display::GetSizeInPixel() const { | 130 gfx::Size Display::GetSizeInPixel() const { |
| 128 return gfx::ToFlooredSize(gfx::ScaleSize(size(), device_scale_factor_)); | 131 return gfx::ToFlooredSize(gfx::ScaleSize(size(), device_scale_factor_)); |
| 129 } | 132 } |
| 130 | 133 |
| 131 std::string Display::ToString() const { | 134 std::string Display::ToString() const { |
| 132 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", | 135 return base::StringPrintf( |
| 133 static_cast<long long int>(id_), | 136 "Display[%lld] bounds=%s, workarea=%s, scale=%f, %s", |
| 134 bounds_.ToString().c_str(), | 137 static_cast<long long int>(id_), |
| 135 work_area_.ToString().c_str(), | 138 bounds_.ToString().c_str(), |
| 136 device_scale_factor_); | 139 work_area_.ToString().c_str(), |
| 140 device_scale_factor_, | |
| 141 IsInternal() ? "internal" : "external"); | |
| 142 } | |
| 143 | |
| 144 bool Display::IsInternal() const { | |
| 145 return is_valid() && (id_ == internal_display_id_); | |
| 146 } | |
| 147 | |
| 148 int64 Display::InternalDisplayId() { | |
| 149 return internal_display_id_; | |
| 150 } | |
| 151 | |
| 152 void Display::SetInternalDisplayId(int64 internal_display_id) { | |
| 153 internal_display_id_ = internal_display_id; | |
| 137 } | 154 } |
| 138 | 155 |
| 139 } // namespace gfx | 156 } // namespace gfx |
| OLD | NEW |