13 #define XBMC_FORCE_INLINE __attribute__((always_inline))    15 #define XBMC_FORCE_INLINE    33   template<
class U> 
explicit constexpr CPointGen(
const CPointGen<U>& rhs)
    34   : x{
static_cast<T
> (rhs.x)}, y{
static_cast<T
> (rhs.y)}
    37   constexpr this_type operator+(
const this_type &point)
 const    39     return {x + point.x, y + point.y};
    42   this_type& operator+=(
const this_type &point)
    49   constexpr this_type operator-(
const this_type &point)
 const    51     return {x - point.x, y - point.y};
    54   this_type& operator-=(
const this_type &point)
    61   constexpr this_type operator*(T factor)
 const    63     return {x * factor, y * factor};
    66   this_type& operator*=(T factor)
    73   constexpr this_type operator/(T factor)
 const    75     return {x / factor, y / factor};
    78   this_type& operator/=(T factor)
    91   return (point1.x == point2.x && point1.y == point2.y);
    97   return !(point1 == point2);
   116   void CheckSet(T width, T height)
   120       throw std::out_of_range(
"Size may not have negative width");
   124       throw std::out_of_range(
"Size may not have negative height");
   137     CheckSet(width, height);
   150   void SetWidth(T width)
   152     CheckSet(width, m_h);
   155   void SetHeight(T height)
   157     CheckSet(m_w, height);
   160   void Set(T width, T height)
   162     CheckSet(width, height);
   167     return (m_w == static_cast<T> (0) && m_h == static_cast<T> (0));
   182     CheckSet(static_cast<T> (rhs.m_w), static_cast<T> (rhs.m_h));
   185   this_type operator+(
const this_type& size)
 const   187     return {m_w + size.m_w, m_h + size.m_h};
   190   this_type& operator+=(
const this_type& size)
   192     CheckSet(m_w + size.m_w, m_h + size.m_h);
   196   this_type operator-(
const this_type& size)
 const   198     return {m_w - size.m_w, m_h - size.m_h};
   201   this_type& operator-=(
const this_type& size)
   203     CheckSet(m_w - size.m_w, m_h - size.m_h);
   207   this_type operator*(T factor)
 const   209     return {m_w * factor, m_h * factor};
   212   this_type& operator*=(T factor)
   214     CheckSet(m_w * factor, m_h * factor);
   218   this_type operator/(T factor)
 const   220     return {m_w / factor, m_h / factor};
   223   this_type& operator/=(T factor)
   225     CheckSet(m_w / factor, m_h / factor);
   233   return (size1.Width() == size2.Width() && size1.Height() == size2.Height());
   239   return !(size1 == size2);
   246 template <
typename T> 
class CRectGen   255   constexpr 
CRectGen(T left, T top, T right, T bottom)
   256   : x1{left}, y1{top}, x2{right}, y2{bottom}
   259   constexpr CRectGen(
const point_type &p1, 
const point_type &p2)
   260   : x1{p1.x}, y1{p1.y}, x2{p2.x}, y2{p2.y}
   263   constexpr CRectGen(
const point_type &origin, 
const size_type &size)
   264   : x1{origin.x}, y1{origin.y}, x2{x1 + size.Width()}, y2{y1 + size.Height()}
   267   template<
class U> 
explicit constexpr CRectGen(
const CRectGen<U>& rhs)
   268   : x1{
static_cast<T
> (rhs.x1)}, y1{
static_cast<T
> (rhs.y1)}, x2{
static_cast<T
> (rhs.x2)}, y2{
static_cast<T
> (rhs.y2)}
   271   void SetRect(T left, T top, T right, T bottom)
   279   constexpr 
bool PtInRect(
const point_type &point)
 const   281     return (x1 <= point.x && point.x <= x2 && y1 <= point.y && point.y <= y2);
   284   constexpr 
bool Intersects(
const this_type& rect)
 const   286     return (x1 < rect.x2 && x2 > rect.x1 && y1 < rect.y2 && y2 > rect.y1);
   289   this_type& operator-=(
const point_type &point) XBMC_FORCE_INLINE
   298   constexpr this_type operator-(
const point_type &point)
 const   300     return {x1 - point.x, y1 - point.y, x2 - point.x, y2 - point.y};
   303   this_type& operator+=(
const point_type &point) XBMC_FORCE_INLINE
   312   constexpr this_type operator+(
const point_type &point)
 const   314     return {x1 + point.x, y1 + point.y, x2 + point.x, y2 + point.y};
   317   this_type& operator-=(
const size_type &size)
   324   constexpr this_type operator-(
const size_type &size)
 const   326     return {x1, y1, x2 - size.Width(), y2 - size.Height()};
   329   this_type& operator+=(
const size_type &size)
   336   constexpr this_type operator+(
const size_type &size)
 const   338     return {x1, y1, x2 + size.Width(), y2 + size.Height()};
   341   this_type& Intersect(
const this_type &rect)
   343     x1 = clamp_range(x1, rect.x1, rect.x2);
   344     x2 = clamp_range(x2, rect.x1, rect.x2);
   345     y1 = clamp_range(y1, rect.y1, rect.y2);
   346     y2 = clamp_range(y2, rect.y1, rect.y2);
   350   this_type& Union(
const this_type &rect)
   354     else if (!rect.IsEmpty())
   356       x1 = std::min(x1,rect.x1);
   357       y1 = std::min(y1,rect.y1);
   359       x2 = std::max(x2,rect.x2);
   360       y2 = std::max(y2,rect.y2);
   366   constexpr 
bool IsEmpty() 
const XBMC_FORCE_INLINE
   368     return (x2 - x1) * (y2 - y1) == 0;
   371   constexpr point_type P1() 
const XBMC_FORCE_INLINE
   376   constexpr point_type P2() 
const XBMC_FORCE_INLINE
   381   constexpr T Width() 
const XBMC_FORCE_INLINE
   386   constexpr T Height() 
const XBMC_FORCE_INLINE
   391   constexpr T Area() 
const XBMC_FORCE_INLINE
   393     return Width() * Height();
   396   size_type ToSize()
 const   398     return {Width(), Height()};
   401   std::vector<this_type> SubtractRect(this_type splitterRect)
   403     std::vector<this_type> newRectanglesList;
   404     this_type intersection = splitterRect.Intersect(*
this);
   406     if (!intersection.IsEmpty())
   411       add = this_type(x1, y1, x2, intersection.y1);
   413         newRectanglesList.push_back(add);
   416       add = this_type(x1, intersection.y2, x2, y2);
   418         newRectanglesList.push_back(add);
   421       add = this_type(x1, intersection.y1, intersection.x1, intersection.y2);
   423         newRectanglesList.push_back(add);
   426       add = this_type(intersection.x2, intersection.y1, x2, intersection.y2);
   428         newRectanglesList.push_back(add);
   432       newRectanglesList.push_back(*
this);
   435     return newRectanglesList;
   438   std::vector<this_type> SubtractRects(
const std::vector<this_type>& intersectionList)
   440     std::vector<this_type> fragmentsList;
   441     fragmentsList.push_back(*
this);
   443     for (
typename std::vector<this_type>::iterator splitter = intersectionList.begin(); splitter != intersectionList.end(); ++splitter)
   445       typename std::vector<this_type> toAddList;
   447       for (
typename std::vector<this_type>::iterator fragment = fragmentsList.begin(); fragment != fragmentsList.end(); ++fragment)
   449         std::vector<this_type> newFragmentsList = fragment->SubtractRect(*splitter);
   450         toAddList.insert(toAddList.end(), newFragmentsList.begin(), newFragmentsList.end());
   453       fragmentsList.clear();
   454       fragmentsList.insert(fragmentsList.end(), toAddList.begin(), toAddList.end());
   457     return fragmentsList;
   460   void GetQuad(point_type (&points)[4])
   462     points[0] = { x1, y1 };
   463     points[1] = { x2, y1 };
   464     points[2] = { x2, y2 };
   465     points[3] = { x1, y2 };
   468   T x1{}, y1{}, x2{}, y2{};
   470   static constexpr T clamp_range(T x, T l, T h) XBMC_FORCE_INLINE
   472     return (x > h) ? h : ((x < l) ? l : x);
   479   return (rect1.x1 == rect2.x1 && rect1.y1 == rect2.y1 && rect1.x2 == rect2.x2 && rect1.y2 == rect2.y2);
   485   return !(rect1 == rect2);
 Definition: StreamInfo.h:15
Definition: Geometry.h:22
Generic two-dimensional size representation. 
Definition: Geometry.h:112