2018-01-19 20:07:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkSGGeometryTransform_DEFINED
|
|
|
|
#define SkSGGeometryTransform_DEFINED
|
|
|
|
|
|
|
|
#include "SkSGGeometryNode.h"
|
|
|
|
|
|
|
|
#include "SkPath.h"
|
2019-01-10 20:24:15 +00:00
|
|
|
|
|
|
|
class SkMatrix;
|
2018-01-19 20:07:29 +00:00
|
|
|
|
|
|
|
namespace sksg {
|
|
|
|
|
2019-01-10 20:24:15 +00:00
|
|
|
class Transform;
|
|
|
|
|
2018-01-19 20:07:29 +00:00
|
|
|
/**
|
|
|
|
* Concrete Effect node, binding a Matrix to a GeometryNode.
|
|
|
|
*/
|
|
|
|
class GeometryTransform final : public GeometryNode {
|
|
|
|
public:
|
2019-01-09 20:37:57 +00:00
|
|
|
static sk_sp<GeometryTransform> Make(sk_sp<GeometryNode> child, sk_sp<Transform> transform) {
|
|
|
|
return child && transform
|
|
|
|
? sk_sp<GeometryTransform>(new GeometryTransform(std::move(child),
|
|
|
|
std::move(transform)))
|
2018-01-19 20:07:29 +00:00
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
~GeometryTransform() override;
|
|
|
|
|
2019-01-09 20:37:57 +00:00
|
|
|
const sk_sp<Transform>& getTransform() const { return fTransform; }
|
2018-01-19 20:07:29 +00:00
|
|
|
|
|
|
|
protected:
|
2018-01-29 21:31:14 +00:00
|
|
|
void onClip(SkCanvas*, bool antiAlias) const override;
|
|
|
|
void onDraw(SkCanvas*, const SkPaint&) const override;
|
|
|
|
|
2018-01-19 20:07:29 +00:00
|
|
|
SkRect onRevalidate(InvalidationController*, const SkMatrix&) override;
|
|
|
|
SkPath onAsPath() const override;
|
|
|
|
|
|
|
|
private:
|
2019-01-09 20:37:57 +00:00
|
|
|
GeometryTransform(sk_sp<GeometryNode>, sk_sp<Transform>);
|
2018-01-19 20:07:29 +00:00
|
|
|
|
|
|
|
const sk_sp<GeometryNode> fChild;
|
2019-01-09 20:37:57 +00:00
|
|
|
const sk_sp<Transform> fTransform;
|
|
|
|
SkPath fTransformedPath;
|
2018-01-19 20:07:29 +00:00
|
|
|
|
2018-01-31 22:06:59 +00:00
|
|
|
using INHERITED = GeometryNode;
|
2018-01-19 20:07:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SkSGGeometryTransform_DEFINED
|