aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-04-20 15:48:37 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-21 15:23:53 +0000
commit8f7dc9f6caabe798723d9f17aff371121369b846 (patch)
tree5062e5b6d635476d519ff6e4dd3dfef39de0ae79 /src/utils
parent5e958e9291f53b81045f776a2af3a871381dd5fb (diff)
Circular shadow fixes for Flutter.
* Fix spot shadow placement for SkSpotShadowMaskFilter. * Make sure we don't try to render an oval as a plain RRect due to floating point error. * Use fast path for uncached circles. * Make sure ShadowMaskFilters can handle near-circles. Change-Id: Ia9967a00a6e1c980a1c0a7ba8248f09fde61a3b7 Reviewed-on: https://skia-review.googlesource.com/13969 Reviewed-by: Jim Van Verth <jvanverth@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/SkShadowUtils.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/utils/SkShadowUtils.cpp b/src/utils/SkShadowUtils.cpp
index 2e560b454e..8206bd3f54 100644
--- a/src/utils/SkShadowUtils.cpp
+++ b/src/utils/SkShadowUtils.cpp
@@ -471,12 +471,12 @@ void SkShadowUtils::DrawShadow(SkCanvas* canvas, const SkPath& path, SkScalar oc
if (ambientAlpha > 0) {
newPaint.setMaskFilter(SkAmbientShadowMaskFilter::Make(occluderHeight, ambientAlpha,
flags));
- canvas->drawPath(path, newPaint);
+ canvas->drawOval(rect, newPaint);
}
if (spotAlpha > 0) {
newPaint.setMaskFilter(SkSpotShadowMaskFilter::Make(occluderHeight, devLightPos,
lightRadius, spotAlpha, flags));
- canvas->drawPath(path, newPaint);
+ canvas->drawOval(rect, newPaint);
}
return;
}
@@ -565,6 +565,26 @@ void SkShadowUtils::DrawUncachedShadow(SkCanvas* canvas, const SkPath& path,
uint32_t flags) {
SkAutoCanvasRestore acr(canvas, true);
SkMatrix viewMatrix = canvas->getTotalMatrix();
+
+ // try circular fast path
+ SkRect rect;
+ if (viewMatrix.isSimilarity() &&
+ path.isOval(&rect) && rect.width() == rect.height()) {
+ SkPaint newPaint;
+ newPaint.setColor(color);
+ if (ambientAlpha > 0) {
+ newPaint.setMaskFilter(SkAmbientShadowMaskFilter::Make(heightFunc(0,0), ambientAlpha,
+ flags));
+ canvas->drawOval(rect, newPaint);
+ }
+ if (spotAlpha > 0) {
+ newPaint.setMaskFilter(SkSpotShadowMaskFilter::Make(heightFunc(0,0), lightPos,
+ lightRadius, spotAlpha, flags));
+ canvas->drawOval(rect, newPaint);
+ }
+ return;
+ }
+
canvas->resetMatrix();
bool transparent = SkToBool(flags & SkShadowFlags::kTransparentOccluder_ShadowFlag);