Chromium Code Reviews| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 #if defined(OS_WIN) | 127 #if defined(OS_WIN) |
| 128 // Windows 8 bots refused to resize the host window, and | 128 // Windows 8 bots refused to resize the host window, and |
| 129 // updating the transform results in incorrectly resizing | 129 // updating the transform results in incorrectly resizing |
| 130 // the root window. Don't apply the transform unless | 130 // the root window. Don't apply the transform unless |
| 131 // necessary so that unit tests pass on win8 bots. | 131 // necessary so that unit tests pass on win8 bots. |
| 132 if (info.rotation() == root_window->GetProperty(kRotationPropertyKey)) | 132 if (info.rotation() == root_window->GetProperty(kRotationPropertyKey)) |
| 133 return; | 133 return; |
| 134 root_window->SetProperty(kRotationPropertyKey, info.rotation()); | 134 root_window->SetProperty(kRotationPropertyKey, info.rotation()); |
| 135 #endif | 135 #endif |
| 136 gfx::Transform rotate; | 136 gfx::Transform rotate; |
| 137 // TODO(oshima): Manually complute the invert of the | |
|
sky
2013/03/25 16:04:32
complute -> compute
invert -> inverse
oshima
2013/03/25 17:49:31
Done.
| |
| 138 // rotate+translate matrix to compensate computation error in | |
|
sky
2013/03/25 16:04:32
'to compensate' -> 'to compensate for'
oshima
2013/03/25 17:49:31
Done.
| |
| 139 // inverted matrix. Ideally, SkMatrix should have special | |
|
sky
2013/03/25 16:04:32
inverted -> the intervted
oshima
2013/03/25 17:49:31
Done.
| |
| 140 // case handling for rotate+translate case. crbug.com/222483. | |
| 141 gfx::Transform reverse_rotate; | |
| 142 | |
| 137 // The origin is (0, 0), so the translate width/height must be reduced by 1. | 143 // The origin is (0, 0), so the translate width/height must be reduced by 1. |
| 138 switch (info.rotation()) { | 144 switch (info.rotation()) { |
| 139 case gfx::Display::ROTATE_0: | 145 case gfx::Display::ROTATE_0: |
| 140 break; | 146 break; |
| 141 case gfx::Display::ROTATE_90: | 147 case gfx::Display::ROTATE_90: |
| 142 rotate.Translate(display.bounds().height() - 1, 0); | 148 rotate.Translate(display.bounds().height() - 1, 0); |
| 143 rotate.Rotate(90); | 149 rotate.Rotate(90); |
| 150 // Rotate 270 instead of 90 as it will cause calcuration error. | |
| 151 reverse_rotate.Rotate(270); | |
| 152 reverse_rotate.Translate(-(display.bounds().height() - 1), 0); | |
| 144 break; | 153 break; |
| 145 case gfx::Display::ROTATE_270: | 154 case gfx::Display::ROTATE_270: |
| 146 rotate.Translate(0, display.bounds().width() - 1); | 155 rotate.Translate(0, display.bounds().width() - 1); |
| 147 rotate.Rotate(270); | 156 rotate.Rotate(270); |
| 157 reverse_rotate.Rotate(90); | |
| 158 reverse_rotate.Translate(0, -(display.bounds().width() - 1)); | |
| 148 break; | 159 break; |
| 149 case gfx::Display::ROTATE_180: | 160 case gfx::Display::ROTATE_180: |
| 150 rotate.Translate(display.bounds().width() - 1, | 161 rotate.Translate(display.bounds().width() - 1, |
| 151 display.bounds().height() - 1); | 162 display.bounds().height() - 1); |
| 152 rotate.Rotate(180); | 163 rotate.Rotate(180); |
| 164 reverse_rotate.Rotate(180); | |
| 165 reverse_rotate.Translate(-(display.bounds().width() - 1), | |
| 166 -(display.bounds().height() - 1)); | |
| 153 break; | 167 break; |
| 154 } | 168 } |
| 155 root_window->SetTransform(rotate); | 169 root_window->SetTransformPair(rotate, reverse_rotate); |
| 156 } | 170 } |
| 157 | 171 |
| 158 void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, | 172 void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, |
| 159 const gfx::Display& display) { | 173 const gfx::Display& display) { |
| 160 internal::DisplayInfo info = | 174 internal::DisplayInfo info = |
| 161 GetDisplayManager()->GetDisplayInfo(display.id()); | 175 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 162 #if defined(OS_CHROMEOS) | 176 #if defined(OS_CHROMEOS) |
| 163 // Native window property (Atom in X11) that specifies the display's | 177 // Native window property (Atom in X11) that specifies the display's |
| 164 // rotation, scale factor and if it's internal display. They are | 178 // rotation, scale factor and if it's internal display. They are |
| 165 // read and used by touchpad/mouse driver directly on X (contact | 179 // read and used by touchpad/mouse driver directly on X (contact |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 } | 898 } |
| 885 | 899 |
| 886 void DisplayController::OnFadeOutForSwapDisplayFinished() { | 900 void DisplayController::OnFadeOutForSwapDisplayFinished() { |
| 887 #if defined(OS_CHROMEOS) | 901 #if defined(OS_CHROMEOS) |
| 888 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); | 902 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); |
| 889 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); | 903 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); |
| 890 #endif | 904 #endif |
| 891 } | 905 } |
| 892 | 906 |
| 893 } // namespace ash | 907 } // namespace ash |
| OLD | NEW |