aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/sksg
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-01-12 14:27:39 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-12 19:48:03 +0000
commit1586d85198d17496efa93a6af812e3913882347f (patch)
tree524c24c5019888a5fd9d5e1ce6d3d216e37e5954 /experimental/sksg
parent966db9e4ee1e5485fce21a5953b426ad8bf95a9d (diff)
[skotty] Refactor paint opacity
Promote to a PaintNode attribute, drop color composite. TBR= Change-Id: Ia79d5f7e193a472d53ac4ff8beb7234d4dc26cef Reviewed-on: https://skia-review.googlesource.com/94280 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/sksg')
-rw-r--r--experimental/sksg/SkSGPaintNode.cpp3
-rw-r--r--experimental/sksg/SkSGPaintNode.h4
2 files changed, 6 insertions, 1 deletions
diff --git a/experimental/sksg/SkSGPaintNode.cpp b/experimental/sksg/SkSGPaintNode.cpp
index 146d248b8e..bb5b714030 100644
--- a/experimental/sksg/SkSGPaintNode.cpp
+++ b/experimental/sksg/SkSGPaintNode.cpp
@@ -31,6 +31,9 @@ SkRect PaintNode::onRevalidate(InvalidationController*, const SkMatrix&) {
this->onApplyToPaint(&fPaint);
+ // Compose opacity on top of the subclass value.
+ fPaint.setAlpha(SkScalarRoundToInt(fPaint.getAlpha() * SkTPin<SkScalar>(fOpacity, 0, 1)));
+
return SkRect::MakeEmpty();
}
diff --git a/experimental/sksg/SkSGPaintNode.h b/experimental/sksg/SkSGPaintNode.h
index a2fbada065..1085e27c0f 100644
--- a/experimental/sksg/SkSGPaintNode.h
+++ b/experimental/sksg/SkSGPaintNode.h
@@ -25,6 +25,7 @@ public:
const SkPaint& makePaint();
SG_ATTRIBUTE(AntiAlias , bool , fAntiAlias )
+ SG_ATTRIBUTE(Opacity , SkScalar , fOpacity )
SG_ATTRIBUTE(StrokeWidth, SkScalar , fStrokeWidth)
SG_ATTRIBUTE(StrokeMiter, SkScalar , fStrokeMiter)
SG_ATTRIBUTE(Style , SkPaint::Style, fStyle )
@@ -41,7 +42,8 @@ protected:
private:
SkPaint fPaint;
- SkScalar fStrokeWidth = 1,
+ SkScalar fOpacity = 1,
+ fStrokeWidth = 1,
fStrokeMiter = 4;
bool fAntiAlias = false;
SkPaint::Style fStyle = SkPaint::kFill_Style;