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 12 // Paint nodes don't generate damage on their own, but via their aggregation ancestor Draw nodes. 13 PaintNode::PaintNode() : INHERITED(kBubbleDamage_Trait) {} 14 15 const SkPaint& PaintNode::makePaint() { 16 SkASSERT(!this->hasInval()); 17 18 return fPaint; 19 } 20 21 SkRect PaintNode::onRevalidate(InvalidationController*, const SkMatrix&) { 22 SkASSERT(this->hasInval()); 23 24 fPaint.reset(); 25 fPaint.setAntiAlias(fAntiAlias); 26 fPaint.setBlendMode(fBlendMode); 27 fPaint.setStyle(fStyle); 28 fPaint.setStrokeWidth(fStrokeWidth); 29 fPaint.setStrokeMiter(fStrokeMiter); 30 fPaint.setStrokeJoin(fStrokeJoin); 31 fPaint.setStrokeCap(fStrokeCap); 32 33 this->onApplyToPaint(&fPaint); 34 35 // Compose opacity on top of the subclass value. 36 fPaint.setAlpha(SkScalarRoundToInt(fPaint.getAlpha() * SkTPin<SkScalar>(fOpacity, 0, 1))); 37 38 return SkRect::MakeEmpty(); 39 } 40 41 } // namespace sksg 42