Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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 229 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 247 of file dl_rendering_unittests.cc.

248 {
249 BoundsTolerance copy = BoundsTolerance(*this);
250 copy.absolute_pad_ += DlPoint(absolute_pad_x, absolute_pad_y);
251 return copy;
252 }
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 261 of file dl_rendering_unittests.cc.

261 {
262 BoundsTolerance copy = BoundsTolerance(*this);
263 copy.discrete_offset_ += discrete_offset;
264 return copy;
265 }

References BoundsTolerance(), and discrete_offset().

◆ addPostClipPadding()

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

Definition at line 254 of file dl_rendering_unittests.cc.

255 {
256 BoundsTolerance copy = BoundsTolerance(*this);
257 copy.clip_pad_ += DlPoint(absolute_pad_x, absolute_pad_y);
258 return copy;
259 }

References BoundsTolerance().

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

◆ clip()

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

Definition at line 267 of file dl_rendering_unittests.cc.

267 {
268 BoundsTolerance copy = BoundsTolerance(*this);
269 copy.clip_ = copy.clip_.IntersectionOrEmpty(clip);
270 return copy;
271 }
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 241 of file dl_rendering_unittests.cc.

241 {
242 BoundsTolerance copy = BoundsTolerance(*this);
243 copy.scale_ *= DlPoint(scale_x, scale_y);
244 return copy;
245 }

References BoundsTolerance().

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

◆ operator==()

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

Definition at line 306 of file dl_rendering_unittests.cc.

306 {
307 return bounds_pad_ == other.bounds_pad_ && scale_ == other.scale_ &&
308 absolute_pad_ == other.absolute_pad_ && clip_ == other.clip_ &&
309 clip_pad_ == other.clip_pad_ &&
310 discrete_offset_ == other.discrete_offset_;
311 }

◆ overflows()

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

Definition at line 279 of file dl_rendering_unittests.cc.

281 {
282 DlRect allowed = DlRect::Make(pix_bounds);
283 allowed = allowed.Expand(bounds_pad_.x, bounds_pad_.y);
284 allowed = Scale(allowed, scale_);
285 allowed = allowed.Expand(absolute_pad_.x, absolute_pad_.y);
286 allowed = allowed.IntersectionOrEmpty(clip_);
287 allowed = allowed.Expand(clip_pad_.x, clip_pad_.y);
288 DlIRect rounded = DlIRect::RoundOut(allowed);
289 int pad_left = std::max(0, pix_bounds.GetLeft() - rounded.GetLeft());
290 int pad_top = std::max(0, pix_bounds.GetTop() - rounded.GetTop());
291 int pad_right = std::max(0, pix_bounds.GetRight() - rounded.GetRight());
292 int pad_bottom = std::max(0, pix_bounds.GetBottom() - rounded.GetBottom());
293 int allowed_pad_x = std::max(pad_left, pad_right);
294 int allowed_pad_y = std::max(pad_top, pad_bottom);
295 if (worst_bounds_pad_x > allowed_pad_x ||
296 worst_bounds_pad_y > allowed_pad_y) {
297 FML_LOG(ERROR) << "acceptable bounds padding: " //
298 << allowed_pad_x << ", " << allowed_pad_y;
299 }
300 return (worst_bounds_pad_x > allowed_pad_x ||
301 worst_bounds_pad_y > allowed_pad_y);
302 }
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:181
RoundOut(const TRect< U > &r)
Definition rect.h:713

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 273 of file dl_rendering_unittests.cc.

273 {
274 DlScalar outset_x = rect.GetWidth() * (scales.x - 1);
275 DlScalar outset_y = rect.GetHeight() * (scales.y - 1);
276 return rect.Expand(outset_x, outset_y);
277 }
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: