Skip to content

Commit

Permalink
Rework "Avoid artifacts when project is rendered as map tiles" option
Browse files Browse the repository at this point in the history
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 080ec98
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 )

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 080ec98

Please sign in to comment.