blob: c929fc60bcc3d3d853320d37eb04460812aa9b18 [file] [log] [blame]
Florin Malita4aa44412017-12-19 12:21:02 -05001/*
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
10namespace sksg {
11
Florin Malitac14f1442018-01-05 11:32:31 -050012// Paint nodes don't generate damage on their own, but via their aggregation ancestor Draw nodes.
13PaintNode::PaintNode() : INHERITED(kBubbleDamage_Trait) {}
Florin Malita4aa44412017-12-19 12:21:02 -050014
Florin Malita97df5dc2018-09-10 15:53:27 -040015SkPaint PaintNode::makePaint() const {
Florin Malitac75e2402018-01-03 16:17:29 -050016 SkASSERT(!this->hasInval());
Florin Malita4aa44412017-12-19 12:21:02 -050017
Florin Malita97df5dc2018-09-10 15:53:27 -040018 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 Malita4aa44412017-12-19 12:21:02 -050034}
35
Florin Malitac14f1442018-01-05 11:32:31 -050036SkRect PaintNode::onRevalidate(InvalidationController*, const SkMatrix&) {
Florin Malitac75e2402018-01-03 16:17:29 -050037 SkASSERT(this->hasInval());
Florin Malita4aa44412017-12-19 12:21:02 -050038
Florin Malitac14f1442018-01-05 11:32:31 -050039 return SkRect::MakeEmpty();
Florin Malita4aa44412017-12-19 12:21:02 -050040}
41
42} // namespace sksg