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 "ash/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
129 // Windows 8 bots refused to resize the host window, and | 129 // Windows 8 bots refused to resize the host window, and |
130 // updating the transform results in incorrectly resizing | 130 // updating the transform results in incorrectly resizing |
131 // the root window. Don't apply the transform unless | 131 // the root window. Don't apply the transform unless |
132 // necessary so that unit tests pass on win8 bots. | 132 // necessary so that unit tests pass on win8 bots. |
133 if (info.rotation() == root_window->GetProperty(kRotationPropertyKey)) | 133 if (info.rotation() == root_window->GetProperty(kRotationPropertyKey)) |
134 return; | 134 return; |
135 root_window->SetProperty(kRotationPropertyKey, info.rotation()); | 135 root_window->SetProperty(kRotationPropertyKey, info.rotation()); |
136 #endif | 136 #endif |
137 gfx::Transform rotate; | 137 gfx::Transform rotate; |
| 138 // TODO(oshima): Manually complute the inverse of the |
| 139 // rotate+translate matrix to compensate for computation error in |
| 140 // the inverted matrix. Ideally, SkMatrix should have special |
| 141 // case handling for rotate+translate case. crbug.com/222483. |
| 142 gfx::Transform reverse_rotate; |
| 143 |
138 // The origin is (0, 0), so the translate width/height must be reduced by 1. | 144 // The origin is (0, 0), so the translate width/height must be reduced by 1. |
139 switch (info.rotation()) { | 145 switch (info.rotation()) { |
140 case gfx::Display::ROTATE_0: | 146 case gfx::Display::ROTATE_0: |
141 break; | 147 break; |
142 case gfx::Display::ROTATE_90: | 148 case gfx::Display::ROTATE_90: |
143 rotate.Translate(display.bounds().height() - 1, 0); | 149 rotate.Translate(display.bounds().height() - 1, 0); |
144 rotate.Rotate(90); | 150 rotate.Rotate(90); |
| 151 // Rotate 270 instead of 90 as it will cause calcuration error. |
| 152 reverse_rotate.Rotate(270); |
| 153 reverse_rotate.Translate(-(display.bounds().height() - 1), 0); |
145 break; | 154 break; |
146 case gfx::Display::ROTATE_270: | 155 case gfx::Display::ROTATE_270: |
147 rotate.Translate(0, display.bounds().width() - 1); | 156 rotate.Translate(0, display.bounds().width() - 1); |
148 rotate.Rotate(270); | 157 rotate.Rotate(270); |
| 158 reverse_rotate.Rotate(90); |
| 159 reverse_rotate.Translate(0, -(display.bounds().width() - 1)); |
149 break; | 160 break; |
150 case gfx::Display::ROTATE_180: | 161 case gfx::Display::ROTATE_180: |
151 rotate.Translate(display.bounds().width() - 1, | 162 rotate.Translate(display.bounds().width() - 1, |
152 display.bounds().height() - 1); | 163 display.bounds().height() - 1); |
153 rotate.Rotate(180); | 164 rotate.Rotate(180); |
| 165 reverse_rotate.Rotate(180); |
| 166 reverse_rotate.Translate(-(display.bounds().width() - 1), |
| 167 -(display.bounds().height() - 1)); |
154 break; | 168 break; |
155 } | 169 } |
156 root_window->SetTransform(rotate); | 170 root_window->SetTransformPair(rotate, reverse_rotate); |
157 } | 171 } |
158 | 172 |
159 void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, | 173 void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, |
160 const gfx::Display& display) { | 174 const gfx::Display& display) { |
161 internal::DisplayInfo info = | 175 internal::DisplayInfo info = |
162 GetDisplayManager()->GetDisplayInfo(display.id()); | 176 GetDisplayManager()->GetDisplayInfo(display.id()); |
163 #if defined(OS_CHROMEOS) | 177 #if defined(OS_CHROMEOS) |
164 // Native window property (Atom in X11) that specifies the display's | 178 // Native window property (Atom in X11) that specifies the display's |
165 // rotation, scale factor and if it's internal display. They are | 179 // rotation, scale factor and if it's internal display. They are |
166 // read and used by touchpad/mouse driver directly on X (contact | 180 // read and used by touchpad/mouse driver directly on X (contact |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 } | 922 } |
909 | 923 |
910 void DisplayController::OnFadeOutForSwapDisplayFinished() { | 924 void DisplayController::OnFadeOutForSwapDisplayFinished() { |
911 #if defined(OS_CHROMEOS) | 925 #if defined(OS_CHROMEOS) |
912 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); | 926 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); |
913 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); | 927 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); |
914 #endif | 928 #endif |
915 } | 929 } |
916 | 930 |
917 } // namespace ash | 931 } // namespace ash |
OLD | NEW |