blob: ce835998719dad44010224ff1e45289de9d3d1fa [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
24void 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