| 95 | } |
| 96 | |
| 97 | void SVGImage::onRender(const SVGRenderContext& context) const { |
| 98 | // Per spec: x, w, width, height attributes establish the new viewport. |
| 99 | const SVGLengthContext& lengthContext = context.lengthContext(); |
| 100 | const Rect viewPort = lengthContext.resolveRect(X, Y, Width, Height); |
| 101 | |
| 102 | ImageInfo image; |
| 103 | const auto imgInfo = LoadImage(Href, viewPort); |
| 104 | if (!imgInfo.image) { |
| 105 | LOGE("can't render image: load image failed\n"); |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | auto matrix = Matrix::MakeScale(viewPort.width() / imgInfo.destinationRect.width(), |
| 110 | viewPort.height() / imgInfo.destinationRect.height()); |
| 111 | matrix.preTranslate(imgInfo.destinationRect.x(), imgInfo.destinationRect.y()); |
| 112 | |
| 113 | context.canvas()->concat(matrix); |
| 114 | context.canvas()->drawImage(imgInfo.image); |
| 115 | } |
| 116 | |
| 117 | Path SVGImage::onAsPath(const SVGRenderContext&) const { |
| 118 | return {}; |
nothing calls this directly
no test coverage detected