Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
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 operator- () const
 
constexpr TSize Min (const TSize &o) const
 
constexpr TSize Max (const TSize &o) const
 
constexpr Type MaxDimension () const
 
constexpr TSize Abs () const
 
constexpr TSize Floor () const
 
constexpr TSize Ceil () const
 
constexpr TSize Round () const
 
constexpr Type Area () const
 
constexpr bool IsEmpty () const
 Returns true if either of the width or height are 0, negative, or NaN.
 
constexpr bool IsSquare () 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 19 of file size.h.

Member Typedef Documentation

◆ Type

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

Definition at line 20 of file size.h.

Constructor & Destructor Documentation

◆ TSize() [1/3]

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

Definition at line 25 of file size.h.

25{}

◆ TSize() [2/3]

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

Definition at line 27 of file size.h.

Type height
Definition size.h:23
Type width
Definition size.h:22

◆ TSize() [3/3]

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

Definition at line 30 of file size.h.

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

Member Function Documentation

◆ Abs()

template<class T >
constexpr TSize impeller::TSize< T >::Abs ( ) const
inlineconstexpr

Definition at line 90 of file size.h.

90{ return {std::fabs(width), std::fabs(height)}; }

◆ Area()

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

Definition at line 102 of file size.h.

102{ return width * height; }

◆ Ceil() [1/2]

template<class T >
constexpr TSize impeller::TSize< T >::Ceil ( ) const
inlineconstexpr

Definition at line 96 of file size.h.

96{ return {std::ceil(width), std::ceil(height)}; }

◆ Ceil() [2/2]

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

Definition at line 110 of file size.h.

110 {
111 return TSize{static_cast<Type>(std::ceil(other.width)),
112 static_cast<Type>(std::ceil(other.height))};
113 }

◆ Floor()

template<class T >
constexpr TSize impeller::TSize< T >::Floor ( ) const
inlineconstexpr

Definition at line 92 of file size.h.

92 {
93 return {std::floor(width), std::floor(height)};
94 }

◆ Infinite()

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

Definition at line 38 of file size.h.

38 {
39 return TSize{std::numeric_limits<Type>::max(),
40 std::numeric_limits<Type>::max()};
41 }

◆ IsEmpty()

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

Returns true if either of the width or height are 0, negative, or NaN.

Definition at line 105 of file size.h.

105{ return !(width > 0 && height > 0); }

◆ IsSquare()

template<class T >
constexpr bool impeller::TSize< T >::IsSquare ( ) const
inlineconstexpr

Definition at line 107 of file size.h.

107{ return width == height; }

◆ MakeWH()

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

Definition at line 34 of file size.h.

34 {
35 return TSize{width, height};
36 }

◆ Max()

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

Definition at line 81 of file size.h.

81 {
82 return {
83 std::max(width, o.width),
84 std::max(height, o.height),
85 };
86 }

◆ MaxDimension()

template<class T >
constexpr Type impeller::TSize< T >::MaxDimension ( ) const
inlineconstexpr

Definition at line 88 of file size.h.

88{ return std::max(width, height); }

◆ Min()

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

Definition at line 74 of file size.h.

74 {
75 return {
76 std::min(width, o.width),
77 std::min(height, o.height),
78 };
79 }

◆ MipCount()

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

Definition at line 115 of file size.h.

115 {
116 constexpr size_t minimum_mip = 1u;
117 if (IsEmpty()) {
118 return minimum_mip;
119 }
120 size_t result = std::max(ceil(log2(width)), ceil(log2(height)));
121 return std::max(result, minimum_mip);
122 }
GAsyncResult * result
SIN Vec< N, float > ceil(const Vec< N, float > &x)
Definition SkVx.h:702
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition size.h:105

◆ operator!=()

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

Definition at line 60 of file size.h.

60 {
61 return s.width != width || s.height != height;
62 }
struct MyStruct s

◆ operator*()

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

Definition at line 43 of file size.h.

43 {
44 return {width * scale, height * scale};
45 }
const Scalar scale

◆ operator+()

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

Definition at line 64 of file size.h.

64 {
65 return {width + s.width, height + s.height};
66 }

◆ operator-() [1/2]

template<class T >
constexpr TSize impeller::TSize< T >::operator- ( ) const
inlineconstexpr

Definition at line 72 of file size.h.

72{ return {-width, -height}; }

◆ operator-() [2/2]

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

Definition at line 68 of file size.h.

68 {
69 return {width - s.width, height - s.height};
70 }

◆ operator/() [1/2]

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

Definition at line 52 of file size.h.

52 {
53 return {width / s.width, height / s.height};
54 }

◆ operator/() [2/2]

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

Definition at line 47 of file size.h.

47 {
48 return {static_cast<Scalar>(width) / scale,
49 static_cast<Scalar>(height) / scale};
50 }
float Scalar
Definition scalar.h:18

◆ operator==()

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

Definition at line 56 of file size.h.

56 {
57 return s.width == width && s.height == height;
58 }

◆ Round()

template<class T >
constexpr TSize impeller::TSize< T >::Round ( ) const
inlineconstexpr

Definition at line 98 of file size.h.

98 {
99 return {std::round(width), std::round(height)};
100 }

Member Data Documentation

◆ height

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

Definition at line 23 of file size.h.

23{};

◆ width

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

Definition at line 22 of file size.h.

22{};

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