OLD | NEW |
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 Loading... |
41 | 41 |
42 void TestScreen::SetDeviceScaleFactor(float device_scale_factor) { | 42 void TestScreen::SetDeviceScaleFactor(float device_scale_factor) { |
43 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); | 43 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); |
44 display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel); | 44 display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel); |
45 host_->OnHostResized(bounds_in_pixel.size()); | 45 host_->OnHostResized(bounds_in_pixel.size()); |
46 } | 46 } |
47 | 47 |
48 void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) { | 48 void TestScreen::SetDisplayRotation(gfx::Display::Rotation rotation) { |
49 display_.set_rotation(rotation); | 49 display_.set_rotation(rotation); |
50 // TODO(oshima|mukai): Update the display_ as well. | 50 // TODO(oshima|mukai): Update the display_ as well. |
51 host_->SetTransform(GetRotationTransform() * GetUIScaleTransform()); | 51 host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform()); |
52 } | 52 } |
53 | 53 |
54 void TestScreen::SetUIScale(float ui_scale) { | 54 void TestScreen::SetUIScale(float ui_scale) { |
55 ui_scale_ = ui_scale; | 55 ui_scale_ = ui_scale; |
56 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); | 56 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); |
57 gfx::Rect new_bounds = gfx::ToNearestRect( | 57 gfx::Rect new_bounds = gfx::ToNearestRect( |
58 gfx::ScaleRect(bounds_in_pixel, 1.0f / ui_scale)); | 58 gfx::ScaleRect(bounds_in_pixel, 1.0f / ui_scale)); |
59 display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds); | 59 display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds); |
60 host_->SetTransform(GetRotationTransform() * GetUIScaleTransform()); | 60 host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform()); |
61 } | 61 } |
62 | 62 |
63 gfx::Transform TestScreen::GetRotationTransform() const { | 63 gfx::Transform TestScreen::GetRotationTransform() const { |
64 gfx::Transform rotate; | 64 gfx::Transform rotate; |
65 float one_pixel = 1.0f / display_.device_scale_factor(); | 65 float one_pixel = 1.0f / display_.device_scale_factor(); |
66 switch (display_.rotation()) { | 66 switch (display_.rotation()) { |
67 case gfx::Display::ROTATE_0: | 67 case gfx::Display::ROTATE_0: |
68 break; | 68 break; |
69 case gfx::Display::ROTATE_90: | 69 case gfx::Display::ROTATE_90: |
70 rotate.Translate(display_.bounds().height() - one_pixel, 0); | 70 rotate.Translate(display_.bounds().height() - one_pixel, 0); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 TestScreen::TestScreen(const gfx::Rect& screen_bounds) | 152 TestScreen::TestScreen(const gfx::Rect& screen_bounds) |
153 : host_(NULL), | 153 : host_(NULL), |
154 ui_scale_(1.0f) { | 154 ui_scale_(1.0f) { |
155 static int64 synthesized_display_id = 2000; | 155 static int64 synthesized_display_id = 2000; |
156 display_.set_id(synthesized_display_id++); | 156 display_.set_id(synthesized_display_id++); |
157 display_.SetScaleAndBounds(1.0f, screen_bounds); | 157 display_.SetScaleAndBounds(1.0f, screen_bounds); |
158 } | 158 } |
159 | 159 |
160 } // namespace aura | 160 } // namespace aura |
OLD | NEW |