| 21 | |
| 22 | namespace tgfx { |
| 23 | std::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 | |
| 44 | Rect MatrixShape::getBounds() const { |
| 45 | auto bounds = shape->getBounds(); |
nothing calls this directly
no test coverage detected