summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-25 04:31:19 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-25 04:31:19 +0000
commitf958054738592c984e713a2582ac66d0e9bd5b4c (patch)
tree6b77e3edfeb2284ee77154b79f0ef2523ceaddef /ui/aura
parent0847a72a829a980801b75b1722c1a03847cd8e4f (diff)
downloadchromium_src-f958054738592c984e713a2582ac66d0e9bd5b4c.zip
chromium_src-f958054738592c984e713a2582ac66d0e9bd5b4c.tar.gz
chromium_src-f958054738592c984e713a2582ac66d0e9bd5b4c.tar.bz2
Supports screen rotation / ui-scaling in snapshot_aura.cc
BUG=235007,236370 TEST=covered by the new tests R=oshima@chromium.org, sky@chromium.org, backer@chromium.org Review URL: https://chromiumcodereview.appspot.com/15160006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202268 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/test/test_screen.cc44
-rw-r--r--ui/aura/test/test_screen.h8
2 files changed, 51 insertions, 1 deletions
diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc
index 69bf767..16afea4 100644
--- a/ui/aura/test/test_screen.cc
+++ b/ui/aura/test/test_screen.cc
@@ -46,6 +46,46 @@ void TestScreen::SetDeviceScaleFactor(float device_scale_factor) {
root_window_->OnHostResized(bounds_in_pixel.size());
}
+void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) {
+ display_.set_rotation(rotation);
+ root_window_->SetTransform(GetRotationTransform() * GetUIScaleTransform());
+}
+
+void TestScreen::SetUIScale(float ui_scale) {
+ ui_scale_ = ui_scale;
+ root_window_->SetTransform(GetRotationTransform() * GetUIScaleTransform());
+}
+
+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.Rotate(90);
+ break;
+ case gfx::Display::ROTATE_270:
+ rotate.Translate(0, display_.bounds().width() - one_pixel);
+ rotate.Rotate(270);
+ break;
+ case gfx::Display::ROTATE_180:
+ rotate.Translate(display_.bounds().width() - one_pixel,
+ display_.bounds().height() - one_pixel);
+ rotate.Rotate(180);
+ break;
+ }
+
+ return rotate;
+}
+
+gfx::Transform TestScreen::GetUIScaleTransform() const {
+ gfx::Transform ui_scale;
+ ui_scale.Scale(1.0f / ui_scale_, 1.0f / ui_scale_);
+ return ui_scale;
+}
+
bool TestScreen::IsDIPEnabled() {
return true;
}
@@ -97,7 +137,9 @@ void TestScreen::AddObserver(gfx::DisplayObserver* observer) {
void TestScreen::RemoveObserver(gfx::DisplayObserver* observer) {
}
-TestScreen::TestScreen(const gfx::Rect& screen_bounds) : root_window_(NULL) {
+TestScreen::TestScreen(const gfx::Rect& screen_bounds)
+ : root_window_(NULL),
+ ui_scale_(1.0f) {
static int64 synthesized_display_id = 2000;
display_.set_id(synthesized_display_id++);
display_.SetScaleAndBounds(1.0f, screen_bounds);
diff --git a/ui/aura/test/test_screen.h b/ui/aura/test/test_screen.h
index 1d14cbc..c4615c7 100644
--- a/ui/aura/test/test_screen.h
+++ b/ui/aura/test/test_screen.h
@@ -12,6 +12,7 @@
namespace gfx {
class Rect;
+class Transform;
}
namespace aura {
@@ -30,8 +31,13 @@ class TestScreen : public gfx::Screen,
RootWindow* CreateRootWindowForPrimaryDisplay();
void SetDeviceScaleFactor(float device_scale_fator);
+ void SetDisplayRotation(gfx::Display::Rotation rotation);
+ void SetUIScale(float ui_scale);
protected:
+ gfx::Transform GetRotationTransform() const;
+ gfx::Transform GetUIScaleTransform() const;
+
// WindowObserver overrides:
virtual void OnWindowBoundsChanged(Window* window,
const gfx::Rect& old_bounds,
@@ -60,6 +66,8 @@ class TestScreen : public gfx::Screen,
gfx::Display display_;
+ float ui_scale_;
+
DISALLOW_COPY_AND_ASSIGN(TestScreen);
};