Florin Malita | 4aa4441 | 2017-12-19 12:21:02 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkSGPaintNode.h" |
| 9 | |
| 10 | namespace sksg { |
| 11 | |
Florin Malita | c14f144 | 2018-01-05 11:32:31 -0500 | [diff] [blame] | 12 | // Paint nodes don't generate damage on their own, but via their aggregation ancestor Draw nodes. |
| 13 | PaintNode::PaintNode() : INHERITED(kBubbleDamage_Trait) {} |
Florin Malita | 4aa4441 | 2017-12-19 12:21:02 -0500 | [diff] [blame] | 14 | |
Florin Malita | 97df5dc | 2018-09-10 15:53:27 -0400 | [diff] [blame] | 15 | SkPaint PaintNode::makePaint() const { |
Florin Malita | c75e240 | 2018-01-03 16:17:29 -0500 | [diff] [blame] | 16 | SkASSERT(!this->hasInval()); |
Florin Malita | 4aa4441 | 2017-12-19 12:21:02 -0500 | [diff] [blame] | 17 | |
Florin Malita | 97df5dc | 2018-09-10 15:53:27 -0400 | [diff] [blame] | 18 | SkPaint paint; |
| 19 | |
| 20 | paint.setAntiAlias(fAntiAlias); |
| 21 | paint.setBlendMode(fBlendMode); |
| 22 | paint.setStyle(fStyle); |
| 23 | paint.setStrokeWidth(fStrokeWidth); |
| 24 | paint.setStrokeMiter(fStrokeMiter); |
| 25 | paint.setStrokeJoin(fStrokeJoin); |
| 26 | paint.setStrokeCap(fStrokeCap); |
| 27 | |
| 28 | this->onApplyToPaint(&paint); |
| 29 | |
| 30 | // Compose opacity on top of the subclass value. |
| 31 | paint.setAlpha(SkScalarRoundToInt(paint.getAlpha() * SkTPin<SkScalar>(fOpacity, 0, 1))); |
| 32 | |
| 33 | return paint; |
Florin Malita | 4aa4441 | 2017-12-19 12:21:02 -0500 | [diff] [blame] | 34 | } |
| 35 | |
Florin Malita | c14f144 | 2018-01-05 11:32:31 -0500 | [diff] [blame] | 36 | SkRect PaintNode::onRevalidate(InvalidationController*, const SkMatrix&) { |
Florin Malita | c75e240 | 2018-01-03 16:17:29 -0500 | [diff] [blame] | 37 | SkASSERT(this->hasInval()); |
Florin Malita | 4aa4441 | 2017-12-19 12:21:02 -0500 | [diff] [blame] | 38 | |
Florin Malita | c14f144 | 2018-01-05 11:32:31 -0500 | [diff] [blame] | 39 | return SkRect::MakeEmpty(); |
Florin Malita | 4aa4441 | 2017-12-19 12:21:02 -0500 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | } // namespace sksg |