check for valid inputs to shadows
Bug: oss-fuzz:6766 Change-Id: I6b131d53564618bb2be50fa38a1c9fdf15deff05 Reviewed-on: https://skia-review.googlesource.com/112483 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
eb3f674d6d
commit
9d5c6743f6
@ -379,9 +379,7 @@ SkAmbientShadowTessellator::SkAmbientShadowTessellator(const SkPath& path,
|
|||||||
, fSplitFirstEdge(false)
|
, fSplitFirstEdge(false)
|
||||||
, fSplitPreviousEdge(false) {
|
, fSplitPreviousEdge(false) {
|
||||||
// TODO: support some concave paths
|
// TODO: support some concave paths
|
||||||
if (!path.isConvex()) {
|
SkASSERT(path.isConvex());
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set base colors
|
// Set base colors
|
||||||
SkScalar umbraAlpha = SkScalarInvert(SkDrawShadowMetrics::AmbientRecipAlpha(heightFunc(0, 0)));
|
SkScalar umbraAlpha = SkScalarInvert(SkDrawShadowMetrics::AmbientRecipAlpha(heightFunc(0, 0)));
|
||||||
@ -807,9 +805,7 @@ SkSpotShadowTessellator::SkSpotShadowTessellator(const SkPath& path, const SkMat
|
|||||||
, fValidUmbra(true) {
|
, fValidUmbra(true) {
|
||||||
|
|
||||||
// TODO: support some concave paths
|
// TODO: support some concave paths
|
||||||
if (!path.isConvex()) {
|
SkASSERT(path.isConvex());
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure we're not below the canvas plane
|
// make sure we're not below the canvas plane
|
||||||
if (this->setZOffset(path.getBounds(), ctm.hasPerspective())) {
|
if (this->setZOffset(path.getBounds(), ctm.hasPerspective())) {
|
||||||
@ -1414,6 +1410,9 @@ void SkSpotShadowTessellator::addEdge(const SkPoint& nextPoint, const SkVector&
|
|||||||
|
|
||||||
sk_sp<SkVertices> SkShadowTessellator::MakeAmbient(const SkPath& path, const SkMatrix& ctm,
|
sk_sp<SkVertices> SkShadowTessellator::MakeAmbient(const SkPath& path, const SkMatrix& ctm,
|
||||||
const SkPoint3& zPlane, bool transparent) {
|
const SkPoint3& zPlane, bool transparent) {
|
||||||
|
if (!path.isFinite() || !path.isConvex() || !ctm.isFinite() || !zPlane.isFinite()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
SkAmbientShadowTessellator ambientTess(path, ctm, zPlane, transparent);
|
SkAmbientShadowTessellator ambientTess(path, ctm, zPlane, transparent);
|
||||||
return ambientTess.releaseVertices();
|
return ambientTess.releaseVertices();
|
||||||
}
|
}
|
||||||
@ -1421,6 +1420,10 @@ sk_sp<SkVertices> SkShadowTessellator::MakeAmbient(const SkPath& path, const SkM
|
|||||||
sk_sp<SkVertices> SkShadowTessellator::MakeSpot(const SkPath& path, const SkMatrix& ctm,
|
sk_sp<SkVertices> SkShadowTessellator::MakeSpot(const SkPath& path, const SkMatrix& ctm,
|
||||||
const SkPoint3& zPlane, const SkPoint3& lightPos,
|
const SkPoint3& zPlane, const SkPoint3& lightPos,
|
||||||
SkScalar lightRadius, bool transparent) {
|
SkScalar lightRadius, bool transparent) {
|
||||||
|
if (!path.isFinite() || !path.isConvex() || !ctm.isFinite() || !zPlane.isFinite() ||
|
||||||
|
!lightPos.isFinite() || !SkScalarIsFinite(lightRadius) || !(lightRadius > 0)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
SkSpotShadowTessellator spotTess(path, ctm, zPlane, lightPos, lightRadius, transparent);
|
SkSpotShadowTessellator spotTess(path, ctm, zPlane, lightPos, lightRadius, transparent);
|
||||||
return spotTess.releaseVertices();
|
return spotTess.releaseVertices();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user