mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-02 00:04:53 -04:00
add option to set max thread count
This commit is contained in:
parent
16cc66a48f
commit
9001c4768b
@ -548,6 +548,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
|
||||
chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
|
||||
chkParallelRendering->setChecked( settings.value( "/qgis/parallel_rendering", false ).toBool() );
|
||||
spinMapUpdateInterval->setValue( settings.value( "/qgis/map_update_interval", 250 ).toInt() );
|
||||
chkMaxCores->setChecked( settings.value( "/qgis/max_cores", 0 ).toInt() != 0 );
|
||||
spinMaxCores->setEnabled( chkMaxCores->isChecked() );
|
||||
spinMaxCores->setRange( 1, QThread::idealThreadCount() );
|
||||
spinMaxCores->setValue( settings.value( "/qgis/max_cores", QThread::idealThreadCount() ).toInt() );
|
||||
|
||||
// Default simplify drawing configuration
|
||||
mSimplifyDrawingGroupBox->setChecked( settings.value( "/qgis/simplifyDrawingHints", ( int )QgsVectorSimplifyMethod::GeometrySimplification ).toInt() != QgsVectorSimplifyMethod::NoSimplification );
|
||||
@ -1072,6 +1076,10 @@ void QgsOptions::saveOptions()
|
||||
settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
|
||||
settings.setValue( "/qgis/enable_render_caching", chkUseRenderCaching->isChecked() );
|
||||
settings.setValue( "/qgis/parallel_rendering", chkParallelRendering->isChecked() );
|
||||
if ( chkMaxCores->isChecked() )
|
||||
settings.setValue( "/qgis/max_cores", int( spinMaxCores->value() ) );
|
||||
else
|
||||
settings.remove( "/qgis/max_cores" );
|
||||
settings.setValue( "/qgis/map_update_interval", spinMapUpdateInterval->value() );
|
||||
settings.setValue( "/qgis/legendDoubleClickAction", cmbLegendDoubleClickAction->currentIndex() );
|
||||
bool legendLayersCapitalise = settings.value( "/qgis/capitaliseLayerName", false ).toBool();
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QtConcurrentMap>
|
||||
#include <QSettings>
|
||||
|
||||
#include "qgscrscache.h"
|
||||
#include "qgslogger.h"
|
||||
@ -731,6 +732,14 @@ void QgsMapRendererParallelJob::start()
|
||||
|
||||
mLayerJobs = prepareJobs( 0, mLabelingEngine );
|
||||
|
||||
// set max thread count
|
||||
QSettings settings;
|
||||
int max_cores = settings.value( "/qgis/max_cores", 0 ).toInt();
|
||||
if ( max_cores <= 0 || max_cores > QThread::idealThreadCount() )
|
||||
max_cores = QThread::idealThreadCount();
|
||||
QThreadPool::globalInstance()->setMaxThreadCount( max_cores );
|
||||
qDebug( "set max thread count to %d", QThreadPool::globalInstance()->maxThreadCount() );
|
||||
|
||||
// start async job
|
||||
|
||||
connect( &mFutureWatcher, SIGNAL( finished() ), SLOT( renderLayersFinished() ) );
|
||||
@ -829,6 +838,10 @@ QImage QgsMapRendererParallelJob::renderedImage()
|
||||
|
||||
void QgsMapRendererParallelJob::renderLayersFinished()
|
||||
{
|
||||
// restore max thread count
|
||||
QThreadPool::globalInstance()->setMaxThreadCount( QThread::idealThreadCount() );
|
||||
qDebug( "restored max thread count to ideal (%d)", QThreadPool::globalInstance()->maxThreadCount() );
|
||||
|
||||
Q_ASSERT( mStatus == RenderingLayers );
|
||||
|
||||
// compose final image
|
||||
|
@ -1629,11 +1629,45 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkParallelRendering">
|
||||
<property name="text">
|
||||
<string>Render layers in parallel using all available CPU cores</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_26">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkParallelRendering">
|
||||
<property name="text">
|
||||
<string>Render layers in parallel using many CPU cores</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkMaxCores">
|
||||
<property name="text">
|
||||
<string>Max cores to use:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinMaxCores"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_41">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
@ -4598,5 +4632,21 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>chkMaxCores</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinMaxCores</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>589</x>
|
||||
<y>110</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>689</x>
|
||||
<y>110</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user