summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 06:23:59 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 06:23:59 +0000
commit7d1119103313fcccecc28ef79a06af377ab88f58 (patch)
tree6afb742f61809ed1ef67c654ef78de868faf9257
parent03308ce875d753de0beb071c36292a5b36274e64 (diff)
downloadchromium_src-7d1119103313fcccecc28ef79a06af377ab88f58.zip
chromium_src-7d1119103313fcccecc28ef79a06af377ab88f58.tar.gz
chromium_src-7d1119103313fcccecc28ef79a06af377ab88f58.tar.bz2
Add virtual resolutions for 1.25 DSF
I'll adjust the threshold in a separate CL. BUG=391822,394941 Review URL: https://codereview.chromium.org/408353002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284859 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/display/display_info.cc5
-rw-r--r--ash/display/display_manager.cc18
-rw-r--r--ash/display/display_manager_unittest.cc10
3 files changed, 24 insertions, 9 deletions
diff --git a/ash/display/display_info.cc b/ash/display/display_info.cc
index 83a3923..087f0a3 100644
--- a/ash/display/display_info.cc
+++ b/ash/display/display_info.cc
@@ -23,6 +23,7 @@
namespace ash {
namespace {
+// TODO(oshima): This feature is obsolete. Remove this after m38.
bool allow_upgrade_to_high_dpi = false;
}
@@ -253,7 +254,7 @@ float DisplayInfo::GetEffectiveDeviceScaleFactor() const {
if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
device_scale_factor_ == 1.0f) {
return 2.0f;
- } else if (device_scale_factor_ == 2.0f && configured_ui_scale_ == 2.0f) {
+ } else if (device_scale_factor_ == configured_ui_scale_) {
return 1.0f;
}
return device_scale_factor_;
@@ -263,7 +264,7 @@ float DisplayInfo::GetEffectiveUIScale() const {
if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
device_scale_factor_ == 1.0f) {
return configured_ui_scale_ * 2.0f;
- } else if (device_scale_factor_ == 2.0f && configured_ui_scale_ == 2.0f) {
+ } else if (device_scale_factor_ == configured_ui_scale_) {
return 1.0f;
}
return configured_ui_scale_;
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index 1a981a4..07d44155 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -65,6 +65,7 @@ const int kMinimumOverlapForInvalidOffset = 100;
// for the full list of resolutions.
const float kUIScalesFor2x[] =
{0.5f, 0.625f, 0.8f, 1.0f, 1.125f, 1.25f, 1.5f, 2.0f};
+const float kUIScalesFor1_25x[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.25f };
const float kUIScalesFor1280[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f };
const float kUIScalesFor1366[] = {0.5f, 0.6f, 0.75f, 1.0f, 1.125f };
@@ -183,23 +184,26 @@ DisplayManager::~DisplayManager() {
// static
std::vector<float> DisplayManager::GetScalesForDisplay(
const DisplayInfo& info) {
+
+#define ASSIGN_ARRAY(v, a) v.assign(a, a + arraysize(a))
+
std::vector<float> ret;
if (info.device_scale_factor() == 2.0f) {
- ret.assign(kUIScalesFor2x, kUIScalesFor2x + arraysize(kUIScalesFor2x));
+ ASSIGN_ARRAY(ret, kUIScalesFor2x);
+ return ret;
+ } else if (info.device_scale_factor() == 1.25f) {
+ ASSIGN_ARRAY(ret, kUIScalesFor1_25x);
return ret;
}
switch (info.bounds_in_native().width()) {
case 1280:
- ret.assign(kUIScalesFor1280,
- kUIScalesFor1280 + arraysize(kUIScalesFor1280));
+ ASSIGN_ARRAY(ret, kUIScalesFor1280);
break;
case 1366:
- ret.assign(kUIScalesFor1366,
- kUIScalesFor1366 + arraysize(kUIScalesFor1366));
+ ASSIGN_ARRAY(ret, kUIScalesFor1366);
break;
default:
- ret.assign(kUIScalesFor1280,
- kUIScalesFor1280 + arraysize(kUIScalesFor1280));
+ ASSIGN_ARRAY(ret, kUIScalesFor1280);
#if defined(OS_CHROMEOS)
if (base::SysInfo::IsRunningOnChromeOS())
NOTREACHED() << "Unknown resolution:" << info.ToString();
diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc
index 7db5ba9..54dd0aa 100644
--- a/ash/display/display_manager_unittest.cc
+++ b/ash/display/display_manager_unittest.cc
@@ -953,6 +953,16 @@ TEST_F(DisplayManagerTest, UIScale) {
display = Shell::GetScreen()->GetPrimaryDisplay();
EXPECT_EQ(1.0f, display.device_scale_factor());
EXPECT_EQ("1280x850", display.bounds().size().ToString());
+
+ // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF
+ // on screen.
+ UpdateDisplay("1280x850*1.25");
+ display_manager()->SetDisplayUIScale(display_id, 1.25f);
+ EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale());
+ EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
+ display = Shell::GetScreen()->GetPrimaryDisplay();
+ EXPECT_EQ(1.0f, display.device_scale_factor());
+ EXPECT_EQ("1280x850", display.bounds().size().ToString());
}
TEST_F(DisplayManagerTest, UIScaleUpgradeToHighDPI) {