| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return display_info; | 103 return display_info; |
| 104 } | 104 } |
| 105 | 105 |
| 106 DisplayInfo::DisplayInfo() | 106 DisplayInfo::DisplayInfo() |
| 107 : id_(gfx::Display::kInvalidDisplayID), | 107 : id_(gfx::Display::kInvalidDisplayID), |
| 108 has_overscan_(false), | 108 has_overscan_(false), |
| 109 rotation_(gfx::Display::ROTATE_0), | 109 rotation_(gfx::Display::ROTATE_0), |
| 110 device_scale_factor_(1.0f), | 110 device_scale_factor_(1.0f), |
| 111 overscan_insets_in_dip_(0, 0, 0, 0), | 111 overscan_insets_in_dip_(0, 0, 0, 0), |
| 112 has_custom_overscan_insets_(false), | 112 has_custom_overscan_insets_(false), |
| 113 ui_scale_(1.0f) { | 113 ui_scale_(1.0f), |
| 114 native_(false) { |
| 114 } | 115 } |
| 115 | 116 |
| 116 DisplayInfo::DisplayInfo(int64 id, | 117 DisplayInfo::DisplayInfo(int64 id, |
| 117 const std::string& name, | 118 const std::string& name, |
| 118 bool has_overscan) | 119 bool has_overscan) |
| 119 : id_(id), | 120 : id_(id), |
| 120 name_(name), | 121 name_(name), |
| 121 has_overscan_(has_overscan), | 122 has_overscan_(has_overscan), |
| 122 rotation_(gfx::Display::ROTATE_0), | 123 rotation_(gfx::Display::ROTATE_0), |
| 123 device_scale_factor_(1.0f), | 124 device_scale_factor_(1.0f), |
| 124 overscan_insets_in_dip_(0, 0, 0, 0), | 125 overscan_insets_in_dip_(0, 0, 0, 0), |
| 125 has_custom_overscan_insets_(false), | 126 has_custom_overscan_insets_(false), |
| 126 ui_scale_(1.0f) { | 127 ui_scale_(1.0f), |
| 128 native_(false) { |
| 127 } | 129 } |
| 128 | 130 |
| 129 DisplayInfo::~DisplayInfo() { | 131 DisplayInfo::~DisplayInfo() { |
| 130 } | 132 } |
| 131 | 133 |
| 132 void DisplayInfo::CopyFromNative(const DisplayInfo& native_info) { | 134 void DisplayInfo::Copy(const DisplayInfo& native_info) { |
| 133 DCHECK(id_ == native_info.id_); | 135 DCHECK(id_ == native_info.id_); |
| 134 name_ = native_info.name_; | 136 name_ = native_info.name_; |
| 135 has_overscan_ = native_info.has_overscan_; | 137 has_overscan_ = native_info.has_overscan_; |
| 136 | 138 |
| 137 DCHECK(!native_info.bounds_in_pixel_.IsEmpty()); | 139 DCHECK(!native_info.bounds_in_pixel_.IsEmpty()); |
| 138 bounds_in_pixel_ = native_info.bounds_in_pixel_; | 140 bounds_in_pixel_ = native_info.bounds_in_pixel_; |
| 139 size_in_pixel_ = native_info.size_in_pixel_; | 141 size_in_pixel_ = native_info.size_in_pixel_; |
| 140 device_scale_factor_ = native_info.device_scale_factor_; | 142 device_scale_factor_ = native_info.device_scale_factor_; |
| 141 rotation_ = native_info.rotation_; | 143 |
| 142 ui_scale_ = native_info.ui_scale_; | 144 // Rotation_ and ui_scale_ are given by preference, or unit |
| 145 // tests. Don't copy if this native_info came from |
| 146 // DisplayChangeObserverX11. |
| 147 if (!native_info.native()) { |
| 148 rotation_ = native_info.rotation_; |
| 149 ui_scale_ = native_info.ui_scale_; |
| 150 } |
| 151 // It makes little sense to scale beyond the original |
| 152 // resolution. This guard is to protect applying |
| 153 // ui_scale to an external display whose DPI has changed |
| 154 // from 2.0 to 1.0 for some reason. |
| 155 if (ui_scale_ > device_scale_factor_) |
| 156 ui_scale_ = 1.0f; |
| 157 |
| 143 // Don't copy insets as it may be given by preference. |rotation_| | 158 // Don't copy insets as it may be given by preference. |rotation_| |
| 144 // is treated as a native so that it can be specified in | 159 // is treated as a native so that it can be specified in |
| 145 // |CreateFromSpec|. | 160 // |CreateFromSpec|. |
| 146 } | 161 } |
| 147 | 162 |
| 148 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_pixel) { | 163 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_pixel) { |
| 149 bounds_in_pixel_ = new_bounds_in_pixel; | 164 bounds_in_pixel_ = new_bounds_in_pixel; |
| 150 size_in_pixel_ = new_bounds_in_pixel.size(); | 165 size_in_pixel_ = new_bounds_in_pixel.size(); |
| 151 UpdateDisplaySize(); | 166 UpdateDisplaySize(); |
| 152 } | 167 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 bounds_in_pixel_.ToString().c_str(), | 214 bounds_in_pixel_.ToString().c_str(), |
| 200 size_in_pixel_.ToString().c_str(), | 215 size_in_pixel_.ToString().c_str(), |
| 201 device_scale_factor_, | 216 device_scale_factor_, |
| 202 overscan_insets_in_dip_.ToString().c_str(), | 217 overscan_insets_in_dip_.ToString().c_str(), |
| 203 rotation_degree, | 218 rotation_degree, |
| 204 ui_scale_); | 219 ui_scale_); |
| 205 } | 220 } |
| 206 | 221 |
| 207 } // namespace internal | 222 } // namespace internal |
| 208 } // namespace ash | 223 } // namespace ash |
| OLD | NEW |