aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/sksg/effects/SkSGTransform.h
blob: 8a97a679ed86e1c60e2757a79cd01fc8361b0f26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkSGTransform_DEFINED
#define SkSGTransform_DEFINED

#include "SkSGEffectNode.h"

#include "SkMatrix.h"

namespace sksg {

/**
 * Concrete Effect node, wrapping an SkMatrix.
 */
class Transform : public EffectNode {
public:
    static sk_sp<Transform> Make(sk_sp<RenderNode> child, const SkMatrix& matrix) {
        return sk_sp<Transform>(new Transform(std::move(child), matrix));
    }

    SG_ATTRIBUTE(Matrix, SkMatrix, fMatrix)

protected:
    Transform(sk_sp<RenderNode>, const SkMatrix&);

    void onRender(SkCanvas*) const override;

    RevalidationResult onRevalidate(InvalidationController*, const SkMatrix&) override;

private:
    SkMatrix fMatrix;

    typedef EffectNode INHERITED;
};

} // namespace sksg

#endif // SkSGTransform_DEFINED