blob: 7319c635fe3c9ee5693af96ad74c20dd2a5bf51b [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 "SkSGDraw.h"
9
10#include "SkSGGeometryNode.h"
11#include "SkSGPaintNode.h"
12
13namespace sksg {
14
15Draw::Draw(sk_sp<GeometryNode> geometry, sk_sp<PaintNode> paint)
16 : fGeometry(std::move(geometry))
17 , fPaint(std::move(paint)) {
18 fGeometry->addInvalReceiver(this);
19 fPaint->addInvalReceiver(this);
20}
21
22Draw::~Draw() {
23 fGeometry->removeInvalReceiver(this);
24 fPaint->removeInvalReceiver(this);
25}
26
27void Draw::onRender(SkCanvas* canvas) const {
28 fGeometry->draw(canvas, fPaint->makePaint());
29}
30
31void Draw::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
32 SkASSERT(this->isInvalidated());
33
34 fGeometry->revalidate(ic, ctm);
35 fPaint->revalidate(ic, ctm);
36}
37
38} // namespace sksg