aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-12-21 10:52:01 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-21 10:52:01 -0800
commitca32da7533ed86fbbe50e078c751b0f1c198bb5b (patch)
tree64d5bb836dda816e7fb9135d3bf327f303c2df6d /src/core
parentfa4f6cba2f9260cec345ec51fb3687c20c50fa61 (diff)
Allow the alpha folding optimization if the single draw's paint has a shader
Let's land this and then leave for 2 weeks. BUG=skia:3119 Review URL: https://codereview.chromium.org/817033002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkRecordOpts.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp
index 7c24a08c88..4a51beea00 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;
}