Commit a6406932 authored by mukai@chromium.org's avatar mukai@chromium.org

Automatically set the overscan insets if the output has the flag and no preference is set.


BUG=141005


Review URL: https://chromiumcodereview.appspot.com/11818008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177236 0039d316-1c4b-4281-b951-d872f2087c98
parent e9675764
...@@ -72,6 +72,14 @@ int64 GetDisplayIdForOutput(XID output) { ...@@ -72,6 +72,14 @@ int64 GetDisplayIdForOutput(XID output) {
} }
#endif #endif
gfx::Insets GetDefaultDisplayOverscan(const gfx::Display& display) {
// Currently we assume 5% overscan and hope for the best if TV claims it
// overscan, but doesn't expose how much.
int width = display.bounds().width() / 40;
int height = display.bounds().height() / 40;
return gfx::Insets(height, width, height, width);
}
} // namespace } // namespace
using aura::RootWindow; using aura::RootWindow;
...@@ -146,6 +154,7 @@ const gfx::Display& DisplayManager::FindDisplayContainingPoint( ...@@ -146,6 +154,7 @@ const gfx::Display& DisplayManager::FindDisplayContainingPoint(
void DisplayManager::SetOverscanInsets(int64 display_id, void DisplayManager::SetOverscanInsets(int64 display_id,
const gfx::Insets& insets_in_dip) { const gfx::Insets& insets_in_dip) {
display_info_[display_id].overscan_insets_in_dip = insets_in_dip; display_info_[display_id].overscan_insets_in_dip = insets_in_dip;
display_info_[display_id].has_custom_overscan_insets = true;
// Copies the |displays_| because UpdateDisplays() compares the passed // Copies the |displays_| because UpdateDisplays() compares the passed
// displays and its internal |displays_|. // displays and its internal |displays_|.
...@@ -201,12 +210,16 @@ void DisplayManager::OnNativeDisplaysChanged( ...@@ -201,12 +210,16 @@ void DisplayManager::OnNativeDisplaysChanged(
new_displays = updated_displays; new_displays = updated_displays;
} }
RefreshDisplayInfo();
for (DisplayList::const_iterator iter = new_displays.begin(); for (DisplayList::const_iterator iter = new_displays.begin();
iter != new_displays.end(); ++iter) { iter != new_displays.end(); ++iter) {
std::map<int64, DisplayInfo>::iterator info = std::map<int64, DisplayInfo>::iterator info =
display_info_.find(iter->id()); display_info_.find(iter->id());
if (info != display_info_.end()) { if (info != display_info_.end()) {
info->second.original_bounds_in_pixel = iter->bounds_in_pixel(); info->second.original_bounds_in_pixel = iter->bounds_in_pixel();
if (info->second.has_overscan && !info->second.has_custom_overscan_insets)
info->second.overscan_insets_in_dip = GetDefaultDisplayOverscan(*iter);
} else { } else {
display_info_[iter->id()].original_bounds_in_pixel = display_info_[iter->id()].original_bounds_in_pixel =
iter->bounds_in_pixel(); iter->bounds_in_pixel();
...@@ -214,7 +227,6 @@ void DisplayManager::OnNativeDisplaysChanged( ...@@ -214,7 +227,6 @@ void DisplayManager::OnNativeDisplaysChanged(
} }
UpdateDisplays(new_displays); UpdateDisplays(new_displays);
RefreshDisplayNames();
} }
void DisplayManager::UpdateDisplays( void DisplayManager::UpdateDisplays(
...@@ -424,7 +436,7 @@ void DisplayManager::Init() { ...@@ -424,7 +436,7 @@ void DisplayManager::Init() {
} }
#endif #endif
RefreshDisplayNames(); RefreshDisplayInfo();
#if defined(OS_WIN) #if defined(OS_WIN)
if (base::win::GetVersion() >= base::win::VERSION_WIN8) if (base::win::GetVersion() >= base::win::VERSION_WIN8)
...@@ -550,7 +562,12 @@ void DisplayManager::EnsurePointerInDisplays() { ...@@ -550,7 +562,12 @@ void DisplayManager::EnsurePointerInDisplays() {
root_window->MoveCursorTo(target_location); root_window->MoveCursorTo(target_location);
} }
void DisplayManager::RefreshDisplayNames() { DisplayManager::DisplayInfo::DisplayInfo()
: has_overscan(false),
has_custom_overscan_insets(false) {
}
void DisplayManager::RefreshDisplayInfo() {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (!base::chromeos::IsRunningOnChromeOS()) if (!base::chromeos::IsRunningOnChromeOS())
return; return;
...@@ -574,6 +591,8 @@ void DisplayManager::RefreshDisplayNames() { ...@@ -574,6 +591,8 @@ void DisplayManager::RefreshDisplayNames() {
} else if (!name.empty()) { } else if (!name.empty()) {
display_info_[id].name = name; display_info_[id].name = name;
} }
ui::GetOutputOverscanFlag(outputs[i], &display_info_[id].has_overscan);
} }
#endif #endif
} }
...@@ -587,5 +606,9 @@ void DisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const { ...@@ -587,5 +606,9 @@ void DisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const {
} }
} }
void DisplayManager::SetHasOverscanFlagForTest(int64 id, bool has_overscan) {
display_info_[id].has_overscan = has_overscan;
}
} // namespace internal } // namespace internal
} // namespace ash } // namespace ash
...@@ -123,6 +123,7 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver { ...@@ -123,6 +123,7 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged); FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged);
FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest,
NativeDisplaysChangedAfterPrimaryChange); NativeDisplaysChangedAfterPrimaryChange);
FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets);
friend class ash::AcceleratorControllerTest; friend class ash::AcceleratorControllerTest;
friend class test::DisplayManagerTestApi; friend class test::DisplayManagerTestApi;
friend class DisplayManagerTest; friend class DisplayManagerTest;
...@@ -132,6 +133,8 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver { ...@@ -132,6 +133,8 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
// Metadata for each display. // Metadata for each display.
struct DisplayInfo { struct DisplayInfo {
DisplayInfo();
// The cached name of the display. // The cached name of the display.
std::string name; std::string name;
...@@ -141,6 +144,14 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver { ...@@ -141,6 +144,14 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
// The overscan insets for the display. // The overscan insets for the display.
gfx::Insets overscan_insets_in_dip; gfx::Insets overscan_insets_in_dip;
// True if we detect that the display has overscan area. False if the
// display doesn't have it, or failed to detect it.
bool has_overscan;
// True if the |overscan_insets_in_dip| is specified. This is set because
// the user may specify an empty inset intentionally.
bool has_custom_overscan_insets;
}; };
void Init(); void Init();
...@@ -162,8 +173,8 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver { ...@@ -162,8 +173,8 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
// the center of the nearest display if it's outside of all displays. // the center of the nearest display if it's outside of all displays.
void EnsurePointerInDisplays(); void EnsurePointerInDisplays();
// Updates |display_names_| by calling platform-dependent functions. // Updates |display_info_| by calling platform-dependent functions.
void RefreshDisplayNames(); void RefreshDisplayInfo();
// Update the display's id in the |display_list| to match the ones // Update the display's id in the |display_list| to match the ones
// stored in this display manager's |displays_|. This is used to // stored in this display manager's |displays_|. This is used to
...@@ -171,6 +182,9 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver { ...@@ -171,6 +182,9 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
// display list with the same display ids but with different bounds // display list with the same display ids but with different bounds
void SetDisplayIdsForTest(DisplayList* display_list) const; void SetDisplayIdsForTest(DisplayList* display_list) const;
// Forcibly specify 'has_overscan' flag of the DisplayInfo for specified |id|.
void SetHasOverscanFlagForTest(int64 id, bool has_overscan);
DisplayList displays_; DisplayList displays_;
int64 internal_display_id_; int64 internal_display_id_;
......
...@@ -514,5 +514,33 @@ TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { ...@@ -514,5 +514,33 @@ TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) {
EXPECT_EQ("0,0 100x100", FindDisplayForId(10).bounds().ToString()); EXPECT_EQ("0,0 100x100", FindDisplayForId(10).bounds().ToString());
} }
TEST_F(DisplayManagerTest, AutomaticOverscanInsets) {
UpdateDisplay("200x200,400x400");
std::vector<gfx::Display> displays;
displays.push_back(*display_manager()->GetDisplayAt(0));
displays.push_back(*display_manager()->GetDisplayAt(1));
int64 id = displays[1].id();
display_manager()->SetHasOverscanFlagForTest(id, true);
display_manager()->OnNativeDisplaysChanged(displays);
// It has overscan insets, although SetOverscanInsets() isn't called.
EXPECT_EQ("11,211 380x380",
display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString());
// If custom overscan insets is specified, the specified value is used.
display_manager()->SetOverscanInsets(id, gfx::Insets(5, 6, 7, 8));
display_manager()->OnNativeDisplaysChanged(displays);
EXPECT_EQ("7,206 386x388",
display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString());
// Do not overscan even though it has 'has_overscan' flag, if the custom
// insets is empty.
display_manager()->SetOverscanInsets(id, gfx::Insets());
display_manager()->OnNativeDisplaysChanged(displays);
EXPECT_EQ("1,201 400x400",
display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString());
}
} // namespace internal } // namespace internal
} // namespace ash } // namespace ash
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment