transformer_util.cc 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/utility/transformer_util.h"
  5. #include <cmath>
  6. #include "ui/display/display_transform.h"
  7. #include "ui/gfx/geometry/size_f.h"
  8. #include "ui/gfx/geometry/transform.h"
  9. namespace ash {
  10. namespace {
  11. display::Display::Rotation RotationBetween(
  12. display::Display::Rotation old_rotation,
  13. display::Display::Rotation new_rotation) {
  14. return static_cast<display::Display::Rotation>(
  15. display::Display::Rotation::ROTATE_0 +
  16. ((new_rotation - old_rotation) + 4) % 4);
  17. }
  18. } // namespace
  19. gfx::Transform CreateRotationTransform(display::Display::Rotation old_rotation,
  20. display::Display::Rotation new_rotation,
  21. const gfx::SizeF& size_to_rotate) {
  22. return display::CreateRotationTransform(
  23. RotationBetween(old_rotation, new_rotation), size_to_rotate);
  24. }
  25. } // namespace ash