1 /* 2 * Copyright 2018 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 SkSGGeometryTransform_DEFINED 9 #define SkSGGeometryTransform_DEFINED 10 11 #include "SkSGGeometryNode.h" 12 13 #include "SkPath.h" 14 #include "SkSGTransform.h" 15 16 class SkMatrix; 17 18 namespace sksg { 19 20 /** 21 * Concrete Effect node, binding a Matrix to a GeometryNode. 22 */ 23 class GeometryTransform final : public GeometryNode { 24 public: Make(sk_sp<GeometryNode> child,sk_sp<Matrix> matrix)25 static sk_sp<GeometryTransform> Make(sk_sp<GeometryNode> child, sk_sp<Matrix> matrix) { 26 return child && matrix 27 ? sk_sp<GeometryTransform>(new GeometryTransform(std::move(child), std::move(matrix))) 28 : nullptr; 29 } 30 Make(sk_sp<GeometryNode> child,const SkMatrix & m)31 static sk_sp<GeometryTransform> Make(sk_sp<GeometryNode> child, const SkMatrix& m) { 32 return Make(std::move(child), Matrix::Make(m)); 33 } 34 35 ~GeometryTransform() override; 36 getMatrix()37 const sk_sp<Matrix>& getMatrix() const { return fMatrix; } 38 39 protected: 40 void onClip(SkCanvas*, bool antiAlias) const override; 41 void onDraw(SkCanvas*, const SkPaint&) const override; 42 43 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override; 44 SkPath onAsPath() const override; 45 46 private: 47 GeometryTransform(sk_sp<GeometryNode>, sk_sp<Matrix>); 48 49 const sk_sp<GeometryNode> fChild; 50 const sk_sp<Matrix> fMatrix; 51 SkPath fTransformed; 52 53 using INHERITED = GeometryNode; 54 }; 55 56 } 57 58 #endif // SkSGGeometryTransform_DEFINED 59