Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2430)

Unified Diff: ash/display/display_info.cc

Issue 12505005: Store rotation/ui scale to local state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/display/display_info.cc
diff --git a/ash/display/display_info.cc b/ash/display/display_info.cc
index b46dceb12490548732c61498bf512cbd27262bbd..739be8904115a70a1812a623c82eff4a6fafa4a6 100644
--- a/ash/display/display_info.cc
+++ b/ash/display/display_info.cc
@@ -110,7 +110,8 @@ DisplayInfo::DisplayInfo()
device_scale_factor_(1.0f),
overscan_insets_in_dip_(0, 0, 0, 0),
has_custom_overscan_insets_(false),
- ui_scale_(1.0f) {
+ ui_scale_(1.0f),
+ native_(false) {
}
DisplayInfo::DisplayInfo(int64 id,
@@ -123,13 +124,14 @@ DisplayInfo::DisplayInfo(int64 id,
device_scale_factor_(1.0f),
overscan_insets_in_dip_(0, 0, 0, 0),
has_custom_overscan_insets_(false),
- ui_scale_(1.0f) {
+ ui_scale_(1.0f),
+ native_(false) {
}
DisplayInfo::~DisplayInfo() {
}
-void DisplayInfo::CopyFromNative(const DisplayInfo& native_info) {
+void DisplayInfo::Copy(const DisplayInfo& native_info) {
DCHECK(id_ == native_info.id_);
name_ = native_info.name_;
has_overscan_ = native_info.has_overscan_;
@@ -138,8 +140,21 @@ void DisplayInfo::CopyFromNative(const DisplayInfo& native_info) {
bounds_in_pixel_ = native_info.bounds_in_pixel_;
size_in_pixel_ = native_info.size_in_pixel_;
device_scale_factor_ = native_info.device_scale_factor_;
- rotation_ = native_info.rotation_;
- ui_scale_ = native_info.ui_scale_;
+
+ // Rotation_ and ui_scale_ are given by preference, or unit
+ // tests. Don't copy if this native_info came from
+ // DisplayChangeObserverX11.
+ if (!native_info.native()) {
+ rotation_ = native_info.rotation_;
+ ui_scale_ = native_info.ui_scale_;
+ }
+ // It makes little sense to scale beyond the original
+ // resolution. This guard is to protect applying
+ // ui_scale to an external display whose DPI has changed
+ // from 2.0 to 1.0 for some reason.
+ if (ui_scale_ > device_scale_factor_)
+ ui_scale_ = 1.0f;
+
// Don't copy insets as it may be given by preference. |rotation_|
// is treated as a native so that it can be specified in
// |CreateFromSpec|.

Powered by Google App Engine
This is Rietveld 408576698