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

Method onRender

src/svg/node/SVGImage.cpp:97–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void 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
117Path SVGImage::onAsPath(const SVGRenderContext&) const {
118 return {};

Callers

nothing calls this directly

Calls 10

LoadImageFunction · 0.85
resolveRectMethod · 0.80
preTranslateMethod · 0.80
xMethod · 0.80
yMethod · 0.80
widthMethod · 0.45
heightMethod · 0.45
concatMethod · 0.45
canvasMethod · 0.45
drawImageMethod · 0.45

Tested by

no test coverage detected