1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33

ash / utility / transformer_util.cc [blame]

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/utility/transformer_util.h"

#include <cmath>

#include "ui/display/display_transform.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/geometry/transform.h"

namespace ash {
namespace {

display::Display::Rotation RotationBetween(
    display::Display::Rotation old_rotation,
    display::Display::Rotation new_rotation) {
  return static_cast<display::Display::Rotation>(
      display::Display::Rotation::ROTATE_0 +
      ((new_rotation - old_rotation) + 4) % 4);
}

}  // namespace

gfx::Transform CreateRotationTransform(display::Display::Rotation old_rotation,
                                       display::Display::Rotation new_rotation,
                                       const gfx::SizeF& size_to_rotate) {
  return display::CreateRotationTransform(
      RotationBetween(old_rotation, new_rotation), size_to_rotate);
}

}  // namespace ash