[TD]use shared renderer for svg tiles

This commit is contained in:
wandererfan
2023-07-24 08:29:37 -04:00
committed by WandererFan
parent ef4ca26382
commit b3ec719c30
2 changed files with 13 additions and 5 deletions

View File

@@ -96,6 +96,8 @@ QGIFace::QGIFace(int index) :
setFillMode(PlainFill);
setFill(m_colDefFill, m_styleDef);
}
m_sharedRender = new QSvgRenderer();
}
QGIFace::~QGIFace()
@@ -540,16 +542,19 @@ void QGIFace::buildSvgHatch()
before = QString::fromStdString(SVGCOLPREFIX + SVGCOLDEFAULT).toUtf8();
after = QString::fromStdString(SVGCOLPREFIX + m_svgCol).toUtf8();
QByteArray colorXML = m_svgXML.replace(before, after);
if (!m_sharedRender->load(colorXML)) {
Base::Console().Message("QGIF::buildSvgHatch - failed to load svg string\n");
return;
}
long int tileCount = 0;
for (int iw = 0; iw < int(nw); iw++) {
for (int ih = 0; ih < int(nh); ih++) {
QGCustomSvg* tile = new QGCustomSvg();
tile->setScale(m_fillScale);
if (tile->load(&colorXML)) {
tile->setParentItem(m_svgHatchArea);
tile->setPos(iw*wTile + getHatchOffset().x,
-h + ih*hTile + getHatchOffset().y);
}
tile->setSharedRenderer(m_sharedRender);
tile->setParentItem(m_svgHatchArea);
tile->setPos(iw*wTile + getHatchOffset().x,
-h + ih*hTile + getHatchOffset().y);
tileCount++;
if (tileCount > m_maxTile) {
Base::Console().Warning("SVG tile count exceeded: %ld\n", tileCount);

View File

@@ -27,6 +27,7 @@
#include <QByteArray>
#include <QPixmap>
#include <QSvgRenderer>
#include <App/Material.h>
@@ -168,6 +169,8 @@ private:
double m_hatchRotation;
Base::Vector3d m_hatchOffset;
QSvgRenderer *m_sharedRender;
};
}