Jim Van Verth | 43475ad | 2017-01-13 14:37:37 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkShadowUtils.h" |
| 9 | #include "SkCanvas.h" |
| 10 | #include "../effects/SkShadowMaskFilter.h" |
| 11 | |
| 12 | // Draw an offset spot shadow and outlining ambient shadow for the given path. |
| 13 | void SkShadowUtils::DrawShadow(SkCanvas* canvas, const SkPath& path, SkScalar occluderHeight, |
| 14 | const SkPoint3& lightPos, SkScalar lightRadius, |
| 15 | SkScalar ambientAlpha, SkScalar spotAlpha, SkColor color, |
| 16 | uint32_t flags) { |
| 17 | SkPaint newPaint; |
| 18 | newPaint.setColor(color); |
| 19 | newPaint.setMaskFilter(SkShadowMaskFilter::Make(occluderHeight, lightPos, lightRadius, |
| 20 | ambientAlpha, spotAlpha, flags)); |
| 21 | |
| 22 | canvas->drawPath(path, newPaint); |
| 23 | } |