[SVGDom] Only apply opacity when needed
authorfmalita <fmalita@chromium.org>
Mon, 19 Sep 2016 13:42:39 +0000 (06:42 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 19 Sep 2016 13:42:39 +0000 (06:42 -0700)
Opacity: 1 is a no-op, but it shows up quite a bit in existing documents.

R=robertphillips@google.com,stephana@google.com,reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2349143002

Review-Url: https://codereview.chromium.org/2349143002

experimental/svg/model/SkSVGRenderContext.cpp

index 46ed5a2..7e2e90e 100644 (file)
@@ -267,7 +267,8 @@ void SkSVGRenderContext::applyPresentationAttributes(const SkSVGPresentationAttr
 
     // Uninherited attributes.  Only apply to the current context.
 
-    if (auto* opacity = attrs.fOpacity.getMaybeNull()) {
+    auto* opacity = attrs.fOpacity.getMaybeNull();
+    if (opacity && opacity->value() < 1) {
         SkPaint opacityPaint;
         opacityPaint.setAlpha(opacity_to_alpha(opacity->value()));
         // Balanced in the destructor, via restoreToCount().