diff options
author | fmalita <fmalita@chromium.org> | 2016-08-15 12:45:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-15 12:45:11 -0700 |
commit | 6fb0648c35aead138e65133c031d2b4fe5c8f0c7 (patch) | |
tree | 20dc5450da40f37e1e68e1ade072ee81c456939a /experimental/svg/model/SkSVGRenderContext.cpp | |
parent | d39430d0574513438b5831947052353290204a06 (diff) |
[SVGDom] Add opacity support
Group opacity support. Unlike the other presentation attributes we
support thus far, group opacity is not inherited.
R=robertphillips@google.com,stephana@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2246943002
Review-Url: https://codereview.chromium.org/2246943002
Diffstat (limited to 'experimental/svg/model/SkSVGRenderContext.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGRenderContext.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/experimental/svg/model/SkSVGRenderContext.cpp b/experimental/svg/model/SkSVGRenderContext.cpp index ee92c47d54..8ad881429a 100644 --- a/experimental/svg/model/SkSVGRenderContext.cpp +++ b/experimental/svg/model/SkSVGRenderContext.cpp @@ -224,6 +224,15 @@ void SkSVGRenderContext::applyPresentationAttributes(const SkSVGPresentationAttr ApplyLazyInheritedAttribute(StrokeWidth); #undef ApplyLazyInheritedAttribute + + // Uninherited attributes. Only apply to the current context. + + if (auto* opacity = attrs.fOpacity.getMaybeNull()) { + SkPaint opacityPaint; + opacityPaint.setAlpha(static_cast<uint8_t>(opacity->value() * 255)); + // Balanced in the destructor, via restoreToCount(). + fCanvas->saveLayer(nullptr, &opacityPaint); + } } const SkPaint* SkSVGRenderContext::fillPaint() const { |