Flutter Engine
 
Loading...
Searching...
No Matches
impeller::TRect< T > Struct Template Reference

#include <rect.h>

Public Member Functions

constexpr TRect ()
 
constexpr bool operator== (const TRect &r) const
 
constexpr TRect Scale (Type scale) const
 
constexpr TRect Scale (Type scale_x, Type scale_y) const
 
constexpr TRect Scale (TPoint< T > scale) const
 
constexpr TRect Scale (TSize< T > scale) const
 
constexpr bool Contains (const TPoint< Type > &p) const
 Returns true iff the provided point |p| is inside the half-open interior of this rectangle.
 
constexpr bool ContainsInclusive (const TPoint< Type > &p) const
 Returns true iff the provided point |p| is inside the closed-range interior of this rectangle.
 
constexpr bool Contains (const TRect &o) const
 Returns true iff this rectangle is not empty and it also contains every point considered inside the provided rectangle |o| (as determined by |Contains(TPoint)|).
 
 IsFinite () const
 Returns true if all of the fields of this floating point rectangle are finite.
 
constexpr bool IsEmpty () const
 Returns true if either of the width or height are 0, negative, or NaN.
 
constexpr bool IsSquare () const
 Returns true if width and height are equal and neither is NaN.
 
constexpr bool IsMaximum () const
 
constexpr TPoint< Type > GetOrigin () const
 Returns the upper left corner of the rectangle as specified by the left/top or x/y values when it was constructed.
 
constexpr TSize< Type > GetSize () const
 Returns the size of the rectangle which may be negative in either width or height and may have been clipped to the maximum integer values for integer rects whose size overflows.
 
constexpr Type GetX () const
 Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
 
constexpr Type GetY () const
 Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
 
constexpr Type GetWidth () const
 Returns the width of the rectangle, equivalent to |GetSize().width|.
 
constexpr Type GetHeight () const
 Returns the height of the rectangle, equivalent to |GetSize().height|.
 
constexpr auto GetLeft () const
 
constexpr auto GetTop () const
 
constexpr auto GetRight () const
 
constexpr auto GetBottom () const
 
constexpr TPoint< T > GetLeftTop () const
 
constexpr TPoint< T > GetRightTop () const
 
constexpr TPoint< T > GetLeftBottom () const
 
constexpr TPoint< T > GetRightBottom () const
 
constexpr T Area () const
 Get the area of the rectangle, equivalent to |GetSize().Area()|.
 
constexpr Point GetCenter () const
 Get the center point as a |Point|.
 
constexpr std::array< T, 4 > GetLTRB () const
 
constexpr std::array< T, 4 > GetXYWH () const
 Get the x, y coordinates of the origin and the width and height of the rectangle in an array.
 
constexpr TRect GetPositive () const
 Get a version of this rectangle that has a non-negative size.
 
constexpr std::array< TPoint< T >, 4 > GetPoints () const
 Get the points that represent the 4 corners of this rectangle in a Z order that is compatible with triangle strips or a set of all zero points if the rectangle is empty. The order is: Top left, top right, bottom left, bottom right.
 
constexpr std::array< TPoint< T >, 4 > GetTransformedPoints (const Matrix &transform) const
 
constexpr TRect TransformAndClipBounds (const Matrix &transform) const
 Creates a new bounding box that contains this transformed rectangle, clipped against the near clipping plane if necessary.
 
constexpr TRect TransformBounds (const Matrix &transform) const
 Creates a new bounding box that contains this transformed rectangle.
 
constexpr Matrix GetNormalizingTransform () const
 Constructs a Matrix that will map all points in the coordinate space of the rectangle into a new normalized coordinate space where the upper left corner of the rectangle maps to (0, 0) and the lower right corner of the rectangle maps to (1, 1).
 
constexpr TRect Union (const TRect &o) const
 
constexpr std::optional< TRectIntersection (const TRect &o) const
 
constexpr TRect IntersectionOrEmpty (const TRect &o) const
 
constexpr bool IntersectsWithRect (const TRect &o) const
 
constexpr std::optional< TRect< T > > Cutout (const TRect &o) const
 Returns the new boundary rectangle that would result from this rectangle being cut out by the specified rectangle.
 
constexpr TRect CutoutOrEmpty (const TRect &o) const
 
constexpr TRect< T > Shift (T dx, T dy) const
 Returns a new rectangle translated by the given offset.
 
constexpr TRect< T > Shift (TPoint< T > offset) const
 Returns a new rectangle translated by the given offset.
 
constexpr TRect< T > Expand (T left, T top, T right, T bottom) const
 Returns a rectangle with expanded edges. Negative expansion results in shrinking.
 
constexpr TRect< T > Expand (T amount) const
 Returns a rectangle with expanded edges in all directions. Negative expansion results in shrinking.
 
constexpr TRect< T > Expand (T horizontal_amount, T vertical_amount) const
 Returns a rectangle with expanded edges in all directions. Negative expansion results in shrinking.
 
constexpr TRect< T > Expand (TPoint< T > amount) const
 Returns a rectangle with expanded edges in all directions. Negative expansion results in shrinking.
 
constexpr TRect< T > Expand (TSize< T > amount) const
 Returns a rectangle with expanded edges in all directions. Negative expansion results in shrinking.
 
constexpr TRect< T > Project (TRect< T > source) const
 Returns a new rectangle that represents the projection of the source rectangle onto this rectangle. In other words, the source rectangle is redefined in terms of the coordinate space of this rectangle.
 
 RoundOut (const TRect< U > &r)
 
 RoundIn (const TRect< U > &r)
 
 Round (const TRect< U > &r)
 

Static Public Member Functions

static constexpr TRect MakeLTRB (Type left, Type top, Type right, Type bottom)
 
static constexpr TRect MakeXYWH (Type x, Type y, Type width, Type height)
 
static constexpr TRect MakeWH (Type width, Type height)
 
static constexpr TRect MakeOriginSize (const TPoint< Type > &origin, const TSize< Type > &size)
 
template<class U >
static constexpr TRect MakeSize (const TSize< U > &size)
 
template<class U , class FT = T>
static constexpr std::enable_if_t< std::is_floating_point_v< FT >, TRectMake (const TRect< U > &rect)
 
template<typename U >
static constexpr std::optional< TRectMakePointBounds (const U &value)
 
template<typename PointIter >
static constexpr std::optional< TRectMakePointBounds (const PointIter first, const PointIter last)
 
static constexpr TRect MakeMaximum ()
 
static constexpr TRect Union (const TRect &a, const std::optional< TRect > b)
 
static constexpr TRect Union (const std::optional< TRect > a, const TRect &b)
 
static constexpr std::optional< TRectUnion (const std::optional< TRect > a, const std::optional< TRect > b)
 
static constexpr std::optional< TRectIntersection (const TRect &a, const std::optional< TRect > b)
 
static constexpr std::optional< TRectIntersection (const std::optional< TRect > a, const TRect &b)
 
static constexpr std::optional< TRectIntersection (const std::optional< TRect > a, const std::optional< TRect > b)
 

Detailed Description

template<class T>
struct impeller::TRect< T >

Templated struct for holding an axis-aligned rectangle.

Rectangles are defined as 4 axis-aligned edges that might contain space. They can be viewed as 2 X coordinates that define the left and right edges and 2 Y coordinates that define the top and bottom edges; or they can be viewed as an origin and horizontal and vertical dimensions (width and height).

When the left and right edges are equal or reversed (right <= left) or the top and bottom edges are equal or reversed (bottom <= top), the rectangle is considered empty. Considering the rectangle in XYWH form, the width and/or the height would be negative or zero. Such reversed/empty rectangles contain no space and act as such in the methods that operate on them (Intersection, Union, IntersectsWithRect, Contains, Cutout, etc.)

Rectangles cannot be modified by any method and a new value can only be stored into an existing rect using assignment. This keeps the API clean compared to implementations that might have similar methods that produce the answer in place, or construct a new object with the answer, or place the result in an indicated result object.

Methods that might fail to produce an answer will use |std::optional| to indicate that success or failure (see |Intersection| and |CutOut|). For convenience, |Intersection| and |Union| both have overloaded variants that take |std::optional| arguments and treat them as if the argument was an empty rect to allow chaining multiple such methods and only needing to check the optional condition of the final result. The primary methods also provide |...OrEmpty| overloaded variants that translate an empty optional answer into a simple empty rectangle of the same type.

Rounding instance methods are not provided as the return value might be wanted as another floating point rectangle or sometimes as an integer rectangle. Instead a |RoundOut| factory, defined only for floating point input rectangles, is provided to provide control over the result type.

NaN and Infinity values

Constructing an LTRB rectangle using Infinity values should work as expected with either 0 or +Infinity returned as dimensions depending on which side the Infinity values are on and the sign.

Constructing an XYWH rectangle using Infinity values will usually not work if the math requires the object to compute a right or bottom edge from ([xy] -Infinity + [wh] +Infinity). Other combinations might work.

The special factory |MakeMaximum| is provided to construct a rectangle of the indicated coordinate type that covers all finite coordinates. It does not use infinity values, but rather the largest finite values to avoid math that might produce a NaN value from various getters.

Any rectangle that is constructed with, or computed to have a NaN value will be considered the same as any empty rectangle.

Empty Rectangle canonical results summary:

Union will ignore any empty rects and return the other rect Intersection will return nullopt if either rect is empty IntersectsWithRect will return false if either rect is empty Cutout will return the source rect if the argument is empty Cutout will return nullopt if the source rectangle is empty Contains(Point) will return false if the source rectangle is empty Contains(Rect) will return false if the source rectangle is empty Contains(Rect) will otherwise return true if the argument is empty Specifically, EmptyRect.Contains(EmptyRect) returns false


Special notes on problems using the XYWH form of specifying rectangles:

It is possible to have integer rectangles whose dimensions exceed the maximum number that their coordinates can represent since (MAX_INT - MIN_INT) overflows the representable positive numbers. Floating point rectangles technically have a similar issue in that overflow can occur, but it will be automatically converted into either an infinity, or a finite-overflow value and still be representable, just with little to no precision.

Secondly, specifying a rectangle using XYWH leads to cases where the math for (x+w) and/or (y+h) are also beyond the maximum representable coordinates. For N-bit integer rectangles declared as XYWH, the maximum right coordinate will require N+1 signed bits which cannot be stored in storage that uses N-bit integers.

Saturated math is used when constructing a rectangle from XYWH values and when returning the dimensions of the rectangle. Constructing an integer rectangle from values such that xy + wh is beyond the range of the integer type will place the right or bottom edges at the maximum value for the integer type. Similarly, constructing an integer rectangle such that the distance from the left to the right (or top to bottom) is greater than the range of the integer type will simply return the maximum integer value as the dimension. Floating point rectangles are naturally saturated by the rules of IEEE arithmetic.

Definition at line 122 of file rect.h.

Constructor & Destructor Documentation

◆ TRect()

Member Function Documentation

◆ Area()

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

Get the area of the rectangle, equivalent to |GetSize().Area()|.

Definition at line 376 of file rect.h.

376 {
377 // TODO(141710): Use saturated math to avoid overflow.
378 return IsEmpty() ? 0 : (right_ - left_) * (bottom_ - top_);
379 }
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition rect.h:297

References impeller::TRect< T >::IsEmpty().

Referenced by impeller::BlitPass::AddCopy(), impeller::BlitCopyBufferToTextureCommandGLES::Encode(), and flutter::testing::CanvasCompareTester::showBoundsOverflow().

◆ Contains() [1/2]

template<class T >
constexpr bool impeller::TRect< T >::Contains ( const TPoint< Type > &  p) const
inlineconstexpr

Returns true iff the provided point |p| is inside the half-open interior of this rectangle.

For purposes of containment, a rectangle contains points along the top and left edges but not points along the right and bottom edges so that a point is only ever considered inside one of two abutting rectangles.

Definition at line 231 of file rect.h.

231 {
232 return !this->IsEmpty() && //
233 p.x >= left_ && //
234 p.y >= top_ && //
235 p.x < right_ && //
236 p.y < bottom_;
237 }

References impeller::TRect< T >::IsEmpty(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by flutter::BM_DisplayListDispatchByVectorCull(), flutter::BM_DisplayListDispatchCull(), flutter::testing::CanvasCompareTester::checkPixels(), flutter::testing::CanvasCompareTester::compareToReference(), impeller::RoundRect::Contains(), impeller::RoundSuperellipse::Contains(), flutter::RSuperellipse::contains(), impeller::FillPathSourceGeometry::CoversArea(), impeller::FillRectGeometry::CoversArea(), impeller::RoundRectGeometry::CoversArea(), impeller::FillRoundRectGeometry::CoversArea(), impeller::RoundSuperellipseGeometry::CoversArea(), flutter::DisplayList::Dispatch(), flutter::DlRegion::MakeIntersection(), flutter::DlRegion::MakeUnion(), impeller::TiledTextureContents::RenderToSnapshot(), flutter::testing::CanvasCompareTester::RenderWith(), flutter::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::DisplayListMatrixClipState::TransformedOvalCoversBounds(), and flutter::DisplayListMatrixClipState::TransformedRectCoversBounds().

◆ Contains() [2/2]

template<class T >
constexpr bool impeller::TRect< T >::Contains ( const TRect< T > &  o) const
inlineconstexpr

Returns true iff this rectangle is not empty and it also contains every point considered inside the provided rectangle |o| (as determined by |Contains(TPoint)|).

This is similar to a definition where the result is true iff the union of the two rectangles is equal to this rectangle, ignoring precision issues with performing those operations and assuming that empty rectangles are never equal.

An empty rectangle can contain no other rectangle.

An empty rectangle is, however, contained within any other non-empy rectangle as the set of points it contains is an empty set and so there are no points to fail the containment criteria.

Definition at line 273 of file rect.h.

273 {
274 return !this->IsEmpty() && //
275 (o.IsEmpty() || (o.left_ >= left_ && //
276 o.top_ >= top_ && //
277 o.right_ <= right_ && //
278 o.bottom_ <= bottom_));
279 }

References impeller::TRect< T >::IsEmpty().

◆ ContainsInclusive()

template<class T >
constexpr bool impeller::TRect< T >::ContainsInclusive ( const TPoint< Type > &  p) const
inlineconstexpr

Returns true iff the provided point |p| is inside the closed-range interior of this rectangle.

Unlike the regular |Contains(TPoint)| method, this method considers all points along the boundary of the rectangle to be contained within the rectangle - useful for testing if vertices that define a filled shape would carry the interior of that shape outside the bounds of the rectangle. Since both geometries are defining half-open spaces, their defining geometry needs to consider their boundaries to be equivalent with respect to interior and exterior.

Definition at line 250 of file rect.h.

250 {
251 return !this->IsEmpty() && //
252 p.x >= left_ && //
253 p.y >= top_ && //
254 p.x <= right_ && //
255 p.y <= bottom_;
256 }

References impeller::TRect< T >::IsEmpty(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::testing::TEST(), and flutter::DisplayListMatrixClipState::TransformedRectCoversBounds().

◆ Cutout()

template<class T >
constexpr std::optional< TRect< T > > impeller::TRect< T >::Cutout ( const TRect< T > &  o) const
inlineconstexpr

Returns the new boundary rectangle that would result from this rectangle being cut out by the specified rectangle.

Definition at line 557 of file rect.h.

557 {
558 if (IsEmpty()) {
559 // This test isn't just a short-circuit, it also prevents the concise
560 // math below from returning the wrong answer on empty rects.
561 // Once we know that this rectangle is not empty, the math below can
562 // only succeed in computing a value if o is also non-empty and non-nan.
563 // Otherwise, the method returns *this by default.
564 return std::nullopt;
565 }
566
567 const auto& [a_left, a_top, a_right, a_bottom] = GetLTRB(); // Source rect.
568 const auto& [b_left, b_top, b_right, b_bottom] = o.GetLTRB(); // Cutout.
569 if (b_left <= a_left && b_right >= a_right) {
570 if (b_top <= a_top && b_bottom >= a_bottom) {
571 // Full cutout.
572 return std::nullopt;
573 }
574 if (b_top <= a_top && b_bottom > a_top) {
575 // Cuts off the top.
576 return TRect::MakeLTRB(a_left, b_bottom, a_right, a_bottom);
577 }
578 if (b_bottom >= a_bottom && b_top < a_bottom) {
579 // Cuts off the bottom.
580 return TRect::MakeLTRB(a_left, a_top, a_right, b_top);
581 }
582 }
583 if (b_top <= a_top && b_bottom >= a_bottom) {
584 if (b_left <= a_left && b_right > a_left) {
585 // Cuts off the left.
586 return TRect::MakeLTRB(b_right, a_top, a_right, a_bottom);
587 }
588 if (b_right >= a_right && b_left < a_right) {
589 // Cuts off the right.
590 return TRect::MakeLTRB(a_left, a_top, b_left, a_bottom);
591 }
592 }
593
594 return *this;
595 }
constexpr std::array< T, 4 > GetLTRB() const
Definition rect.h:387
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition rect.h:129

References impeller::TRect< T >::GetLTRB(), impeller::TRect< T >::IsEmpty(), and impeller::TRect< T >::MakeLTRB().

Referenced by impeller::TRect< T >::CutoutOrEmpty(), and impeller::testing::TEST().

◆ CutoutOrEmpty()

template<class T >
constexpr TRect impeller::TRect< T >::CutoutOrEmpty ( const TRect< T > &  o) const
inlineconstexpr

Definition at line 597 of file rect.h.

597 {
598 return Cutout(o).value_or(TRect());
599 }
constexpr std::optional< TRect< T > > Cutout(const TRect &o) const
Returns the new boundary rectangle that would result from this rectangle being cut out by the specifi...
Definition rect.h:557
constexpr TRect()
Definition rect.h:127

References impeller::TRect< T >::Cutout(), and impeller::TRect< T >::TRect().

Referenced by impeller::testing::TEST().

◆ Expand() [1/5]

template<class T >
constexpr TRect< T > impeller::TRect< T >::Expand ( amount) const
inlineconstexpr

Returns a rectangle with expanded edges in all directions. Negative expansion results in shrinking.

Definition at line 632 of file rect.h.

632 {
633 return {
634 saturated::Sub(left_, amount), //
635 saturated::Sub(top_, amount), //
636 saturated::Add(right_, amount), //
637 saturated::Add(bottom_, amount), //
638 };
639 }

◆ Expand() [2/5]

template<class T >
constexpr TRect< T > impeller::TRect< T >::Expand ( horizontal_amount,
vertical_amount 
) const
inlineconstexpr

Returns a rectangle with expanded edges in all directions. Negative expansion results in shrinking.

Definition at line 643 of file rect.h.

644 {
645 return {
646 saturated::Sub(left_, horizontal_amount), //
647 saturated::Sub(top_, vertical_amount), //
648 saturated::Add(right_, horizontal_amount), //
649 saturated::Add(bottom_, vertical_amount), //
650 };
651 }

◆ Expand() [3/5]

template<class T >
constexpr TRect< T > impeller::TRect< T >::Expand ( left,
top,
right,
bottom 
) const
inlineconstexpr

Returns a rectangle with expanded edges. Negative expansion results in shrinking.

Definition at line 618 of file rect.h.

621 {
622 return {
623 saturated::Sub(left_, left), //
624 saturated::Sub(top_, top), //
625 saturated::Add(right_, right), //
626 saturated::Add(bottom_, bottom), //
627 };
628 }

Referenced by flutter::testing::DisplayListTestBase< BaseT >::check_inverted_bounds(), impeller::RoundRectGeometry::CoversArea(), impeller::FillRoundRectGeometry::CoversArea(), impeller::Canvas::DrawArc(), impeller::RoundRect::Expand(), impeller::RoundSuperellipse::Expand(), impeller::RoundRect::Expand(), impeller::RoundSuperellipse::Expand(), impeller::RoundRect::Expand(), impeller::RoundSuperellipse::Expand(), impeller::TRect< T >::Expand(), impeller::TRect< T >::Expand(), impeller::SolidRRectLikeBlurContents::GetCoverage(), impeller::BorderMaskBlurFilterContents::GetFilterCoverage(), impeller::BorderMaskBlurFilterContents::GetFilterSourceCoverage(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), impeller::DirectionalMorphologyFilterContents::GetFilterSourceCoverage(), impeller::DrawImageRectAtlasGeometry::GetStrictSrcRect(), impeller::StrokeSegmentsGeometry::GetStrokeCoverage(), flutter::DlImageFilter::inset_device_bounds(), flutter::DlBlurImageFilter::map_local_bounds(), flutter::DlDilateImageFilter::map_local_bounds(), flutter::DlErodeImageFilter::map_local_bounds(), flutter::DlImageFilter::outset_device_bounds(), flutter::testing::BoundsTolerance::overflows(), flutter::testing::MockTexture::Paint(), impeller::TextureContents::Render(), flutter::testing::CanvasCompareTester::RenderWithClips(), flutter::testing::CanvasCompareTester::RenderWithSaveRestore(), flutter::testing::BoundsTolerance::Scale(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), and impeller::testing::TEST_P().

◆ Expand() [4/5]

template<class T >
constexpr TRect< T > impeller::TRect< T >::Expand ( TPoint< T >  amount) const
inlineconstexpr

Returns a rectangle with expanded edges in all directions. Negative expansion results in shrinking.

Definition at line 655 of file rect.h.

655 {
656 return Expand(amount.x, amount.y);
657 }
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
Definition rect.h:618

References impeller::TRect< T >::Expand(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ Expand() [5/5]

template<class T >
constexpr TRect< T > impeller::TRect< T >::Expand ( TSize< T >  amount) const
inlineconstexpr

Returns a rectangle with expanded edges in all directions. Negative expansion results in shrinking.

Definition at line 661 of file rect.h.

661 {
662 return Expand(amount.width, amount.height);
663 }

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

◆ GetBottom()

template<class T >
constexpr auto impeller::TRect< T >::GetBottom ( ) const
inlineconstexpr

Definition at line 357 of file rect.h.

357{ return bottom_; }

Referenced by flutter::AccumulationRect::accumulate(), impeller::BlitPass::AddCopy(), flutter::testing::BM_DrawDRRect(), flutter::testing::BM_DrawRect(), flutter::testing::BM_DrawRRect(), impeller::Canvas::Canvas(), flutter::testing::DisplayListTestBase< BaseT >::check_inverted_bounds(), flutter::testing::containsInclusive(), flutter::testing::containsInclusive(), flutter::ConvertMutation(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::EllipsePathSource::Dispatch(), flutter::DlRegion::DlRegion(), flutter::DlCanvas::DrawImageRect(), impeller::NinePatchConverter::DrawNinePatch(), flutter::DlVertexPainter::DrawRect(), FlutterRectMake(), flutter::PlatformViewAndroidJNIImpl::FlutterViewOnDisplayPlatformView(), flutter::Canvas::getDestinationClipBounds(), flutter::Canvas::getLocalClipBounds(), impeller::StrokeRectGeometry::GetPositionBuffer(), flutter::DlImageFilter::inset_device_bounds(), flutter::DlRegion::intersects(), impeller::TRect< T >::Make(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), flutter::PlatformViewAndroidJNIImpl::onDisplayPlatformView2(), flutter::DlImageFilter::outset_device_bounds(), flutter::testing::BoundsTolerance::overflows(), impeller::EntityPassClipStack::RecordClip(), RectNear(), impeller::AtlasContents::Render(), flutter::testing::SaveLayerBoundsExpector::saveLayer(), flutter::testing::CanvasCompareTester::showBoundsOverflow(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::DlStopwatchVisualizer::Visualize().

◆ GetCenter()

◆ GetHeight()

template<class T >
constexpr Type impeller::TRect< T >::GetHeight ( ) const
inlineconstexpr

Returns the height of the rectangle, equivalent to |GetSize().height|.

Definition at line 347 of file rect.h.

347 {
348 return saturated::Sub(bottom_, top_);
349 }

Referenced by impeller::RoundRectGeometry::CoversArea(), impeller::FillRoundRectGeometry::CoversArea(), impeller::Canvas::DrawImageRect(), impeller::BlitCopyBufferToTextureCommandGLES::Encode(), impeller::BlitCopyTextureToTextureCommandGLES::Encode(), impeller::BlitResizeTextureCommandGLES::Encode(), impeller::Tessellator::FilledRoundRect(), FLUTTER_ASSERT_ARC::GetCGRectFromDlRect(), impeller::TRect< T >::GetNormalizingTransform(), impeller::TRect< T >::GetSize(), impeller::TRect< T >::GetXYWH(), impeller::RoundRect::IsOval(), impeller::RoundSuperellipse::IsOval(), flutter::PerformanceOverlayLayer::Paint(), flutter::testing::MockTexture::Paint(), impeller::TRect< T >::Project(), impeller::SolidRRectLikeBlurContents::Render(), flutter::testing::BoundsTolerance::Scale(), impeller::PassBindingsCacheMTL::SetScissor(), impeller::PassBindingsCacheMTL::SetViewport(), flutter::AndroidExternalViewEmbedder::SubmitFlutterView(), flutter::AndroidExternalViewEmbedder2::SubmitFlutterView(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), impeller::interop::ToSkiaType(), impeller::interop::ToSkiaType(), flutter::OverlayLayer::UpdateViewState(), and flutter::DlStopwatchVisualizer::Visualize().

◆ GetLeft()

template<class T >
constexpr auto impeller::TRect< T >::GetLeft ( ) const
inlineconstexpr

Definition at line 351 of file rect.h.

351{ return left_; }

Referenced by flutter::AccumulationRect::accumulate(), impeller::Canvas::Canvas(), flutter::testing::DisplayListTestBase< BaseT >::check_inverted_bounds(), flutter::testing::containsInclusive(), flutter::testing::containsInclusive(), flutter::ConvertMutation(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::EllipsePathSource::Dispatch(), flutter::DlRegion::DlRegion(), impeller::DrawGlyph(), flutter::DlCanvas::DrawImageRect(), impeller::Canvas::DrawImageRect(), impeller::NinePatchConverter::DrawNinePatch(), flutter::DlVertexPainter::DrawRect(), FlutterRectMake(), flutter::PlatformViewAndroidJNIImpl::FlutterViewOnDisplayPlatformView(), flutter::Canvas::getDestinationClipBounds(), flutter::Canvas::getLocalClipBounds(), impeller::StrokeRectGeometry::GetPositionBuffer(), flutter::DlImageFilter::inset_device_bounds(), flutter::DlRegion::intersects(), impeller::TRect< T >::Make(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), flutter::PlatformViewAndroidJNIImpl::onDisplayPlatformView2(), flutter::DlImageFilter::outset_device_bounds(), flutter::testing::BoundsTolerance::overflows(), flutter::ShaderMaskLayer::Paint(), impeller::EntityPassClipStack::RecordClip(), RectNear(), flutter::testing::SaveLayerBoundsExpector::saveLayer(), flutter::testing::CanvasCompareTester::showBoundsOverflow(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ GetLeftBottom()

template<class T >
constexpr TPoint< T > impeller::TRect< T >::GetLeftBottom ( ) const
inlineconstexpr

◆ GetLeftTop()

◆ GetLTRB()

template<class T >
constexpr std::array< T, 4 > impeller::TRect< T >::GetLTRB ( ) const
inlineconstexpr

Definition at line 387 of file rect.h.

387 {
388 return {left_, top_, right_, bottom_};
389 }

Referenced by impeller::TRect< T >::Cutout().

◆ GetNormalizingTransform()

template<class T >
constexpr Matrix impeller::TRect< T >::GetNormalizingTransform ( ) const
inlineconstexpr

Constructs a Matrix that will map all points in the coordinate space of the rectangle into a new normalized coordinate space where the upper left corner of the rectangle maps to (0, 0) and the lower right corner of the rectangle maps to (1, 1).

Empty and non-finite rectangles will return a zero-scaling transform that maps all points to (0, 0).

Definition at line 491 of file rect.h.

491 {
492 if (!IsEmpty()) {
493 Scalar sx = 1.0 / GetWidth();
494 Scalar sy = 1.0 / GetHeight();
495 Scalar tx = left_ * -sx;
496 Scalar ty = top_ * -sy;
497
498 // Exclude NaN and infinities and either scale underflowing to zero
499 if (sx != 0.0 && sy != 0.0 && 0.0 * sx * sy * tx * ty == 0.0) {
500 // clang-format off
501 return Matrix( sx, 0.0f, 0.0f, 0.0f,
502 0.0f, sy, 0.0f, 0.0f,
503 0.0f, 0.0f, 1.0f, 0.0f,
504 tx, ty, 0.0f, 1.0f);
505 // clang-format on
506 }
507 }
508
509 // Map all coordinates to the origin.
510 return Matrix::MakeScale({0.0f, 0.0f, 1.0f});
511 }
float Scalar
Definition scalar.h:19
static constexpr Matrix MakeScale(const Vector3 &s)
Definition matrix.h:104
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition rect.h:347
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition rect.h:341

References impeller::TRect< T >::GetHeight(), impeller::TRect< T >::GetWidth(), impeller::TRect< T >::IsEmpty(), and impeller::Matrix::MakeScale().

Referenced by impeller::DlVerticesGeometry::GetPositionUVColorBuffer(), and impeller::TiledTextureContents::Render().

◆ GetOrigin()

template<class T >
constexpr TPoint< Type > impeller::TRect< T >::GetOrigin ( ) const
inlineconstexpr

Returns the upper left corner of the rectangle as specified by the left/top or x/y values when it was constructed.

Definition at line 320 of file rect.h.

320 {
321 return {left_, top_};
322 }

Referenced by impeller::AdvancedBlend(), impeller::DirectionalMorphologyFilterContents::GetFilterCoverage(), impeller::PipelineBlend(), impeller::SolidRRectLikeBlurContents::Render(), impeller::Canvas::Restore(), and impeller::testing::TEST().

◆ GetPoints()

template<class T >
constexpr std::array< TPoint< T >, 4 > impeller::TRect< T >::GetPoints ( ) const
inlineconstexpr

Get the points that represent the 4 corners of this rectangle in a Z order that is compatible with triangle strips or a set of all zero points if the rectangle is empty. The order is: Top left, top right, bottom left, bottom right.

Definition at line 414 of file rect.h.

414 {
415 if (IsEmpty()) {
416 return {};
417 }
418 return {
419 TPoint{left_, top_},
420 TPoint{right_, top_},
421 TPoint{left_, bottom_},
422 TPoint{right_, bottom_},
423 };
424 }

References impeller::TRect< T >::IsEmpty().

Referenced by impeller::DlAtlasGeometry::CreateBlendVertexBuffer(), impeller::DrawImageRectAtlasGeometry::CreateBlendVertexBuffer(), impeller::DlAtlasGeometry::CreateSimpleVertexBuffer(), impeller::DrawImageRectAtlasGeometry::CreateSimpleVertexBuffer(), impeller::FillRectGeometry::GetPositionBuffer(), impeller::TRect< T >::GetTransformedPoints(), impeller::ClipContents::Render(), and flutter::testing::TestBounds().

◆ GetPositive()

template<class T >
constexpr TRect impeller::TRect< T >::GetPositive ( ) const
inlineconstexpr

Get a version of this rectangle that has a non-negative size.

Definition at line 398 of file rect.h.

398 {
399 if (!IsEmpty()) {
400 return *this;
401 }
402 return {
403 std::min(left_, right_),
404 std::min(top_, bottom_),
405 std::max(left_, right_),
406 std::max(top_, bottom_),
407 };
408 }

References impeller::TRect< T >::IsEmpty().

Referenced by tonic::DartConverter< flutter::RRect >::FromDart(), impeller::DashedLinePathSource::GetBounds(), impeller::RoundRect::MakeRectRadii(), impeller::RoundSuperellipse::MakeRectRadii(), impeller::SolidRRectLikeBlurContents::Render(), and impeller::RoundingRadii::Scaled().

◆ GetRight()

template<class T >
constexpr auto impeller::TRect< T >::GetRight ( ) const
inlineconstexpr

Definition at line 355 of file rect.h.

355{ return right_; }

Referenced by flutter::AccumulationRect::accumulate(), impeller::BlitPass::AddCopy(), flutter::testing::BM_DrawDRRect(), flutter::testing::BM_DrawRRect(), impeller::Canvas::Canvas(), flutter::testing::DisplayListTestBase< BaseT >::check_inverted_bounds(), flutter::testing::containsInclusive(), flutter::testing::containsInclusive(), flutter::ConvertMutation(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::EllipsePathSource::Dispatch(), flutter::DlRegion::DlRegion(), flutter::DlCanvas::DrawImageRect(), impeller::NinePatchConverter::DrawNinePatch(), flutter::DlVertexPainter::DrawRect(), FlutterRectMake(), flutter::PlatformViewAndroidJNIImpl::FlutterViewOnDisplayPlatformView(), flutter::Canvas::getDestinationClipBounds(), flutter::Canvas::getLocalClipBounds(), impeller::StrokeRectGeometry::GetPositionBuffer(), flutter::DlImageFilter::inset_device_bounds(), flutter::DlRegion::intersects(), impeller::TRect< T >::Make(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), flutter::PlatformViewAndroidJNIImpl::onDisplayPlatformView2(), flutter::DlImageFilter::outset_device_bounds(), flutter::testing::BoundsTolerance::overflows(), impeller::EntityPassClipStack::RecordClip(), RectNear(), impeller::AtlasContents::Render(), flutter::testing::SaveLayerBoundsExpector::saveLayer(), flutter::testing::CanvasCompareTester::showBoundsOverflow(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ GetRightBottom()

◆ GetRightTop()

template<class T >
constexpr TPoint< T > impeller::TRect< T >::GetRightTop ( ) const
inlineconstexpr

◆ GetSize()

◆ GetTop()

template<class T >
constexpr auto impeller::TRect< T >::GetTop ( ) const
inlineconstexpr

Definition at line 353 of file rect.h.

353{ return top_; }

Referenced by flutter::AccumulationRect::accumulate(), impeller::Canvas::Canvas(), flutter::testing::DisplayListTestBase< BaseT >::check_inverted_bounds(), flutter::testing::containsInclusive(), flutter::testing::containsInclusive(), flutter::ConvertMutation(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::EllipsePathSource::Dispatch(), flutter::DlRegion::DlRegion(), impeller::DrawGlyph(), flutter::DlCanvas::DrawImageRect(), impeller::Canvas::DrawImageRect(), impeller::NinePatchConverter::DrawNinePatch(), flutter::DlVertexPainter::DrawRect(), FlutterRectMake(), flutter::PlatformViewAndroidJNIImpl::FlutterViewOnDisplayPlatformView(), flutter::Canvas::getDestinationClipBounds(), flutter::Canvas::getLocalClipBounds(), impeller::StrokeRectGeometry::GetPositionBuffer(), flutter::DlImageFilter::inset_device_bounds(), flutter::DlRegion::intersects(), impeller::TRect< T >::Make(), impeller::RoundSuperellipseParam::MakeBoundsRadii(), flutter::PlatformViewAndroidJNIImpl::onDisplayPlatformView2(), flutter::DlImageFilter::outset_device_bounds(), flutter::testing::BoundsTolerance::overflows(), flutter::ShaderMaskLayer::Paint(), impeller::EntityPassClipStack::RecordClip(), RectNear(), flutter::testing::SaveLayerBoundsExpector::saveLayer(), flutter::testing::CanvasCompareTester::showBoundsOverflow(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ GetTransformedPoints()

template<class T >
constexpr std::array< TPoint< T >, 4 > impeller::TRect< T >::GetTransformedPoints ( const Matrix transform) const
inlineconstexpr

Definition at line 426 of file rect.h.

427 {
428 auto points = GetPoints();
429 for (size_t i = 0; i < points.size(); i++) {
430 points[i] = transform * points[i];
431 }
432 return points;
433 }
constexpr std::array< TPoint< T >, 4 > GetPoints() const
Get the points that represent the 4 corners of this rectangle in a Z order that is compatible with tr...
Definition rect.h:414
std::vector< Point > points

References impeller::TRect< T >::GetPoints(), i, points, and transform.

Referenced by impeller::GaussianBlurFilterContents::CalculateUVs(), impeller::Snapshot::GetCoverageUVs(), impeller::testing::TEST(), and impeller::TRect< T >::TransformBounds().

◆ GetWidth()

template<class T >
constexpr Type impeller::TRect< T >::GetWidth ( ) const
inlineconstexpr

Returns the width of the rectangle, equivalent to |GetSize().width|.

Definition at line 341 of file rect.h.

341 {
342 return saturated::Sub(right_, left_);
343 }

Referenced by impeller::RoundRectGeometry::CoversArea(), impeller::FillRoundRectGeometry::CoversArea(), impeller::Canvas::DrawImageRect(), impeller::Canvas::DrawOval(), impeller::BlitCopyBufferToTextureCommandGLES::Encode(), impeller::BlitCopyTextureToTextureCommandGLES::Encode(), impeller::BlitResizeTextureCommandGLES::Encode(), impeller::Tessellator::FilledEllipse(), impeller::Tessellator::FilledRoundRect(), FLUTTER_ASSERT_ARC::GetCGRectFromDlRect(), impeller::TRect< T >::GetNormalizingTransform(), impeller::TRect< T >::GetSize(), impeller::TRect< T >::GetXYWH(), impeller::RoundRect::IsOval(), impeller::RoundSuperellipse::IsOval(), flutter::PerformanceOverlayLayer::Paint(), flutter::testing::MockTexture::Paint(), impeller::TRect< T >::Project(), impeller::SolidRRectLikeBlurContents::Render(), flutter::testing::BoundsTolerance::Scale(), impeller::PassBindingsCacheMTL::SetScissor(), impeller::PassBindingsCacheMTL::SetViewport(), flutter::AndroidExternalViewEmbedder::SubmitFlutterView(), flutter::AndroidExternalViewEmbedder2::SubmitFlutterView(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::interop::ToSkiaType(), impeller::interop::ToSkiaType(), flutter::OverlayLayer::UpdateViewState(), and flutter::DlStopwatchVisualizer::Visualize().

◆ GetX()

◆ GetXYWH()

template<class T >
constexpr std::array< T, 4 > impeller::TRect< T >::GetXYWH ( ) const
inlineconstexpr

Get the x, y coordinates of the origin and the width and height of the rectangle in an array.

Definition at line 393 of file rect.h.

393 {
394 return {left_, top_, GetWidth(), GetHeight()};
395 }

References impeller::TRect< T >::GetHeight(), and impeller::TRect< T >::GetWidth().

Referenced by impeller::testing::TEST().

◆ GetY()

◆ Intersection() [1/4]

template<class T >
static constexpr std::optional< TRect > impeller::TRect< T >::Intersection ( const std::optional< TRect< T > >  a,
const std::optional< TRect< T > >  b 
)
inlinestaticconstexpr

Definition at line 730 of file rect.h.

732 {
733 return a.has_value() ? Intersection(a.value(), b) : b;
734 }
constexpr std::optional< TRect > Intersection(const TRect &o) const
Definition rect.h:528

References impeller::TRect< T >::Intersection().

◆ Intersection() [2/4]

template<class T >
static constexpr std::optional< TRect > impeller::TRect< T >::Intersection ( const std::optional< TRect< T > >  a,
const TRect< T > &  b 
)
inlinestaticconstexpr

Definition at line 724 of file rect.h.

726 {
727 return a.has_value() ? a->Intersection(b) : b;
728 }

◆ Intersection() [3/4]

template<class T >
static constexpr std::optional< TRect > impeller::TRect< T >::Intersection ( const TRect< T > &  a,
const std::optional< TRect< T > >  b 
)
inlinestaticconstexpr

Definition at line 718 of file rect.h.

720 {
721 return b.has_value() ? a.Intersection(b.value()) : a;
722 }

References impeller::TRect< T >::Intersection().

◆ Intersection() [4/4]

template<class T >
constexpr std::optional< TRect > impeller::TRect< T >::Intersection ( const TRect< T > &  o) const
inlineconstexpr

◆ IntersectionOrEmpty()

template<class T >
constexpr TRect impeller::TRect< T >::IntersectionOrEmpty ( const TRect< T > &  o) const
inlineconstexpr

◆ IntersectsWithRect()

template<class T >
constexpr bool impeller::TRect< T >::IntersectsWithRect ( const TRect< T > &  o) const
inlineconstexpr

◆ IsEmpty()

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

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

Definition at line 297 of file rect.h.

297 {
298 // Computing the non-empty condition and negating the result causes any
299 // NaN value to return true - i.e. is considered empty.
300 return !(left_ < right_ && top_ < bottom_);
301 }

Referenced by flutter::AccumulationRect::accumulate(), impeller::TRect< T >::Area(), flutter::testing::DisplayListTestBase< BaseT >::check_inverted_bounds(), impeller::TRect< T >::Contains(), impeller::TRect< T >::Contains(), impeller::TRect< T >::ContainsInclusive(), flutter::DisplayListMatrixClipState::content_culled(), impeller::TRect< T >::Cutout(), flutter::DisplayList::Dispatch(), impeller::FirstPassDispatcher::drawDisplayList(), impeller::Canvas::DrawImageRect(), impeller::NinePatchConverter::DrawNinePatch(), impeller::ClipContents::GetClipCoverage(), flutter::DisplayList::GetCulledIndices(), flutter::DisplayListMatrixClipState::GetLocalCullCoverage(), impeller::TRect< T >::GetNormalizingTransform(), impeller::TRect< T >::GetPoints(), impeller::TRect< T >::GetPositive(), impeller::StrokeSegmentsGeometry::GetStrokeCoverage(), impeller::TRect< T >::IntersectsWithRect(), flutter::DisplayListMatrixClipState::is_cull_rect_empty(), flutter::Layer::is_empty(), impeller::RoundRect::IsEmpty(), impeller::RoundSuperellipse::IsEmpty(), impeller::RoundRect::IsOval(), impeller::RoundSuperellipse::IsOval(), impeller::RoundRect::IsRect(), impeller::RoundSuperellipse::IsRect(), impeller::TRect< T >::IsSquare(), impeller::TRect< T >::Project(), flutter::ProtectEmpty(), impeller::TextureContents::Render(), flutter::testing::CanvasCompareTester::RenderWith(), flutter::DisplayListMatrixClipState::resetDeviceCullRect(), flutter::DisplayListMatrixClipState::resetLocalCullRect(), flutter::DisplayListBuilder::SaveLayer(), impeller::RoundingRadii::Scaled(), flutter::DlRTree::search(), flutter::SliceViews(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::TRect< T >::TransformAndClipBounds(), impeller::TRect< T >::TransformBounds(), flutter::DisplayListMatrixClipState::TransformedOvalCoversBounds(), flutter::DisplayListMatrixClipState::TransformedRectCoversBounds(), flutter::DisplayListMatrixClipState::TransformedRoundSuperellipseCoversBounds(), flutter::DisplayListMatrixClipState::TransformedRRectCoversBounds(), and impeller::TRect< T >::Union().

◆ IsFinite()

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

Returns true if all of the fields of this floating point rectangle are finite.

Note that the results of |GetWidth()| and |GetHeight()| may still be infinite due to overflow even if the fields themselves are finite.

Definition at line 288 of file rect.h.

288 {
289 return std::isfinite(left_) && //
290 std::isfinite(top_) && //
291 std::isfinite(right_) && //
292 std::isfinite(bottom_);
293 }

Referenced by impeller::Arc::Arc(), flutter::DisplayListBuilder::ClipOval(), flutter::DisplayListMatrixClipState::clipOval(), flutter::DisplayListBuilder::ClipRect(), flutter::DisplayListMatrixClipState::clipRect(), impeller::RoundRect::IsFinite(), impeller::RoundSuperellipse::IsFinite(), impeller::RoundRect::MakeRectRadii(), and impeller::RoundSuperellipse::MakeRectRadii().

◆ IsMaximum()

template<class T >
constexpr bool impeller::TRect< T >::IsMaximum ( ) const
inlineconstexpr

Definition at line 314 of file rect.h.

314 {
315 return *this == MakeMaximum();
316 }
static constexpr TRect MakeMaximum()
Definition rect.h:188

References impeller::TRect< T >::MakeMaximum().

Referenced by impeller::ComputeSaveLayerCoverage(), and impeller::FirstPassDispatcher::drawDisplayList().

◆ IsSquare()

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

Returns true if width and height are equal and neither is NaN.

Definition at line 304 of file rect.h.

304 {
305 // empty rectangles can technically be "square", but would be
306 // misleading to most callers. Using |IsEmpty| also prevents
307 // "non-empty and non-overflowing" computations from happening
308 // to be equal to "empty and overflowing" results.
309 // (Consider LTRB(10, 15, MAX-2, MIN+2) which is empty, but both
310 // w/h subtractions equal "5").
311 return !IsEmpty() && (right_ - left_) == (bottom_ - top_);
312 }

References impeller::TRect< T >::IsEmpty().

Referenced by impeller::Canvas::DrawArc(), impeller::Canvas::DrawOval(), impeller::Tessellator::FilledEllipse(), and impeller::Arc::IsPerfectCircle().

◆ Make()

template<class T >
template<class U , class FT = T>
static constexpr std::enable_if_t< std::is_floating_point_v< FT >, TRect > impeller::TRect< T >::Make ( const TRect< U > &  rect)
inlinestaticconstexpr

Construct a floating point rect |Rect| from another Rect of a potentially different storage type (eg. |IRect|).

Definition at line 157 of file rect.h.

158 {
159 return MakeLTRB(
160 static_cast<FT>(rect.GetLeft()), static_cast<FT>(rect.GetTop()),
161 static_cast<FT>(rect.GetRight()), static_cast<FT>(rect.GetBottom()));
162 }

References impeller::TRect< T >::GetBottom(), impeller::TRect< T >::GetLeft(), impeller::TRect< T >::GetRight(), impeller::TRect< T >::GetTop(), and impeller::TRect< T >::MakeLTRB().

◆ MakeLTRB()

template<class T >
static constexpr TRect impeller::TRect< T >::MakeLTRB ( Type  left,
Type  top,
Type  right,
Type  bottom 
)
inlinestaticconstexpr

Definition at line 129 of file rect.h.

132 {
133 return TRect(left, top, right, bottom);
134 }

References impeller::TRect< T >::TRect().

Referenced by flutter::testing::CanvasCompareTester::compareToReference(), flutter::testing::CreateAllRenderingOps(), impeller::TRect< T >::Cutout(), impeller::TRect< T >::Make(), impeller::TRect< T >::MakeMaximum(), impeller::TRect< T >::MakePointBounds(), impeller::TRect< T >::Round(), impeller::TRect< T >::RoundIn(), impeller::TRect< T >::RoundOut(), flutter::testing::CanvasCompareTester::showBoundsOverflow(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), and impeller::testing::TEST_P().

◆ MakeMaximum()

template<class T >
static constexpr TRect impeller::TRect< T >::MakeMaximum ( )
inlinestaticconstexpr

Definition at line 188 of file rect.h.

188 {
189 return TRect::MakeLTRB(std::numeric_limits<Type>::lowest(),
190 std::numeric_limits<Type>::lowest(),
191 std::numeric_limits<Type>::max(),
192 std::numeric_limits<Type>::max());
193 }

References impeller::TRect< T >::MakeLTRB().

Referenced by impeller::TRect< T >::IsMaximum(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ MakeOriginSize()

template<class T >
static constexpr TRect impeller::TRect< T >::MakeOriginSize ( const TPoint< Type > &  origin,
const TSize< Type > &  size 
)
inlinestaticconstexpr

Definition at line 144 of file rect.h.

145 {
146 return MakeXYWH(origin.x, origin.y, size.width, size.height);
147 }
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
Definition rect.h:136

References impeller::TRect< T >::MakeXYWH(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::testing::TEST().

◆ MakePointBounds() [1/2]

template<class T >
template<typename PointIter >
static constexpr std::optional< TRect > impeller::TRect< T >::MakePointBounds ( const PointIter  first,
const PointIter  last 
)
inlinestaticconstexpr

Definition at line 170 of file rect.h.

171 {
172 if (first == last) {
173 return std::nullopt;
174 }
175 auto left = first->x;
176 auto top = first->y;
177 auto right = first->x;
178 auto bottom = first->y;
179 for (auto it = first + 1; it < last; ++it) {
180 left = std::min(left, it->x);
181 top = std::min(top, it->y);
182 right = std::max(right, it->x);
183 bottom = std::max(bottom, it->y);
184 }
185 return TRect::MakeLTRB(left, top, right, bottom);
186 }

References impeller::TRect< T >::MakeLTRB().

◆ MakePointBounds() [2/2]

template<class T >
template<typename U >
static constexpr std::optional< TRect > impeller::TRect< T >::MakePointBounds ( const U &  value)
inlinestaticconstexpr

Definition at line 165 of file rect.h.

165 {
166 return MakePointBounds(value.begin(), value.end());
167 }
int32_t value
static constexpr std::optional< TRect > MakePointBounds(const U &value)
Definition rect.h:165

References impeller::TRect< T >::MakePointBounds(), and value.

Referenced by impeller::TRect< T >::MakePointBounds(), impeller::TRect< T >::TransformAndClipBounds(), and impeller::TRect< T >::TransformBounds().

◆ MakeSize()

◆ MakeWH()

◆ MakeXYWH()

template<class T >
static constexpr TRect impeller::TRect< T >::MakeXYWH ( Type  x,
Type  y,
Type  width,
Type  height 
)
inlinestaticconstexpr

◆ operator==()

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

Definition at line 195 of file rect.h.

195 {
196 return left_ == r.left_ && //
197 top_ == r.top_ && //
198 right_ == r.right_ && //
199 bottom_ == r.bottom_;
200 }

◆ Project()

template<class T >
constexpr TRect< T > impeller::TRect< T >::Project ( TRect< T >  source) const
inlineconstexpr

Returns a new rectangle that represents the projection of the source rectangle onto this rectangle. In other words, the source rectangle is redefined in terms of the coordinate space of this rectangle.

Definition at line 669 of file rect.h.

669 {
670 if (IsEmpty()) {
671 return {};
672 }
673 return source.Shift(-left_, -top_)
674 .Scale(1.0 / static_cast<Scalar>(GetWidth()),
675 1.0 / static_cast<Scalar>(GetHeight()));
676 }

References impeller::TRect< T >::GetHeight(), impeller::TRect< T >::GetWidth(), impeller::TRect< T >::IsEmpty(), and impeller::TRect< T >::Shift().

Referenced by impeller::DrawImageRectAtlasGeometry::CreateBlendVertexBuffer(), impeller::DrawImageRectAtlasGeometry::CreateSimpleVertexBuffer(), impeller::DrawImageRectAtlasGeometry::GetStrictSrcRect(), and impeller::TextureContents::Render().

◆ Round()

template<class T >
impeller::TRect< T >::Round ( const TRect< U > &  r)
inline

Definition at line 695 of file rect.h.

695 {
696 return TRect::MakeLTRB(saturated::Cast<U, Type>(round(r.GetLeft())),
697 saturated::Cast<U, Type>(round(r.GetTop())),
698 saturated::Cast<U, Type>(round(r.GetRight())),
699 saturated::Cast<U, Type>(round(r.GetBottom())));
700 }

References impeller::TRect< T >::MakeLTRB().

Referenced by flutter::Canvas::drawImageNine(), and impeller::testing::TEST().

◆ RoundIn()

template<class T >
impeller::TRect< T >::RoundIn ( const TRect< U > &  r)
inline

Definition at line 687 of file rect.h.

687 {
688 return TRect::MakeLTRB(saturated::Cast<U, Type>(ceil(r.GetLeft())),
689 saturated::Cast<U, Type>(ceil(r.GetTop())),
690 saturated::Cast<U, Type>(floor(r.GetRight())),
691 saturated::Cast<U, Type>(floor(r.GetBottom())));
692 }

References impeller::TRect< T >::MakeLTRB().

Referenced by flutter::SliceViews().

◆ RoundOut()

template<class T >
impeller::TRect< T >::RoundOut ( const TRect< U > &  r)
inline

◆ Scale() [1/4]

template<class T >
constexpr TRect impeller::TRect< T >::Scale ( TPoint< T >  scale) const
inlineconstexpr

Definition at line 216 of file rect.h.

216 {
217 return Scale(scale.x, scale.y);
218 }
constexpr TRect Scale(Type scale) const
Definition rect.h:202

References impeller::TRect< T >::Scale(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ Scale() [2/4]

template<class T >
constexpr TRect impeller::TRect< T >::Scale ( TSize< T >  scale) const
inlineconstexpr

Definition at line 220 of file rect.h.

220 {
221 return Scale(scale.width, scale.height);
222 }

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

◆ Scale() [3/4]

template<class T >
constexpr TRect impeller::TRect< T >::Scale ( Type  scale) const
inlineconstexpr

◆ Scale() [4/4]

template<class T >
constexpr TRect impeller::TRect< T >::Scale ( Type  scale_x,
Type  scale_y 
) const
inlineconstexpr

Definition at line 209 of file rect.h.

209 {
210 return TRect(left_ * scale_x, //
211 top_ * scale_y, //
212 right_ * scale_x, //
213 bottom_ * scale_y);
214 }

References impeller::TRect< T >::TRect().

◆ Shift() [1/2]

◆ Shift() [2/2]

template<class T >
constexpr TRect< T > impeller::TRect< T >::Shift ( TPoint< T >  offset) const
inlineconstexpr

Returns a new rectangle translated by the given offset.

Definition at line 612 of file rect.h.

612 {
613 return Shift(offset.x, offset.y);
614 }
constexpr TRect< T > Shift(T dx, T dy) const
Returns a new rectangle translated by the given offset.
Definition rect.h:602

References impeller::TRect< T >::Shift(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ TransformAndClipBounds()

template<class T >
constexpr TRect impeller::TRect< T >::TransformAndClipBounds ( const Matrix transform) const
inlineconstexpr

Creates a new bounding box that contains this transformed rectangle, clipped against the near clipping plane if necessary.

Definition at line 438 of file rect.h.

439 {
440 if (!transform.HasPerspective2D()) {
442 }
443
444 if (IsEmpty()) {
445 return {};
446 }
447
448 auto ul = transform.TransformHomogenous({left_, top_});
449 auto ur = transform.TransformHomogenous({right_, top_});
450 auto ll = transform.TransformHomogenous({left_, bottom_});
451 auto lr = transform.TransformHomogenous({right_, bottom_});
452
453 // It can probably be proven that we only ever have 5 points at most
454 // which happens when only 1 corner is clipped and we get 2 points
455 // in return for it as we interpolate against its neighbors.
456 Point points[8];
457 int index = 0;
458
459 // Process (clip and interpolate) each point against its 2 neighbors:
460 // left, pt, right
461 index = ClipAndInsert(points, index, ll, ul, ur);
462 index = ClipAndInsert(points, index, ul, ur, lr);
463 index = ClipAndInsert(points, index, ur, lr, ll);
464 index = ClipAndInsert(points, index, lr, ll, ul);
465
466 auto bounds = TRect::MakePointBounds(points, points + index);
467 return bounds.value_or(TRect{});
468 }
TPoint< Scalar > Point
Definition point.h:327
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition rect.h:472

References impeller::TRect< T >::IsEmpty(), impeller::TRect< T >::MakePointBounds(), points, transform, and impeller::TRect< T >::TransformBounds().

Referenced by flutter::EmbeddedViewParams::EmbeddedViewParams(), flutter::DlMatrixImageFilter::get_input_device_bounds(), flutter::DlMatrixImageFilter::map_device_bounds(), flutter::DlMatrixImageFilter::map_local_bounds(), flutter::DisplayListMatrixClipState::mapAndClipRect(), flutter::DisplayListMatrixClipState::mapRect(), flutter::TransformLayer::Preroll(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TestBoundsWithMatrix(), and flutter::DisplayListMatrixClipState::TransformedRectCoversBounds().

◆ TransformBounds()

template<class T >
constexpr TRect impeller::TRect< T >::TransformBounds ( const Matrix transform) const
inlineconstexpr

Creates a new bounding box that contains this transformed rectangle.

Definition at line 472 of file rect.h.

472 {
473 if (IsEmpty()) {
474 return {};
475 }
477 auto bounds = TRect::MakePointBounds(points.begin(), points.end());
478 if (bounds.has_value()) {
479 return bounds.value();
480 }
482 }
#define FML_UNREACHABLE()
Definition logging.h:128
constexpr std::array< TPoint< T >, 4 > GetTransformedPoints(const Matrix &transform) const
Definition rect.h:426

References FML_UNREACHABLE, impeller::TRect< T >::GetTransformedPoints(), impeller::TRect< T >::IsEmpty(), impeller::TRect< T >::MakePointBounds(), points, and transform.

Referenced by impeller::ComputeSaveLayerCoverage(), impeller::FillRectGeometry::CoversArea(), impeller::RoundRectGeometry::CoversArea(), impeller::FillRoundRectGeometry::CoversArea(), impeller::RoundSuperellipseGeometry::CoversArea(), impeller::DlDispatcherBase::drawDisplayList(), impeller::Canvas::DrawImageRect(), impeller::Snapshot::GetCoverage(), impeller::AtlasContents::GetCoverage(), impeller::ColorFilterAtlasContents::GetCoverage(), impeller::SolidRRectLikeBlurContents::GetCoverage(), impeller::TextureContents::GetCoverage(), impeller::DlVerticesGeometry::GetCoverage(), impeller::PointFieldGeometry::GetCoverage(), impeller::FillRectGeometry::GetCoverage(), impeller::StrokeRectGeometry::GetCoverage(), impeller::MatrixFilterContents::GetFilterCoverage(), impeller::LocalMatrixFilterContents::GetFilterSourceCoverage(), flutter::DisplayListMatrixClipState::GetLocalCullCoverage(), impeller::StrokeSegmentsGeometry::GetStrokeCoverage(), impeller::FirstPassDispatcher::saveLayer(), flutter::testing::TEST_F(), flutter::testing::TestInvalidBounds(), and impeller::TRect< T >::TransformAndClipBounds().

◆ Union() [1/4]

template<class T >
static constexpr std::optional< TRect > impeller::TRect< T >::Union ( const std::optional< TRect< T > >  a,
const std::optional< TRect< T > >  b 
)
inlinestaticconstexpr

Definition at line 712 of file rect.h.

714 {
715 return a.has_value() ? Union(a.value(), b) : b;
716 }
constexpr TRect Union(const TRect &o) const
Definition rect.h:513

References impeller::TRect< T >::Union().

◆ Union() [2/4]

template<class T >
static constexpr TRect impeller::TRect< T >::Union ( const std::optional< TRect< T > >  a,
const TRect< T > &  b 
)
inlinestaticconstexpr

Definition at line 707 of file rect.h.

708 {
709 return a.has_value() ? a->Union(b) : b;
710 }

References impeller::TRect< T >::Union().

◆ Union() [3/4]

template<class T >
static constexpr TRect impeller::TRect< T >::Union ( const TRect< T > &  a,
const std::optional< TRect< T > >  b 
)
inlinestaticconstexpr

Definition at line 702 of file rect.h.

703 {
704 return b.has_value() ? a.Union(b.value()) : a;
705 }

References impeller::TRect< T >::Union().

◆ Union() [4/4]


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