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

Side by Side Diff: ash/display/display_controller.cc

Issue 14361002: Use GetInverse (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « ash/ash_root_window_transformer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <map> 9 #include <map>
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 #if defined(OS_WIN) 144 #if defined(OS_WIN)
145 // Windows 8 bots refused to resize the host window, and 145 // Windows 8 bots refused to resize the host window, and
146 // updating the transform results in incorrectly resizing 146 // updating the transform results in incorrectly resizing
147 // the root window. Don't apply the transform unless 147 // the root window. Don't apply the transform unless
148 // necessary so that unit tests pass on win8 bots. 148 // necessary so that unit tests pass on win8 bots.
149 if (info.rotation() == root_window->GetProperty(kRotationPropertyKey)) 149 if (info.rotation() == root_window->GetProperty(kRotationPropertyKey))
150 return; 150 return;
151 root_window->SetProperty(kRotationPropertyKey, info.rotation()); 151 root_window->SetProperty(kRotationPropertyKey, info.rotation());
152 #endif 152 #endif
153 gfx::Transform rotate; 153 gfx::Transform rotate;
154 // TODO(oshima): Manually complute the inverse of the
155 // rotate+translate matrix to compensate for computation error in
156 // the inverted matrix. Ideally, SkMatrix should have special
157 // case handling for rotate+translate case. crbug.com/222483.
158 gfx::Transform reverse_rotate;
159
160 // The origin is (0, 0), so the translate width/height must be reduced by 154 // The origin is (0, 0), so the translate width/height must be reduced by
161 // 1 pixel. 155 // 1 pixel.
162 float one_pixel = 1.0f / display.device_scale_factor(); 156 float one_pixel = 1.0f / display.device_scale_factor();
163 switch (info.rotation()) { 157 switch (info.rotation()) {
164 case gfx::Display::ROTATE_0: 158 case gfx::Display::ROTATE_0:
165 break; 159 break;
166 case gfx::Display::ROTATE_90: 160 case gfx::Display::ROTATE_90:
167 rotate.Translate(display.bounds().height() - one_pixel, 0); 161 rotate.Translate(display.bounds().height() - one_pixel, 0);
168 rotate.Rotate(90); 162 rotate.Rotate(90);
169 reverse_rotate.Rotate(270);
170 reverse_rotate.Translate(-(display.bounds().height() - one_pixel), 0);
171 break; 163 break;
172 case gfx::Display::ROTATE_270: 164 case gfx::Display::ROTATE_270:
173 rotate.Translate(0, display.bounds().width() - one_pixel); 165 rotate.Translate(0, display.bounds().width() - one_pixel);
174 rotate.Rotate(270); 166 rotate.Rotate(270);
175 reverse_rotate.Rotate(90);
176 reverse_rotate.Translate(0, -(display.bounds().width() - one_pixel));
177 break; 167 break;
178 case gfx::Display::ROTATE_180: 168 case gfx::Display::ROTATE_180:
179 rotate.Translate(display.bounds().width() - one_pixel, 169 rotate.Translate(display.bounds().width() - one_pixel,
180 display.bounds().height() - one_pixel); 170 display.bounds().height() - one_pixel);
181 rotate.Rotate(180); 171 rotate.Rotate(180);
182 reverse_rotate.Rotate(180);
183 reverse_rotate.Translate(-(display.bounds().width() - one_pixel),
184 -(display.bounds().height() - one_pixel));
185 break; 172 break;
186 } 173 }
187 RoundNearZero(&rotate); 174 RoundNearZero(&rotate);
188 RoundNearZero(&reverse_rotate);
189 175
190 scoped_ptr<aura::RootWindowTransformer> transformer( 176 scoped_ptr<aura::RootWindowTransformer> transformer(
191 new AshRootWindowTransformer(root_window, 177 new AshRootWindowTransformer(root_window,
192 rotate, 178 rotate,
193 reverse_rotate,
194 info.GetOverscanInsetsInPixel(), 179 info.GetOverscanInsetsInPixel(),
195 info.ui_scale())); 180 info.ui_scale()));
196 root_window->SetRootWindowTransformer(transformer.Pass()); 181 root_window->SetRootWindowTransformer(transformer.Pass());
197 } 182 }
198 183
199 void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, 184 void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root,
200 const gfx::Display& display) { 185 const gfx::Display& display) {
201 internal::DisplayInfo info = 186 internal::DisplayInfo info =
202 GetDisplayManager()->GetDisplayInfo(display.id()); 187 GetDisplayManager()->GetDisplayInfo(display.id());
203 #if defined(OS_CHROMEOS) 188 #if defined(OS_CHROMEOS)
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 1018 }
1034 1019
1035 void DisplayController::OnFadeOutForSwapDisplayFinished() { 1020 void DisplayController::OnFadeOutForSwapDisplayFinished() {
1036 #if defined(OS_CHROMEOS) 1021 #if defined(OS_CHROMEOS)
1037 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); 1022 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay());
1038 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); 1023 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation();
1039 #endif 1024 #endif
1040 } 1025 }
1041 1026
1042 } // namespace ash 1027 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ash_root_window_transformer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698