blob: dc31623db2a542c3de97bcd96a10838138e0cfa8 [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 "SkSGTransform.h"
9
10#include "SkCanvas.h"
11
12namespace sksg {
13
14Transform::Transform(sk_sp<RenderNode> child, const SkMatrix& matrix)
15 : INHERITED(std::move(child))
16 , fMatrix(matrix) {}
17
18void Transform::onRender(SkCanvas* canvas) const {
19 SkAutoCanvasRestore acr(canvas, !fMatrix.isIdentity());
20 canvas->concat(fMatrix);
21 this->INHERITED::onRender(canvas);
22}
23
Florin Malita0ebf4192018-01-04 19:21:58 -050024Node::RevalidationResult Transform::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
Florin Malitac75e2402018-01-03 16:17:29 -050025 SkASSERT(this->hasInval());
26
Florin Malita0ebf4192018-01-04 19:21:58 -050027 auto result = this->INHERITED::onRevalidate(ic, SkMatrix::Concat(ctm, fMatrix));
28 fMatrix.mapRect(&result.fBounds);
Florin Malitac75e2402018-01-03 16:17:29 -050029
Florin Malita0ebf4192018-01-04 19:21:58 -050030 return result;
Florin Malita4aa44412017-12-19 12:21:02 -050031}
32
33} // namespace sksg