Commit 3b0ffac8 authored by Bart Coppens's avatar Bart Coppens

Make the swap options configurable through the preferences dialog

svn path=/trunk/koffice/; revision=443202
parent 8435f6e2
......@@ -34,6 +34,8 @@ namespace {
const Q_INT32 IMG_DEFAULT_HEIGHT = 512;
const enumCursorStyle DEFAULT_CURSOR_STYLE = CURSOR_STYLE_TOOLICON;
const Q_INT32 DEFAULT_MAX_THREADS = 4;
const Q_INT32 DEFAULT_MAX_TILES_MEM = 500; // 8192 kilobytes given 64x64 tiles with 32bpp
const Q_INT32 DEFAULT_SWAPPINESS = 100;
}
KisConfig::KisConfig()
......@@ -223,3 +225,22 @@ void KisConfig::setMaxNumberOfThreads(Q_INT32 maxThreads)
m_cfg -> writeEntry("maxthreads", maxThreads);
}
Q_INT32 KisConfig::maxTilesInMem() const
{
return m_cfg -> readNumEntry("maxtilesinmem", DEFAULT_MAX_TILES_MEM);
}
void KisConfig::setMaxTilesInMem(Q_INT32 tiles)
{
m_cfg -> writeEntry("maxtilesinmem", tiles);
}
Q_INT32 KisConfig::swappiness() const
{
return m_cfg -> readNumEntry("swappiness", DEFAULT_SWAPPINESS);
}
void KisConfig::setSwappiness(Q_INT32 swappiness)
{
m_cfg -> writeEntry("swappiness", swappiness);
}
......@@ -73,6 +73,15 @@ public:
Q_INT32 maxNumberOfThreads();
void setMaxNumberOfThreads(Q_INT32 numberOfThreads);
/// Maximum tiles in memory (this is a guideline, not absolute)
Q_INT32 maxTilesInMem() const;
void setMaxTilesInMem(Q_INT32 tiles);
/// Number of tiles that will be swapped at once. The higher, the more swapped, but more
/// chance that it will become slow
Q_INT32 swappiness() const;
void setSwappiness(Q_INT32 swappiness);
private:
KisConfig(const KisConfig&);
KisConfig& operator=(const KisConfig&);
......
......@@ -27,6 +27,8 @@
#include <kstaticdeleter.h>
#include "kis_config.h"
#include "kis_tileddatamanager.h"
#include "kis_tile.h"
#include "kis_tilemanager.h"
......@@ -38,6 +40,8 @@ KisTileManager* KisTileManager::m_singleton = 0;
static KStaticDeleter<KisTileManager> staticDeleter;
KisTileManager::KisTileManager() {
KisConfig config;
Q_ASSERT(KisTileManager::m_singleton == 0);
KisTileManager::m_singleton = this;
m_fileSize = 0;
......@@ -45,9 +49,8 @@ KisTileManager::KisTileManager() {
m_bytesTotal = 0;
m_currentInMem = 0;
// ### make these configurable
m_maxInMem = 500;
m_swappiness = 100;
m_maxInMem = config.maxTilesInMem();
m_swappiness = config.swappiness();
counter = 0;
}
......@@ -254,3 +257,14 @@ void KisTileManager::printInfo() {
kdDebug(DBG_AREA_TILES) << m_freeList.size() << " elements in the freelist\n";
kdDebug(DBG_AREA_TILES) << endl;
}
void KisTileManager::configChanged() {
KisConfig config;
m_maxInMem = config.maxTilesInMem();
m_swappiness = config.swappiness();
kdDebug(DBG_AREA_TILES) << "TileManager has new config: maxinmem: " << m_maxInMem
<< " swappiness: " << m_swappiness << endl;
doSwapping();
}
......@@ -40,6 +40,9 @@ public:
void ensureTileLoaded(KisTile* tile);
void maySwapTile(KisTile* tile);
public slots:
void configChanged();
private:
KisTileManager();
KisTileManager(KisTileManager& rhs) {}
......
......@@ -45,7 +45,8 @@ libkisui_la_SOURCES = \
wdgnewimage.ui \
wdgcolorsettings.ui \
wdgapplyprofile.ui \
wdglayerbox.ui
wdglayerbox.ui \
wdgperformancesettings.ui
noinst_HEADERS = kis_dlg_preferences.h \
......@@ -78,7 +79,8 @@ noinst_HEADERS = kis_dlg_preferences.h \
wdgnewimage.h \
wdgcolorsettings.h \
wdgapplyprofile.h \
wdglayerbox.h
wdglayerbox.h \
wdgperformancesettings.h
libkisui_la_METASOURCES = AUTO
......
......@@ -29,6 +29,7 @@
#include <qpixmap.h>
#include <qbitmap.h>
#include <qbuttongroup.h>
#include <qslider.h>
#include <klocale.h>
#include <knuminput.h>
......@@ -47,6 +48,10 @@
#include "kis_cmb_idlist.h"
#include "kis_profile.h"
#include "wdgcolorsettings.h"
#include "wdgperformancesettings.h"
// for the performance update
#include "tiles/kis_tilemanager.h"
GeneralTab::GeneralTab( QWidget *_parent, const char *_name )
: QWidget( _parent, _name )
......@@ -272,6 +277,29 @@ void ColorSettingsTab::refillImportProfiles(const KisID & s)
}
}
PerformanceTab::PerformanceTab(QWidget *parent, const char *name )
: QWidget(parent, name)
{
// XXX: Make sure only profiles that fit the specified color model
// are shown in the profile combos
QGridLayout * l = new QGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint());
m_page = new WdgPerformanceSettings(this);
l -> addWidget(m_page, 0, 0);
KisConfig cfg;
// it's scaled from 0 - 6, but the config is in 0 - 300
m_page -> m_swappiness -> setValue(cfg.swappiness() / 50);
m_page -> m_maxTiles -> setValue(cfg.maxTilesInMem());
}
void PerformanceTab::setDefault()
{
m_page -> m_swappiness -> setValue(3);
m_page -> m_maxTiles -> setValue(500);
}
PreferencesDialog::PreferencesDialog( QWidget* parent, const char* name )
: KDialogBase( IconList, i18n("Preferences"), Ok | Cancel | Help | Default | Apply, Ok, parent, name, true, true )
{
......@@ -288,6 +316,9 @@ PreferencesDialog::PreferencesDialog( QWidget* parent, const char* name )
vbox = addVBoxPage( i18n( "Color Settings"), i18n( "Color Settings"), BarIcon( "colorize", KIcon::SizeMedium ));
m_colorSettings = new ColorSettingsTab( vbox );
vbox = addVBoxPage( i18n( "Performance Settings"), i18n( "Performance Settings"), BarIcon( "fork", KIcon::SizeMedium ));
m_performanceSettings = new PerformanceTab ( vbox );
}
PreferencesDialog::~PreferencesDialog()
......@@ -326,6 +357,12 @@ bool PreferencesDialog::editPreferences()
cfg.setAskProfileOnPaste( dialog -> m_colorSettings -> m_page -> chkAskPaste -> isChecked());
cfg.setApplyMonitorProfileOnCopy( dialog -> m_colorSettings -> m_page -> chkApplyMonitorOnCopy -> isChecked());
cfg.setRenderIntent( dialog -> m_colorSettings -> m_page -> grpIntent -> selectedId());
// it's scaled from 0 - 6, but the config is in 0 - 300
cfg.setSwappiness(dialog -> m_performanceSettings -> m_page -> m_swappiness -> value() * 50);
cfg.setMaxTilesInMem(dialog -> m_performanceSettings -> m_page -> m_maxTiles -> value());
// let the tile manager know
KisTileManager::instance() -> configChanged();
}
delete dialog;
return baccept;
......
......@@ -31,6 +31,7 @@ class QLineEdit;
class QCheckBox;
class KURLRequester;
class WdgColorSettings;
class WdgPerformanceSettings;
class KisCmbIDList;
class KisID;
......@@ -113,6 +114,21 @@ public:
};
/**
* "Directories"-tab for preferences dialog
*/
class PerformanceTab : public QWidget
{
Q_OBJECT
public:
PerformanceTab( QWidget *parent = 0, const char *name = 0 );
public:
void setDefault();
WdgPerformanceSettings * m_page;
};
//=======================
/**
......@@ -138,6 +154,7 @@ protected:
DirectoriesTab* m_directories;
UndoRedoTab* m_undoRedo;
ColorSettingsTab* m_colorSettings;
PerformanceTab* m_performanceSettings;
protected slots:
......
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>WdgPerformanceSettings</class>
<widget class="QWidget">
<property name="name">
<cstring>WdgPerformanceSettings</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>359</width>
<height>232</height>
</rect>
</property>
<property name="caption">
<string>Form1</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QSlider" row="1" column="1">
<property name="name">
<cstring>m_swappiness</cstring>
</property>
<property name="maxValue">
<number>6</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="tickmarks">
<enum>Below</enum>
</property>
<property name="whatsThis" stdset="0">
<string>This configures how much Krita likes to swap. Move the slider to the left, and there is no swapping at all. Move it to the right there is a lot of swapping going on.</string>
</property>
</widget>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="text">
<string>Maximum of tiles in memory</string>
</property>
<property name="whatsThis" stdset="0">
<string>The maximum number of "tiles" that is kept in memory. For regular RGBA8 images, each tile is about 16 kB big. Thus, for a value of 500 tiles this usually means about 8 megabytes of data used for image data. If you regularily handle big images, a bigger value here might be useful.
Note that this number is only a guideline for Krita, and is not guaranteed to be the actual number of tiles in memory.</string>
</property>
</widget>
<widget class="KIntNumInput" row="0" column="1">
<property name="name">
<cstring>m_maxTiles</cstring>
</property>
<property name="value">
<number>500</number>
</property>
<property name="minValue">
<number>0</number>
</property>
<property name="whatsThis" stdset="0">
<string>The maximum number of "tiles" that is kept in memory. For regular RGBA8 images, each tile is about 16 kB big. Thus, for a value of 500 tiles this usually means about 8 megabytes of data used for image data. If you regularily handle big images, a bigger value here might be useful.
Note that this number is only a guideline for Krita, and is not guaranteed to be the actual number of tiles in memory.</string>
</property>
</widget>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="text">
<string>Swappiness</string>
</property>
<property name="whatsThis" stdset="0">
<string>This configures how much Krita likes to swap. Move the slider to the left, and there is no swapping at all. Move it to the right there is a lot of swapping going on.</string>
</property>
</widget>
</grid>
</widget>
<layoutdefaults spacing="6" margin="11"/>
<includehints>
<includehint>knuminput.h</includehint>
<includehint>knuminput.h</includehint>
</includehints>
</UI>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment