Fix analytic shadows when rotated 180 degrees.
A 180 degree rotation matrix is functionally like a scale matrix, but the elements are negative. To compensate for this, we use abs(). Bug: b/137547660 Change-Id: Ib0e7449872523af024e7de9005b9bb70743e04b5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229394 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
fa3305ae3f
commit
eda9a55baa
@ -96,6 +96,7 @@ void draw_paths(SkCanvas* canvas, ShadowMode mode) {
|
|||||||
m->postScale(1.2f, 0.8f, 25.f, 25.f);
|
m->postScale(1.2f, 0.8f, 25.f, 25.f);
|
||||||
for (auto& m : matrices) {
|
for (auto& m : matrices) {
|
||||||
for (int flags : { kNone_ShadowFlag, kTransparentOccluder_ShadowFlag }) {
|
for (int flags : { kNone_ShadowFlag, kTransparentOccluder_ShadowFlag }) {
|
||||||
|
int pathCounter = 0;
|
||||||
for (const auto& path : paths) {
|
for (const auto& path : paths) {
|
||||||
SkRect postMBounds = path.getBounds();
|
SkRect postMBounds = path.getBounds();
|
||||||
m.mapRect(&postMBounds);
|
m.mapRect(&postMBounds);
|
||||||
@ -112,6 +113,11 @@ void draw_paths(SkCanvas* canvas, ShadowMode mode) {
|
|||||||
canvas->save();
|
canvas->save();
|
||||||
canvas->concat(m);
|
canvas->concat(m);
|
||||||
|
|
||||||
|
// flip a couple of paths to test 180° rotation
|
||||||
|
if (kTransparentOccluder_ShadowFlag == flags && 0 == pathCounter % 3) {
|
||||||
|
canvas->save();
|
||||||
|
canvas->rotate(180, 25, 25);
|
||||||
|
}
|
||||||
if (kDebugColorNoOccluders == mode || kDebugColorOccluders == mode) {
|
if (kDebugColorNoOccluders == mode || kDebugColorOccluders == mode) {
|
||||||
draw_shadow(canvas, path, kHeight, SK_ColorRED, lightPos, kLightR,
|
draw_shadow(canvas, path, kHeight, SK_ColorRED, lightPos, kLightR,
|
||||||
true, flags);
|
true, flags);
|
||||||
@ -143,11 +149,15 @@ void draw_paths(SkCanvas* canvas, ShadowMode mode) {
|
|||||||
paint.setStyle(SkPaint::kFill_Style);
|
paint.setStyle(SkPaint::kFill_Style);
|
||||||
}
|
}
|
||||||
canvas->drawPath(path, paint);
|
canvas->drawPath(path, paint);
|
||||||
|
if (kTransparentOccluder_ShadowFlag == flags && 0 == pathCounter % 3) {
|
||||||
|
canvas->restore();
|
||||||
|
}
|
||||||
canvas->restore();
|
canvas->restore();
|
||||||
|
|
||||||
canvas->translate(dx, 0);
|
canvas->translate(dx, 0);
|
||||||
x += dx;
|
x += dx;
|
||||||
dy = SkTMax(dy, postMBounds.height() + kPad + kHeight);
|
dy = SkTMax(dy, postMBounds.height() + kPad + kHeight);
|
||||||
|
++pathCounter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1139,7 @@ bool GrRenderTargetContext::drawFastShadow(const GrClip& clip,
|
|||||||
|
|
||||||
// 1/scale
|
// 1/scale
|
||||||
SkScalar devToSrcScale = viewMatrix.isScaleTranslate() ?
|
SkScalar devToSrcScale = viewMatrix.isScaleTranslate() ?
|
||||||
SkScalarInvert(viewMatrix[SkMatrix::kMScaleX]) :
|
SkScalarInvert(SkScalarAbs(viewMatrix[SkMatrix::kMScaleX])) :
|
||||||
sk_float_rsqrt(viewMatrix[SkMatrix::kMScaleX] * viewMatrix[SkMatrix::kMScaleX] +
|
sk_float_rsqrt(viewMatrix[SkMatrix::kMScaleX] * viewMatrix[SkMatrix::kMScaleX] +
|
||||||
viewMatrix[SkMatrix::kMSkewX] * viewMatrix[SkMatrix::kMSkewX]);
|
viewMatrix[SkMatrix::kMSkewX] * viewMatrix[SkMatrix::kMSkewX]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user