| 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::DecompressedImage::ConvertToRGBA(), impeller::TextureDescriptor::GetByteSizeOfAllMipLevels(), impeller::TextureDescriptor::GetByteSizeOfBaseMipLevel(), and impeller::UpdateAtlasBitmap().

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

Referenced by impeller::AppendToExistingAtlas(), impeller::PairsFitInAtlasOfSize(), and impeller::Contents::RenderToSnapshot().

## ◆ 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::AppendToExistingAtlas(), impeller::BulkUpdateAtlasBitmap(), impeller::CanAppendToExistingAtlas(), impeller::TypographerContextSkia::CreateGlyphAtlas(), impeller::RenderTargetCache::CreateOffscreen(), impeller::RenderTargetAllocator::CreateOffscreen(), impeller::RenderTargetCache::CreateOffscreenMSAA(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::TextureDescriptor::IsValid(), impeller::TSize< Scalar >::MipCount(), impeller::PairsFitInAtlasOfSize(), and impeller::UpdateAtlasBitmap().

## ◆ 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; }

## ◆ 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 }

Referenced by impeller::android::NativeWindow::GetSize(), impeller::OptimumAtlasSizeForFontGlyphPairs(), and impeller::interop::ToImpellerType().

## ◆ 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::android::HardwareBufferDescriptor::MakeForSwapchainImage(), and 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::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::Allocator::CreateTexture(), impeller::CreateTextureForDecompressedImage(), impeller::DisplayListToTexture(), impeller::testing::TEST(), and impeller::testing::TEST_P().

## ◆ 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< Scalar >::Abs(), impeller::BlitPass::AddCopy(), impeller::PathBuilder::AddRoundedRect(), impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::AppendToExistingAtlas(), impeller::TSize< Scalar >::Area(), impeller::GaussianBlurFilterContents::CalculateUVs(), impeller::CanAppendToExistingAtlas(), impeller::TSize< Scalar >::Ceil(), impeller::ComputeNextAtlasSize(), impeller::RoundRectGeometry::CoversArea(), impeller::CreateAtlasBitmap(), impeller::Allocator::CreateTexture(), impeller::DisplayListToTexture(), impeller::TRect< Scalar >::Expand(), impeller::Tessellator::FilledRoundRect(), impeller::TSize< Scalar >::Floor(), impeller::TextureDescriptor::GetByteSizeOfAllMipLevels(), impeller::GetImageInfo(), impeller::RenderTargetConfig::Hash(), impeller::TSize< Scalar >::IsEmpty(), impeller::TSize< Scalar >::IsSquare(), impeller::TRect< Scalar >::MakeOriginSize(), impeller::Matrix::MakeOrthographic(), impeller::Matrix::MakePerspective(), impeller::TRect< Scalar >::MakeSize(), impeller::TSize< Scalar >::MakeWH(), impeller::TSize< Scalar >::Max(), impeller::TSize< Scalar >::MaxDimension(), impeller::TSize< Scalar >::Min(), impeller::TSize< Scalar >::MipCount(), impeller::TSize< Scalar >::operator!=(), impeller::Trig::operator*(), impeller::TSize< Scalar >::operator*(), impeller::TPoint< Scalar >::operator*(), impeller::TPoint< Scalar >::operator*=(), impeller::TSize< Scalar >::operator+(), impeller::TPoint< Scalar >::operator+(), impeller::TPoint< Scalar >::operator+=(), impeller::TSize< Scalar >::operator-(), impeller::TPoint< Scalar >::operator-(), impeller::operator-(), impeller::TPoint< Scalar >::operator-=(), impeller::TSize< Scalar >::operator/(), impeller::TPoint< Scalar >::operator/(), impeller::operator/(), impeller::TPoint< Scalar >::operator/=(), std::operator<<(), impeller::TSize< Scalar >::operator==(), impeller::OptimumAtlasSizeForFontGlyphPairs(), impeller::PairsFitInAtlasOfSize(), impeller::SolidRRectBlurContents::Render(), impeller::TSize< Scalar >::Round(), SizeNear(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::android::ToAHardwareBufferDesc(), impeller::ToMTLTextureDescriptor(), and impeller::UpdateAtlasBitmap().

## ◆ width

template<class T >

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

Definition at line 22 of file size.h.

Referenced by impeller::TSize< Scalar >::Abs(), impeller::BlitPass::AddCopy(), impeller::PathBuilder::AddRoundedRect(), impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::AppendToExistingAtlas(), impeller::TSize< Scalar >::Area(), impeller::GaussianBlurFilterContents::CalculateUVs(), impeller::CanAppendToExistingAtlas(), impeller::TSize< Scalar >::Ceil(), impeller::ComputeNextAtlasSize(), impeller::RoundRectGeometry::CoversArea(), impeller::CreateAtlasBitmap(), impeller::Allocator::CreateTexture(), impeller::CreateVKImageView(), impeller::CreateVKImageWrapperForAndroidHarwareBuffer(), impeller::DisplayListToTexture(), impeller::TRect< Scalar >::Expand(), impeller::Tessellator::FilledRoundRect(), impeller::TSize< Scalar >::Floor(), impeller::TextureDescriptor::GetByteSizeOfAllMipLevels(), impeller::TextureDescriptor::GetBytesPerRow(), impeller::GetImageInfo(), impeller::RenderTargetConfig::Hash(), impeller::TSize< Scalar >::IsEmpty(), impeller::TSize< Scalar >::IsSquare(), impeller::TRect< Scalar >::MakeOriginSize(), impeller::Matrix::MakeOrthographic(), impeller::Matrix::MakePerspective(), impeller::TRect< Scalar >::MakeSize(), impeller::TSize< Scalar >::MakeWH(), impeller::TSize< Scalar >::Max(), impeller::TSize< Scalar >::MaxDimension(), impeller::TSize< Scalar >::Min(), impeller::TSize< Scalar >::MipCount(), impeller::TSize< Scalar >::operator!=(), impeller::Trig::operator*(), impeller::TSize< Scalar >::operator*(), impeller::TPoint< Scalar >::operator*(), impeller::TPoint< Scalar >::operator*=(), impeller::TSize< Scalar >::operator+(), impeller::TPoint< Scalar >::operator+(), impeller::TPoint< Scalar >::operator+=(), impeller::TSize< Scalar >::operator-(), impeller::TPoint< Scalar >::operator-(), impeller::operator-(), impeller::TPoint< Scalar >::operator-=(), impeller::TSize< Scalar >::operator/(), impeller::TPoint< Scalar >::operator/(), impeller::operator/(), impeller::TPoint< Scalar >::operator/=(), std::operator<<(), impeller::TSize< Scalar >::operator==(), impeller::OptimumAtlasSizeForFontGlyphPairs(), impeller::PairsFitInAtlasOfSize(), impeller::SolidRRectBlurContents::Render(), impeller::TSize< Scalar >::Round(), SizeNear(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::android::ToAHardwareBufferDesc(), impeller::ToMTLTextureDescriptor(), impeller::ToTextureDescriptor(), and impeller::UpdateAtlasBitmap().

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
scale
const Scalar scale
Definition: stroke_path_geometry.cc:301
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