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

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..05f366e6052170f8375af8d836b9475ab253124f 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,
mtklein 2015/01/14 13:28:31 Just FYI, SkPaint has a setAlpha() helper.
+ SkMulDiv255Round(SkColorGetA(drawColor),
+ SkColorGetA(layerColor))));
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);
}
« gm/recordopts.cpp ('K') | « gyp/gmslides.gypi ('k') | tests/RecordOptsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698