check for huge paths
Bug:802976 Change-Id: Ibb5930442f75ca8483afc8dfa5869cac98573904 Reviewed-on: https://skia-review.googlesource.com/98440 Reviewed-by: Cary Clark <caryclark@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
ca02c0a464
commit
1fe0bcc4f9
@ -1937,6 +1937,11 @@ bool SkPaint::unflatten(SkReadBuffer& buffer) {
|
||||
|
||||
bool SkPaint::getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
|
||||
SkScalar resScale) const {
|
||||
if (!src.isFinite()) {
|
||||
dst->reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
SkStrokeRec rec(*this, resScale);
|
||||
|
||||
const SkPath* srcPtr = &src;
|
||||
@ -1957,6 +1962,11 @@ bool SkPaint::getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect
|
||||
*dst = *srcPtr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dst->isFinite()) {
|
||||
dst->reset();
|
||||
return false;
|
||||
}
|
||||
return !rec.isHairlineStyle();
|
||||
}
|
||||
|
||||
|
@ -756,9 +756,8 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip,
|
||||
|
||||
#include "SkRasterClip.h"
|
||||
|
||||
void SkScan::FillPath(const SkPath& path, const SkRasterClip& clip,
|
||||
SkBlitter* blitter) {
|
||||
if (clip.isEmpty()) {
|
||||
void SkScan::FillPath(const SkPath& path, const SkRasterClip& clip, SkBlitter* blitter) {
|
||||
if (clip.isEmpty() || !path.isFinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -776,7 +775,7 @@ void SkScan::FillPath(const SkPath& path, const SkRasterClip& clip,
|
||||
|
||||
void SkScan::AntiFillPath(const SkPath& path, const SkRasterClip& clip,
|
||||
SkBlitter* blitter, bool forceDAA) {
|
||||
if (clip.isEmpty()) {
|
||||
if (clip.isEmpty() || !path.isFinite()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4949,3 +4949,38 @@ DEF_TEST(AndroidArc, reporter) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Try a range of crazy values, just to ensure that we don't assert/crash.
|
||||
*/
|
||||
DEF_TEST(HugeGeometry, reporter) {
|
||||
auto surf = SkSurface::MakeRasterN32Premul(100, 100);
|
||||
auto canvas = surf->getCanvas();
|
||||
|
||||
const bool aas[] = { false, true };
|
||||
const SkPaint::Style styles[] = {
|
||||
SkPaint::kFill_Style, SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style
|
||||
};
|
||||
const SkScalar values[] = {
|
||||
0, 1, 1000, 1000 * 1000, 1000.f * 1000 * 10000, SK_ScalarMax / 2, SK_ScalarMax,
|
||||
SK_ScalarInfinity
|
||||
};
|
||||
|
||||
SkPaint paint;
|
||||
for (auto x : values) {
|
||||
SkRect r = { -x, -x, x, x };
|
||||
for (auto width : values) {
|
||||
paint.setStrokeWidth(width);
|
||||
for (auto aa : aas) {
|
||||
paint.setAntiAlias(aa);
|
||||
for (auto style : styles) {
|
||||
paint.setStyle(style);
|
||||
canvas->drawRect(r, paint);
|
||||
canvas->drawOval(r, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user