desktop_frame_rotation.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_ROTATION_H_
  11. #define MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_ROTATION_H_
  12. #include "modules/desktop_capture/desktop_frame.h"
  13. #include "modules/desktop_capture/desktop_geometry.h"
  14. namespace webrtc {
  15. // Represents the rotation of a DesktopFrame.
  16. enum class Rotation {
  17. CLOCK_WISE_0,
  18. CLOCK_WISE_90,
  19. CLOCK_WISE_180,
  20. CLOCK_WISE_270,
  21. };
  22. // Rotates input DesktopFrame |source|, copies pixel in an unrotated rectangle
  23. // |source_rect| into the target rectangle of another DesktopFrame |target|.
  24. // Target rectangle here is the rotated |source_rect| plus |target_offset|.
  25. // |rotation| specifies |source| to |target| rotation. |source_rect| is in
  26. // |source| coordinate. |target_offset| is in |target| coordinate.
  27. // This function triggers check failure if |source| does not cover the
  28. // |source_rect|, or |target| does not cover the rotated |rect|.
  29. void RotateDesktopFrame(const DesktopFrame& source,
  30. const DesktopRect& source_rect,
  31. const Rotation& rotation,
  32. const DesktopVector& target_offset,
  33. DesktopFrame* target);
  34. // Returns a reverse rotation of |rotation|.
  35. Rotation ReverseRotation(Rotation rotation);
  36. // Returns a rotated DesktopSize of |size|.
  37. DesktopSize RotateSize(DesktopSize size, Rotation rotation);
  38. // Returns a rotated DesktopRect of |rect|. The |size| represents the size of
  39. // the DesktopFrame which |rect| belongs in.
  40. DesktopRect RotateRect(DesktopRect rect, DesktopSize size, Rotation rotation);
  41. } // namespace webrtc
  42. #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_ROTATION_H_