Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: src/core/SkRecordOpts.cpp

Issue 2314073002: check for null-layer-paint after prev fix to savelayer ops (Closed)
Patch Set: combine layerPaint sections Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRecordOpts.cpp
diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp
index 7899077a99dcf040018ce199c208336d3a12e184..d46a6573b5f055a12d0cb373d4cad7d4dcaf017a 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,26 +121,27 @@ static bool fold_opacity_layer_color_to_paint(const SkPaint& layerPaint,
return false;
}
- const uint32_t layerColor = layerPaint.getColor();
- // The layer paint color must have only alpha component.
- if (SK_ColorTRANSPARENT != SkColorSetA(layerColor, SK_AlphaTRANSPARENT)) {
- return false;
- }
+ if (layerPaint) {
+ const uint32_t layerColor = layerPaint->getColor();
+ // 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;
+ // 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)));
}
- paint->setAlpha(SkMulDiv255Round(paint->getAlpha(), SkColorGetA(layerColor)));
-
return true;
}
@@ -211,7 +212,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 +265,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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698