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 "SkSGDraw.h" |
| 9 | |
| 10 | #include "SkSGGeometryNode.h" |
| 11 | #include "SkSGPaintNode.h" |
| 12 | |
| 13 | namespace sksg { |
| 14 | |
| 15 | Draw::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 | |
| 22 | Draw::~Draw() { |
| 23 | fGeometry->removeInvalReceiver(this); |
| 24 | fPaint->removeInvalReceiver(this); |
| 25 | } |
| 26 | |
| 27 | void Draw::onRender(SkCanvas* canvas) const { |
| 28 | fGeometry->draw(canvas, fPaint->makePaint()); |
| 29 | } |
| 30 | |
| 31 | void 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 |