Chromium Code Reviews| Index: src/core/SkRecordOpts.cpp |
| diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp |
| index 7899077a99dcf040018ce199c208336d3a12e184..af137109e7e25ca43b22a5551adb6993209b204e 100644 |
| --- a/src/core/SkRecordOpts.cpp |
| +++ b/src/core/SkRecordOpts.cpp |
| @@ -87,7 +87,7 @@ struct SaveOnlyDrawsRestoreNooper { |
| } |
| }; |
| -static bool fold_opacity_layer_color_to_paint(const SkPaint& layerPaint, |
| +static bool fold_opacity_layer_color_to_paint(const SkPaint* layerPaint, |
| bool isSaveLayer, |
| SkPaint* paint) { |
| // We assume layerPaint is always from a saveLayer. If isSaveLayer is |
| @@ -121,22 +121,24 @@ static bool fold_opacity_layer_color_to_paint(const SkPaint& layerPaint, |
| return false; |
| } |
| - const uint32_t layerColor = layerPaint.getColor(); |
| + const uint32_t layerColor = layerPaint ? layerPaint->getColor() : SK_ColorBLACK; |
|
mtklein
2016/09/06 16:00:53
How about
if (layerPaint) {
SkColor layerColor
reed1
2016/09/06 16:49:44
Done.
|
| // The layer paint color must have only alpha component. |
| if (SK_ColorTRANSPARENT != SkColorSetA(layerColor, SK_AlphaTRANSPARENT)) { |
| return false; |
| } |
| - // The layer paint can not have any effects. |
| - if (layerPaint.getPathEffect() || |
| - layerPaint.getShader() || |
| - layerPaint.getXfermode() || |
| - layerPaint.getMaskFilter() || |
| - layerPaint.getColorFilter() || |
| - layerPaint.getRasterizer() || |
| - layerPaint.getLooper() || |
| - layerPaint.getImageFilter()) { |
| - return false; |
| + if (layerPaint) { |
| + // The layer paint can not have any effects. |
| + if (layerPaint->getPathEffect() || |
| + layerPaint->getShader() || |
| + layerPaint->getXfermode() || |
| + layerPaint->getMaskFilter() || |
| + layerPaint->getColorFilter() || |
| + layerPaint->getRasterizer() || |
| + layerPaint->getLooper() || |
| + layerPaint->getImageFilter()) { |
| + return false; |
| + } |
| } |
| paint->setAlpha(SkMulDiv255Round(paint->getAlpha(), SkColorGetA(layerColor))); |
| @@ -211,7 +213,7 @@ struct SaveLayerDrawRestoreNooper { |
| return false; |
| } |
| - if (!fold_opacity_layer_color_to_paint(*layerPaint, false /*isSaveLayer*/, drawPaint)) { |
| + if (!fold_opacity_layer_color_to_paint(layerPaint, false /*isSaveLayer*/, drawPaint)) { |
| return false; |
| } |
| @@ -264,7 +266,7 @@ struct SvgOpacityAndFilterLayerMergePass { |
| return false; |
| } |
| - if (!fold_opacity_layer_color_to_paint(*opacityPaint, true /*isSaveLayer*/, |
| + if (!fold_opacity_layer_color_to_paint(opacityPaint, true /*isSaveLayer*/, |
| filterLayerPaint)) { |
| return false; |
| } |