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

Unified Diff: remoting/host/chromeos/point_transformer.cc

Issue 1712343004: Respect display rotation on Chrome OS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use GetTargetTransform() Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/chromeos/point_transformer.cc
diff --git a/remoting/host/chromeos/point_transformer.cc b/remoting/host/chromeos/point_transformer.cc
index 2c8b89317a9f974816dbd3da74305bd7100be144..43a3941d25c98328cd00c40695563dd62bc33930 100644
--- a/remoting/host/chromeos/point_transformer.cc
+++ b/remoting/host/chromeos/point_transformer.cc
@@ -13,6 +13,8 @@ namespace remoting {
PointTransformer::PointTransformer() {
root_window_ = ash::Shell::GetPrimaryRootWindow();
root_window_->AddObserver(this);
+ // Set the initial display rotation.
+ OnWindowTransformed(root_window_);
}
PointTransformer::~PointTransformer() {
@@ -25,15 +27,16 @@ void PointTransformer::OnWindowTransformed(aura::Window* window) {
ui::Layer* layer = root_window_->layer();
float scale = ui::GetDeviceScaleFactor(layer);
- // |layer->transform()| returns a transform comprising a rotation and a
- // translation, but in DIPs, so we need to switch device pixels to
- // DIPs, apply it, then switch from DIPs back to device pixels.
- gfx::Transform rotation = layer->transform();
+ // Use GetTargetTransform() instead of transform() as the layer may be
+ // animating. GetTargetTransform() returns a transform comprising a rotation
+ // and a translation, but in DIPs, so we need to switch device pixels to DIPs,
+ // apply it, then switch from DIPs back to device pixels.
+ gfx::Transform rotation = layer->GetTargetTransform();
gfx::Transform inverse_rotation;
gfx::Transform to_device_pixels;
gfx::Transform to_dip;
- CHECK(!rotation.GetInverse(&inverse_rotation))
+ CHECK(rotation.GetInverse(&inverse_rotation))
<< "Cannot inverse the root transform." << rotation.ToString();
to_device_pixels.Scale(scale, scale);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698