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 "SkSGTransform.h" |
| 9 | |
| 10 | #include "SkCanvas.h" |
| 11 | |
| 12 | namespace sksg { |
| 13 | |
| 14 | Transform::Transform(sk_sp<RenderNode> child, const SkMatrix& matrix) |
| 15 | : INHERITED(std::move(child)) |
| 16 | , fMatrix(matrix) {} |
| 17 | |
| 18 | void Transform::onRender(SkCanvas* canvas) const { |
| 19 | SkAutoCanvasRestore acr(canvas, !fMatrix.isIdentity()); |
| 20 | canvas->concat(fMatrix); |
| 21 | this->INHERITED::onRender(canvas); |
| 22 | } |
| 23 | |
| 24 | void Transform::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) { |
| 25 | const auto localCTM = SkMatrix::Concat(ctm, fMatrix); |
| 26 | this->INHERITED::onRevalidate(ic, localCTM); |
| 27 | } |
| 28 | |
| 29 | } // namespace sksg |