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

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
« no previous file with comments | « no previous file | tests/RecordOptsTest.cpp » ('j') | 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 7ab80546d952a1ac031626176db35c4a34a0b417..df29b1baba88efdf792ffcd89d808c55fecab55a 100644
--- a/src/core/SkRecordOpts.cpp
+++ b/src/core/SkRecordOpts.cpp
@@ -106,14 +106,12 @@ 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->setAlpha(SkMulDiv255Round(SkColorGetA(drawColor), SkColorGetA(layerColor)));
return KillSaveLayerAndRestore(record, begin);
}
@@ -145,9 +143,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);
}
« no previous file with comments | « no previous file | tests/RecordOptsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698