Size.h 916 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. namespace unity
  3. {
  4. namespace webrtc
  5. {
  6. using namespace ::webrtc;
  7. class Size
  8. {
  9. public:
  10. constexpr Size()
  11. : width_(0)
  12. , height_(0)
  13. {
  14. }
  15. constexpr Size(int width, int height)
  16. : width_(std::max(0, width))
  17. , height_(std::max(0, height))
  18. {
  19. }
  20. void set_width(int width) { width_ = std::max(0, width); }
  21. void set_height(int height) { height_ = std::max(0, height); }
  22. constexpr int width() const { return width_; }
  23. constexpr int height() const { return height_; }
  24. private:
  25. int width_;
  26. int height_;
  27. };
  28. inline bool operator==(const Size& lhs, const Size& rhs)
  29. {
  30. return lhs.width() == rhs.width() && lhs.height() == rhs.height();
  31. }
  32. inline bool operator!=(const Size& lhs, const Size& rhs) { return !(lhs == rhs); }
  33. }
  34. }