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

Unified Diff: experimental/svg/model/SkSVGRenderContext.cpp

Issue 2359603002: Revert of [SVGDom] Opacity optimization (Closed)
Patch Set: Created 4 years, 3 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 | « experimental/svg/model/SkSVGRenderContext.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/svg/model/SkSVGRenderContext.cpp
diff --git a/experimental/svg/model/SkSVGRenderContext.cpp b/experimental/svg/model/SkSVGRenderContext.cpp
index 147d64edb3998bf60ed82686527ac4b3aae34505..7e2e90e22c4ddaa5ca743fbce51ea1d2c9083456 100644
--- a/experimental/svg/model/SkSVGRenderContext.cpp
+++ b/experimental/svg/model/SkSVGRenderContext.cpp
@@ -239,8 +239,7 @@
return v ? v->get() : nullptr;
}
-void SkSVGRenderContext::applyPresentationAttributes(const SkSVGPresentationAttributes& attrs,
- uint32_t flags) {
+void SkSVGRenderContext::applyPresentationAttributes(const SkSVGPresentationAttributes& attrs) {
#define ApplyLazyInheritedAttribute(ATTR) \
do { \
@@ -268,36 +267,10 @@
// Uninherited attributes. Only apply to the current context.
- if (auto* opacity = attrs.fOpacity.getMaybeNull()) {
- this->applyOpacity(opacity->value(), flags);
- }
-}
-
-void SkSVGRenderContext::applyOpacity(SkScalar opacity, uint32_t flags) {
- if (opacity >= 1) {
- return;
- }
-
- const bool hasFill = SkToBool(this->fillPaint());
- const bool hasStroke = SkToBool(this->strokePaint());
-
- // We can apply the opacity as paint alpha iif it only affects one atomic draw.
- // For now, this means a) the target node doesn't have any descendants, and
- // b) it only has a stroke or a fill (but not both). Going forward, we may need
- // to refine this heuristic (e.g. to accommodate markers).
- if ((flags & kLeaf) && (hasFill ^ hasStroke)) {
- auto* pctx = fPresentationContext.writable();
- if (hasFill) {
- pctx->fFillPaint.setAlpha(
- SkScalarRoundToInt(opacity * pctx->fFillPaint.getAlpha()));
- } else {
- pctx->fStrokePaint.setAlpha(
- SkScalarRoundToInt(opacity * pctx->fStrokePaint.getAlpha()));
- }
- } else {
- // Expensive, layer-based fall back.
+ auto* opacity = attrs.fOpacity.getMaybeNull();
+ if (opacity && opacity->value() < 1) {
SkPaint opacityPaint;
- opacityPaint.setAlpha(opacity_to_alpha(opacity));
+ opacityPaint.setAlpha(opacity_to_alpha(opacity->value()));
// Balanced in the destructor, via restoreToCount().
fCanvas->saveLayer(nullptr, &opacityPaint);
}
« no previous file with comments | « experimental/svg/model/SkSVGRenderContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698