Skip to content

Commit

Permalink
Optimize simple marker: do not construct/destruct "size" all the time
Browse files Browse the repository at this point in the history
13% speedup when rendering 1m points from memory provider
  • Loading branch information
wonder-sk committed Oct 3, 2014
1 parent 86015ea commit fbbea90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Expand Up @@ -45,6 +45,8 @@ static void _fixQPictureDPI( QPainter* p )
( double )qt_defaultDpiY() / p->device()->logicalDpiY() );
}

const QString QgsSimpleMarkerSymbolLayerV2::EXPR_SIZE( "size" );

//////

QgsSimpleMarkerSymbolLayerV2::QgsSimpleMarkerSymbolLayerV2( QString name, QColor color, QColor borderColor, double size, double angle, QgsSymbolV2::ScaleMethod scaleMethod )
Expand Down Expand Up @@ -504,7 +506,7 @@ void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV
return;
}

QgsExpression *sizeExpression = expression( "size" );
QgsExpression *sizeExpression = expression( EXPR_SIZE );
bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale || sizeExpression;

double scaledSize = mSize;
Expand Down
2 changes: 2 additions & 0 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.h
Expand Up @@ -133,6 +133,8 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
//Maximum width/height of cache image
static const int mMaximumCacheWidth = 3000;

static const QString EXPR_SIZE;

private:
QgsExpression *mAngleExpression;
QgsExpression *mNameExpression;
Expand Down

0 comments on commit fbbea90

Please sign in to comment.