Flutter Engine
impeller::TSize< T > Struct Template Reference

#include <size.h>

Public Types

using Type = T
 

Public Member Functions

constexpr TSize ()
 
constexpr TSize (Type width, Type height)
 
template<class U >
constexpr TSize (const TSize< U > &other)
 
constexpr TSize operator* (Scalar scale) const
 
constexpr TSize operator/ (Scalar scale) const
 
constexpr TSize operator/ (const TSize &s) const
 
constexpr bool operator== (const TSize &s) const
 
constexpr bool operator!= (const TSize &s) const
 
constexpr TSize operator+ (const TSize &s) const
 
constexpr TSize operator- (const TSize &s) const
 
constexpr TSize Min (const TSize &o) const
 
constexpr TSize Max (const TSize &o) const
 
constexpr Type Area () const
 
constexpr bool IsPositive () const
 
constexpr bool IsNegative () const
 
constexpr bool IsZero () const
 
constexpr bool IsEmpty () const
 
constexpr size_t MipCount () const
 

Static Public Member Functions

static constexpr TSize MakeWH (Type width, Type height)
 
static constexpr TSize Infinite ()
 
template<class U >
static constexpr TSize Ceil (const TSize< U > &other)
 

Public Attributes

Type width = {}
 
Type height = {}
 

Detailed Description

template<class T>
struct impeller::TSize< T >

Definition at line 18 of file size.h.

Member Typedef Documentation

◆ Type

template<class T>
using impeller::TSize< T >::Type = T

Definition at line 19 of file size.h.

Constructor & Destructor Documentation

◆ TSize() [1/3]

template<class T>
constexpr impeller::TSize< T >::TSize ( )
inline

Definition at line 24 of file size.h.

24 {}

◆ TSize() [2/3]

template<class T>
constexpr impeller::TSize< T >::TSize ( Type  width,
Type  height 
)
inline

Definition at line 26 of file size.h.

26 : width(width), height(height) {}
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ TSize() [3/3]

template<class T>
template<class U >
constexpr impeller::TSize< T >::TSize ( const TSize< U > &  other)
inlineexplicit

Definition at line 29 of file size.h.

30  : TSize(static_cast<Type>(other.width), static_cast<Type>(other.height)) {
31  }
constexpr TSize()
Definition: size.h:24

Member Function Documentation

◆ Area()

template<class T>
constexpr Type impeller::TSize< T >::Area ( ) const
inline

◆ Ceil()

template<class T>
template<class U >
static constexpr TSize impeller::TSize< T >::Ceil ( const TSize< U > &  other)
inlinestatic

Definition at line 96 of file size.h.

96  {
97  return TSize{static_cast<Type>(std::ceil(other.width)),
98  static_cast<Type>(std::ceil(other.height))};
99  }
constexpr TSize()
Definition: size.h:24

◆ Infinite()

template<class T>
static constexpr TSize impeller::TSize< T >::Infinite ( )
inlinestatic

Definition at line 37 of file size.h.

37  {
38  return TSize{std::numeric_limits<Type>::max(),
39  std::numeric_limits<Type>::max()};
40  }
constexpr TSize()
Definition: size.h:24

◆ IsEmpty()

template<class T>
constexpr bool impeller::TSize< T >::IsEmpty ( ) const
inline

Definition at line 93 of file size.h.

Referenced by impeller::RenderTarget::CreateOffscreen(), impeller::Canvas::DrawImageRect(), and impeller::TRect< Scalar >::IsEmpty().

93 { return IsNegative() || IsZero(); }
constexpr bool IsZero() const
Definition: size.h:91
constexpr bool IsNegative() const
Definition: size.h:89

◆ IsNegative()

template<class T>
constexpr bool impeller::TSize< T >::IsNegative ( ) const
inline

Definition at line 89 of file size.h.

Referenced by impeller::TSize< Type >::IsEmpty().

89 { return width < 0 || height < 0; }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ IsPositive()

template<class T>
constexpr bool impeller::TSize< T >::IsPositive ( ) const
inline

Definition at line 87 of file size.h.

Referenced by impeller::TextureDescriptor::IsValid(), and impeller::TSize< Type >::MipCount().

87 { return width > 0 && height > 0; }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ IsZero()

template<class T>
constexpr bool impeller::TSize< T >::IsZero ( ) const
inline

Definition at line 91 of file size.h.

Referenced by impeller::TSize< Type >::IsEmpty(), and impeller::TRect< Scalar >::IsZero().

91 { return width == 0 || height == 0; }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ MakeWH()

template<class T>
static constexpr TSize impeller::TSize< T >::MakeWH ( Type  width,
Type  height 
)
inlinestatic

Definition at line 33 of file size.h.

33  {
34  return TSize{width, height};
35  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22
constexpr TSize()
Definition: size.h:24

◆ Max()

template<class T>
constexpr TSize impeller::TSize< T >::Max ( const TSize< T > &  o) const
inline

Definition at line 78 of file size.h.

78  {
79  return {
80  std::max(width, o.width),
81  std::max(height, o.height),
82  };
83  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ Min()

template<class T>
constexpr TSize impeller::TSize< T >::Min ( const TSize< T > &  o) const
inline

Definition at line 71 of file size.h.

71  {
72  return {
73  std::min(width, o.width),
74  std::min(height, o.height),
75  };
76  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ MipCount()

template<class T>
constexpr size_t impeller::TSize< T >::MipCount ( ) const
inline

Definition at line 101 of file size.h.

Referenced by impeller::testing::TEST().

101  {
102  if (!IsPositive()) {
103  return 1u;
104  }
105  return std::max(ceil(log2(width)), ceil(log2(height)));
106  }
constexpr bool IsPositive() const
Definition: size.h:87
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ operator!=()

template<class T>
constexpr bool impeller::TSize< T >::operator!= ( const TSize< T > &  s) const
inline

Definition at line 59 of file size.h.

59  {
60  return s.width != width || s.height != height;
61  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ operator*()

template<class T>
constexpr TSize impeller::TSize< T >::operator* ( Scalar  scale) const
inline

Definition at line 42 of file size.h.

42  {
43  return {width * scale, height * scale};
44  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ operator+()

template<class T>
constexpr TSize impeller::TSize< T >::operator+ ( const TSize< T > &  s) const
inline

Definition at line 63 of file size.h.

63  {
64  return {width + s.width, height + s.height};
65  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ operator-()

template<class T>
constexpr TSize impeller::TSize< T >::operator- ( const TSize< T > &  s) const
inline

Definition at line 67 of file size.h.

67  {
68  return {width - s.width, height - s.height};
69  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ operator/() [1/2]

template<class T>
constexpr TSize impeller::TSize< T >::operator/ ( Scalar  scale) const
inline

Definition at line 46 of file size.h.

46  {
47  return {static_cast<Scalar>(width) / scale,
48  static_cast<Scalar>(height) / scale};
49  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22
float Scalar
Definition: scalar.h:15

◆ operator/() [2/2]

template<class T>
constexpr TSize impeller::TSize< T >::operator/ ( const TSize< T > &  s) const
inline

Definition at line 51 of file size.h.

51  {
52  return {width / s.width, height / s.height};
53  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

◆ operator==()

template<class T>
constexpr bool impeller::TSize< T >::operator== ( const TSize< T > &  s) const
inline

Definition at line 55 of file size.h.

55  {
56  return s.width == width && s.height == height;
57  }
Type width
Definition: size.h:21
Type height
Definition: size.h:22

Member Data Documentation

◆ height

◆ width

template<class T>
Type impeller::TSize< T >::width = {}

The documentation for this struct was generated from the following file: