Skip to content
Permalink
Browse files

Rework "Avoid artifacts when project is rendered as map tiles" option

Instead of force disabling ALL feature clipping to rendered map bounds
(which is INCREDIBLY expensive to disable, and can result in slooow
map renders), be more intelligent and only disable the feature clipping
for symbols where we know there'll be visible map tile artifacts
between neighbouring tiles.

If there's not going to be any artifacts (eg the symbol is a solid
color fill), then it's pointless to disable the huge speed boost
we get from the automatic geometry clipping...
  • Loading branch information
nyalldawson committed Feb 12, 2021
1 parent cc208f4 commit 080ec9896404975277126f5a074a631f0c30f859
Showing with 14 additions and 4 deletions.
  1. +14 −4 src/core/symbology/qgssymbol.cpp
@@ -917,7 +917,17 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
}
}

bool tileMapRendering = context.testFlag( QgsRenderContext::RenderMapTile );
bool clippingEnabled = clipFeaturesToExtent();
if ( clippingEnabled && context.testFlag( QgsRenderContext::RenderMapTile ) )
{
// If the "avoid artifacts between adjacent tiles" flag is set (RenderMapTile), then we'll force disable
// the geometry clipping IF (and only if) this symbol can potentially have rendering artifacts when rendered as map tiles.
// If the symbol won't have any artifacts anyway, then it's pointless and incredibly expensive to skip the clipping!
if ( canCauseArtifactsBetweenAdjacentTiles() )
{
clippingEnabled = false;
}
}

mSymbolRenderContext->setGeometryPartCount( geom.constGet()->partCount() );
mSymbolRenderContext->setGeometryPartNum( 1 );
@@ -973,7 +983,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
QVector< PolygonInfo > polygonsToRender;

std::function< void ( const QgsAbstractGeometry * )> getPartGeometry;
getPartGeometry = [&pointsToRender, &linesToRender, &polygonsToRender, &getPartGeometry, &context, &tileMapRendering, &markers, &feature, &usingSegmentizedGeometry, this]( const QgsAbstractGeometry * part )
getPartGeometry = [&pointsToRender, &linesToRender, &polygonsToRender, &getPartGeometry, &context, &clippingEnabled, &markers, &feature, &usingSegmentizedGeometry, this]( const QgsAbstractGeometry * part )
{
Q_UNUSED( feature )

@@ -1078,7 +1088,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont

LineInfo info;
info.originalGeometry = qgsgeometry_cast<const QgsCurve *>( part );
info.renderLine = _getLineString( context, *qgsgeometry_cast<const QgsCurve *>( processedGeometry ), !tileMapRendering && clipFeaturesToExtent() );
info.renderLine = _getLineString( context, *qgsgeometry_cast<const QgsCurve *>( processedGeometry ), clippingEnabled );
linesToRender << info;
break;
}
@@ -1101,7 +1111,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
break;
}

_getPolygon( info.renderExterior, info.renderRings, context, *qgsgeometry_cast<const QgsPolygon *>( processedGeometry ), !tileMapRendering && clipFeaturesToExtent(), mForceRHR );
_getPolygon( info.renderExterior, info.renderRings, context, *qgsgeometry_cast<const QgsPolygon *>( processedGeometry ), clippingEnabled, mForceRHR );
polygonsToRender << info;
break;
}

0 comments on commit 080ec98

Please sign in to comment.