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

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

Issue 13916004: Translate 1 pixel not 1 dip when rotating the display. (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 | « no previous file | ash/display/display_controller_unittest.cc » ('j') | ui/aura/root_window.cc » ('J')
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 <map> 8 #include <map>
9 9
10 #include "ash/ash_root_window_transformer.h" 10 #include "ash/ash_root_window_transformer.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return; 135 return;
136 root_window->SetProperty(kRotationPropertyKey, info.rotation()); 136 root_window->SetProperty(kRotationPropertyKey, info.rotation());
137 #endif 137 #endif
138 gfx::Transform rotate; 138 gfx::Transform rotate;
139 // TODO(oshima): Manually complute the inverse of the 139 // TODO(oshima): Manually complute the inverse of the
140 // rotate+translate matrix to compensate for computation error in 140 // rotate+translate matrix to compensate for computation error in
141 // the inverted matrix. Ideally, SkMatrix should have special 141 // the inverted matrix. Ideally, SkMatrix should have special
142 // case handling for rotate+translate case. crbug.com/222483. 142 // case handling for rotate+translate case. crbug.com/222483.
143 gfx::Transform reverse_rotate; 143 gfx::Transform reverse_rotate;
144 144
145 // The origin is (0, 0), so the translate width/height must be reduced by 1. 145 // The origin is (0, 0), so the translate width/height must be reduced by
146 // 1 pixel.
147 float one_pixel = 1.0f / display.device_scale_factor();
146 switch (info.rotation()) { 148 switch (info.rotation()) {
147 case gfx::Display::ROTATE_0: 149 case gfx::Display::ROTATE_0:
148 break; 150 break;
149 case gfx::Display::ROTATE_90: 151 case gfx::Display::ROTATE_90:
150 rotate.Translate(display.bounds().height() - 1, 0); 152 rotate.Translate(display.bounds().height() - one_pixel, 0);
151 rotate.Rotate(90); 153 rotate.Rotate(90);
152 // Rotate 270 instead of 90 as it will cause calcuration error. 154 // Rotate 270 instead of 90 as it will cause calcuration error.
153 reverse_rotate.Rotate(270); 155 reverse_rotate.Rotate(270);
154 reverse_rotate.Translate(-(display.bounds().height() - 1), 0); 156 reverse_rotate.Translate(-(display.bounds().height() - one_pixel), 0);
155 break; 157 break;
156 case gfx::Display::ROTATE_270: 158 case gfx::Display::ROTATE_270:
157 rotate.Translate(0, display.bounds().width() - 1); 159 rotate.Translate(0, display.bounds().width() - one_pixel);
158 rotate.Rotate(270); 160 rotate.Rotate(270);
159 reverse_rotate.Rotate(90); 161 reverse_rotate.Rotate(90);
160 reverse_rotate.Translate(0, -(display.bounds().width() - 1)); 162 reverse_rotate.Translate(0, -(display.bounds().width() - one_pixel));
161 break; 163 break;
162 case gfx::Display::ROTATE_180: 164 case gfx::Display::ROTATE_180:
163 rotate.Translate(display.bounds().width() - 1, 165 rotate.Translate(display.bounds().width() - one_pixel,
164 display.bounds().height() - 1); 166 display.bounds().height() - one_pixel);
165 rotate.Rotate(180); 167 rotate.Rotate(180);
166 reverse_rotate.Rotate(180); 168 reverse_rotate.Rotate(180);
167 reverse_rotate.Translate(-(display.bounds().width() - 1), 169 reverse_rotate.Translate(-(display.bounds().width() - one_pixel),
168 -(display.bounds().height() - 1)); 170 -(display.bounds().height() - one_pixel));
169 break; 171 break;
170 } 172 }
171 scoped_ptr<aura::RootWindowTransformer> transformer( 173 scoped_ptr<aura::RootWindowTransformer> transformer(
172 new AshRootWindowTransformer(root_window, 174 new AshRootWindowTransformer(root_window,
173 rotate, 175 rotate,
174 reverse_rotate, 176 reverse_rotate,
175 info.GetOverscanInsetsInPixel(), 177 info.GetOverscanInsetsInPixel(),
176 info.ui_scale())); 178 info.ui_scale()));
177 root_window->SetRootWindowTransformer(transformer.Pass()); 179 root_window->SetRootWindowTransformer(transformer.Pass());
178 } 180 }
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 } 940 }
939 941
940 void DisplayController::OnFadeOutForSwapDisplayFinished() { 942 void DisplayController::OnFadeOutForSwapDisplayFinished() {
941 #if defined(OS_CHROMEOS) 943 #if defined(OS_CHROMEOS)
942 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); 944 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay());
943 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); 945 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation();
944 #endif 946 #endif
945 } 947 }
946 948
947 } // namespace ash 949 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/display/display_controller_unittest.cc » ('j') | ui/aura/root_window.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698