diff options
author | dnicoara@chromium.org <dnicoara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-04 19:13:40 +0000 |
---|---|---|
committer | dnicoara@chromium.org <dnicoara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-04 19:13:40 +0000 |
commit | aa0759e04b57f8be7412036f0fed1435d460ab4e (patch) | |
tree | 596d4617513e80a6c440ede8d421ec5a1c3b3174 /ui | |
parent | e4c4b6cd5e8075f87a738ce53c3a27617f57704c (diff) | |
download | chromium_src-aa0759e04b57f8be7412036f0fed1435d460ab4e.zip chromium_src-aa0759e04b57f8be7412036f0fed1435d460ab4e.tar.gz chromium_src-aa0759e04b57f8be7412036f0fed1435d460ab4e.tar.bz2 |
Move Is*DisplaySizeBlackListed to ui/display and build it for non-X11 platforms as well
BUG=333413
Review URL: https://codereview.chromium.org/226163002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/x/x11_util.cc | 29 | ||||
-rw-r--r-- | ui/base/x/x11_util.h | 5 | ||||
-rw-r--r-- | ui/base/x/x11_util_unittest.cc | 25 | ||||
-rw-r--r-- | ui/display/display.gyp | 2 | ||||
-rw-r--r-- | ui/display/display_unittests.gypi | 1 | ||||
-rw-r--r-- | ui/display/display_util.cc | 43 | ||||
-rw-r--r-- | ui/display/display_util.h | 19 | ||||
-rw-r--r-- | ui/display/display_util_unittest.cc | 23 | ||||
-rw-r--r-- | ui/ui_unittests.gyp | 1 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_screen_x11.cc | 14 |
10 files changed, 95 insertions, 67 deletions
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index 708f962..668c787 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -261,16 +261,6 @@ bool IsShapeAvailable() { } -// A list of bogus sizes in mm that X detects that should be ignored. -// See crbug.com/136533. The first element maintains the minimum -// size required to be valid size. -const unsigned long kInvalidDisplaySizeList[][2] = { - {40, 30}, - {50, 40}, - {160, 90}, - {160, 100}, -}; - } // namespace bool XDisplayExists() { @@ -1428,25 +1418,6 @@ bool IsX11WindowFullScreen(XID window) { #endif } -bool IsXDisplaySizeBlackListed(unsigned long mm_width, - unsigned long mm_height) { - // Ignore if the reported display is smaller than minimum size. - if (mm_width <= kInvalidDisplaySizeList[0][0] || - mm_height <= kInvalidDisplaySizeList[0][1]) { - LOG(WARNING) << "Smaller than minimum display size"; - return true; - } - for (unsigned long i = 1 ; i < arraysize(kInvalidDisplaySizeList); ++i) { - const unsigned long* size = kInvalidDisplaySizeList[i]; - if (mm_width == size[0] && mm_height == size[1]) { - LOG(WARNING) << "Black listed display size detected:" - << size[0] << "x" << size[1]; - return true; - } - } - return false; -} - const unsigned char* XRefcountedMemory::front() const { return x11_data_; } diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index 519b149..d87635f9 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -324,11 +324,6 @@ UI_BASE_EXPORT void SetDefaultX11ErrorHandlers(); // Return true if a given window is in full-screen mode. UI_BASE_EXPORT bool IsX11WindowFullScreen(XID window); -// Returns true if a given size is in list of bogus sizes in mm that X detects -// that should be ignored. -UI_BASE_EXPORT bool IsXDisplaySizeBlackListed(unsigned long mm_width, - unsigned long mm_height); - // Manages a piece of X11 allocated memory as a RefCountedMemory segment. This // object takes ownership over the passed in memory and will free it with the // X11 allocator when done. diff --git a/ui/base/x/x11_util_unittest.cc b/ui/base/x/x11_util_unittest.cc deleted file mode 100644 index 0194726..0000000 --- a/ui/base/x/x11_util_unittest.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/base/x/x11_util.h" - -#include "testing/gtest/include/gtest/gtest.h" - -typedef testing::Test XUtilTest; - -namespace ui { - -TEST_F(XUtilTest, TestBlackListedDisplay) { - EXPECT_TRUE(IsXDisplaySizeBlackListed(10, 10)); - EXPECT_TRUE(IsXDisplaySizeBlackListed(40, 30)); - EXPECT_TRUE(IsXDisplaySizeBlackListed(50, 40)); - EXPECT_TRUE(IsXDisplaySizeBlackListed(160, 90)); - EXPECT_TRUE(IsXDisplaySizeBlackListed(160, 100)); - - EXPECT_FALSE(IsXDisplaySizeBlackListed(50, 60)); - EXPECT_FALSE(IsXDisplaySizeBlackListed(100, 70)); - EXPECT_FALSE(IsXDisplaySizeBlackListed(272, 181)); -} - -} diff --git a/ui/display/display.gyp b/ui/display/display.gyp index 7bd9a33..d330efd9 100644 --- a/ui/display/display.gyp +++ b/ui/display/display.gyp @@ -47,6 +47,8 @@ 'display_export.h', 'display_switches.cc', 'display_switches.h', + 'display_util.cc', + 'display_util.h', 'edid_parser.cc', 'edid_parser.h', 'x11/edid_parser_x11.cc', diff --git a/ui/display/display_unittests.gypi b/ui/display/display_unittests.gypi index 591bde5..50ebf93 100644 --- a/ui/display/display_unittests.gypi +++ b/ui/display/display_unittests.gypi @@ -16,6 +16,7 @@ 'chromeos/output_configurator_unittest.cc', 'chromeos/x11/display_util_x11_unittest.cc', 'chromeos/x11/native_display_event_dispatcher_x11_unittest.cc', + 'display_util_unittest.cc', ], 'conditions': [ # TODO(dnicoara) When we add non-chromeos display code this dependency can diff --git a/ui/display/display_util.cc b/ui/display/display_util.cc new file mode 100644 index 0000000..a51b19a --- /dev/null +++ b/ui/display/display_util.cc @@ -0,0 +1,43 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/display/display_util.h" + +#include "base/logging.h" + +namespace ui { + +namespace { + +// A list of bogus sizes in mm that should be ignored. +// See crbug.com/136533. The first element maintains the minimum +// size required to be valid size. +const int kInvalidDisplaySizeList[][2] = { + {40, 30}, + {50, 40}, + {160, 90}, + {160, 100}, +}; + +} // namespace + +bool IsDisplaySizeBlackListed(const gfx::Size& physical_size) { + // Ignore if the reported display is smaller than minimum size. + if (physical_size.width() <= kInvalidDisplaySizeList[0][0] || + physical_size.height() <= kInvalidDisplaySizeList[0][1]) { + LOG(WARNING) << "Smaller than minimum display size"; + return true; + } + for (size_t i = 1; i < arraysize(kInvalidDisplaySizeList); ++i) { + const gfx::Size size(kInvalidDisplaySizeList[i][0], + kInvalidDisplaySizeList[i][1]); + if (physical_size == size) { + LOG(WARNING) << "Black listed display size detected:" << size.ToString(); + return true; + } + } + return false; +} + +} // namespace ui diff --git a/ui/display/display_util.h b/ui/display/display_util.h new file mode 100644 index 0000000..f8c0bd2 --- /dev/null +++ b/ui/display/display_util.h @@ -0,0 +1,19 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_DISPLAY_DISPLAY_UTIL_H_ +#define UI_DISPLAY_DISPLAY_UTIL_H_ + +#include "ui/display/display_export.h" +#include "ui/gfx/geometry/size.h" + +namespace ui { + +// Returns true if a given size is in the list of bogus sizes in mm that should +// be ignored. +DISPLAY_EXPORT bool IsDisplaySizeBlackListed(const gfx::Size& physical_size); + +} // namespace ui + +#endif // UI_DISPLAY_DISPLAY_UTIL_H_ diff --git a/ui/display/display_util_unittest.cc b/ui/display/display_util_unittest.cc new file mode 100644 index 0000000..8a63ef2 --- /dev/null +++ b/ui/display/display_util_unittest.cc @@ -0,0 +1,23 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/display/display_util.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace ui { + +TEST(DisplayUtilTest, TestBlackListedDisplay) { + EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(10, 10))); + EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(40, 30))); + EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(50, 40))); + EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(160, 90))); + EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(160, 100))); + + EXPECT_FALSE(IsDisplaySizeBlackListed(gfx::Size(50, 60))); + EXPECT_FALSE(IsDisplaySizeBlackListed(gfx::Size(100, 70))); + EXPECT_FALSE(IsDisplaySizeBlackListed(gfx::Size(272, 181))); +} + +} // namespace ui diff --git a/ui/ui_unittests.gyp b/ui/ui_unittests.gyp index f09b35b..7339f49 100644 --- a/ui/ui_unittests.gyp +++ b/ui/ui_unittests.gyp @@ -141,7 +141,6 @@ 'base/text/bytes_formatting_unittest.cc', 'base/view_prop_unittest.cc', 'base/webui/web_ui_util_unittest.cc', - 'base/x/x11_util_unittest.cc', 'gfx/animation/tween_unittest.cc', 'gfx/blit_unittest.cc', 'gfx/break_list_unittest.cc', diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc index 970d86c..99f90e6 100644 --- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc @@ -16,7 +16,7 @@ #include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_tree_host.h" #include "ui/base/layout.h" -#include "ui/base/x/x11_util.h" +#include "ui/display/display_util.h" #include "ui/display/x11/edid_parser_x11.h" #include "ui/gfx/display.h" #include "ui/gfx/display_observer.h" @@ -48,14 +48,14 @@ std::vector<gfx::Display> GetFallbackDisplayList() { ::Screen* screen = DefaultScreenOfDisplay(display); int width = WidthOfScreen(screen); int height = HeightOfScreen(screen); - int mm_width = WidthMMOfScreen(screen); - int mm_height = HeightMMOfScreen(screen); + gfx::Size physical_size(WidthMMOfScreen(screen), HeightMMOfScreen(screen)); gfx::Rect bounds_in_pixels(0, 0, width, height); gfx::Display gfx_display(0, bounds_in_pixels); if (!gfx::Display::HasForceDeviceScaleFactor() && - !ui::IsXDisplaySizeBlackListed(mm_width, mm_height)) { - float device_scale_factor = GetDeviceScaleFactor(width, mm_width); + !ui::IsDisplaySizeBlackListed(physical_size)) { + float device_scale_factor = GetDeviceScaleFactor( + width, physical_size.width()); DCHECK_LE(1.0f, device_scale_factor); gfx_display.SetScaleAndBounds(device_scale_factor, bounds_in_pixels); } @@ -386,8 +386,8 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() { gfx::Display display(display_id, crtc_bounds); if (!gfx::Display::HasForceDeviceScaleFactor()) { - if (i == 0 && !ui::IsXDisplaySizeBlackListed(output_info->mm_width, - output_info->mm_height)) { + if (i == 0 && !ui::IsDisplaySizeBlackListed( + gfx::Size(output_info->mm_width, output_info->mm_height))) { // As per display scale factor is not supported right now, // the primary display's scale factor is always used. device_scale_factor = GetDeviceScaleFactor(crtc->width, |