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 15 class SkMatrix; 16 17 namespace sksg { 18 19 class Transform; 20 21 /** 22 * Concrete Effect node, binding a Matrix to a GeometryNode. 23 */ 24 class GeometryTransform final : public GeometryNode { 25 public: Make(sk_sp<GeometryNode> child,sk_sp<Transform> transform)26 static sk_sp<GeometryTransform> Make(sk_sp<GeometryNode> child, sk_sp<Transform> transform) { 27 return child && transform 28 ? sk_sp<GeometryTransform>(new GeometryTransform(std::move(child), 29 std::move(transform))) 30 : nullptr; 31 } 32 33 ~GeometryTransform() override; 34 getTransform()35 const sk_sp<Transform>& getTransform() const { return fTransform; } 36 37 protected: 38 void onClip(SkCanvas*, bool antiAlias) const override; 39 void onDraw(SkCanvas*, const SkPaint&) const override; 40 41 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override; 42 SkPath onAsPath() const override; 43 44 private: 45 GeometryTransform(sk_sp<GeometryNode>, sk_sp<Transform>); 46 47 const sk_sp<GeometryNode> fChild; 48 const sk_sp<Transform> fTransform; 49 SkPath fTransformedPath; 50 51 using INHERITED = GeometryNode; 52 }; 53 54 } 55 56 #endif // SkSGGeometryTransform_DEFINED 57