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

Unified Diff: ash/display/display_info.cc

Issue 1251573006: Cleanup: Enable 125DSFForUIScaling on by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « ash/display/display_info.h ('k') | ash/display/display_info_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_info.cc
diff --git a/ash/display/display_info.cc b/ash/display/display_info.cc
index 3e088853fc4e279efa2ac0077abc170838abeece..fa4019c40b07bb45b07e9202098ae5219800a470 100644
--- a/ash/display/display_info.cc
+++ b/ash/display/display_info.cc
@@ -24,7 +24,7 @@
namespace ash {
namespace {
-bool use_125_dsf_for_ui_scaling = false;
+bool use_125_dsf_for_ui_scaling = true;
// Check the content of |spec| and fill |bounds| and |device_scale_factor|.
// Returns true when |bounds| is found.
@@ -61,6 +61,11 @@ struct DisplayModeSorter {
bool is_internal;
};
+bool IsInternalDisplayId(int64 id) {
+ return id == gfx::Display::InternalDisplayId() &&
+ id != gfx::Display::kInvalidDisplayID;
+}
+
} // namespace
DisplayMode::DisplayMode()
@@ -84,12 +89,11 @@ DisplayMode::DisplayMode(const gfx::Size& size,
gfx::Size DisplayMode::GetSizeInDIP(bool is_internal) const {
gfx::SizeF size_dip(size);
size_dip.Scale(ui_scale);
- // DSF=1.25 is special. The screen is drawn with DSF=1.25 in some mode but it
- // doesn't affect the screen size computation.
- if (!(use_125_dsf_for_ui_scaling && is_internal) ||
- device_scale_factor != 1.25f) {
- size_dip.Scale(1.0f / device_scale_factor);
- }
+ // DSF=1.25 is special on internal display. The screen is drawn with DSF=1.25
+ // but it doesn't affect the screen size computation.
+ if (use_125_dsf_for_ui_scaling && is_internal && device_scale_factor == 1.25f)
+ return gfx::ToFlooredSize(size_dip);
+ size_dip.Scale(1.0f / device_scale_factor);
return gfx::ToFlooredSize(size_dip);
}
@@ -106,11 +110,6 @@ DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) {
}
// static
-void DisplayInfo::SetUse125DSFForUIScaling(bool enable) {
- use_125_dsf_for_ui_scaling = enable;
-}
-
-// static
DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec,
int64 id) {
// Use larger than max int to catch overflow early.
@@ -231,6 +230,11 @@ DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec,
return display_info;
}
+// static
+void DisplayInfo::SetUse125DSFForUIScalingForTest(bool enable) {
+ use_125_dsf_for_ui_scaling = enable;
+}
+
DisplayInfo::DisplayInfo()
: id_(gfx::Display::kInvalidDisplayID),
has_overscan_(false),
@@ -321,7 +325,7 @@ void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) {
}
float DisplayInfo::GetEffectiveDeviceScaleFactor() const {
- if (Use125DSFRorUIScaling() && device_scale_factor_ == 1.25f)
+ if (Use125DSFForUIScaling() && device_scale_factor_ == 1.25f)
return (configured_ui_scale_ == 0.8f) ? 1.25f : 1.0f;
if (device_scale_factor_ == configured_ui_scale_)
return 1.0f;
@@ -329,7 +333,7 @@ float DisplayInfo::GetEffectiveDeviceScaleFactor() const {
}
float DisplayInfo::GetEffectiveUIScale() const {
- if (Use125DSFRorUIScaling() && device_scale_factor_ == 1.25f)
+ if (Use125DSFForUIScaling() && device_scale_factor_ == 1.25f)
return (configured_ui_scale_ == 0.8f) ? 1.0f : configured_ui_scale_;
if (device_scale_factor_ == configured_ui_scale_)
return 1.0f;
@@ -367,7 +371,7 @@ void DisplayInfo::SetDisplayModes(
const std::vector<DisplayMode>& display_modes) {
display_modes_ = display_modes;
std::sort(display_modes_.begin(), display_modes_.end(),
- DisplayModeSorter(id_ == gfx::Display::InternalDisplayId()));
+ DisplayModeSorter(IsInternalDisplayId(id_)));
}
gfx::Size DisplayInfo::GetNativeModeSize() const {
@@ -429,8 +433,8 @@ bool DisplayInfo::IsColorProfileAvailable(
profile) != available_color_profiles_.end();
}
-bool DisplayInfo::Use125DSFRorUIScaling() const {
- return use_125_dsf_for_ui_scaling && id_ == gfx::Display::InternalDisplayId();
+bool DisplayInfo::Use125DSFForUIScaling() const {
+ return use_125_dsf_for_ui_scaling && IsInternalDisplayId(id_);
}
} // namespace ash
« no previous file with comments | « ash/display/display_info.h ('k') | ash/display/display_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698