blob: ca4c5cd1625e85374d45a922b9f8ecf6df41155f [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 Malitac75e2402018-01-03 16:17:29 -050024SkRect Transform::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
25 SkASSERT(this->hasInval());
26
27 auto bounds = this->INHERITED::onRevalidate(ic, SkMatrix::Concat(ctm, fMatrix));
28 fMatrix.mapRect(&bounds);
29
30 return bounds;
Florin Malita4aa44412017-12-19 12:21:02 -050031}
32
33} // namespace sksg