2017-12-19 17:21:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkSGPaintNode.h"
|
|
|
|
|
|
|
|
namespace sksg {
|
|
|
|
|
2018-01-05 16:32:31 +00:00
|
|
|
// Paint nodes don't generate damage on their own, but via their aggregation ancestor Draw nodes.
|
|
|
|
PaintNode::PaintNode() : INHERITED(kBubbleDamage_Trait) {}
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
const SkPaint& PaintNode::makePaint() {
|
2018-01-03 21:17:29 +00:00
|
|
|
SkASSERT(!this->hasInval());
|
2017-12-19 17:21:02 +00:00
|
|
|
|
|
|
|
return fPaint;
|
|
|
|
}
|
|
|
|
|
2018-01-05 16:32:31 +00:00
|
|
|
SkRect PaintNode::onRevalidate(InvalidationController*, const SkMatrix&) {
|
2018-01-03 21:17:29 +00:00
|
|
|
SkASSERT(this->hasInval());
|
2017-12-19 17:21:02 +00:00
|
|
|
|
2018-01-05 16:32:31 +00:00
|
|
|
fPaint.reset();
|
|
|
|
fPaint.setAntiAlias(fAntiAlias);
|
2018-01-23 18:37:59 +00:00
|
|
|
fPaint.setBlendMode(fBlendMode);
|
2018-01-05 16:32:31 +00:00
|
|
|
fPaint.setStyle(fStyle);
|
|
|
|
fPaint.setStrokeWidth(fStrokeWidth);
|
|
|
|
fPaint.setStrokeMiter(fStrokeMiter);
|
|
|
|
fPaint.setStrokeJoin(fStrokeJoin);
|
|
|
|
fPaint.setStrokeCap(fStrokeCap);
|
2017-12-29 16:52:44 +00:00
|
|
|
|
2018-01-05 16:32:31 +00:00
|
|
|
this->onApplyToPaint(&fPaint);
|
2018-01-03 21:17:29 +00:00
|
|
|
|
2018-01-12 19:27:39 +00:00
|
|
|
// Compose opacity on top of the subclass value.
|
|
|
|
fPaint.setAlpha(SkScalarRoundToInt(fPaint.getAlpha() * SkTPin<SkScalar>(fOpacity, 0, 1)));
|
|
|
|
|
2018-01-05 16:32:31 +00:00
|
|
|
return SkRect::MakeEmpty();
|
2017-12-19 17:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace sksg
|