diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-20 02:54:01 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-20 02:54:01 +0000 |
commit | ccb962dfd9abe9fe9c990372a56e04cc9aa8ddb8 (patch) | |
tree | 32ed8af1514c97d0093b76afa5d3be2b5d5cf0da | |
parent | f57d7f729c8bede8290c172ce73ffe60096c2546 (diff) | |
download | chromium_src-ccb962dfd9abe9fe9c990372a56e04cc9aa8ddb8.zip chromium_src-ccb962dfd9abe9fe9c990372a56e04cc9aa8ddb8.tar.gz chromium_src-ccb962dfd9abe9fe9c990372a56e04cc9aa8ddb8.tar.bz2 |
Allow 1.0f scale factor on pixel
BUG=246274
TEST=covered by test
Review URL: https://codereview.chromium.org/72903002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236112 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/desktop_background/desktop_background_view.cc | 8 | ||||
-rw-r--r-- | ash/display/display_controller_unittest.cc | 3 | ||||
-rw-r--r-- | ash/display/display_info.cc | 18 | ||||
-rw-r--r-- | ash/display/display_info.h | 28 | ||||
-rw-r--r-- | ash/display/display_info_unittest.cc | 4 | ||||
-rw-r--r-- | ash/display/display_manager.cc | 16 | ||||
-rw-r--r-- | ash/display/display_manager_unittest.cc | 71 | ||||
-rw-r--r-- | ash/display/root_window_transformers.cc | 22 | ||||
-rw-r--r-- | ash/display/root_window_transformers_unittest.cc | 3 | ||||
-rw-r--r-- | ash/system/chromeos/tray_display.cc | 162 | ||||
-rw-r--r-- | chrome/browser/chromeos/display/display_preferences.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/display/display_preferences_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/chromeos/display_options_handler.cc | 2 |
13 files changed, 188 insertions, 158 deletions
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc index 5eb5072..6a7bf82 100644 --- a/ash/desktop_background/desktop_background_view.cc +++ b/ash/desktop_background/desktop_background_view.cc @@ -55,15 +55,15 @@ class LayerControlView : public views::View { GetWidget()->GetNativeView()); DisplayManager* display_manager = Shell::GetInstance()->display_manager(); DisplayInfo info = display_manager->GetDisplayInfo(display.id()); - + float ui_scale = info.GetEffectiveUIScale(); gfx::SizeF pixel_size = display.size(); - pixel_size.Scale(1.0f / info.ui_scale()); + pixel_size.Scale(1.0f / ui_scale); gfx::Size rounded_size = gfx::ToCeiledSize(pixel_size); DCHECK_EQ(1, child_count()); views::View* child = child_at(0); child->SetBounds(0, 0, rounded_size.width(), rounded_size.height()); gfx::Transform transform; - transform.Scale(info.ui_scale(), info.ui_scale()); + transform.Scale(ui_scale, ui_scale); child->SetTransform(transform); } @@ -103,7 +103,7 @@ void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { DisplayManager* display_manager = Shell::GetInstance()->display_manager(); DisplayInfo display_info = display_manager->GetDisplayInfo(display.id()); - float scaling = display_info.ui_scale(); + float scaling = display_info.GetEffectiveUIScale(); if (scaling <= 1.0f) scaling = 1.0f; // Allow scaling up to the UI scaling. diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc index 88a3e7e..35b585f 100644 --- a/ash/display/display_controller_unittest.cc +++ b/ash/display/display_controller_unittest.cc @@ -277,7 +277,8 @@ gfx::Display::Rotation GetStoredRotation(int64 id) { } float GetStoredUIScale(int64 id) { - return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale(); + return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). + GetEffectiveUIScale(); } #if defined(USE_X11) diff --git a/ash/display/display_info.cc b/ash/display/display_info.cc index ec48f31..01c604f 100644 --- a/ash/display/display_info.cc +++ b/ash/display/display_info.cc @@ -116,7 +116,7 @@ DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan); display_info.set_device_scale_factor(device_scale_factor); display_info.set_rotation(rotation); - display_info.set_ui_scale(ui_scale); + display_info.set_configured_ui_scale(ui_scale); display_info.SetBounds(bounds_in_native); display_info.set_resolutions(resolutions); @@ -140,7 +140,7 @@ DisplayInfo::DisplayInfo() touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), device_scale_factor_(1.0f), overscan_insets_in_dip_(0, 0, 0, 0), - ui_scale_(1.0f), + configured_ui_scale_(1.0f), native_(false) { } @@ -154,7 +154,7 @@ DisplayInfo::DisplayInfo(int64 id, touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), device_scale_factor_(1.0f), overscan_insets_in_dip_(0, 0, 0, 0), - ui_scale_(1.0f), + configured_ui_scale_(1.0f), native_(false) { } @@ -185,7 +185,7 @@ void DisplayInfo::Copy(const DisplayInfo& native_info) { // DisplayChangeObserver. if (!native_info.native()) { rotation_ = native_info.rotation_; - ui_scale_ = native_info.ui_scale_; + configured_ui_scale_ = native_info.configured_ui_scale_; } // Don't copy insets as it may be given by preference. |rotation_| // is treated as a native so that it can be specified in @@ -198,6 +198,12 @@ void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) { UpdateDisplaySize(); } +float DisplayInfo::GetEffectiveUIScale() const { + if (device_scale_factor_ == 2.0f && configured_ui_scale_ == 2.0f) + return 1.0f; + return configured_ui_scale_; +} + void DisplayInfo::UpdateDisplaySize() { size_in_pixel_ = bounds_in_native_.size(); if (!overscan_insets_in_dip_.empty()) { @@ -212,7 +218,7 @@ void DisplayInfo::UpdateDisplaySize() { rotation_ == gfx::Display::ROTATE_270) size_in_pixel_.SetSize(size_in_pixel_.height(), size_in_pixel_.width()); gfx::SizeF size_f(size_in_pixel_); - size_f.Scale(ui_scale_); + size_f.Scale(GetEffectiveUIScale()); size_in_pixel_ = gfx::ToFlooredSize(size_f); } @@ -235,7 +241,7 @@ std::string DisplayInfo::ToString() const { device_scale_factor_, overscan_insets_in_dip_.ToString().c_str(), rotation_degree, - ui_scale_, + configured_ui_scale_, touch_support_ == gfx::Display::TOUCH_SUPPORT_AVAILABLE ? "yes" : touch_support_ == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE ? "no" : "unknown"); diff --git a/ash/display/display_info.h b/ash/display/display_info.h index 958b6d4..69b83dc 100644 --- a/ash/display/display_info.h +++ b/ash/display/display_info.h @@ -9,7 +9,6 @@ #include <vector> #include "ash/ash_export.h" -#include "base/gtest_prod_util.h" #include "ui/gfx/display.h" #include "ui/gfx/insets.h" #include "ui/gfx/rect.h" @@ -98,8 +97,9 @@ class ASH_EXPORT DisplayInfo { float device_scale_factor() const { return device_scale_factor_; } void set_device_scale_factor(float scale) { device_scale_factor_ = scale; } - // The native bounds for the display. The size of this can be different from - // the |size_in_pixel| when overscan insets are set and/or |ui_scale_| is set. + // The native bounds for the display. The size of this can be + // different from the |size_in_pixel| when overscan insets are set + // and/or |configured_ui_scale_| is set. const gfx::Rect bounds_in_native() const { return bounds_in_native_; } @@ -112,12 +112,19 @@ class ASH_EXPORT DisplayInfo { return overscan_insets_in_dip_; } - float ui_scale() const { return ui_scale_; } - void set_ui_scale(float scale) { ui_scale_ = scale; } + // Sets/gets configured ui scale. This can be different from the ui + // scale actually used when the scale is 2.0 and DSF is 2.0. + // (the effective ui scale is 1.0 in this case). + float configured_ui_scale() const { return configured_ui_scale_; } + void set_configured_ui_scale(float scale) { configured_ui_scale_ = scale; } - // Copy the display info except for fields that can be modified by a user - // (|rotation_| and |ui_scale_|). |rotation_| and |ui_scale_| are copied - // when the |another_info| isn't native one. + // Returns the ui scale used for the device scale factor. This + // return 1.0f if the ui scale and dsf are both set to 2.0. + float GetEffectiveUIScale() const; + + // Copy the display info except for fields that can be modified by a + // user (|rotation_| and |configured_ui_scale_|). |rotation_| and + // |configured_ui_scale_| are copied when the |another_info| isn't native one. void Copy(const DisplayInfo& another_info); // Update the |bounds_in_native_| and |size_in_pixel_| using @@ -174,8 +181,9 @@ class ASH_EXPORT DisplayInfo { // shrink) the desktop over the native display resolution (useful in // HighDPI display). Note that this should not be confused with the // device scale factor, which specifies the pixel density of the - // display. - float ui_scale_; + // display. The actuall scale value to be used depends on the device + // scale factor. See |GetEffectiveScaleFactor()|. + float configured_ui_scale_; // True if this comes from native platform (DisplayChangeObserver). bool native_; diff --git a/ash/display/display_info_unittest.cc b/ash/display/display_info_unittest.cc index 6b110fb..9faa0aa 100644 --- a/ash/display/display_info_unittest.cc +++ b/ash/display/display_info_unittest.cc @@ -18,7 +18,7 @@ TEST_F(DisplayInfoTest, CreateFromSpec) { EXPECT_EQ("200x100", info.size_in_pixel().ToString()); EXPECT_EQ(gfx::Display::ROTATE_0, info.rotation()); EXPECT_EQ("0,0,0,0", info.overscan_insets_in_dip().ToString()); - EXPECT_EQ(1.0f, info.ui_scale()); + EXPECT_EQ(1.0f, info.configured_ui_scale()); info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/o", 10); EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); @@ -42,7 +42,7 @@ TEST_F(DisplayInfoTest, CreateFromSpec) { info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/l@1.5", 10); EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); EXPECT_EQ(gfx::Display::ROTATE_270, info.rotation()); - EXPECT_EQ(1.5f, info.ui_scale()); + EXPECT_EQ(1.5f, info.configured_ui_scale()); info = DisplayInfo::CreateFromSpecWithID( "200x200#300x200|200x200|100x100", 10); diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc index 855221b..10f79c5 100644 --- a/ash/display/display_manager.cc +++ b/ash/display/display_manager.cc @@ -56,7 +56,8 @@ const int kMinimumOverlapForInvalidOffset = 100; // 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on // 2560 pixel width 2x density display. Please see crbug.com/233375 // for the full list of resolutions. -const float kUIScalesFor2x[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f, 1.25f, 1.5f}; +const float kUIScalesFor2x[] = + {0.5f, 0.625f, 0.8f, 1.0f, 1.125f, 1.25f, 1.5f, 2.0f}; 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 }; @@ -187,7 +188,7 @@ std::vector<float> DisplayManager::GetScalesForDisplay( // static float DisplayManager::GetNextUIScale(const DisplayInfo& info, bool up) { - float scale = info.ui_scale(); + float scale = info.configured_ui_scale(); std::vector<float> scales = GetScalesForDisplay(info); for (size_t i = 0; i < scales.size(); ++i) { if (ScaleComparator(scales[i])(scale)) { @@ -395,7 +396,7 @@ void DisplayManager::SetDisplayUIScale(int64 display_id, iter != displays_.end(); ++iter) { DisplayInfo info = GetDisplayInfo(iter->id()); if (info.id() == display_id) { - if (info.ui_scale() == ui_scale) + if (info.configured_ui_scale() == ui_scale) return; std::vector<float> scales = GetScalesForDisplay(info); ScaleComparator comparator(ui_scale); @@ -403,7 +404,7 @@ void DisplayManager::SetDisplayUIScale(int64 display_id, scales.end()) { return; } - info.set_ui_scale(ui_scale); + info.set_configured_ui_scale(ui_scale); } display_info_list.push_back(info); } @@ -453,7 +454,7 @@ void DisplayManager::RegisterDisplayProperty( display_info_[display_id].set_rotation(rotation); // Just in case the preference file was corrupted. if (0.5f <= ui_scale && ui_scale <= 2.0f) - display_info_[display_id].set_ui_scale(ui_scale); + display_info_[display_id].set_configured_ui_scale(ui_scale); if (overscan_insets) display_info_[display_id].SetOverscanInsets(*overscan_insets); if (!resolution_in_pixels.IsEmpty()) @@ -932,12 +933,15 @@ gfx::Display DisplayManager::CreateDisplayFromDisplayInfoById(int64 id) { gfx::Display new_display(display_info.id()); gfx::Rect bounds_in_native(display_info.size_in_pixel()); + float device_scale_factor = display_info.device_scale_factor(); + if (device_scale_factor == 2.0f && display_info.configured_ui_scale() == 2.0f) + device_scale_factor = 1.0f; // Simply set the origin to (0,0). The primary display's origin is // always (0,0) and the secondary display's bounds will be updated // in |UpdateSecondaryDisplayBoundsForLayout| called in |UpdateDisplay|. new_display.SetScaleAndBounds( - display_info.device_scale_factor(), gfx::Rect(bounds_in_native.size())); + device_scale_factor, gfx::Rect(bounds_in_native.size())); new_display.set_rotation(display_info.rotation()); new_display.set_touch_support(display_info.touch_support()); return new_display; diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index f6bd59e..162f9a9 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc @@ -804,69 +804,82 @@ TEST_F(DisplayManagerTest, UIScale) { UpdateDisplay("1280x800"); int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); display_manager()->SetDisplayUIScale(display_id, 1.125f); - EXPECT_EQ(1.0, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.8f); - EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.75f); - EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.625f); - EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); gfx::Display::SetInternalDisplayId(display_id); display_manager()->SetDisplayUIScale(display_id, 1.5f); - EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 1.25f); - EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 1.125f); - EXPECT_EQ(1.125f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.8f); - EXPECT_EQ(0.8f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.75f); - EXPECT_EQ(0.8f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.625f); - EXPECT_EQ(0.625f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.6f); - EXPECT_EQ(0.625f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.5f); - EXPECT_EQ(0.5f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); UpdateDisplay("1366x768"); display_manager()->SetDisplayUIScale(display_id, 1.5f); - EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 1.25f); - EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 1.125f); - EXPECT_EQ(1.125f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.8f); - EXPECT_EQ(1.125f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.75f); - EXPECT_EQ(0.75f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.75f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.6f); - EXPECT_EQ(0.6f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.6f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.625f); - EXPECT_EQ(0.6f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.6f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.5f); - EXPECT_EQ(0.5f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); UpdateDisplay("1280x850*2"); - EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 1.5f); - EXPECT_EQ(1.5f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.5f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 1.25f); - EXPECT_EQ(1.25f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 1.125f); - EXPECT_EQ(1.125f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); + display_manager()->SetDisplayUIScale(display_id, 1.0f); + EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); + gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); + EXPECT_EQ(2.0f, display.device_scale_factor()); + EXPECT_EQ("640x425", display.bounds().size().ToString()); + display_manager()->SetDisplayUIScale(display_id, 0.8f); - EXPECT_EQ(0.8f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.75f); - EXPECT_EQ(0.8f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.625f); - EXPECT_EQ(0.625f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.6f); - EXPECT_EQ(0.625f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); display_manager()->SetDisplayUIScale(display_id, 0.5f); - EXPECT_EQ(0.5f, GetDisplayInfoAt(0).ui_scale()); + EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); + + display_manager()->SetDisplayUIScale(display_id, 2.0f); + EXPECT_EQ(2.0f, 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()); } diff --git a/ash/display/root_window_transformers.cc b/ash/display/root_window_transformers.cc index 0c81684..7f808dd 100644 --- a/ash/display/root_window_transformers.cc +++ b/ash/display/root_window_transformers.cc @@ -123,32 +123,24 @@ gfx::Transform CreateInsetsAndScaleTransform(const gfx::Insets& insets, return transform; } -gfx::Transform CreateOverscanAndUIScaleTransform(aura::Window* root_window, - const gfx::Display& display) { - DisplayInfo info = - Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); - return CreateInsetsAndScaleTransform( - info.GetOverscanInsetsInPixel(), - ui::GetDeviceScaleFactor(root_window->layer()), - info.ui_scale()); -} - // RootWindowTransformer for ash environment. class AshRootWindowTransformer : public aura::RootWindowTransformer { public: AshRootWindowTransformer(aura::Window* root, const gfx::Display& display) : root_window_(root) { + DisplayInfo info = Shell::GetInstance()->display_manager()-> + GetDisplayInfo(display.id()); + host_insets_ = info.GetOverscanInsetsInPixel(); + root_window_ui_scale_ = info.GetEffectiveUIScale(); root_window_bounds_transform_ = - CreateOverscanAndUIScaleTransform(root, display) * + CreateInsetsAndScaleTransform(host_insets_, + display.device_scale_factor(), + root_window_ui_scale_) * CreateRotationTransform(root, display); transform_ = root_window_bounds_transform_ * CreateMagnifierTransform(root); CHECK(transform_.GetInverse(&invert_transform_)); - DisplayInfo info = Shell::GetInstance()->display_manager()-> - GetDisplayInfo(display.id()); - root_window_ui_scale_ = info.ui_scale(); - host_insets_ = info.GetOverscanInsetsInPixel(); } // aura::RootWindowTransformer overrides: diff --git a/ash/display/root_window_transformers_unittest.cc b/ash/display/root_window_transformers_unittest.cc index 5029e20..7919243 100644 --- a/ash/display/root_window_transformers_unittest.cc +++ b/ash/display/root_window_transformers_unittest.cc @@ -113,7 +113,8 @@ gfx::Display::Rotation GetStoredRotation(int64 id) { } float GetStoredUIScale(int64 id) { - return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale(); + return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). + GetEffectiveUIScale(); } } // namespace diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc index fcee915..bf0b3dc 100644 --- a/ash/system/chromeos/tray_display.cc +++ b/ash/system/chromeos/tray_display.cc @@ -106,81 +106,6 @@ base::string16 GetAllDisplayInfo() { return JoinString(lines, '\n'); } -// Returns the name of the currently connected external display. -// This should not be used when the external display is used for -// mirroring. -base::string16 GetExternalDisplayName() { - DisplayManager* display_manager = GetDisplayManager(); - DCHECK(!display_manager->IsMirrored()); - - int64 external_id = gfx::Display::kInvalidDisplayID; - for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { - int64 id = display_manager->GetDisplayAt(i).id(); - if (id != gfx::Display::InternalDisplayId()) { - external_id = id; - break; - } - } - - if (external_id == gfx::Display::kInvalidDisplayID) - return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); - - // The external display name may have an annotation of "(width x height)" in - // case that the display is rotated or its resolution is changed. - base::string16 name = GetDisplayName(external_id); - const DisplayInfo& display_info = - display_manager->GetDisplayInfo(external_id); - if (display_info.rotation() != gfx::Display::ROTATE_0 || - display_info.ui_scale() != 1.0f || - !display_info.overscan_insets_in_dip().empty()) { - name = l10n_util::GetStringFUTF16( - IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, - name, GetDisplaySize(external_id)); - } else if (display_info.overscan_insets_in_dip().empty() && - display_info.has_overscan()) { - name = l10n_util::GetStringFUTF16( - IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, - name, l10n_util::GetStringUTF16( - IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN)); - } - - return name; -} - -base::string16 GetTrayDisplayMessage(base::string16* additional_message_out) { - DisplayManager* display_manager = GetDisplayManager(); - if (display_manager->GetNumDisplays() > 1) { - if (GetDisplayManager()->HasInternalDisplay()) { - return l10n_util::GetStringFUTF16( - IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetExternalDisplayName()); - } - return l10n_util::GetStringUTF16( - IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); - } - - if (display_manager->IsMirrored()) { - if (GetDisplayManager()->HasInternalDisplay()) { - return l10n_util::GetStringFUTF16( - IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, - GetDisplayName(display_manager->mirrored_display_id())); - } - return l10n_util::GetStringUTF16( - IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL); - } - - int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); - if (display_manager->HasInternalDisplay() && - !display_manager->IsInternalDisplayId(primary_id)) { - if (additional_message_out) { - *additional_message_out = l10n_util::GetStringUTF16( - IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION); - } - return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED); - } - - return base::string16(); -} - void OpenSettings() { user::LoginStatus login_status = Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); @@ -241,12 +166,90 @@ class DisplayView : public internal::ActionableView { return true; } + // Returns the name of the currently connected external display. + // This should not be used when the external display is used for + // mirroring. + static base::string16 GetExternalDisplayName() { + DisplayManager* display_manager = GetDisplayManager(); + DCHECK(!display_manager->IsMirrored()); + + int64 external_id = gfx::Display::kInvalidDisplayID; + for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { + int64 id = display_manager->GetDisplayAt(i).id(); + if (id != gfx::Display::InternalDisplayId()) { + external_id = id; + break; + } + } + + if (external_id == gfx::Display::kInvalidDisplayID) { + return l10n_util::GetStringUTF16( + IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); + } + + // The external display name may have an annotation of "(width x height)" in + // case that the display is rotated or its resolution is changed. + base::string16 name = GetDisplayName(external_id); + const DisplayInfo& display_info = + display_manager->GetDisplayInfo(external_id); + if (display_info.rotation() != gfx::Display::ROTATE_0 || + display_info.configured_ui_scale() != 1.0f || + !display_info.overscan_insets_in_dip().empty()) { + name = l10n_util::GetStringFUTF16( + IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, + name, GetDisplaySize(external_id)); + } else if (display_info.overscan_insets_in_dip().empty() && + display_info.has_overscan()) { + name = l10n_util::GetStringFUTF16( + IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, + name, l10n_util::GetStringUTF16( + IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN)); + } + + return name; + } + + static base::string16 GetTrayDisplayMessage( + base::string16* additional_message_out) { + DisplayManager* display_manager = GetDisplayManager(); + if (display_manager->GetNumDisplays() > 1) { + if (GetDisplayManager()->HasInternalDisplay()) { + return l10n_util::GetStringFUTF16( + IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetExternalDisplayName()); + } + return l10n_util::GetStringUTF16( + IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); + } + + if (display_manager->IsMirrored()) { + if (GetDisplayManager()->HasInternalDisplay()) { + return l10n_util::GetStringFUTF16( + IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, + GetDisplayName(display_manager->mirrored_display_id())); + } + return l10n_util::GetStringUTF16( + IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL); + } + + int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); + if (display_manager->HasInternalDisplay() && + !display_manager->IsInternalDisplayId(primary_id)) { + if (additional_message_out) { + *additional_message_out = l10n_util::GetStringUTF16( + IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION); + } + return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED); + } + + return base::string16(); + } + private: bool ShouldShowFirstDisplayInfo() const { const DisplayInfo& display_info = GetDisplayManager()->GetDisplayInfo( GetDisplayManager()->first_display_id()); return display_info.rotation() != gfx::Display::ROTATE_0 || - display_info.ui_scale() != 1.0f || + display_info.configured_ui_scale() != 1.0f || !display_info.overscan_insets_in_dip().empty() || display_info.has_overscan(); } @@ -300,7 +303,7 @@ bool TrayDisplay::GetDisplayMessageForNotification( // Display is added or removed. Use the same message as the one in // the system tray. if (display_info_.size() != old_info.size()) { - *message_out = GetTrayDisplayMessage(additional_message_out); + *message_out = DisplayView::GetTrayDisplayMessage(additional_message_out); return true; } @@ -311,11 +314,12 @@ bool TrayDisplay::GetDisplayMessageForNotification( // for the transition between docked mode and mirrored display. Falls back // to GetTrayDisplayMessage(). if (old_iter == old_info.end()) { - *message_out = GetTrayDisplayMessage(additional_message_out); + *message_out = DisplayView::GetTrayDisplayMessage(additional_message_out); return true; } - if (iter->second.ui_scale() != old_iter->second.ui_scale()) { + if (iter->second.configured_ui_scale() != + old_iter->second.configured_ui_scale()) { *message_out = l10n_util::GetStringFUTF16( IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED, GetDisplayName(iter->first), diff --git a/chrome/browser/chromeos/display/display_preferences.cc b/chrome/browser/chromeos/display/display_preferences.cc index 80856b0..8b733ca 100644 --- a/chrome/browser/chromeos/display/display_preferences.cc +++ b/chrome/browser/chromeos/display/display_preferences.cc @@ -194,8 +194,9 @@ void StoreCurrentDisplayProperties() { scoped_ptr<base::DictionaryValue> property_value( new base::DictionaryValue()); property_value->SetInteger("rotation", static_cast<int>(info.rotation())); - property_value->SetInteger("ui-scale", - static_cast<int>(info.ui_scale() * 1000)); + property_value->SetInteger( + "ui-scale", + static_cast<int>(info.configured_ui_scale() * 1000)); gfx::Size resolution; if (!display.IsInternal() && display_manager->GetSelectedResolutionForDisplayId(id, &resolution)) { diff --git a/chrome/browser/chromeos/display/display_preferences_unittest.cc b/chrome/browser/chromeos/display/display_preferences_unittest.cc index 06eeffe..e088828 100644 --- a/chrome/browser/chromeos/display/display_preferences_unittest.cc +++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc @@ -476,12 +476,12 @@ TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { const ash::internal::DisplayInfo& info1 = display_manager->GetDisplayInfo(id1); - EXPECT_EQ(1.25f, info1.ui_scale()); + EXPECT_EQ(1.25f, info1.configured_ui_scale()); const ash::internal::DisplayInfo& info_primary = display_manager->GetDisplayInfo(new_primary); EXPECT_EQ(gfx::Display::ROTATE_90, info_primary.rotation()); - EXPECT_EQ(1.0f, info_primary.ui_scale()); + EXPECT_EQ(1.0f, info_primary.configured_ui_scale()); } TEST_F(DisplayPreferencesTest, StorePowerStateNoLogin) { 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 06e37dc..639d60a 100644 --- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc @@ -223,7 +223,7 @@ void DisplayOptionsHandler::SendDisplayInfo( if (ui_scales[i] == 1.0f) resolution_info->SetBoolean("isBest", true); resolution_info->SetBoolean( - "selected", display_info.ui_scale() == ui_scales[i]); + "selected", display_info.configured_ui_scale() == ui_scales[i]); } else { // Picks the largest one as the "best", which is the last element // because |resolutions| is sorted by its area. |