Skip to content

Commit

Permalink
At the composition stage of the second pass introduced with selective…
Browse files Browse the repository at this point in the history
… masking, the unmasked elements located under the mask are copied into a temporary image buffer and then readded later to the final image.

This copy was done using the masks from selective masking with their full opacity informations. Unmasked informations were thus combined with opacity from the mask leading to the introduction of several artefacts :
* The "phantom lines" #34650 (opacity information introduced by the antialising on mask drawing)
* Opacity applied on non masked surfaces in #34947

To fix this issue a temporary mask is created for the copy of unmasked pixels, in this temporary mask the alpha channel is "binarized" (fully opaque on masking pixel, fully transparent on non masking pixel).

Should fix #34650 and fix #34947
  • Loading branch information
obrix authored and nyalldawson committed Jun 7, 2020
1 parent 76f53d2 commit 708910a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/qgsmaprendererjob.cpp
Expand Up @@ -817,7 +817,16 @@ void QgsMapRendererJob::composeSecondPass( LayerRenderJobs &secondPassJobs, Labe
// Only retain parts of the second rendering that are "inside" the mask image
QPainter *painter = job.context.painter();
painter->setCompositionMode( QPainter::CompositionMode_DestinationIn );
painter->drawImage( 0, 0, *maskImage );
QImage maskBinAlpha( *maskImage );
QRgb *pdata = ( QRgb * )maskBinAlpha.bits();
for ( int i = 0; i < maskBinAlpha.width() * maskBinAlpha.height(); ++i )
{
pdata[i] = qRgba( qRed( pdata[i] ),
qGreen( pdata[i] ),
qBlue( pdata[i] ),
qAlpha( pdata[i] ) > 0 ? 255 : 0 );
}
painter->drawImage( 0, 0, maskBinAlpha );
#if DEBUG_RENDERING
job.img->save( QString( "/tmp/second_%1_a.png" ).arg( i ) );
#endif
Expand Down

0 comments on commit 708910a

Please sign in to comment.