Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
flutter::testing::BoundsTolerance Class Reference

Public Member Functions

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

Static Public Member Functions

static SkRect Scale (const SkRect &rect, const SkPoint &scales)
 

Detailed Description

Definition at line 243 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 ( SkScalar  absolute_pad_x,
SkScalar  absolute_pad_y 
) const
inline

Definition at line 262 of file dl_rendering_unittests.cc.

263 {
265 copy.absolute_pad_.offset(absolute_pad_x, absolute_pad_y);
266 return copy;
267 }
Definition copy.py:1

◆ addBoundsPadding()

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

Definition at line 248 of file dl_rendering_unittests.cc.

249 {
251 copy.bounds_pad_.offset(bounds_pad_x, bounds_pad_y);
252 return copy;
253 }

◆ addDiscreteOffset()

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

Definition at line 276 of file dl_rendering_unittests.cc.

276 {
278 copy.discrete_offset_ += discrete_offset;
279 return copy;
280 }

◆ addPostClipPadding()

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

Definition at line 269 of file dl_rendering_unittests.cc.

270 {
272 copy.clip_pad_.offset(absolute_pad_x, absolute_pad_y);
273 return copy;
274 }

◆ clip()

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

Definition at line 282 of file dl_rendering_unittests.cc.

282 {
284 if (!copy.clip_.intersect(clip)) {
285 copy.clip_.setEmpty();
286 }
287 return copy;
288 }
BoundsTolerance clip(SkRect clip) const

◆ discrete_offset()

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

Definition at line 323 of file dl_rendering_unittests.cc.

323{ return discrete_offset_; }

◆ mulScale()

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

Definition at line 255 of file dl_rendering_unittests.cc.

255 {
257 copy.scale_.fX *= scale_x;
258 copy.scale_.fY *= scale_y;
259 return copy;
260 }

◆ operator==()

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

Definition at line 325 of file dl_rendering_unittests.cc.

325 {
326 return bounds_pad_ == other.bounds_pad_ && scale_ == other.scale_ &&
327 absolute_pad_ == other.absolute_pad_ && clip_ == other.clip_ &&
328 clip_pad_ == other.clip_pad_ &&
329 discrete_offset_ == other.discrete_offset_;
330 }

◆ overflows()

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

Definition at line 296 of file dl_rendering_unittests.cc.

298 {
299 SkRect allowed = SkRect::Make(pix_bounds);
300 allowed.outset(bounds_pad_.fX, bounds_pad_.fY);
301 allowed = Scale(allowed, scale_);
302 allowed.outset(absolute_pad_.fX, absolute_pad_.fY);
303 if (!allowed.intersect(clip_)) {
304 allowed.setEmpty();
305 }
306 allowed.outset(clip_pad_.fX, clip_pad_.fY);
307 SkIRect rounded = allowed.roundOut();
308 int pad_left = std::max(0, pix_bounds.fLeft - rounded.fLeft);
309 int pad_top = std::max(0, pix_bounds.fTop - rounded.fTop);
310 int pad_right = std::max(0, pix_bounds.fRight - rounded.fRight);
311 int pad_bottom = std::max(0, pix_bounds.fBottom - rounded.fBottom);
312 int allowed_pad_x = std::max(pad_left, pad_right);
313 int allowed_pad_y = std::max(pad_top, pad_bottom);
314 if (worst_bounds_pad_x > allowed_pad_x ||
315 worst_bounds_pad_y > allowed_pad_y) {
316 FML_LOG(ERROR) << "acceptable bounds padding: " //
317 << allowed_pad_x << ", " << allowed_pad_y;
318 }
319 return (worst_bounds_pad_x > allowed_pad_x ||
320 worst_bounds_pad_y > allowed_pad_y);
321 }
#define FML_LOG(severity)
Definition logging.h:82
int32_t fBottom
larger y-axis bounds
Definition SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition SkRect.h:35
float fX
x-axis value
float fY
y-axis value
static SkRect Make(const SkISize &size)
Definition SkRect.h:669
bool intersect(const SkRect &r)
Definition SkRect.cpp:114
void outset(float dx, float dy)
Definition SkRect.h:1077
void roundOut(SkIRect *dst) const
Definition SkRect.h:1241
void setEmpty()
Definition SkRect.h:842
#define ERROR(message)

◆ Scale()

static SkRect flutter::testing::BoundsTolerance::Scale ( const SkRect rect,
const SkPoint scales 
)
inlinestatic

Definition at line 290 of file dl_rendering_unittests.cc.

290 {
291 SkScalar outset_x = rect.width() * (scales.fX - 1);
292 SkScalar outset_y = rect.height() * (scales.fY - 1);
293 return rect.makeOutset(outset_x, outset_y);
294 }
float SkScalar
Definition extension.cpp:12
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350

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