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 | #ifndef SkSGTransform_DEFINED |
| 9 | #define SkSGTransform_DEFINED |
| 10 | |
| 11 | #include "SkSGEffectNode.h" |
| 12 | |
| 13 | #include "SkMatrix.h" |
| 14 | |
| 15 | namespace sksg { |
| 16 | |
| 17 | /** |
| 18 | * Concrete Effect node, wrapping an SkMatrix. |
| 19 | */ |
| 20 | class Transform : public EffectNode { |
| 21 | public: |
| 22 | static sk_sp<Transform> Make(sk_sp<RenderNode> child, const SkMatrix& matrix) { |
| 23 | return sk_sp<Transform>(new Transform(std::move(child), matrix)); |
| 24 | } |
| 25 | |
| 26 | SG_ATTRIBUTE(Matrix, SkMatrix, fMatrix) |
| 27 | |
| 28 | protected: |
| 29 | Transform(sk_sp<RenderNode>, const SkMatrix&); |
| 30 | |
| 31 | void onRender(SkCanvas*) const override; |
| 32 | |
| 33 | void onRevalidate(InvalidationController*, const SkMatrix&) override; |
| 34 | |
| 35 | private: |
| 36 | SkMatrix fMatrix; |
| 37 | |
| 38 | typedef EffectNode INHERITED; |
| 39 | }; |
| 40 | |
| 41 | } // namespace sksg |
| 42 | |
| 43 | #endif // SkSGTransform_DEFINED |