Skip to content

Commit 9d3c904

Browse files
committed
Use svg cache for svg fill layer
1 parent 2fcf608 commit 9d3c904

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/core/symbology-ng/qgsfillsymbollayerv2.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "qgsrendercontext.h"
66
#include "qgsproject.h"
7+
#include "qgssvgcache.h"
78

89
#include <QPainter>
910
#include <QFile>
@@ -201,6 +202,18 @@ void QgsSVGFillSymbolLayer::startRender( QgsSymbolV2RenderContext& context )
201202
return;
202203
}
203204

205+
QColor fillColor( Qt::black );
206+
QColor outlineColor( Qt::black );
207+
double outlineWidth = 1;
208+
int size = context.outputPixelSize( mPatternWidth );
209+
const QImage& patternImage = QgsSvgCache::instance()->svgAsImage( mSvgFilePath, size, fillColor, outlineColor, outlineWidth,
210+
context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor() );
211+
QTransform brushTransform;
212+
brushTransform.scale( 1.0 / context.renderContext().rasterScaleFactor(), 1.0 / context.renderContext().rasterScaleFactor() );
213+
mBrush.setTextureImage( patternImage );
214+
mBrush.setTransform( brushTransform );
215+
216+
#if 0
204217
//create QImage with appropriate dimensions
205218
int pixelWidth = context.outputPixelSize( mPatternWidth );
206219
int pixelHeight = pixelWidth / mSvgViewBox.width() * mSvgViewBox.height();
@@ -227,6 +240,7 @@ void QgsSVGFillSymbolLayer::startRender( QgsSymbolV2RenderContext& context )
227240
brushTransform.scale( 1.0 / context.renderContext().rasterScaleFactor(), 1.0 / context.renderContext().rasterScaleFactor() );
228241
mBrush.setTextureImage( textureImage );
229242
mBrush.setTransform( brushTransform );
243+
#endif //0
230244

231245
if ( mOutline )
232246
{

0 commit comments

Comments
 (0)