Flutter Engine
 
Loading...
Searching...
No Matches
flutter::testing::BoundsTolerance Class Reference

Public Member Functions

 BoundsTolerance ()=default
 
 BoundsTolerance (const BoundsTolerance &)=default
 
BoundsTolerance addBoundsPadding (DlScalar bounds_pad_x, DlScalar bounds_pad_y) const
 
BoundsTolerance mulScale (DlScalar scale_x, DlScalar scale_y) const
 
BoundsTolerance addAbsolutePadding (DlScalar absolute_pad_x, DlScalar absolute_pad_y) const
 
BoundsTolerance addPostClipPadding (DlScalar absolute_pad_x, DlScalar absolute_pad_y) const
 
BoundsTolerance addDiscreteOffset (DlScalar discrete_offset) const
 
BoundsTolerance clip (DlRect clip) const
 
bool overflows (DlIRect pix_bounds, int worst_bounds_pad_x, int worst_bounds_pad_y) const
 
DlScalar discrete_offset () const
 
bool operator== (BoundsTolerance const &other) const
 

Static Public Member Functions

static DlRect Scale (const DlRect &rect, const DlPoint &scales)
 

Detailed Description

Definition at line 262 of file dl_rendering_unittests.cc.

Constructor & Destructor Documentation

◆ BoundsTolerance() [1/2]

flutter::testing::BoundsTolerance::BoundsTolerance ( )
default

◆ BoundsTolerance() [2/2]

flutter::testing::BoundsTolerance::BoundsTolerance ( const BoundsTolerance )
default

Member Function Documentation

◆ addAbsolutePadding()

BoundsTolerance flutter::testing::BoundsTolerance::addAbsolutePadding ( DlScalar  absolute_pad_x,
DlScalar  absolute_pad_y 
) const
inline

Definition at line 280 of file dl_rendering_unittests.cc.

281 {
282 BoundsTolerance copy = BoundsTolerance(*this);
283 copy.absolute_pad_ += DlPoint(absolute_pad_x, absolute_pad_y);
284 return copy;
285 }
impeller::Point DlPoint

References BoundsTolerance().

Referenced by flutter::testing::TEST_F().

◆ addBoundsPadding()

BoundsTolerance flutter::testing::BoundsTolerance::addBoundsPadding ( DlScalar  bounds_pad_x,
DlScalar  bounds_pad_y 
) const
inline

◆ addDiscreteOffset()

BoundsTolerance flutter::testing::BoundsTolerance::addDiscreteOffset ( DlScalar  discrete_offset) const
inline

Definition at line 294 of file dl_rendering_unittests.cc.

294 {
295 BoundsTolerance copy = BoundsTolerance(*this);
296 copy.discrete_offset_ += discrete_offset;
297 return copy;
298 }

References BoundsTolerance(), and discrete_offset().

◆ addPostClipPadding()

BoundsTolerance flutter::testing::BoundsTolerance::addPostClipPadding ( DlScalar  absolute_pad_x,
DlScalar  absolute_pad_y 
) const
inline

Definition at line 287 of file dl_rendering_unittests.cc.

288 {
289 BoundsTolerance copy = BoundsTolerance(*this);
290 copy.clip_pad_ += DlPoint(absolute_pad_x, absolute_pad_y);
291 return copy;
292 }

References BoundsTolerance().

Referenced by flutter::testing::CanvasCompareTester::RenderWithClips().

◆ clip()

BoundsTolerance flutter::testing::BoundsTolerance::clip ( DlRect  clip) const
inline

Definition at line 300 of file dl_rendering_unittests.cc.

300 {
301 BoundsTolerance copy = BoundsTolerance(*this);
302 copy.clip_ = copy.clip_.IntersectionOrEmpty(clip);
303 return copy;
304 }
BoundsTolerance clip(DlRect clip) const

References BoundsTolerance(), clip(), and impeller::TRect< T >::IntersectionOrEmpty().

Referenced by clip(), and flutter::testing::CanvasCompareTester::RenderWithClips().

◆ discrete_offset()

DlScalar flutter::testing::BoundsTolerance::discrete_offset ( ) const
inline

◆ mulScale()

BoundsTolerance flutter::testing::BoundsTolerance::mulScale ( DlScalar  scale_x,
DlScalar  scale_y 
) const
inline

Definition at line 274 of file dl_rendering_unittests.cc.

274 {
275 BoundsTolerance copy = BoundsTolerance(*this);
276 copy.scale_ *= DlPoint(scale_x, scale_y);
277 return copy;
278 }

References BoundsTolerance().

Referenced by flutter::testing::CanvasCompareTester::RenderWithTransforms().

◆ operator==()

bool flutter::testing::BoundsTolerance::operator== ( BoundsTolerance const &  other) const
inline

Definition at line 339 of file dl_rendering_unittests.cc.

339 {
340 return bounds_pad_ == other.bounds_pad_ && scale_ == other.scale_ &&
341 absolute_pad_ == other.absolute_pad_ && clip_ == other.clip_ &&
342 clip_pad_ == other.clip_pad_ &&
343 discrete_offset_ == other.discrete_offset_;
344 }

◆ overflows()

bool flutter::testing::BoundsTolerance::overflows ( DlIRect  pix_bounds,
int  worst_bounds_pad_x,
int  worst_bounds_pad_y 
) const
inline

Definition at line 312 of file dl_rendering_unittests.cc.

314 {
315 DlRect allowed = DlRect::Make(pix_bounds);
316 allowed = allowed.Expand(bounds_pad_.x, bounds_pad_.y);
317 allowed = Scale(allowed, scale_);
318 allowed = allowed.Expand(absolute_pad_.x, absolute_pad_.y);
319 allowed = allowed.IntersectionOrEmpty(clip_);
320 allowed = allowed.Expand(clip_pad_.x, clip_pad_.y);
321 DlIRect rounded = DlIRect::RoundOut(allowed);
322 int pad_left = std::max(0, pix_bounds.GetLeft() - rounded.GetLeft());
323 int pad_top = std::max(0, pix_bounds.GetTop() - rounded.GetTop());
324 int pad_right = std::max(0, pix_bounds.GetRight() - rounded.GetRight());
325 int pad_bottom = std::max(0, pix_bounds.GetBottom() - rounded.GetBottom());
326 int allowed_pad_x = std::max(pad_left, pad_right);
327 int allowed_pad_y = std::max(pad_top, pad_bottom);
328 if (worst_bounds_pad_x > allowed_pad_x ||
329 worst_bounds_pad_y > allowed_pad_y) {
330 FML_LOG(ERROR) << "acceptable bounds padding: " //
331 << allowed_pad_x << ", " << allowed_pad_y;
332 }
333 return (worst_bounds_pad_x > allowed_pad_x ||
334 worst_bounds_pad_y > allowed_pad_y);
335 }
static DlRect Scale(const DlRect &rect, const DlPoint &scales)
#define FML_LOG(severity)
Definition logging.h:101
impeller::Rect DlRect
impeller::IRect32 DlIRect
static constexpr std::enable_if_t< std::is_floating_point_v< FT >, TRect > Make(const TRect< U > &rect)
Definition rect.h:157
RoundOut(const TRect< U > &r)
Definition rect.h:679

References impeller::TRect< T >::Expand(), FML_LOG, impeller::TRect< T >::GetBottom(), impeller::TRect< T >::GetLeft(), impeller::TRect< T >::GetRight(), impeller::TRect< T >::GetTop(), impeller::TRect< T >::IntersectionOrEmpty(), impeller::TRect< Scalar >::Make(), impeller::TRect< T >::RoundOut(), Scale(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by flutter::testing::CanvasCompareTester::showBoundsOverflow().

◆ Scale()

static DlRect flutter::testing::BoundsTolerance::Scale ( const DlRect rect,
const DlPoint scales 
)
inlinestatic

Definition at line 306 of file dl_rendering_unittests.cc.

306 {
307 DlScalar outset_x = rect.GetWidth() * (scales.x - 1);
308 DlScalar outset_y = rect.GetHeight() * (scales.y - 1);
309 return rect.Expand(outset_x, outset_y);
310 }
impeller::Scalar DlScalar

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

Referenced by overflows().


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