Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Unified Diff: ui/aura/test/test_screen.cc

Issue 475533008: Revert of Rotate screen in response to accelerator or device orientation sensors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/system/system_ui_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/test/test_screen.cc
diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc
index 75b5bb9c5fdedd327cbb9486e11138d360765448..4ffc2d855eada7ec162b6f32a1be29b79c5a2546 100644
--- a/ui/aura/test/test_screen.cc
+++ b/ui/aura/test/test_screen.cc
@@ -15,15 +15,6 @@
#include "ui/gfx/screen.h"
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) {
@@ -56,14 +47,8 @@
}
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);
- display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds);
+ // TODO(oshima|mukai): Update the display_ as well.
host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform());
}
@@ -78,20 +63,21 @@
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(), 0);
+ rotate.Translate(display_.bounds().height() - one_pixel, 0);
rotate.Rotate(90);
break;
case gfx::Display::ROTATE_270:
- rotate.Translate(0, display_.bounds().width());
+ rotate.Translate(0, display_.bounds().width() - one_pixel);
rotate.Rotate(270);
break;
case gfx::Display::ROTATE_180:
- rotate.Translate(display_.bounds().width(),
- display_.bounds().height());
+ rotate.Translate(display_.bounds().width() - one_pixel,
+ display_.bounds().height() - one_pixel);
rotate.Rotate(180);
break;
}
« no previous file with comments | « athena/system/system_ui_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698