Skip to content

Commit

Permalink
[map themes] fix map renderer ignore theme blend and transparency lay…
Browse files Browse the repository at this point in the history
…er settings
  • Loading branch information
nirvn committed Jun 11, 2018
1 parent ce6ea18 commit 5ba1e91
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/core/qgsmaprendererjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,6 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter *painter, QgsLabelingEn
LayerRenderJob &job = layerJobs.last();
job.cached = false;
job.img = nullptr;
job.blendMode = ml->blendMode();
job.opacity = 1.0;
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml ) )
{
job.opacity = vl->opacity();
}
job.layer = ml;
job.renderingTime = -1;

Expand All @@ -304,9 +298,23 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter *painter, QgsLabelingEn
if ( mFeatureFilterProvider )
job.context.setFeatureFilterProvider( mFeatureFilterProvider );

bool hasStyleOverride = mSettings.layerStyleOverrides().contains( ml->id() );
if ( hasStyleOverride )
ml->styleManager()->setOverrideStyle( mSettings.layerStyleOverrides().value( ml->id() ) );

job.blendMode = ml->blendMode();
job.opacity = 1.0;
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml ) )
{
job.opacity = vl->opacity();
}

// if we can use the cache, let's do it and avoid rendering!
if ( mCache && mCache->hasCacheImage( ml->id() ) )
{
if ( hasStyleOverride )
ml->styleManager()->restoreOverrideStyle();

job.cached = true;
job.imageInitialized = true;
job.img = new QImage( mCache->cacheImage( ml->id() ) );
Expand All @@ -327,6 +335,9 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter *painter, QgsLabelingEn
mSettings.outputImageFormat() );
if ( mypFlattenedImage->isNull() )
{
if ( hasStyleOverride )
ml->styleManager()->restoreOverrideStyle();

mErrors.append( Error( ml->id(), tr( "Insufficient memory for image %1x%2" ).arg( mSettings.outputSize().width() ).arg( mSettings.outputSize().height() ) ) );
delete mypFlattenedImage;
layerJobs.removeLast();
Expand All @@ -339,18 +350,13 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter *painter, QgsLabelingEn
job.context.setPainter( mypPainter );
}

bool hasStyleOverride = mSettings.layerStyleOverrides().contains( ml->id() );
if ( hasStyleOverride )
ml->styleManager()->setOverrideStyle( mSettings.layerStyleOverrides().value( ml->id() ) );

QTime layerTime;
layerTime.start();
job.renderer = ml->createMapRenderer( job.context );
job.renderingTime = layerTime.elapsed(); // include job preparation time in layer rendering time

if ( hasStyleOverride )
ml->styleManager()->restoreOverrideStyle();

} // while (li.hasPrevious())

return layerJobs;
Expand Down

0 comments on commit 5ba1e91

Please sign in to comment.