Chromium Code Reviews| Index: src/utils/SkShadowPaintFilterCanvas.cpp |
| diff --git a/src/utils/SkShadowPaintFilterCanvas.cpp b/src/utils/SkShadowPaintFilterCanvas.cpp |
| index 31b7661296151023a8266cf67d5d74468b181dc5..3c1f712a848e3f556a283b91cb4ed8b83b8353dc 100644 |
| --- a/src/utils/SkShadowPaintFilterCanvas.cpp |
| +++ b/src/utils/SkShadowPaintFilterCanvas.cpp |
| @@ -11,7 +11,12 @@ |
| #ifdef SK_EXPERIMENTAL_SHADOWING |
| SkShadowPaintFilterCanvas::SkShadowPaintFilterCanvas(SkCanvas *canvas) |
| - : SkPaintFilterCanvas(canvas) { } |
| + : SkPaintFilterCanvas(canvas) { |
| + fShType.fShadowRadius = 0.0f; |
| + fShType.fBlurAlgorithm = SkShadowType::kNoBlur_BlurAlgorithm; |
| + fShType.fBiasingConstant = 0.0f; |
| + fShType.fMinVariance = 0.0f; |
| +} |
| // TODO use a shader instead |
| bool SkShadowPaintFilterCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type type) const { |
| @@ -24,6 +29,15 @@ bool SkShadowPaintFilterCanvas::onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Ty |
| SkColor color = 0xFF000000; // init color to opaque black |
| color |= z; // Put the index into the blue component |
| + |
| + if (fShType.fBlurAlgorithm == SkShadowType::kVariance_BlurAlgorithm) { |
| + int z2 = z * z; |
| + if (z2 > 255 * 256) { |
| + color |= (255) << 8; |
| + } else { |
| + color |= (z2 / 256) << 8; |
|
jvanverth1
2016/08/12 17:39:09
I think (z2/256) << 8 is the same as (z2 & ~0xff).
vjiaoblack
2016/08/12 19:07:42
Done.
|
| + } |
| + } |
| newPaint.setColor(color); |
| *paint->writable() = newPaint; |
| @@ -42,6 +56,9 @@ SkISize SkShadowPaintFilterCanvas::ComputeDepthMapSize(const SkLights::Light& li |
| return SkISize::Make(dMapWidth, dMapHeight); |
| } |
| +void SkShadowPaintFilterCanvas::setShadowType(SkShadowType sType) { |
| + fShType = sType; |
| +} |
| void SkShadowPaintFilterCanvas::onDrawPicture(const SkPicture *picture, const SkMatrix *matrix, |
| const SkPaint *paint) { |