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 "modules/sksg/include/SkSGGeometryNode.h" 12 13 #include "include/core/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 bool onContains(const SkPoint&) const override; 41 42 SkRect onRevalidate(InvalidationController*, const SkMatrix&) override; 43 SkPath onAsPath() const override; 44 45 private: 46 GeometryTransform(sk_sp<GeometryNode>, sk_sp<Transform>); 47 48 const sk_sp<GeometryNode> fChild; 49 const sk_sp<Transform> fTransform; 50 SkPath fTransformedPath; 51 52 using INHERITED = GeometryNode; 53 }; 54 55 } 56 57 #endif // SkSGGeometryTransform_DEFINED 58