Skip to content
Permalink
Browse files
Fix handling of blend modes for nested group layers
  • Loading branch information
nyalldawson committed Nov 25, 2021
1 parent 01ca203 commit e04e20cedf36f3a7c31f2eea00dcb787c9f98bff
Showing with 8 additions and 4 deletions.
  1. +7 −4 src/core/qgsgrouplayerrenderer.cpp
  2. +1 −0 src/core/qgsgrouplayerrenderer.h
@@ -55,6 +55,8 @@ QgsGroupLayerRenderer::QgsGroupLayerRenderer( QgsGroupLayer *layer, QgsRenderCon
}

mPaintEffect.reset( layer->paintEffect() ? layer->paintEffect()->clone() : nullptr );

mForceRasterRender = layer->blendMode() != QPainter::CompositionMode_SourceOver;
}

QgsGroupLayerRenderer::~QgsGroupLayerRenderer() = default;
@@ -92,6 +94,9 @@ bool QgsGroupLayerRenderer::render()
context.setExtent( extentInChildLayerCrs );

QImage image;
if ( context.useAdvancedEffects() )
context.painter()->setCompositionMode( mRendererCompositionModes[i] );

QPainter *prevPainter = context.painter();
std::unique_ptr< QPainter > imagePainter;
if ( renderer->forceRasterRender() )
@@ -110,14 +115,12 @@ bool QgsGroupLayerRenderer::render()
{
imagePainter->end();
context.setPainter( prevPainter );
if ( context.useAdvancedEffects() )
context.painter()->setCompositionMode( mRendererCompositionModes[i] );

context.painter()->setOpacity( mRendererOpacity[i] );
context.painter()->drawImage( 0, 0, image );
context.painter()->setOpacity( 1.0 );
context.painter()->setCompositionMode( QPainter::CompositionMode_SourceOver );
}
context.painter()->setCompositionMode( QPainter::CompositionMode_SourceOver );
i++;
}

@@ -136,7 +139,7 @@ bool QgsGroupLayerRenderer::forceRasterRender() const
if ( !renderContext()->testFlag( Qgis::RenderContextFlag::UseAdvancedEffects ) )
return false;

if ( !qgsDoubleNear( mLayerOpacity, 1.0 ) )
if ( mForceRasterRender || !qgsDoubleNear( mLayerOpacity, 1.0 ) )
return true;

for ( QPainter::CompositionMode mode : mRendererCompositionModes )
@@ -55,6 +55,7 @@ class CORE_EXPORT QgsGroupLayerRenderer : public QgsMapLayerRenderer

private:
std::unique_ptr< QgsFeedback > mFeedback;
bool mForceRasterRender = false;
std::vector< std::unique_ptr< QgsMapLayerRenderer > > mChildRenderers;
std::vector< QPainter::CompositionMode > mRendererCompositionModes;
std::vector< double > mRendererOpacity;

0 comments on commit e04e20c

Please sign in to comment.