blob: 14c37d98b9cc798652c963106d82b65011dc1c40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkSGGeometryTransform.h"
#include "SkCanvas.h"
namespace sksg {
GeometryTransform::GeometryTransform(sk_sp<GeometryNode> child, sk_sp<Matrix> matrix)
: fChild(std::move(child))
, fMatrix(std::move(matrix)) {
fChild->addInvalReceiver(this);
fMatrix->addInvalReceiver(this);
}
GeometryTransform::~GeometryTransform() {
fChild->removeInvalReceiver(this);
fMatrix->removeInvalReceiver(this);
}
SkRect GeometryTransform::onRevalidate(InvalidationController* ic, const SkMatrix& ctm) {
SkASSERT(this->hasInval());
// We don't care about matrix reval results.
fMatrix->revalidate(ic, ctm);
const auto& m = fMatrix->getMatrix();
auto bounds = fChild->revalidate(ic, ctm);
fTransformed = fChild->asPath();
fTransformed.transform(m);
m.mapRect(&bounds);
return bounds;
}
SkPath GeometryTransform::onAsPath() const {
return fTransformed;
}
void GeometryTransform::onDraw(SkCanvas* canvas, const SkPaint& paint) const {
canvas->drawPath(fTransformed, paint);
}
} // namespace sksg
|