Flutter Engine
The Flutter Engine
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 244 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 263 of file dl_rendering_unittests.cc.

264 {
266 copy.absolute_pad_.offset(absolute_pad_x, absolute_pad_y);
267 return copy;
268 }
static void copy(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
Definition: SkSwizzler.cpp:31
Definition: copy.py:1

◆ addBoundsPadding()

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

Definition at line 249 of file dl_rendering_unittests.cc.

250 {
252 copy.bounds_pad_.offset(bounds_pad_x, bounds_pad_y);
253 return copy;
254 }

◆ addDiscreteOffset()

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

Definition at line 277 of file dl_rendering_unittests.cc.

277 {
279 copy.discrete_offset_ += discrete_offset;
280 return copy;
281 }

◆ addPostClipPadding()

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

Definition at line 270 of file dl_rendering_unittests.cc.

271 {
273 copy.clip_pad_.offset(absolute_pad_x, absolute_pad_y);
274 return copy;
275 }

◆ clip()

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

Definition at line 283 of file dl_rendering_unittests.cc.

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

◆ discrete_offset()

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

Definition at line 324 of file dl_rendering_unittests.cc.

324{ return discrete_offset_; }

◆ mulScale()

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

Definition at line 256 of file dl_rendering_unittests.cc.

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

◆ operator==()

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

Definition at line 326 of file dl_rendering_unittests.cc.

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

◆ overflows()

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

Definition at line 297 of file dl_rendering_unittests.cc.

299 {
300 SkRect allowed = SkRect::Make(pix_bounds);
301 allowed.outset(bounds_pad_.fX, bounds_pad_.fY);
302 allowed = Scale(allowed, scale_);
303 allowed.outset(absolute_pad_.fX, absolute_pad_.fY);
304 if (!allowed.intersect(clip_)) {
305 allowed.setEmpty();
306 }
307 allowed.outset(clip_pad_.fX, clip_pad_.fY);
308 SkIRect rounded = allowed.roundOut();
309 int pad_left = std::max(0, pix_bounds.fLeft - rounded.fLeft);
310 int pad_top = std::max(0, pix_bounds.fTop - rounded.fTop);
311 int pad_right = std::max(0, pix_bounds.fRight - rounded.fRight);
312 int pad_bottom = std::max(0, pix_bounds.fBottom - rounded.fBottom);
313 int allowed_pad_x = std::max(pad_left, pad_right);
314 int allowed_pad_y = std::max(pad_top, pad_bottom);
315 if (worst_bounds_pad_x > allowed_pad_x ||
316 worst_bounds_pad_y > allowed_pad_y) {
317 FML_LOG(ERROR) << "acceptable bounds padding: " //
318 << allowed_pad_x << ", " << allowed_pad_y;
319 }
320 return (worst_bounds_pad_x > allowed_pad_x ||
321 worst_bounds_pad_y > allowed_pad_y);
322 }
static SkRect Scale(const SkRect &rect, const SkPoint &scales)
#define FML_LOG(severity)
Definition: logging.h:82
static float max(float r, float g, float b)
Definition: hsl.cpp:49
Definition: SkRect.h:32
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
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
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)
Definition: elf_loader.cc:260

◆ Scale()

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

Definition at line 291 of file dl_rendering_unittests.cc.

291 {
292 SkScalar outset_x = rect.width() * (scales.fX - 1);
293 SkScalar outset_y = rect.height() * (scales.fY - 1);
294 return rect.makeOutset(outset_x, outset_y);
295 }
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: