| 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 | Min (const TSize &o) const
constexpr TSize | Max (const TSize &o) const
constexpr TSize | Abs () const
constexpr TSize | Floor () const
constexpr TSize | Ceil () const
constexpr TSize | Round () 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 constexpr

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 constexpr

Definition at line 26 of file size.h.

26 : 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 29 of file size.h.

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

## Member Function Documentation

## ◆ Abs()

template<class T >

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

Definition at line 85 of file size.h.

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

## ◆ Area()

template<class T >

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

Definition at line 97 of file size.h.

97 { return width * height; }

Referenced by 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 91 of file size.h.

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

Referenced by impeller::ColorSource::MakeImage().

## ◆ 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 108 of file size.h.

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

## ◆ Floor()

template<class T >

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

Definition at line 87 of file size.h.

87 {
88 return {std::floor(width), std::floor(height)};
89 }

## ◆ Infinite()

template<class T >

static constexpr TSize impeller::TSize< T >::Infinite | ( |  | ) |
| inline static constexpr

Definition at line 37 of file size.h.

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

## ◆ IsEmpty()

template<class T >

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

Definition at line 105 of file size.h.

105 { return IsNegative() || IsZero(); }

Referenced by impeller::CanAppendToExistingAtlas(), impeller::RenderTarget::CreateOffscreen(), impeller::RenderTarget::CreateOffscreenMSAA(), impeller::Canvas::DrawImageRect(), impeller::ComputePass::EncodeCommands(), impeller::TRect< Scalar >::IsEmpty(), impeller::PairsFitInAtlasOfSize(), impeller::TextureContents::Render(), and impeller::Picture::ToImage().

## ◆ IsNegative()

template<class T >

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

Definition at line 101 of file size.h.

101 { return width < 0 || height < 0; }

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

## ◆ IsPositive()

template<class T >

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

Definition at line 99 of file size.h.

99 { return width > 0 && height > 0; }

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

## ◆ IsZero()

template<class T >

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

Definition at line 103 of file size.h.

103 { return width == 0 || height == 0; }

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

## ◆ MakeWH()

template<class T >

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

Definition at line 33 of file size.h.

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

## ◆ Max()

template<class T >

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

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 }

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

## ◆ Min()

template<class T >

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

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 }

## ◆ MipCount()

template<class T >

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

Definition at line 113 of file size.h.

113 {
114 constexpr size_t minimum_mip = 1u;
115 if (!IsPositive()) {
116 return minimum_mip;
117 }
118 size_t result = std::max(ceil(log2(width)), ceil(log2(height)));
119 return std::max(result, minimum_mip);
120 }

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 59 of file size.h.

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

## ◆ operator*()

template<class T >

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

Definition at line 42 of file size.h.

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

## ◆ operator+()

template<class T >

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

Definition at line 63 of file size.h.

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

## ◆ operator-()

template<class T >

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

Definition at line 67 of file size.h.

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

## ◆ operator/() [1/2]

template<class T >

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

Definition at line 51 of file size.h.

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

## ◆ operator/() [2/2]

template<class T >

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

Definition at line 46 of file size.h.

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

## ◆ operator==()

template<class T >

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

Definition at line 55 of file size.h.

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

## ◆ Round()

template<class T >

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

Definition at line 93 of file size.h.

93 {
94 return {std::round(width), std::round(height)};
95 }

## Member Data Documentation

## ◆ height

template<class T >

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

Definition at line 22 of file size.h.

Referenced by impeller::TSize< Type >::Abs(), impeller::PathBuilder::AddArc(), impeller::PathBuilder::AddOval(), impeller::PathBuilder::AddRect(), impeller::PathBuilder::AddRoundedRect(), impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::TSize< Type >::Area(), impeller::CanAppendToExistingAtlas(), impeller::TSize< Type >::Ceil(), impeller::Canvas::ClipRRect(), impeller::CreateAtlasBitmap(), impeller::Allocator::CreateTexture(), impeller::DrawGlyph(), impeller::BlitCopyTextureToTextureCommandGLES::Encode(), impeller::BlitCopyTextureToTextureCommandMTL::Encode(), impeller::BlitCopyTextureToTextureCommandVK::Encode(), impeller::BlitCopyTextureToBufferCommandGLES::Encode(), impeller::BlitCopyTextureToBufferCommandMTL::Encode(), impeller::BlitCopyTextureToBufferCommandVK::Encode(), impeller::TRect< Scalar >::Expand(), impeller::TSize< Type >::Floor(), impeller::TRect< Scalar >::GetBottom(), impeller::TRect< Scalar >::GetTop(), impeller::TSize< Type >::IsNegative(), impeller::TSize< Type >::IsPositive(), impeller::TSize< Type >::IsZero(), impeller::Matrix::MakeOrthographic(), impeller::Matrix::MakePerspective(), impeller::testing::MetalScreenshoter::MakeScreenshot(), impeller::TRect< Scalar >::MakeSize(), impeller::TSize< Type >::MakeWH(), impeller::TSize< Type >::Max(), impeller::TSize< Type >::Min(), impeller::TSize< Type >::MipCount(), impeller::TSize< Type >::operator!=(), impeller::AtlasBlenderKey::Hash::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(), RectNear(), impeller::TextContents::Render(), impeller::TSize< Type >::Round(), impeller::TRect< Scalar >::Scale(), impeller::PassBindingsCache::SetScissor(), impeller::PassBindingsCache::SetViewport(), 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 21 of file size.h.

Referenced by impeller::TSize< Type >::Abs(), impeller::PathBuilder::AddArc(), impeller::PathBuilder::AddOval(), impeller::PathBuilder::AddRect(), impeller::PathBuilder::AddRoundedRect(), impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::TSize< Type >::Area(), impeller::CanAppendToExistingAtlas(), impeller::TSize< Type >::Ceil(), impeller::Canvas::ClipRRect(), impeller::CreateAtlasBitmap(), impeller::Allocator::CreateTexture(), impeller::DrawGlyph(), impeller::BlitCopyTextureToTextureCommandGLES::Encode(), impeller::BlitCopyTextureToTextureCommandMTL::Encode(), impeller::BlitCopyTextureToTextureCommandVK::Encode(), impeller::BlitCopyTextureToBufferCommandGLES::Encode(), impeller::BlitCopyTextureToBufferCommandMTL::Encode(), impeller::BlitCopyTextureToBufferCommandVK::Encode(), impeller::TRect< Scalar >::Expand(), impeller::TSize< Type >::Floor(), impeller::TextureDescriptor::GetBytesPerRow(), impeller::TRect< Scalar >::GetLeft(), impeller::TRect< Scalar >::GetRight(), impeller::TSize< Type >::IsNegative(), impeller::TSize< Type >::IsPositive(), impeller::TSize< Type >::IsZero(), impeller::Matrix::MakeOrthographic(), impeller::Matrix::MakePerspective(), impeller::testing::MetalScreenshoter::MakeScreenshot(), impeller::TRect< Scalar >::MakeSize(), impeller::TSize< Type >::MakeWH(), impeller::TSize< Type >::Max(), impeller::TSize< Type >::Min(), impeller::TSize< Type >::MipCount(), impeller::TSize< Type >::operator!=(), impeller::AtlasBlenderKey::Hash::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(), RectNear(), impeller::TextContents::Render(), impeller::TSize< Type >::Round(), impeller::TRect< Scalar >::Scale(), impeller::PassBindingsCache::SetScissor(), impeller::PassBindingsCache::SetViewport(), 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:15
impeller::TSize::TSize
constexpr TSize()
Definition: size.h:24
impeller::TSize::Type
T Type
Definition: size.h:19
impeller::TSize::IsNegative
constexpr bool IsNegative() const
Definition: size.h:101
impeller::TSize::IsZero
constexpr bool IsZero() const
Definition: size.h:103
impeller::TSize::width
Type width
Definition: size.h:21
impeller::TSize::height
Type height
Definition: size.h:22
impeller::TSize::IsPositive
constexpr bool IsPositive() const
Definition: size.h:99