MCPcopy Create free account
hub / github.com/Tencent/tgfx / ApplyMatrix

Method ApplyMatrix

src/core/shapes/MatrixShape.cpp:23–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22namespace tgfx {
23std::shared_ptr<Shape> Shape::ApplyMatrix(std::shared_ptr<Shape> shape, const Matrix& matrix) {
24 if (shape == nullptr) {
25 return nullptr;
26 }
27 if (matrix.isIdentity()) {
28 return shape;
29 }
30 if (!matrix.invertible()) {
31 return nullptr;
32 }
33 if (shape->type() != Type::Matrix) {
34 return std::make_shared<MatrixShape>(std::move(shape), matrix);
35 }
36 auto matrixShape = std::static_pointer_cast<MatrixShape>(shape);
37 auto totalMatrix = matrix * matrixShape->matrix;
38 if (totalMatrix.isIdentity()) {
39 return matrixShape->shape;
40 }
41 return std::make_shared<MatrixShape>(matrixShape->shape, totalMatrix);
42}
43
44Rect MatrixShape::getBounds() const {
45 auto bounds = shape->getBounds();

Callers

nothing calls this directly

Calls 3

isIdentityMethod · 0.80
invertibleMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected