Flutter Impeller
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)
 
constexpr TSize (Type dimension)
 
template<class U >
constexpr TSize (const TSize< U > &other)
 
constexpr TSize operator* (Scalar scale) const
 
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TSize operator*= (U scale)
 
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 MinDimension () 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...
 
 IsFinite () const
 
constexpr bool IsSquare () const
 
constexpr size_t MipCount () const
 Return the mip count of the texture. More...
 

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

Member Typedef Documentation

◆ Type

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

Definition at line 26 of file size.h.

Constructor & Destructor Documentation

◆ TSize() [1/4]

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

Definition at line 31 of file size.h.

31 {}

◆ TSize() [2/4]

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

Definition at line 33 of file size.h.

33 : width(width), height(height) {}
Type height
Definition: size.h:29
Type width
Definition: size.h:28

◆ TSize() [3/4]

template<class T >
constexpr impeller::TSize< T >::TSize ( Type  dimension)
inlineexplicitconstexpr

Definition at line 35 of file size.h.

36  : width(dimension), height(dimension) {}

◆ TSize() [4/4]

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

Definition at line 39 of file size.h.

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

Member Function Documentation

◆ Abs()

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

Definition at line 108 of file size.h.

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

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ Area()

◆ Ceil() [1/2]

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

◆ Ceil() [2/2]

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

Definition at line 131 of file size.h.

131  {
132  return TSize{static_cast<Type>(std::ceil(other.width)),
133  static_cast<Type>(std::ceil(other.height))};
134  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ Floor()

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

Definition at line 110 of file size.h.

110  {
111  return {std::floor(width), std::floor(height)};
112  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ Infinite()

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

Definition at line 47 of file size.h.

47  {
48  return TSize{std::numeric_limits<Type>::max(),
49  std::numeric_limits<Type>::max()};
50  }

◆ IsEmpty()

◆ IsFinite()

template<class T >
impeller::TSize< T >::IsFinite ( ) const
inline

Definition at line 126 of file size.h.

126 { return std::isfinite(width) && std::isfinite(height); }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

Referenced by impeller::RoundRect::IsFinite(), impeller::RoundSuperellipse::IsFinite(), and impeller::RoundingRadii::IsFinite().

◆ IsSquare()

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

Definition at line 128 of file size.h.

128 { return width == height; }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ MakeWH()

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

◆ Max()

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

Definition at line 97 of file size.h.

97  {
98  return {
99  std::max(width, o.width),
100  std::max(height, o.height),
101  };
102  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

Referenced by impeller::android::HardwareBufferDescriptor::MakeForSwapchainImage(), and impeller::Playground::OpenPlaygroundHere().

◆ MaxDimension()

◆ Min()

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

Definition at line 90 of file size.h.

90  {
91  return {
92  std::min(width, o.width),
93  std::min(height, o.height),
94  };
95  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ MinDimension()

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

Definition at line 104 of file size.h.

104 { return std::min(width, height); }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ MipCount()

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

Return the mip count of the texture.

Definition at line 137 of file size.h.

137  {
138  constexpr size_t minimum_mip = 1u;
139  if (IsEmpty() || width <= 0 || height <= 0) {
140  return minimum_mip;
141  }
142  size_t result = std::min(log2(width), log2(height));
143  return std::max(result, minimum_mip);
144  }
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition: size.h:123

References impeller::TSize< T >::height, impeller::TSize< T >::IsEmpty(), and impeller::TSize< T >::width.

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
inlineconstexpr

Definition at line 76 of file size.h.

76  {
77  return s.width != width || s.height != height;
78  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ operator*()

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

Definition at line 52 of file size.h.

52  {
53  return {width * scale, height * scale};
54  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ operator*=()

template<class T >
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TSize impeller::TSize< T >::operator*= ( scale)
inline

Definition at line 57 of file size.h.

57  {
58  width *= static_cast<Type>(scale);
59  height *= static_cast<Type>(scale);
60  return *this;
61  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ operator+()

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

Definition at line 80 of file size.h.

80  {
81  return {width + s.width, height + s.height};
82  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ operator-() [1/2]

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

Definition at line 88 of file size.h.

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

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ operator-() [2/2]

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

Definition at line 84 of file size.h.

84  {
85  return {width - s.width, height - s.height};
86  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ operator/() [1/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  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ operator/() [2/2]

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

Definition at line 63 of file size.h.

63  {
64  return {static_cast<Scalar>(width) / scale,
65  static_cast<Scalar>(height) / scale};
66  }
float Scalar
Definition: scalar.h:19

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ operator==()

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

Definition at line 72 of file size.h.

72  {
73  return s.width == width && s.height == height;
74  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

◆ Round()

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

Definition at line 116 of file size.h.

116  {
117  return {std::round(width), std::round(height)};
118  }

References impeller::TSize< T >::height, and impeller::TSize< T >::width.

Member Data Documentation

◆ height

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

Definition at line 29 of file size.h.

Referenced by impeller::TSize< T >::Abs(), impeller::BlitPass::AddCopy(), impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::AppendToExistingAtlas(), impeller::TSize< T >::Area(), impeller::RoundingRadii::AreAllCornersSame(), impeller::GaussianBlurFilterContents::CalculateUVs(), impeller::TSize< T >::Ceil(), impeller::ComputeNextAtlasSize(), impeller::CornerContains(), impeller::RoundRectGeometry::CoversArea(), impeller::FillRoundRectGeometry::CoversArea(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::Allocator::CreateTexture(), impeller::DisplayListToTexture(), impeller::EncodeCommandsInReactor(), impeller::TRect< T >::Expand(), impeller::Tessellator::FilledRoundRect(), impeller::TSize< T >::Floor(), impeller::TextureDescriptor::GetByteSizeOfAllMipLevels(), impeller::GetImageInfo(), impeller::RSTransform::GetQuad(), impeller::RenderTargetConfig::Hash(), impeller::TSize< T >::IsEmpty(), impeller::TSize< T >::IsFinite(), impeller::RoundRect::IsOval(), impeller::RoundSuperellipse::IsOval(), impeller::TSize< T >::IsSquare(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), impeller::TRect< T >::MakeOriginSize(), impeller::Matrix::MakeOrthographic(), impeller::Matrix::MakePerspective(), impeller::TRect< T >::MakeSize(), impeller::TSize< T >::MakeWH(), impeller::TSize< T >::Max(), impeller::TSize< T >::MaxDimension(), impeller::TSize< T >::Min(), impeller::TSize< T >::MinDimension(), impeller::TSize< T >::MipCount(), impeller::AiksPlayground::OpenPlaygroundHere(), impeller::DlPlayground::OpenPlaygroundHere(), impeller::TSize< T >::operator!=(), impeller::Trig::operator*(), impeller::TPoint< T >::operator*(), impeller::TSize< T >::operator*(), impeller::TPoint< T >::operator*=(), impeller::TSize< T >::operator*=(), impeller::TSize< T >::operator+(), impeller::TPoint< T >::operator+(), impeller::TPoint< T >::operator+=(), impeller::TSize< T >::operator-(), impeller::TPoint< T >::operator-(), impeller::operator-(), impeller::TPoint< T >::operator-=(), impeller::TPoint< T >::operator/(), impeller::operator/(), impeller::TSize< T >::operator/(), impeller::TPoint< T >::operator/=(), std::operator<<(), impeller::TSize< T >::operator==(), impeller::PairsFitInAtlasOfSize(), impeller::TSize< T >::Round(), impeller::interop::DisplayListBuilder::Scale(), impeller::TRect< T >::Scale(), impeller::RoundingRadii::Scaled(), SizeNear(), impeller::SizeToPoint(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::android::ToAHardwareBufferDesc(), impeller::ToMTLTextureDescriptor(), impeller::interop::ToSkiaVector(), and impeller::UpdateAtlasBitmap().

◆ width

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

Definition at line 28 of file size.h.

Referenced by impeller::TSize< T >::Abs(), impeller::BlitPass::AddCopy(), impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::AppendToExistingAtlas(), impeller::TSize< T >::Area(), impeller::RoundingRadii::AreAllCornersSame(), impeller::GaussianBlurFilterContents::CalculateUVs(), impeller::TSize< T >::Ceil(), impeller::ComputeNextAtlasSize(), impeller::CornerContains(), impeller::RoundRectGeometry::CoversArea(), impeller::FillRoundRectGeometry::CoversArea(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::Allocator::CreateTexture(), impeller::DisplayListToTexture(), impeller::TRect< T >::Expand(), impeller::Tessellator::FilledRoundRect(), impeller::TSize< T >::Floor(), impeller::TextureDescriptor::GetByteSizeOfAllMipLevels(), impeller::TextureDescriptor::GetBytesPerRow(), impeller::GetImageInfo(), impeller::RSTransform::GetQuad(), impeller::RenderTargetConfig::Hash(), impeller::TSize< T >::IsEmpty(), impeller::TSize< T >::IsFinite(), impeller::RoundRect::IsOval(), impeller::RoundSuperellipse::IsOval(), impeller::TSize< T >::IsSquare(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), impeller::TRect< T >::MakeOriginSize(), impeller::Matrix::MakeOrthographic(), impeller::Matrix::MakePerspective(), impeller::TRect< T >::MakeSize(), impeller::TSize< T >::MakeWH(), impeller::TSize< T >::Max(), impeller::TSize< T >::MaxDimension(), impeller::TSize< T >::Min(), impeller::TSize< T >::MinDimension(), impeller::TSize< T >::MipCount(), impeller::AiksPlayground::OpenPlaygroundHere(), impeller::DlPlayground::OpenPlaygroundHere(), impeller::TSize< T >::operator!=(), impeller::Trig::operator*(), impeller::TPoint< T >::operator*(), impeller::TSize< T >::operator*(), impeller::TPoint< T >::operator*=(), impeller::TSize< T >::operator*=(), impeller::TSize< T >::operator+(), impeller::TPoint< T >::operator+(), impeller::TPoint< T >::operator+=(), impeller::TSize< T >::operator-(), impeller::TPoint< T >::operator-(), impeller::operator-(), impeller::TPoint< T >::operator-=(), impeller::TPoint< T >::operator/(), impeller::operator/(), impeller::TSize< T >::operator/(), impeller::TPoint< T >::operator/=(), std::operator<<(), impeller::TSize< T >::operator==(), impeller::PairsFitInAtlasOfSize(), impeller::TSize< T >::Round(), impeller::interop::DisplayListBuilder::Scale(), impeller::TRect< T >::Scale(), impeller::RoundingRadii::Scaled(), SizeNear(), impeller::SizeToPoint(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::android::ToAHardwareBufferDesc(), impeller::ToMTLTextureDescriptor(), impeller::interop::ToSkiaVector(), and impeller::UpdateAtlasBitmap().


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