Implement tilted concave ambient shadow

Bug: skia:7971
Change-Id: I6a92a5021f53ae10fb35ef355081653e96bc04b0
Reviewed-on: https://skia-review.googlesource.com/134844
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Jim Van Verth 2018-06-14 14:43:00 -04:00 committed by Skia Commit-Bot
parent 0510edeebf
commit e39bc9fd43
2 changed files with 19 additions and 3 deletions

View File

@ -315,6 +315,7 @@ protected:
fWideOvalPath.getBounds().height() / 2);
translate = SkPoint::Make(100, 600);
view.restore();
view.save();
view.rotateY(fAnimAngle);
view.getMatrix(&persp);
persp.preTranslate(-pivot.fX, -pivot.fY);
@ -325,6 +326,21 @@ protected:
SkTMax(1.0f, 32 + fZDelta) + SkScalarSin(radians)*pivot.fX);
this->drawShadowedPath(canvas, fWideOvalPath, zPlaneParams, paint, .1f,
lightPos, kLightWidth, .5f);
pivot = SkPoint::Make(fStarPath.getBounds().width() / 2,
fStarPath.getBounds().height() / 2);
translate = SkPoint::Make(700, 250);
view.restore();
view.rotateY(fAnimAngle);
view.getMatrix(&persp);
persp.preTranslate(-pivot.fX, -pivot.fY);
persp.postTranslate(pivot.fX + translate.fX, pivot.fY + translate.fY);
canvas->setMatrix(persp);
zPlaneParams = SkPoint3::Make(-SkScalarSin(radians),
0,
SkTMax(1.0f, 8 + fZDelta) + SkScalarSin(radians)*pivot.fX);
this->drawShadowedPath(canvas, fStarPath, zPlaneParams, paint, .1f,
lightPos, kLightWidth, .5f);
}
bool onAnimate(const SkAnimTimer& timer) override {

View File

@ -794,9 +794,9 @@ bool SkAmbientShadowTessellator::computeConcaveShadow() {
SkTDArray<int> penumbraIndices;
penumbraPolygon.setReserve(umbraPolygon.count());
penumbraIndices.setReserve(umbraPolygon.count());
// TODO: handle tilt
SkScalar radius = this->offset(fTransformedHeightFunc(fPathPolygon[0]));
if (!SkOffsetSimplePolygon(&fPathPolygon[0], fPathPolygon.count(), -radius,
auto offsetFunc = [this](const SkPoint& p) { return -this->offset(fTransformedHeightFunc(p)); };
if (!SkOffsetSimplePolygon(&fPathPolygon[0], fPathPolygon.count(), offsetFunc,
&penumbraPolygon, &penumbraIndices)) {
// TODO: figure out how to handle this case
return false;