Skip to content
Permalink
Browse files

Tweak API

  • Loading branch information
nyalldawson committed Dec 4, 2017
1 parent be95458 commit 38cca6ca7e3e55ded6f79cdf265c1c92a92fa9f8
@@ -142,12 +142,6 @@ List of errors that happened during the rendering job - available when the rende
:rtype: int
%End

QMap< QString, int > perLayerRenderingTime() const;
%Docstring
Returns the render time (in ms) per layer, by layer ID.
.. versionadded:: 3.0
:rtype: QMap< str, int >
%End

const QgsMapSettings &mapSettings() const;
%Docstring
@@ -64,6 +64,17 @@ void QgsMapRendererJob::setCache( QgsMapRendererCache *cache )
mCache = cache;
}

QHash<QgsMapLayer *, int> QgsMapRendererJob::perLayerRenderingTime() const
{
QHash<QgsMapLayer *, int> result;
for ( auto it = mPerLayerRenderingTime.constBegin(); it != mPerLayerRenderingTime.constEnd(); ++it )
{
if ( it.key() )
result.insert( it.key(), it.value() );
}
return result;
}

const QgsMapSettings &QgsMapRendererJob::mapSettings() const
{
return mSettings;
@@ -414,7 +425,7 @@ void QgsMapRendererJob::cleanupJobs( LayerRenderJobs &jobs )
}

if ( job.layer )
mPerLayerRenderingTime.insert( job.layer->id(), job.renderingTime );
mPerLayerRenderingTime.insert( job.layer, job.renderingTime );
}

jobs.clear();
@@ -206,10 +206,11 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
int renderingTime() const { return mRenderingTime; }

/**
* Returns the render time (in ms) per layer, by layer ID.
* Returns the render time (in ms) per layer.
* \note Not available in Python bindings.
* \since QGIS 3.0
*/
QMap< QString, int > perLayerRenderingTime() const { return mPerLayerRenderingTime; }
QHash< QgsMapLayer *, int > perLayerRenderingTime() const SIP_SKIP;

/**
* Return map settings with which this job was started.
@@ -249,7 +250,7 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
int mRenderingTime = 0;

//! Render time (in ms) per layer, by layer ID
QMap< QString, int > mPerLayerRenderingTime;
QHash< QgsWeakMapLayerPointer, int > mPerLayerRenderingTime;

/**
* Prepares the cache for storing the result of labeling. Returns false if
@@ -612,7 +612,12 @@ void QgsMapCanvas::rendererJobFinished()

mMap->setContent( img, imageRect( img, mSettings ) );

mLastLayerRenderTime = mJob->perLayerRenderingTime();
mLastLayerRenderTime.clear();
const auto times = mJob->perLayerRenderingTime();
for ( auto it = times.constBegin(); it != times.constEnd(); ++it )
{
mLastLayerRenderTime.insert( it.key()->id(), it.value() );
}
if ( mUsePreviewJobs )
startPreviewJobs();
}
@@ -2284,7 +2289,7 @@ void QgsMapCanvas::startPreviewJob( int number )
context.maxRenderingTimeMs = MAXIMUM_LAYER_PREVIEW_TIME_MS;
for ( QgsMapLayer *layer : layers )
{
context.lastRenderingTimeMs = mLastLayerRenderTime.value( layer->id() );
context.lastRenderingTimeMs = mLastLayerRenderTime.value( layer->id(), 0 );
if ( !layer->dataProvider()->renderInPreview( context ) )
{
QgsDebugMsgLevel( QString( "Layer %1 not rendered because it does not match the renderInPreview criterion %2" ).arg( layer->id() ).arg( mLastLayerRenderTime.value( layer->id() ) ), 3 );
@@ -1000,7 +1000,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView

bool mUsePreviewJobs = false;

QMap< QString, int > mLastLayerRenderTime;
QHash< QString, int > mLastLayerRenderTime;

/**
* Force a resize of the map canvas item

0 comments on commit 38cca6c

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