| Flutter Impeller |

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. More...
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 | ( |  | ) |
| inline constexpr

Definition at line 25 of file size.h.

25 {}

## ◆ TSize() [2/3]

template<class T >

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

Definition at line 27 of file size.h.

27 : width(width), height(height) {}

## ◆ TSize() [3/3]

template<class T >
template<class U >

constexpr impeller::TSize< T >::TSize | ( | const TSize< U > & | other | ) |
| inline explicit constexpr

Definition at line 30 of file size.h.

31 : TSize(static_cast<Type>(other.width), static_cast<Type>(other.height)) {
32 }

## Member Function Documentation

## ◆ Abs()

template<class T >

constexpr TSize impeller::TSize< T >::Abs | ( |  | ) | const
| inline constexpr

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
| inline constexpr

Definition at line 102 of file size.h.

102 { return width * height; }

Referenced by impeller::TRect< Scalar >::Area(), impeller::DecompressedImage::ConvertToRGBA(), and impeller::TextureDescriptor::GetByteSizeOfBaseMipLevel().

## ◆ Ceil() [1/2]

template<class T >

constexpr TSize impeller::TSize< T >::Ceil | ( |  | ) | const
| inline constexpr

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 | ) |
| inline static constexpr

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
| inline constexpr

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 | ( |  | ) |
| inline static constexpr

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
| inline constexpr

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); }

Referenced by impeller::CanAppendToExistingAtlas(), impeller::Canvas::ClipRRect(), impeller::RenderTarget::CreateOffscreen(), impeller::RenderTarget::CreateOffscreenMSAA(), impeller::ComputePass::EncodeCommands(), impeller::TRect< Scalar >::IsEmpty(), impeller::TextureDescriptor::IsValid(), impeller::TSize< Type >::MipCount(), impeller::PairsFitInAtlasOfSize(), and impeller::Picture::ToImage().

## ◆ IsSquare()

template<class T >

constexpr bool impeller::TSize< T >::IsSquare | ( |  | ) | const
| inline constexpr

Definition at line 107 of file size.h.

107 { return width == height; }

Referenced by impeller::TRect< Scalar >::IsSquare().

## ◆ MakeWH()

template<class T >

static constexpr TSize impeller::TSize< T >::MakeWH | ( | Type | width,
|  | Type | height
| ) |  |
| inline static constexpr

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
| inline constexpr

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 }

Referenced by impeller::Playground::OpenPlaygroundHere().

## ◆ MaxDimension()

template<class T >

constexpr Type impeller::TSize< T >::MaxDimension | ( |  | ) | const
| inline constexpr

Definition at line 88 of file size.h.

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

Referenced by impeller::Tessellator::FilledEllipse(), and impeller::Tessellator::FilledRoundRect().

## ◆ Min()

template<class T >

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

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
| inline constexpr

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 }

Referenced by impeller::CreateTextureForDecompressedImage(), and impeller::testing::TEST().

## ◆ operator!=()

template<class T >

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

Definition at line 60 of file size.h.

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

## ◆ operator*()

template<class T >

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

Definition at line 43 of file size.h.

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

## ◆ operator+()

template<class T >

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

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
| inline constexpr

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
| inline constexpr

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
| inline constexpr

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
| inline constexpr

Definition at line 47 of file size.h.

47 {
48 return {static_cast<Scalar>(width) / scale,
49 static_cast<Scalar>(height) / scale};
50 }

## ◆ operator==()

template<class T >

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

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
| inline constexpr

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.

Referenced by impeller::TSize< Type >::Abs(), impeller::PathBuilder::AddRoundedRect(), impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::TSize< Type >::Area(), impeller::GaussianBlurFilterContents::CalculateUVs(), impeller::CanAppendToExistingAtlas(), impeller::TSize< Type >::Ceil(), impeller::Canvas::ClipRRect(), impeller::RoundRectGeometry::CoversArea(), impeller::CreateAtlasBitmap(), impeller::Allocator::CreateTexture(), impeller::TRect< Scalar >::Expand(), impeller::Tessellator::FilledRoundRect(), impeller::TSize< Type >::Floor(), impeller::TRect< Scalar >::GetBottom(), impeller::TRect< Scalar >::GetCenter(), impeller::TRect< Scalar >::GetHeight(), impeller::TRect< Scalar >::GetNormalizingTransform(), impeller::TRect< Scalar >::GetTop(), impeller::TRect< Scalar >::GetXYWH(), impeller::TSize< Type >::IsEmpty(), impeller::TSize< Type >::IsSquare(), impeller::Matrix::MakeOrthographic(), impeller::Matrix::MakePerspective(), impeller::testing::MetalScreenshotter::MakeScreenshot(), impeller::TRect< Scalar >::MakeSize(), impeller::TSize< Type >::MakeWH(), impeller::TSize< Type >::Max(), impeller::TSize< Type >::MaxDimension(), impeller::TSize< Type >::Min(), impeller::TSize< Type >::MipCount(), impeller::TSize< Type >::operator!=(), impeller::Trig::operator*(), impeller::TSize< Type >::operator*(), impeller::TRect< Scalar >::operator*(), impeller::TPoint< Type >::operator*(), impeller::TPoint< Type >::operator*=(), impeller::TSize< Type >::operator+(), impeller::TRect< Scalar >::operator+(), impeller::TPoint< Type >::operator+(), impeller::TPoint< Type >::operator+=(), impeller::TSize< Type >::operator-(), impeller::TRect< Scalar >::operator-(), impeller::TPoint< Type >::operator-(), impeller::operator-(), impeller::TPoint< Type >::operator-=(), impeller::TSize< Type >::operator/(), impeller::TPoint< Type >::operator/(), impeller::operator/(), impeller::TPoint< Type >::operator/=(), std::operator<<(), impeller::TSize< Type >::operator==(), impeller::OptimumAtlasSizeForFontGlyphPairs(), impeller::PairsFitInAtlasOfSize(), impeller::TRect< Scalar >::Project(), impeller::TSize< Type >::Round(), impeller::TRect< Scalar >::Scale(), impeller::TRect< Scalar >::Shift(), SizeNear(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::ToMTLTextureDescriptor().

## ◆ width

template<class T >

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

Definition at line 22 of file size.h.

Referenced by impeller::TSize< Type >::Abs(), impeller::PathBuilder::AddRoundedRect(), impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::TSize< Type >::Area(), impeller::GaussianBlurFilterContents::CalculateUVs(), impeller::CanAppendToExistingAtlas(), impeller::TSize< Type >::Ceil(), impeller::Canvas::ClipRRect(), impeller::RoundRectGeometry::CoversArea(), impeller::CreateAtlasBitmap(), impeller::Allocator::CreateTexture(), impeller::TRect< Scalar >::Expand(), impeller::Tessellator::FilledRoundRect(), impeller::TSize< Type >::Floor(), impeller::TextureDescriptor::GetBytesPerRow(), impeller::TRect< Scalar >::GetCenter(), impeller::TRect< Scalar >::GetLeft(), impeller::TRect< Scalar >::GetNormalizingTransform(), impeller::TRect< Scalar >::GetRight(), impeller::TRect< Scalar >::GetWidth(), impeller::TRect< Scalar >::GetXYWH(), impeller::TSize< Type >::IsEmpty(), impeller::TSize< Type >::IsSquare(), impeller::Matrix::MakeOrthographic(), impeller::Matrix::MakePerspective(), impeller::testing::MetalScreenshotter::MakeScreenshot(), impeller::TRect< Scalar >::MakeSize(), impeller::TSize< Type >::MakeWH(), impeller::TSize< Type >::Max(), impeller::TSize< Type >::MaxDimension(), impeller::TSize< Type >::Min(), impeller::TSize< Type >::MipCount(), impeller::TSize< Type >::operator!=(), impeller::Trig::operator*(), impeller::TSize< Type >::operator*(), impeller::TRect< Scalar >::operator*(), impeller::TPoint< Type >::operator*(), impeller::TPoint< Type >::operator*=(), impeller::TSize< Type >::operator+(), impeller::TRect< Scalar >::operator+(), impeller::TPoint< Type >::operator+(), impeller::TPoint< Type >::operator+=(), impeller::TSize< Type >::operator-(), impeller::TRect< Scalar >::operator-(), impeller::TPoint< Type >::operator-(), impeller::operator-(), impeller::TPoint< Type >::operator-=(), impeller::TSize< Type >::operator/(), impeller::TPoint< Type >::operator/(), impeller::operator/(), impeller::TPoint< Type >::operator/=(), std::operator<<(), impeller::TSize< Type >::operator==(), impeller::OptimumAtlasSizeForFontGlyphPairs(), impeller::PairsFitInAtlasOfSize(), impeller::TRect< Scalar >::Project(), impeller::SolidRRectBlurContents::Render(), impeller::TSize< Type >::Round(), impeller::TRect< Scalar >::Scale(), impeller::TRect< Scalar >::Shift(), SizeNear(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::ToMTLTextureDescriptor().

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

- impeller/geometry/size.h

impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::TSize::TSize
constexpr TSize()
Definition: size.h:25
impeller::TSize::Type
T Type
Definition: size.h:20
impeller::TSize::width
Type width
Definition: size.h:22
impeller::TSize::height
Type height
Definition: size.h:23
impeller::TSize::IsEmpty
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition: size.h:105