mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-06 00:05:16 -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() );
|
chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
|
||||||
chkParallelRendering->setChecked( settings.value( "/qgis/parallel_rendering", false ).toBool() );
|
chkParallelRendering->setChecked( settings.value( "/qgis/parallel_rendering", false ).toBool() );
|
||||||
spinMapUpdateInterval->setValue( settings.value( "/qgis/map_update_interval", 250 ).toInt() );
|
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
|
// Default simplify drawing configuration
|
||||||
mSimplifyDrawingGroupBox->setChecked( settings.value( "/qgis/simplifyDrawingHints", ( int )QgsVectorSimplifyMethod::GeometrySimplification ).toInt() != QgsVectorSimplifyMethod::NoSimplification );
|
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_anti_aliasing", chkAntiAliasing->isChecked() );
|
||||||
settings.setValue( "/qgis/enable_render_caching", chkUseRenderCaching->isChecked() );
|
settings.setValue( "/qgis/enable_render_caching", chkUseRenderCaching->isChecked() );
|
||||||
settings.setValue( "/qgis/parallel_rendering", chkParallelRendering->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/map_update_interval", spinMapUpdateInterval->value() );
|
||||||
settings.setValue( "/qgis/legendDoubleClickAction", cmbLegendDoubleClickAction->currentIndex() );
|
settings.setValue( "/qgis/legendDoubleClickAction", cmbLegendDoubleClickAction->currentIndex() );
|
||||||
bool legendLayersCapitalise = settings.value( "/qgis/capitaliseLayerName", false ).toBool();
|
bool legendLayersCapitalise = settings.value( "/qgis/capitaliseLayerName", false ).toBool();
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtConcurrentMap>
|
#include <QtConcurrentMap>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include "qgscrscache.h"
|
#include "qgscrscache.h"
|
||||||
#include "qgslogger.h"
|
#include "qgslogger.h"
|
||||||
@ -731,6 +732,14 @@ void QgsMapRendererParallelJob::start()
|
|||||||
|
|
||||||
mLayerJobs = prepareJobs( 0, mLabelingEngine );
|
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
|
// start async job
|
||||||
|
|
||||||
connect( &mFutureWatcher, SIGNAL( finished() ), SLOT( renderLayersFinished() ) );
|
connect( &mFutureWatcher, SIGNAL( finished() ), SLOT( renderLayersFinished() ) );
|
||||||
@ -829,6 +838,10 @@ QImage QgsMapRendererParallelJob::renderedImage()
|
|||||||
|
|
||||||
void QgsMapRendererParallelJob::renderLayersFinished()
|
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 );
|
Q_ASSERT( mStatus == RenderingLayers );
|
||||||
|
|
||||||
// compose final image
|
// compose final image
|
||||||
|
@ -1628,13 +1628,47 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_26">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="chkParallelRendering">
|
<widget class="QCheckBox" name="chkParallelRendering">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Render layers in parallel using all available CPU cores</string>
|
<string>Render layers in parallel using many CPU cores</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
@ -4598,5 +4632,21 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</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>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user