diff options
author | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-18 18:07:21 +0000 |
---|---|---|
committer | flackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-18 18:08:32 +0000 |
commit | 36b2b0af7a30d7c89b6597b60f7ac9a4e65c27d9 (patch) | |
tree | 22ac8381ef4d1b15ebefb26dfdd01eb76e2b2089 /ui | |
parent | 1a682bc6ce930a908380397acc9719cd61f6c63a (diff) | |
download | chromium_src-36b2b0af7a30d7c89b6597b60f7ac9a4e65c27d9.zip chromium_src-36b2b0af7a30d7c89b6597b60f7ac9a4e65c27d9.tar.gz chromium_src-36b2b0af7a30d7c89b6597b60f7ac9a4e65c27d9.tar.bz2 |
Reland "Rotate screen in response to accelerator or device orientation sensors. (patchset #12 of https://codereview.chromium.org/431183003/ )"
For DEPS modification, already reviewed in previous patch:
TBR=danakj, sadrul
BUG=385295
TEST=Press Ctrl+Shift+F3, screen rotates.
Review URL: https://codereview.chromium.org/486733002
Cr-Commit-Position: refs/heads/master@{#290300}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/test/test_screen.cc | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc index 4ffc2d8..75b5bb9 100644 --- a/ui/aura/test/test_screen.cc +++ b/ui/aura/test/test_screen.cc @@ -16,6 +16,15 @@ namespace aura { +namespace { + +bool IsRotationPortrait(gfx::Display::Rotation rotation) { + return rotation == gfx::Display::ROTATE_90 || + rotation == gfx::Display::ROTATE_270; +} + +} // namespace + // static TestScreen* TestScreen::Create(const gfx::Size& size) { const gfx::Size kDefaultSize(800, 600); @@ -47,8 +56,14 @@ void TestScreen::SetDeviceScaleFactor(float device_scale_factor) { } void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) { + gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); + gfx::Rect new_bounds(bounds_in_pixel); + if (IsRotationPortrait(rotation) != IsRotationPortrait(display_.rotation())) { + new_bounds.set_width(bounds_in_pixel.height()); + new_bounds.set_height(bounds_in_pixel.width()); + } display_.set_rotation(rotation); - // TODO(oshima|mukai): Update the display_ as well. + display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds); host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform()); } @@ -63,21 +78,20 @@ void TestScreen::SetUIScale(float ui_scale) { gfx::Transform TestScreen::GetRotationTransform() const { gfx::Transform rotate; - float one_pixel = 1.0f / display_.device_scale_factor(); switch (display_.rotation()) { case gfx::Display::ROTATE_0: break; case gfx::Display::ROTATE_90: - rotate.Translate(display_.bounds().height() - one_pixel, 0); + rotate.Translate(display_.bounds().height(), 0); rotate.Rotate(90); break; case gfx::Display::ROTATE_270: - rotate.Translate(0, display_.bounds().width() - one_pixel); + rotate.Translate(0, display_.bounds().width()); rotate.Rotate(270); break; case gfx::Display::ROTATE_180: - rotate.Translate(display_.bounds().width() - one_pixel, - display_.bounds().height() - one_pixel); + rotate.Translate(display_.bounds().width(), + display_.bounds().height()); rotate.Rotate(180); break; } |