Skip to content
Permalink
Browse files

[map themes] fix map renderer ignore theme blend and transparency lay…

…er settings
  • Loading branch information
nirvn committed Jun 10, 2018
1 parent ce6ea18 commit 5ba1e91d21f87f32acf147cd5086ef563f02f9ff
Showing with 17 additions and 11 deletions.
  1. +17 −11 src/core/qgsmaprendererjob.cpp
@@ -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;

@@ -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() ) );
@@ -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();
@@ -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;

0 comments on commit 5ba1e91

Please sign in to comment.
You can’t perform that action at this time.