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

Side by Side Diff: ui/aura/test/test_screen.cc

Issue 431183003: Rotate screen in response to accelerator or device orientation sensors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use the FILE thread for IO 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/test/test_screen.h" 5 #include "ui/aura/test/test_screen.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/aura/env.h" 8 #include "ui/aura/env.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/aura/window_event_dispatcher.h" 10 #include "ui/aura/window_event_dispatcher.h"
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 void TestScreen::SetDeviceScaleFactor(float device_scale_factor) { 43 void TestScreen::SetDeviceScaleFactor(float device_scale_factor) {
44 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); 44 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
45 display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel); 45 display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
46 host_->OnHostResized(bounds_in_pixel.size()); 46 host_->OnHostResized(bounds_in_pixel.size());
47 } 47 }
48 48
49 void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) { 49 void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) {
50 display_.set_rotation(rotation); 50 display_.set_rotation(rotation);
51 // TODO(oshima|mukai): Update the display_ as well. 51 // TODO(oshima|mukai): Update the display_ as well.
oshima 2014/08/14 19:28:53 sorry I missed this. can you update the display_?
flackr 2014/08/14 21:04:09 Done.
52 host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform()); 52 host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform());
53 } 53 }
54 54
55 void TestScreen::SetUIScale(float ui_scale) { 55 void TestScreen::SetUIScale(float ui_scale) {
56 ui_scale_ = ui_scale; 56 ui_scale_ = ui_scale;
57 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); 57 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
58 gfx::Rect new_bounds = gfx::ToNearestRect( 58 gfx::Rect new_bounds = gfx::ToNearestRect(
59 gfx::ScaleRect(bounds_in_pixel, 1.0f / ui_scale)); 59 gfx::ScaleRect(bounds_in_pixel, 1.0f / ui_scale));
60 display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds); 60 display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds);
61 host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform()); 61 host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform());
62 } 62 }
63 63
64 gfx::Transform TestScreen::GetRotationTransform() const { 64 gfx::Transform TestScreen::GetRotationTransform() const {
65 gfx::Transform rotate; 65 gfx::Transform rotate;
66 float one_pixel = 1.0f / display_.device_scale_factor();
67 switch (display_.rotation()) { 66 switch (display_.rotation()) {
68 case gfx::Display::ROTATE_0: 67 case gfx::Display::ROTATE_0:
69 break; 68 break;
70 case gfx::Display::ROTATE_90: 69 case gfx::Display::ROTATE_90:
71 rotate.Translate(display_.bounds().height() - one_pixel, 0); 70 rotate.Translate(display_.bounds().width(), 0);
72 rotate.Rotate(90); 71 rotate.Rotate(90);
73 break; 72 break;
74 case gfx::Display::ROTATE_270: 73 case gfx::Display::ROTATE_270:
75 rotate.Translate(0, display_.bounds().width() - one_pixel); 74 rotate.Translate(0, display_.bounds().height());
76 rotate.Rotate(270); 75 rotate.Rotate(270);
77 break; 76 break;
78 case gfx::Display::ROTATE_180: 77 case gfx::Display::ROTATE_180:
79 rotate.Translate(display_.bounds().width() - one_pixel, 78 rotate.Translate(display_.bounds().height(),
80 display_.bounds().height() - one_pixel); 79 display_.bounds().width());
81 rotate.Rotate(180); 80 rotate.Rotate(180);
82 break; 81 break;
83 } 82 }
84 83
85 return rotate; 84 return rotate;
86 } 85 }
87 86
88 gfx::Transform TestScreen::GetUIScaleTransform() const { 87 gfx::Transform TestScreen::GetUIScaleTransform() const {
89 gfx::Transform ui_scale; 88 gfx::Transform ui_scale;
90 ui_scale.Scale(1.0f / ui_scale_, 1.0f / ui_scale_); 89 ui_scale.Scale(1.0f / ui_scale_, 1.0f / ui_scale_);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 151
153 TestScreen::TestScreen(const gfx::Rect& screen_bounds) 152 TestScreen::TestScreen(const gfx::Rect& screen_bounds)
154 : host_(NULL), 153 : host_(NULL),
155 ui_scale_(1.0f) { 154 ui_scale_(1.0f) {
156 static int64 synthesized_display_id = 2000; 155 static int64 synthesized_display_id = 2000;
157 display_.set_id(synthesized_display_id++); 156 display_.set_id(synthesized_display_id++);
158 display_.SetScaleAndBounds(1.0f, screen_bounds); 157 display_.SetScaleAndBounds(1.0f, screen_bounds);
159 } 158 }
160 159
161 } // namespace aura 160 } // namespace aura
OLDNEW
« athena/system/orientation_controller.cc ('K') | « athena/system/system_ui_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698