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

Unified Diff: src/core/SkRecordOpts.cpp

Issue 840483005: Fold alpha to the draw in savelayer-draw-restore patterns with non-opaque draw (Closed) Base URL: https://skia.googlesource.com/skia.git@unique-id-unflatten
Patch Set: Created 5 years, 11 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
Index: src/core/SkRecordOpts.cpp
diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp
index 4a51beea001df2d138dcc218fff401892859ae0c..17595c01c55b5cef09a6509163346f2ebb0996a2 100644
--- a/src/core/SkRecordOpts.cpp
+++ b/src/core/SkRecordOpts.cpp
@@ -111,14 +111,14 @@ struct SaveLayerDrawRestoreNooper {
const uint32_t layerColor = layerPaint->getColor();
const uint32_t drawColor = drawPaint->getColor();
- if (!IsOnlyAlpha(layerColor) || !IsOpaque(drawColor) ||
- 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.
+ if (!IsOnlyAlpha(layerColor) || HasAnyEffect(*layerPaint) || CantFoldAlpha(*drawPaint)) {
+ // Too fancy for us.
return false;
}
- drawPaint->setColor(SkColorSetA(drawColor, SkColorGetA(layerColor)));
+ drawPaint->setColor(SkColorSetA(drawColor,
+ SkFloatToIntRound(SkColorGetA(drawColor) *
mtklein 2015/01/13 18:48:20 Let's use SkMulDiv255Round?
Kimmo Kinnunen 2015/01/14 13:07:51 Done.
+ SkColorGetA(layerColor) / 255.0f)));
return KillSaveLayerAndRestore(record, begin);
}
@@ -150,9 +150,6 @@ struct SaveLayerDrawRestoreNooper {
paint.getImageFilter();
}
- static bool IsOpaque(SkColor color) {
- return SkColorGetA(color) == SK_AlphaOPAQUE;
- }
static bool IsOnlyAlpha(SkColor color) {
return SK_ColorTRANSPARENT == SkColorSetA(color, SK_AlphaTRANSPARENT);
}

Powered by Google App Engine
This is Rietveld 408576698