summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-10 21:21:10 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-10 21:21:10 +0000
commitc5832bd9976001d5d51c923b66cbb60953d8ea96 (patch)
tree38075c1830f2898e7a2e3c9300faa828bfc52824
parentd55603f9d4311755735a41f3eac30e4d9b3d629d (diff)
downloadchromium_src-c5832bd9976001d5d51c923b66cbb60953d8ea96.zip
chromium_src-c5832bd9976001d5d51c923b66cbb60953d8ea96.tar.gz
chromium_src-c5832bd9976001d5d51c923b66cbb60953d8ea96.tar.bz2
Revert 262922 "Modifies the threshold for hidpi displays."
> Modifies the threshold for hidpi displays. > > It is really tough to use some 4K monitor from ChromeOS because > the resolution is too high in comparison with the physical size. > > Better to use 2X mode in such case. > > BUG=348279 > R=oshima@chromium.org > TEST=manually > > Review URL: https://codereview.chromium.org/227593011 TBR=mukai@chromium.org Review URL: https://codereview.chromium.org/327923002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276152 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/display/display_change_observer_chromeos.cc15
-rw-r--r--chrome/browser/resources/options/chromeos/display_options.css3
-rw-r--r--chrome/browser/resources/options/chromeos/display_options.js12
-rw-r--r--chrome/browser/ui/webui/options/chromeos/display_options_handler.cc162
4 files changed, 71 insertions, 121 deletions
diff --git a/ash/display/display_change_observer_chromeos.cc b/ash/display/display_change_observer_chromeos.cc
index 40a1a37..a7bb2e1 100644
--- a/ash/display/display_change_observer_chromeos.cc
+++ b/ash/display/display_change_observer_chromeos.cc
@@ -30,6 +30,13 @@ using ui::DisplayConfigurator;
namespace {
+// The DPI threshold to detect high density screen.
+// Higher DPI than this will use device_scale_factor=2.
+const unsigned int kHighDensityDPIThreshold = 170;
+
+// 1 inch in mm.
+const float kInchInMm = 25.4f;
+
// Display mode list is sorted by (in descending priority):
// * the area in pixels.
// * refresh rate.
@@ -126,8 +133,12 @@ void DisplayChangeObserver::OnDisplayModeChanged(
if (!mode_info)
continue;
- float device_scale_factor = ui::GetScaleFactor(
- state.display->physical_size(), mode_info->size());
+ float device_scale_factor = 1.0f;
+ if (!ui::IsDisplaySizeBlackListed(state.display->physical_size()) &&
+ (kInchInMm * mode_info->size().width() /
+ state.display->physical_size().width()) > kHighDensityDPIThreshold) {
+ device_scale_factor = 2.0f;
+ }
gfx::Rect display_bounds(state.display->origin(), mode_info->size());
std::vector<DisplayMode> display_modes = GetDisplayModeList(state);
diff --git a/chrome/browser/resources/options/chromeos/display_options.css b/chrome/browser/resources/options/chromeos/display_options.css
index 4bc5964..3f73879 100644
--- a/chrome/browser/resources/options/chromeos/display_options.css
+++ b/chrome/browser/resources/options/chromeos/display_options.css
@@ -4,7 +4,6 @@
#display-options-page {
background-color: rgb(240, 240, 240);
- min-width: 450px;
}
#display-options-content-area {
@@ -93,5 +92,5 @@
}
.display-options-button {
- width: 155px;
+ width: 130px;
}
diff --git a/chrome/browser/resources/options/chromeos/display_options.js b/chrome/browser/resources/options/chromeos/display_options.js
index 54452d8..e0285c2 100644
--- a/chrome/browser/resources/options/chromeos/display_options.js
+++ b/chrome/browser/resources/options/chromeos/display_options.js
@@ -622,17 +622,9 @@ cr.define('options', function() {
} else {
for (var i = 0; i < display.resolutions.length; i++) {
var option = document.createElement('option');
- var width = display.resolutions[i].width;
- var height = display.resolutions[i].height;
- var scaleFactor = display.resolutions[i].scaleFactor;
- if (display.resolutions[i].scaleFactor) {
- width /= scaleFactor;
- height /= scaleFactor;
- }
option.value = i;
- option.textContent = width + 'x' + height;
- if (scaleFactor && scaleFactor > 1)
- option.textContent += '(x' + scaleFactor + ')';
+ option.textContent = display.resolutions[i].width + 'x' +
+ display.resolutions[i].height;
if (display.resolutions[i].isBest) {
option.textContent += ' ' +
loadTimeData.getString('annotateBest');
diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
index 679bffb..52a5e23 100644
--- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
@@ -54,33 +54,10 @@ int64 GetDisplayId(const base::ListValue* args) {
return display_id;
}
-bool CompareResolution(base::Value* display1, base::Value* display2) {
- base::DictionaryValue* d1 = NULL;
- base::DictionaryValue* d2 = NULL;
- CHECK(display1->GetAsDictionary(&d1) && display2->GetAsDictionary(&d2));
- int width1 = 0, height1 = 0, width2 = 0, height2 = 0;
- CHECK(d1->GetInteger("width", &width1) && d1->GetInteger("height", &height1));
- CHECK(d2->GetInteger("width", &width2) && d2->GetInteger("height", &height2));
- double scale_factor1 = 0, scale_factor2 = 0;
- if (d1->GetDouble("scaleFactor", &scale_factor1)) {
- width1 /= scale_factor1;
- height1 /= scale_factor1;
- }
- if (d2->GetDouble("scaleFactor", &scale_factor2)) {
- width2 /= scale_factor2;
- height2 /= scale_factor2;
- }
-
- if (width1 * height1 == width2 * height2) {
- if (scale_factor1 != scale_factor2)
- return scale_factor1 < scale_factor2;
-
- int refresh_rate1 = 0, refresh_rate2 = 0;
- CHECK(d1->GetInteger("refreshRate", &refresh_rate1) ==
- d2->GetInteger("refreshRate", &refresh_rate2));
- return refresh_rate1 < refresh_rate2;
- }
- return width1 * height1 < width2 * height2;
+bool CompareDisplayMode(ash::DisplayMode d1, ash::DisplayMode d2) {
+ if (d1.size.GetArea() == d2.size.GetArea())
+ return d1.refresh_rate < d2.refresh_rate;
+ return d1.size.GetArea() < d2.size.GetArea();
}
base::string16 GetColorProfileName(ui::ColorCalibrationProfile profile) {
@@ -105,79 +82,6 @@ base::string16 GetColorProfileName(ui::ColorCalibrationProfile profile) {
return base::string16();
}
-scoped_ptr<base::ListValue> GetResolutionsForInternalDisplay(
- const ash::DisplayInfo& display_info) {
- scoped_ptr<base::ListValue> js_resolutions(new base::ListValue);
- const std::vector<float> ui_scales =
- DisplayManager::GetScalesForDisplay(display_info);
- gfx::SizeF base_size = display_info.bounds_in_native().size();
- base_size.Scale(1.0f / display_info.device_scale_factor());
- if (display_info.rotation() == gfx::Display::ROTATE_90 ||
- display_info.rotation() == gfx::Display::ROTATE_270) {
- float tmp = base_size.width();
- base_size.set_width(base_size.height());
- base_size.set_height(tmp);
- }
-
- for (size_t i = 0; i < ui_scales.size(); ++i) {
- base::DictionaryValue* resolution_info = new base::DictionaryValue();
- gfx::SizeF new_size = base_size;
- new_size.Scale(ui_scales[i]);
- gfx::Size resolution = gfx::ToFlooredSize(new_size);
- resolution_info->SetDouble("scale", ui_scales[i]);
- if (ui_scales[i] == 1.0f)
- resolution_info->SetBoolean("isBest", true);
- resolution_info->SetBoolean(
- "selected", display_info.configured_ui_scale() == ui_scales[i]);
- resolution_info->SetInteger("width", resolution.width());
- resolution_info->SetInteger("height", resolution.height());
- js_resolutions->Append(resolution_info);
- }
-
- return js_resolutions.Pass();
-}
-
-scoped_ptr<base::ListValue> GetResolutionsForExternalDisplay(
- const ash::DisplayInfo& display_info) {
- scoped_ptr<base::ListValue> js_resolutions(new base::ListValue);
-
- gfx::Size current_size = display_info.bounds_in_native().size();
- int largest_index = -1;
- int largest_area = -1;
-
- for (size_t i = 0; i < display_info.display_modes().size(); ++i) {
- base::DictionaryValue* resolution_info = new base::DictionaryValue();
- const ash::DisplayMode& display_mode = display_info.display_modes()[i];
- gfx::Size resolution = display_mode.size;
-
- if (resolution.GetArea() > largest_area) {
- resolution_info->SetBoolean("isBest", true);
- largest_area = resolution.GetArea();
- if (largest_index >= 0) {
- base::DictionaryValue* prev_largest = NULL;
- CHECK(js_resolutions->GetDictionary(largest_index, &prev_largest));
- prev_largest->SetBoolean("isBest", false);
- }
- largest_index = i;
- }
-
- if (resolution == current_size) {
- // Right now, the scale factor for unselected resolutions is unknown.
- // TODO(mukai): Set the scale factor for unselected ones.
- resolution_info->SetDouble(
- "scaleFactor", display_info.device_scale_factor());
- resolution_info->SetBoolean("selected", true);
- }
-
- resolution_info->SetInteger("width", resolution.width());
- resolution_info->SetInteger("height", resolution.height());
- resolution_info->SetDouble("refreshRate", display_mode.refresh_rate);
- js_resolutions->Append(resolution_info);
- }
-
- return js_resolutions.Pass();
-}
-
} // namespace
DisplayOptionsHandler::DisplayOptionsHandler() {
@@ -313,13 +217,57 @@ void DisplayOptionsHandler::SendDisplayInfo(
js_display->SetBoolean("isInternal", display.IsInternal());
js_display->SetInteger("orientation",
static_cast<int>(display_info.rotation()));
-
- scoped_ptr<base::ListValue> js_resolutions = display.IsInternal() ?
- GetResolutionsForInternalDisplay(display_info) :
- GetResolutionsForExternalDisplay(display_info);
- std::sort(
- js_resolutions->begin(), js_resolutions->end(), CompareResolution);
- js_display->Set("resolutions", js_resolutions.release());
+ std::vector<ash::DisplayMode> display_modes;
+ std::vector<float> ui_scales;
+ if (display.IsInternal()) {
+ ui_scales = DisplayManager::GetScalesForDisplay(display_info);
+ gfx::SizeF base_size = display_info.bounds_in_native().size();
+ base_size.Scale(1.0f / display_info.device_scale_factor());
+ if (display_info.rotation() == gfx::Display::ROTATE_90 ||
+ display_info.rotation() == gfx::Display::ROTATE_270) {
+ float tmp = base_size.width();
+ base_size.set_width(base_size.height());
+ base_size.set_height(tmp);
+ }
+ for (size_t i = 0; i < ui_scales.size(); ++i) {
+ gfx::SizeF new_size = base_size;
+ new_size.Scale(ui_scales[i]);
+ display_modes.push_back(ash::DisplayMode(
+ gfx::ToFlooredSize(new_size), -1.0f, false, false));
+ }
+ } else {
+ for (size_t i = 0; i < display_info.display_modes().size(); ++i)
+ display_modes.push_back(display_info.display_modes()[i]);
+ }
+ std::sort(display_modes.begin(), display_modes.end(), CompareDisplayMode);
+
+ base::ListValue* js_resolutions = new base::ListValue();
+ gfx::Size current_size = display_info.bounds_in_native().size();
+ for (size_t i = 0; i < display_modes.size(); ++i) {
+ base::DictionaryValue* resolution_info = new base::DictionaryValue();
+ gfx::Size resolution = display_modes[i].size;
+ if (!ui_scales.empty()) {
+ resolution_info->SetDouble("scale", ui_scales[i]);
+ if (ui_scales[i] == 1.0f)
+ resolution_info->SetBoolean("isBest", true);
+ resolution_info->SetBoolean(
+ "selected", display_info.configured_ui_scale() == ui_scales[i]);
+ } else {
+ // Picks the largest one as the "best", which is the last element
+ // because |display_modes| is sorted by its area.
+ if (i == display_modes.size() - 1)
+ resolution_info->SetBoolean("isBest", true);
+ resolution_info->SetBoolean("selected", (resolution == current_size));
+ }
+ resolution_info->SetInteger("width", resolution.width());
+ resolution_info->SetInteger("height", resolution.height());
+ if (display_modes[i].refresh_rate > 0.0f) {
+ resolution_info->SetDouble("refreshRate",
+ display_modes[i].refresh_rate);
+ }
+ js_resolutions->Append(resolution_info);
+ }
+ js_display->Set("resolutions", js_resolutions);
js_display->SetInteger("colorProfile", display_info.color_profile());
base::ListValue* available_color_profiles = new base::ListValue();