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

Unified Diff: src/core/SkRecordOpts.cpp

Issue 817033002: Allow the alpha folding optimization if the single draw's paint has a shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fearless Created 6 years 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 7c24a08c881da97f3898805344c6fd0f2c207706..4a51beea001df2d138dcc218fff401892859ae0c 100644
--- a/src/core/SkRecordOpts.cpp
+++ b/src/core/SkRecordOpts.cpp
@@ -112,7 +112,7 @@ struct SaveLayerDrawRestoreNooper {
const uint32_t layerColor = layerPaint->getColor();
const uint32_t drawColor = drawPaint->getColor();
if (!IsOnlyAlpha(layerColor) || !IsOpaque(drawColor) ||
- HasAnyEffect(*layerPaint) || HasAnyEffect(*drawPaint)) {
+ HasAnyEffect(*layerPaint) || CantFoldAlpha(*drawPaint)) {
// Too fancy for us. Actually, as long as layerColor is just an alpha
// we can blend it into drawColor's alpha; drawColor doesn't strictly have to be opaque.
return false;
@@ -139,6 +139,17 @@ struct SaveLayerDrawRestoreNooper {
paint.getImageFilter();
}
+ // The alpha folding can proceed if the single draw's paint has a shader,
+ // path effect, mask filter and/or rasterizer.
+ // TODO: most likely the looper and only some xfer modes are the hard
+ // constraints
+ static bool CantFoldAlpha(const SkPaint& paint) {
+ return paint.getXfermode() ||
+ paint.getColorFilter() ||
+ paint.getLooper() ||
+ paint.getImageFilter();
+ }
+
static bool IsOpaque(SkColor color) {
return SkColorGetA(color) == SK_AlphaOPAQUE;
}
« 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