| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "ui/gfx/geometry/insets.h" | 15 #include "ui/gfx/geometry/insets.h" |
| 15 #include "ui/gfx/geometry/point_conversions.h" | 16 #include "ui/gfx/geometry/point_conversions.h" |
| 16 #include "ui/gfx/geometry/point_f.h" | 17 #include "ui/gfx/geometry/point_f.h" |
| 17 #include "ui/gfx/geometry/size_conversions.h" | 18 #include "ui/gfx/geometry/size_conversions.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // static | 71 // static |
| 71 void Display::ResetForceDeviceScaleFactorForTesting() { | 72 void Display::ResetForceDeviceScaleFactorForTesting() { |
| 72 g_has_forced_device_scale_factor = -1; | 73 g_has_forced_device_scale_factor = -1; |
| 73 g_forced_device_scale_factor = -1.0; | 74 g_forced_device_scale_factor = -1.0; |
| 74 } | 75 } |
| 75 | 76 |
| 76 Display::Display() | 77 Display::Display() |
| 77 : id_(kInvalidDisplayID), | 78 : id_(kInvalidDisplayID), |
| 78 device_scale_factor_(GetForcedDeviceScaleFactor()), | 79 device_scale_factor_(GetForcedDeviceScaleFactor()), |
| 79 rotation_(ROTATE_0), | 80 rotation_(ROTATE_0), |
| 80 touch_support_(TOUCH_SUPPORT_UNKNOWN) { | 81 touch_support_(TOUCH_SUPPORT_UNKNOWN) {} |
| 81 } | |
| 82 | 82 |
| 83 Display::Display(int64_t id) | 83 Display::Display(int64_t id) |
| 84 : id_(id), | 84 : id_(id), |
| 85 device_scale_factor_(GetForcedDeviceScaleFactor()), | 85 device_scale_factor_(GetForcedDeviceScaleFactor()), |
| 86 rotation_(ROTATE_0), | 86 rotation_(ROTATE_0), |
| 87 touch_support_(TOUCH_SUPPORT_UNKNOWN) {} | 87 touch_support_(TOUCH_SUPPORT_UNKNOWN) {} |
| 88 | 88 |
| 89 Display::Display(int64_t id, const gfx::Rect& bounds) | 89 Display::Display(int64_t id, const gfx::Rect& bounds) |
| 90 : id_(id), | 90 : id_(id), |
| 91 bounds_(bounds), | 91 bounds_(bounds), |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 bounds_.ToString().c_str(), | 188 bounds_.ToString().c_str(), |
| 189 work_area_.ToString().c_str(), | 189 work_area_.ToString().c_str(), |
| 190 device_scale_factor_, | 190 device_scale_factor_, |
| 191 IsInternal() ? "internal" : "external"); | 191 IsInternal() ? "internal" : "external"); |
| 192 } | 192 } |
| 193 | 193 |
| 194 bool Display::IsInternal() const { | 194 bool Display::IsInternal() const { |
| 195 return is_valid() && (id_ == internal_display_id_); | 195 return is_valid() && (id_ == internal_display_id_); |
| 196 } | 196 } |
| 197 | 197 |
| 198 bool Display::IsPhysicalSizeAvailable() const { |
| 199 return physical_size_mm_.width() != 0 && physical_size_mm_.height() != 0; |
| 200 } |
| 201 |
| 202 gfx::Size Display::GetPhysicalSizeMm() const { |
| 203 DCHECK(IsPhysicalSizeAvailable()); |
| 204 return physical_size_mm_; |
| 205 } |
| 206 |
| 207 void Display::SetPhysicalSizeMm(gfx::Size physical_size) { |
| 208 physical_size_mm_ = physical_size; |
| 209 } |
| 210 |
| 198 // static | 211 // static |
| 199 int64_t Display::InternalDisplayId() { | 212 int64_t Display::InternalDisplayId() { |
| 200 DCHECK_NE(kInvalidDisplayID, internal_display_id_); | 213 DCHECK_NE(kInvalidDisplayID, internal_display_id_); |
| 201 return internal_display_id_; | 214 return internal_display_id_; |
| 202 } | 215 } |
| 203 | 216 |
| 204 // static | 217 // static |
| 205 void Display::SetInternalDisplayId(int64_t internal_display_id) { | 218 void Display::SetInternalDisplayId(int64_t internal_display_id) { |
| 206 internal_display_id_ = internal_display_id; | 219 internal_display_id_ = internal_display_id; |
| 207 } | 220 } |
| 208 | 221 |
| 209 // static | 222 // static |
| 210 bool Display::IsInternalDisplayId(int64_t display_id) { | 223 bool Display::IsInternalDisplayId(int64_t display_id) { |
| 211 DCHECK_NE(kInvalidDisplayID, display_id); | 224 DCHECK_NE(kInvalidDisplayID, display_id); |
| 212 return HasInternalDisplay() && internal_display_id_ == display_id; | 225 return HasInternalDisplay() && internal_display_id_ == display_id; |
| 213 } | 226 } |
| 214 | 227 |
| 215 // static | 228 // static |
| 216 bool Display::HasInternalDisplay() { | 229 bool Display::HasInternalDisplay() { |
| 217 return internal_display_id_ != kInvalidDisplayID; | 230 return internal_display_id_ != kInvalidDisplayID; |
| 218 } | 231 } |
| 219 | 232 |
| 220 } // namespace gfx | 233 } // namespace gfx |
| OLD | NEW |