diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-12 07:44:59 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-12 07:44:59 +0000 |
commit | dd478da7c316c605f4687fffabbc44cdcef641e8 (patch) | |
tree | f4cb59634cae80a6e8b31ac5fe48d3047320712b /ash | |
parent | 739d08d3ccd12f41362e192f28e03121bd45b556 (diff) | |
download | chromium_src-dd478da7c316c605f4687fffabbc44cdcef641e8.zip chromium_src-dd478da7c316c605f4687fffabbc44cdcef641e8.tar.gz chromium_src-dd478da7c316c605f4687fffabbc44cdcef641e8.tar.bz2 |
Allows insets of displays, in case of overscans.
This CL itself doesn't change the behavior. Another CL will enables the customization.
BUG=139419
Review URL: https://chromiumcodereview.appspot.com/11066107
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161532 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/display/multi_display_manager.cc | 17 | ||||
-rw-r--r-- | ash/display/multi_display_manager.h | 8 | ||||
-rw-r--r-- | ash/display/multi_display_manager_unittest.cc | 52 |
3 files changed, 77 insertions, 0 deletions
diff --git a/ash/display/multi_display_manager.cc b/ash/display/multi_display_manager.cc index ef20b0e..c754868 100644 --- a/ash/display/multi_display_manager.cc +++ b/ash/display/multi_display_manager.cc @@ -146,6 +146,12 @@ const gfx::Display& MultiDisplayManager::FindDisplayContainingPoint( return GetInvalidDisplay(); } +void MultiDisplayManager::SetOverscanInsets(int64 display_id, + const gfx::Insets& insets_in_dip) { + overscan_mapping_[display_id] = insets_in_dip; + OnNativeDisplaysChanged(displays_); +} + void MultiDisplayManager::OnNativeDisplaysChanged( const std::vector<gfx::Display>& updated_displays) { if (updated_displays.empty()) { @@ -187,6 +193,17 @@ void MultiDisplayManager::OnNativeDisplaysChanged( new_displays = updated_displays; } + for (DisplayList::iterator iter = new_displays.begin(); + iter != new_displays.end(); ++iter) { + std::map<int64, gfx::Insets>::const_iterator overscan_insets = + overscan_mapping_.find(iter->id()); + if (overscan_insets != overscan_mapping_.end()) { + gfx::Rect bounds = iter->bounds_in_pixel(); + bounds.Inset(overscan_insets->second.Scale(iter->device_scale_factor())); + iter->SetScaleAndBounds(iter->device_scale_factor(), bounds); + } + } + std::sort(displays_.begin(), displays_.end(), DisplaySortFunctor()); std::sort(new_displays.begin(), new_displays.end(), DisplaySortFunctor()); DisplayList removed_displays; diff --git a/ash/display/multi_display_manager.h b/ash/display/multi_display_manager.h index 18d952b..0d2a4cf 100644 --- a/ash/display/multi_display_manager.h +++ b/ash/display/multi_display_manager.h @@ -73,6 +73,11 @@ class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager, const gfx::Display& FindDisplayContainingPoint( const gfx::Point& point_in_screen) const; + // Registers the overscan insets for the display of the specified ID. Note + // that the insets size should be specified in DIP size. It also triggers the + // display's bounds change. + void SetOverscanInsets(int64 display_id, const gfx::Insets& insets_in_dip); + // DisplayManager overrides: virtual void OnNativeDisplaysChanged( const std::vector<gfx::Display>& displays) OVERRIDE; @@ -133,6 +138,9 @@ class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager, bool force_bounds_changed_; + // The mapping from the display ID to its overscan insets. + std::map<int64, gfx::Insets> overscan_mapping_; + DISALLOW_COPY_AND_ASSIGN(MultiDisplayManager); }; diff --git a/ash/display/multi_display_manager_unittest.cc b/ash/display/multi_display_manager_unittest.cc index c10480f..c30ada9 100644 --- a/ash/display/multi_display_manager_unittest.cc +++ b/ash/display/multi_display_manager_unittest.cc @@ -100,9 +100,11 @@ class MultiDisplayManagerTest : public test::AshTestBase, // Reenable when extended desktop is enabled by default. #define MAYBE_NativeDisplayTest NativeDisplayTest #define MAYBE_EmulatorTest EmulatorTest +#define MAYBE_OverscanInsetsTest OverscanInsetsTest #else #define MAYBE_NativeDisplayTest DISABLED_NativeDisplayTest #define MAYBE_EmulatorTest DISABLED_EmulatorTest +#define MAYBE_OverscanInsetsTest DISABLED_OverscanInsetsTest #endif TEST_F(MultiDisplayManagerTest, MAYBE_NativeDisplayTest) { @@ -217,6 +219,56 @@ TEST_F(MultiDisplayManagerTest, MAYBE_EmulatorTest) { reset(); } +TEST_F(MultiDisplayManagerTest, MAYBE_OverscanInsetsTest) { + UpdateDisplay("0+0-500x500,0+501-400x400"); + reset(); + ASSERT_EQ(2u, display_manager()->GetNumDisplays()); + gfx::Display display1(*display_manager()->GetDisplayAt(0)); + gfx::Display display2(*display_manager()->GetDisplayAt(1)); + + display_manager()->SetOverscanInsets( + display2.id(), gfx::Insets(10, 11, 12, 13)); + std::vector<gfx::Display> changed_displays = changed(); + EXPECT_EQ(1u, changed_displays.size()); + EXPECT_EQ(display2.id(), changed_displays[0].id()); + EXPECT_EQ("0,0 500x500", + display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); + EXPECT_EQ("11,511 376x378", + display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); + + // Recreate a new 2nd display. It won't apply the overscan inset because the + // new display has a different ID. + UpdateDisplay("0+0-500x500"); + UpdateDisplay("0+0-500x500,0+501-400x400"); + EXPECT_EQ("0,0 500x500", + display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); + EXPECT_EQ("0,501 400x400", + display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); + + // Recreate the displays with the same ID. It should apply the overscan + // inset. + UpdateDisplay("0+0-500x500"); + std::vector<gfx::Display> displays; + displays.push_back(display1); + displays.push_back(display2); + display_manager()->OnNativeDisplaysChanged(displays); + EXPECT_EQ("0,0 500x500", + display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); + EXPECT_EQ("11,511 376x378", + display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); + + // HiDPI but overscan display. The specified insets size should be doubled. + UpdateDisplay("0+0-500x500"); + UpdateDisplay("0+0-500x500,0+501-400x400*2"); + display_manager()->SetOverscanInsets( + display_manager()->GetDisplayAt(1)->id(), gfx::Insets(4, 5, 6, 7)); + EXPECT_EQ("0,0 500x500", + display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); + EXPECT_EQ("10,509 376x380", + display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); + EXPECT_EQ("188x190", display_manager()->GetDisplayAt(1)->size().ToString()); +} + // TODO(oshima): Device scale factor is supported on chromeos only for now. #if defined(OS_CHROMEOS) #define MAYBE_TestDeviceScaleOnlyChange TestDeviceScaleOnlyChange |