mirror of https://github.com/JakubMelka/PDF4QT.git
Settings of cache size
This commit is contained in:
parent
3cd2dd5104
commit
7dbae1c3dc
|
@ -92,6 +92,11 @@ void PDFAsynchronousPageCompiler::reset()
|
|||
start();
|
||||
}
|
||||
|
||||
void PDFAsynchronousPageCompiler::setCacheLimit(int limit)
|
||||
{
|
||||
m_cache.setMaxCost(limit);
|
||||
}
|
||||
|
||||
const PDFPrecompiledPage* PDFAsynchronousPageCompiler::getCompiledPage(PDFInteger pageIndex, bool compile)
|
||||
{
|
||||
if (m_state != State::Active || !m_proxy->getDocument())
|
||||
|
@ -112,6 +117,7 @@ const PDFPrecompiledPage* PDFAsynchronousPageCompiler::getCompiledPage(PDFIntege
|
|||
return compiledPage;
|
||||
};
|
||||
|
||||
m_proxy->getFontCache()->setCacheShrinkEnabled(false);
|
||||
CompileTask& task = m_tasks[pageIndex];
|
||||
task.taskFuture = QtConcurrent::run(compilePage);
|
||||
task.taskWatcher = new QFutureWatcher<PDFPrecompiledPage>(this);
|
||||
|
@ -160,6 +166,9 @@ void PDFAsynchronousPageCompiler::onPageCompiled()
|
|||
}
|
||||
}
|
||||
|
||||
// We allow font cache shrinking, when we aren't doing something in parallel.
|
||||
m_proxy->getFontCache()->setCacheShrinkEnabled(m_tasks.empty());
|
||||
|
||||
if (!compiledPages.empty())
|
||||
{
|
||||
Q_ASSERT(std::is_sorted(compiledPages.cbegin(), compiledPages.cend()));
|
||||
|
|
|
@ -53,6 +53,10 @@ public:
|
|||
/// Resets the engine - calls stop and then calls start.
|
||||
void reset();
|
||||
|
||||
/// Sets cache limit in bytes
|
||||
/// \param limit Cache limit [bytes]
|
||||
void setCacheLimit(int limit);
|
||||
|
||||
enum class State
|
||||
{
|
||||
Inactive,
|
||||
|
|
|
@ -58,6 +58,10 @@ static constexpr const char* PDF_OBJECT_END_MARK = "endobj";
|
|||
// Colors
|
||||
static constexpr const int PDF_MAX_COLOR_COMPONENTS = 32;
|
||||
|
||||
// Cache limits
|
||||
static constexpr size_t DEFAULT_FONT_CACHE_LIMIT = 32;
|
||||
static constexpr size_t DEFAULT_REALIZED_FONT_CACHE_LIMIT = 128;
|
||||
|
||||
} // namespace pdf
|
||||
|
||||
#endif // PDFCONSTANTS_H
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "pdfrenderer.h"
|
||||
#include "pdfpainter.h"
|
||||
#include "pdfcompiler.h"
|
||||
#include "pdfconstants.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
|
@ -34,7 +35,7 @@ PDFDrawSpaceController::PDFDrawSpaceController(QObject* parent) :
|
|||
m_pageLayoutMode(PageLayout::OneColumn),
|
||||
m_verticalSpacingMM(5.0),
|
||||
m_horizontalSpacingMM(1.0),
|
||||
m_fontCache(FONT_CACHE_LIMIT, REALIZED_FONT_CACHE_LIMIT)
|
||||
m_fontCache(DEFAULT_FONT_CACHE_LIMIT, DEFAULT_REALIZED_FONT_CACHE_LIMIT)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -103,6 +103,9 @@ public:
|
|||
/// Returns the font cache
|
||||
const PDFFontCache* getFontCache() const { return &m_fontCache; }
|
||||
|
||||
/// Returns the font cache
|
||||
PDFFontCache* getFontCache() { return &m_fontCache; }
|
||||
|
||||
/// Returns optional content activity
|
||||
const PDFOptionalContentActivity* getOptionalContentActivity() const { return m_optionalContentActivity; }
|
||||
|
||||
|
@ -136,9 +139,6 @@ private:
|
|||
|
||||
using BlockItems = std::vector<LayoutBlock>;
|
||||
|
||||
static constexpr size_t FONT_CACHE_LIMIT = 32;
|
||||
static constexpr size_t REALIZED_FONT_CACHE_LIMIT = 128;
|
||||
|
||||
const PDFDocument* m_document;
|
||||
const PDFOptionalContentActivity* m_optionalContentActivity;
|
||||
|
||||
|
@ -267,10 +267,11 @@ public:
|
|||
static constexpr PDFReal ZOOM_STEP = 1.2;
|
||||
|
||||
const PDFDocument* getDocument() const { return m_controller->getDocument(); }
|
||||
const PDFFontCache* getFontCache() const { return m_controller->getFontCache(); }
|
||||
PDFFontCache* getFontCache() const { return m_controller->getFontCache(); }
|
||||
const PDFOptionalContentActivity* getOptionalContentActivity() const { return m_controller->getOptionalContentActivity(); }
|
||||
PDFRenderer::Features getFeatures() const;
|
||||
const PDFMeshQualitySettings& getMeshQualitySettings() const { return m_meshQualitySettings; }
|
||||
PDFAsynchronousPageCompiler* getCompiler() const { return m_compiler; }
|
||||
|
||||
void setFeatures(PDFRenderer::Features features);
|
||||
void setPreferredMeshResolutionRatio(PDFReal ratio);
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
|
||||
#include "pdfdrawwidget.h"
|
||||
#include "pdfdrawspacecontroller.h"
|
||||
#include "pdfcompiler.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QGridLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QApplication>
|
||||
#include <QPixmapCache>
|
||||
|
||||
namespace pdf
|
||||
{
|
||||
|
@ -96,6 +98,13 @@ void PDFWidget::updateRenderer(RendererEngine engine, int samplesCount)
|
|||
updateRendererImpl();
|
||||
}
|
||||
|
||||
void PDFWidget::updateCacheLimits(int compiledPageCacheLimit, int thumbnailsCacheLimit, int fontCacheLimit, int instancedFontCacheLimit)
|
||||
{
|
||||
m_proxy->getCompiler()->setCacheLimit(compiledPageCacheLimit);
|
||||
QPixmapCache::setCacheLimit(thumbnailsCacheLimit);
|
||||
m_proxy->getFontCache()->setCacheLimits(fontCacheLimit, instancedFontCacheLimit);
|
||||
}
|
||||
|
||||
int PDFWidget::getPageRenderingErrorCount() const
|
||||
{
|
||||
int count = 0;
|
||||
|
|
|
@ -67,6 +67,13 @@ public:
|
|||
/// \param samplesCount Samples count for rendering engine MSAA antialiasing
|
||||
void updateRenderer(RendererEngine engine, int samplesCount);
|
||||
|
||||
/// Updates cache limits
|
||||
/// \param compiledPageCacheLimit Compiled page cache limit [bytes]
|
||||
/// \param thumbnailsCacheLimit Thumbnail image cache limit [kB]
|
||||
/// \param fontCacheLimit Font cache limit [-]
|
||||
/// \param instancedFontCacheLimit Instanced font cache limit [-]
|
||||
void updateCacheLimits(int compiledPageCacheLimit, int thumbnailsCacheLimit, int fontCacheLimit, int instancedFontCacheLimit);
|
||||
|
||||
IDrawWidget* getDrawWidget() const { return m_drawWidget; }
|
||||
QScrollBar* getHorizontalScrollbar() const { return m_horizontalScrollBar; }
|
||||
QScrollBar* getVerticalScrollbar() const { return m_verticalScrollBar; }
|
||||
|
|
|
@ -1399,7 +1399,7 @@ PDFFontPointer PDFFontCache::getFont(const PDFObject& fontObject) const
|
|||
// We must create the font
|
||||
PDFFontPointer font = PDFFont::createFont(fontObject, m_document);
|
||||
|
||||
if (m_fontCache.size() >= m_fontCacheLimit)
|
||||
if (m_fontCacheShrinkEnabled && m_fontCache.size() >= m_fontCacheLimit)
|
||||
{
|
||||
// We have exceeded the cache limit. Clear the cache.
|
||||
m_fontCache.clear();
|
||||
|
@ -1427,7 +1427,7 @@ PDFRealizedFontPointer PDFFontCache::getRealizedFont(const PDFFontPointer& font,
|
|||
// We must create the realized font
|
||||
PDFRealizedFontPointer realizedFont = PDFRealizedFont::createRealizedFont(font, size, reporter);
|
||||
|
||||
if (m_realizedFontCache.size() >= m_realizedFontCacheLimit)
|
||||
if (m_fontCacheShrinkEnabled && m_realizedFontCache.size() >= m_realizedFontCacheLimit)
|
||||
{
|
||||
m_realizedFontCache.clear();
|
||||
}
|
||||
|
@ -1438,6 +1438,41 @@ PDFRealizedFontPointer PDFFontCache::getRealizedFont(const PDFFontPointer& font,
|
|||
return it->second;
|
||||
}
|
||||
|
||||
void PDFFontCache::setCacheShrinkEnabled(bool enabled)
|
||||
{
|
||||
if (m_fontCacheShrinkEnabled != enabled)
|
||||
{
|
||||
m_fontCacheShrinkEnabled = enabled;
|
||||
shrink();
|
||||
}
|
||||
}
|
||||
|
||||
void PDFFontCache::setCacheLimits(int fontCacheLimit, int instancedFontCacheLimit)
|
||||
{
|
||||
if (m_fontCacheLimit != fontCacheLimit || m_realizedFontCacheLimit != instancedFontCacheLimit)
|
||||
{
|
||||
m_fontCacheLimit = fontCacheLimit;
|
||||
m_realizedFontCacheLimit = instancedFontCacheLimit;
|
||||
shrink();
|
||||
}
|
||||
}
|
||||
|
||||
void PDFFontCache::shrink()
|
||||
{
|
||||
if (m_fontCacheShrinkEnabled)
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
if (m_fontCache.size() >= m_fontCacheLimit)
|
||||
{
|
||||
m_fontCache.clear();
|
||||
}
|
||||
if (m_realizedFontCache.size() >= m_realizedFontCacheLimit)
|
||||
{
|
||||
m_realizedFontCache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QByteArray* FontDescriptor::getEmbeddedFontData() const
|
||||
{
|
||||
if (!fontFile.isEmpty())
|
||||
|
|
|
@ -373,6 +373,7 @@ class PDFFontCache
|
|||
{
|
||||
public:
|
||||
inline explicit PDFFontCache(size_t fontCacheLimit, size_t realizedFontCacheLimit) :
|
||||
m_fontCacheShrinkEnabled(true),
|
||||
m_fontCacheLimit(fontCacheLimit),
|
||||
m_realizedFontCacheLimit(realizedFontCacheLimit),
|
||||
m_document(nullptr)
|
||||
|
@ -396,9 +397,20 @@ public:
|
|||
/// \param reporter Error reporter
|
||||
PDFRealizedFontPointer getRealizedFont(const PDFFontPointer& font, PDFReal size, PDFRenderErrorReporter* reporter) const;
|
||||
|
||||
/// Sets or unsets font shrinking (i.e. font can be deleted from the cache). In multithreading environment,
|
||||
/// font deletion is not thread safe. For this reason, disable font deletion by calling this function.
|
||||
void setCacheShrinkEnabled(bool enabled);
|
||||
|
||||
/// Set font cache limits
|
||||
void setCacheLimits(int fontCacheLimit, int instancedFontCacheLimit);
|
||||
|
||||
/// If shrinking is enabled, then erase font, if cache limit is exceeded.
|
||||
void shrink();
|
||||
|
||||
private:
|
||||
const size_t m_fontCacheLimit;
|
||||
const size_t m_realizedFontCacheLimit;
|
||||
bool m_fontCacheShrinkEnabled;
|
||||
size_t m_fontCacheLimit;
|
||||
size_t m_realizedFontCacheLimit;
|
||||
mutable QMutex m_mutex;
|
||||
const PDFDocument* m_document;
|
||||
mutable std::map<PDFObjectReference, PDFFontPointer> m_fontCache;
|
||||
|
|
|
@ -22,5 +22,6 @@
|
|||
<file>resources/zoom-fit-horizontal.svg</file>
|
||||
<file>resources/zoom-fit-vertical.svg</file>
|
||||
<file>resources/synchronize.svg</file>
|
||||
<file>resources/cache.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -153,6 +153,7 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget *parent) :
|
|||
m_pdfWidget = new pdf::PDFWidget(m_settings->getRendererEngine(), m_settings->isMultisampleAntialiasingEnabled() ? m_settings->getRendererSamples() : -1, this);
|
||||
setCentralWidget(m_pdfWidget);
|
||||
setFocusProxy(m_pdfWidget);
|
||||
m_pdfWidget->updateCacheLimits(m_settings->getCompiledPageCacheLimit() * 1024, m_settings->getThumbnailsCacheLimit(), m_settings->getFontCacheLimit(), m_settings->getInstancedFontCacheLimit());
|
||||
|
||||
m_sidebarWidget = new PDFSidebarWidget(m_pdfWidget->getDrawWidgetProxy(), this);
|
||||
m_sidebarDockWidget = new QDockWidget(tr("Sidebar"), this);
|
||||
|
@ -650,10 +651,12 @@ void PDFViewerMainWindow::updateUI(bool fullUpdate)
|
|||
void PDFViewerMainWindow::onViewerSettingsChanged()
|
||||
{
|
||||
m_pdfWidget->updateRenderer(m_settings->getRendererEngine(), m_settings->isMultisampleAntialiasingEnabled() ? m_settings->getRendererSamples() : -1);
|
||||
m_pdfWidget->updateCacheLimits(m_settings->getCompiledPageCacheLimit() * 1024, m_settings->getThumbnailsCacheLimit(), m_settings->getFontCacheLimit(), m_settings->getInstancedFontCacheLimit());
|
||||
m_pdfWidget->getDrawWidgetProxy()->setFeatures(m_settings->getFeatures());
|
||||
m_pdfWidget->getDrawWidgetProxy()->setPreferredMeshResolutionRatio(m_settings->getPreferredMeshResolutionRatio());
|
||||
m_pdfWidget->getDrawWidgetProxy()->setMinimalMeshResolutionRatio(m_settings->getMinimalMeshResolutionRatio());
|
||||
m_pdfWidget->getDrawWidgetProxy()->setColorTolerance(m_settings->getColorTolerance());
|
||||
|
||||
updateRenderingOptionActions();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,13 @@
|
|||
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "pdfviewersettings.h"
|
||||
#include "pdfconstants.h"
|
||||
|
||||
#include <QPixmapCache>
|
||||
|
||||
namespace pdfviewer
|
||||
{
|
||||
const int PIXMAP_CACHE_LIMIT = QPixmapCache::cacheLimit();
|
||||
|
||||
void PDFViewerSettings::setSettings(const PDFViewerSettings::Settings& settings)
|
||||
{
|
||||
|
@ -40,6 +44,10 @@ void PDFViewerSettings::readSettings(QSettings& settings)
|
|||
m_settings.m_preferredMeshResolutionRatio = settings.value("preferredMeshResolutionRatio", defaultSettings.m_preferredMeshResolutionRatio).toDouble();
|
||||
m_settings.m_minimalMeshResolutionRatio = settings.value("minimalMeshResolutionRatio", defaultSettings.m_minimalMeshResolutionRatio).toDouble();
|
||||
m_settings.m_colorTolerance = settings.value("colorTolerance", defaultSettings.m_colorTolerance).toDouble();
|
||||
m_settings.m_compiledPageCacheLimit = settings.value("compiledPageCacheLimit", defaultSettings.m_compiledPageCacheLimit).toInt();
|
||||
m_settings.m_thumbnailsCacheLimit = settings.value("thumbnailsCacheLimit", defaultSettings.m_thumbnailsCacheLimit).toInt();
|
||||
m_settings.m_fontCacheLimit = settings.value("fontCacheLimit", defaultSettings.m_fontCacheLimit).toInt();
|
||||
m_settings.m_instancedFontCacheLimit = settings.value("instancedFontCacheLimit", defaultSettings.m_instancedFontCacheLimit).toInt();
|
||||
m_settings.m_allowLaunchApplications = settings.value("allowLaunchApplications", defaultSettings.m_allowLaunchApplications).toBool();
|
||||
m_settings.m_allowLaunchURI = settings.value("allowLaunchURI", defaultSettings.m_allowLaunchURI).toBool();
|
||||
settings.endGroup();
|
||||
|
@ -59,6 +67,10 @@ void PDFViewerSettings::writeSettings(QSettings& settings)
|
|||
settings.setValue("preferredMeshResolutionRatio", m_settings.m_preferredMeshResolutionRatio);
|
||||
settings.setValue("minimalMeshResolutionRatio", m_settings.m_minimalMeshResolutionRatio);
|
||||
settings.setValue("colorTolerance", m_settings.m_colorTolerance);
|
||||
settings.setValue("compiledPageCacheLimit", m_settings.m_compiledPageCacheLimit);
|
||||
settings.setValue("thumbnailsCacheLimit", m_settings.m_thumbnailsCacheLimit);
|
||||
settings.setValue("fontCacheLimit", m_settings.m_fontCacheLimit);
|
||||
settings.setValue("instancedFontCacheLimit", m_settings.m_instancedFontCacheLimit);
|
||||
settings.setValue("allowLaunchApplications", m_settings.m_allowLaunchApplications);
|
||||
settings.setValue("allowLaunchURI", m_settings.m_allowLaunchURI);
|
||||
settings.endGroup();
|
||||
|
@ -147,4 +159,23 @@ void PDFViewerSettings::setColorTolerance(pdf::PDFReal colorTolerance)
|
|||
}
|
||||
}
|
||||
|
||||
PDFViewerSettings::Settings::Settings() :
|
||||
m_features(pdf::PDFRenderer::getDefaultFeatures()),
|
||||
m_rendererEngine(pdf::RendererEngine::OpenGL),
|
||||
m_multisampleAntialiasing(true),
|
||||
m_rendererSamples(16),
|
||||
m_prefetchPages(true),
|
||||
m_preferredMeshResolutionRatio(0.02),
|
||||
m_minimalMeshResolutionRatio(0.005),
|
||||
m_colorTolerance(0.01),
|
||||
m_allowLaunchApplications(true),
|
||||
m_allowLaunchURI(true),
|
||||
m_compiledPageCacheLimit(128 * 1024),
|
||||
m_thumbnailsCacheLimit(PIXMAP_CACHE_LIMIT),
|
||||
m_fontCacheLimit(pdf::DEFAULT_FONT_CACHE_LIMIT),
|
||||
m_instancedFontCacheLimit(pdf::DEFAULT_REALIZED_FONT_CACHE_LIMIT)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // namespace pdfviewer
|
||||
|
|
|
@ -38,20 +38,7 @@ public:
|
|||
|
||||
struct Settings
|
||||
{
|
||||
Settings() :
|
||||
m_features(pdf::PDFRenderer::getDefaultFeatures()),
|
||||
m_rendererEngine(pdf::RendererEngine::OpenGL),
|
||||
m_multisampleAntialiasing(true),
|
||||
m_rendererSamples(16),
|
||||
m_prefetchPages(true),
|
||||
m_preferredMeshResolutionRatio(0.02),
|
||||
m_minimalMeshResolutionRatio(0.005),
|
||||
m_colorTolerance(0.01),
|
||||
m_allowLaunchApplications(true),
|
||||
m_allowLaunchURI(true)
|
||||
{
|
||||
|
||||
}
|
||||
Settings();
|
||||
|
||||
pdf::PDFRenderer::Features m_features;
|
||||
QString m_directory;
|
||||
|
@ -64,6 +51,12 @@ public:
|
|||
pdf::PDFReal m_colorTolerance;
|
||||
bool m_allowLaunchApplications;
|
||||
bool m_allowLaunchURI;
|
||||
|
||||
// Cache settings
|
||||
int m_compiledPageCacheLimit;
|
||||
int m_thumbnailsCacheLimit;
|
||||
int m_fontCacheLimit;
|
||||
int m_instancedFontCacheLimit;
|
||||
};
|
||||
|
||||
const Settings& getSettings() const { return m_settings; }
|
||||
|
@ -96,6 +89,11 @@ public:
|
|||
pdf::PDFReal getColorTolerance() const { return m_settings.m_colorTolerance; }
|
||||
void setColorTolerance(pdf::PDFReal colorTolerance);
|
||||
|
||||
int getCompiledPageCacheLimit() const { return m_settings.m_compiledPageCacheLimit; }
|
||||
int getThumbnailsCacheLimit() const { return m_settings.m_thumbnailsCacheLimit; }
|
||||
int getFontCacheLimit() const { return m_settings.m_fontCacheLimit; }
|
||||
int getInstancedFontCacheLimit() const { return m_settings.m_instancedFontCacheLimit; }
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ PDFViewerSettingsDialog::PDFViewerSettingsDialog(const PDFViewerSettings::Settin
|
|||
new QListWidgetItem(QIcon(":/resources/engine.svg"), tr("Engine"), ui->optionsPagesWidget, EngineSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/rendering.svg"), tr("Rendering"), ui->optionsPagesWidget, RenderingSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/shading.svg"), tr("Shading"), ui->optionsPagesWidget, ShadingSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/cache.svg"), tr("Cache"), ui->optionsPagesWidget, CacheSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/security.svg"), tr("Security"), ui->optionsPagesWidget, SecuritySettings);
|
||||
|
||||
ui->renderingEngineComboBox->addItem(tr("Software"), static_cast<int>(pdf::RendererEngine::Software));
|
||||
|
@ -65,6 +66,10 @@ PDFViewerSettingsDialog::PDFViewerSettingsDialog(const PDFViewerSettings::Settin
|
|||
{
|
||||
connect(spinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &PDFViewerSettingsDialog::saveData);
|
||||
}
|
||||
for (QSpinBox* spinBox : findChildren<QSpinBox*>())
|
||||
{
|
||||
connect(spinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &PDFViewerSettingsDialog::saveData);
|
||||
}
|
||||
|
||||
ui->optionsPagesWidget->setCurrentRow(0);
|
||||
adjustSize();
|
||||
|
@ -94,6 +99,10 @@ void PDFViewerSettingsDialog::on_optionsPagesWidget_currentItemChanged(QListWidg
|
|||
ui->stackedWidget->setCurrentWidget(ui->shadingPage);
|
||||
break;
|
||||
|
||||
case CacheSettings:
|
||||
ui->stackedWidget->setCurrentWidget(ui->cachePage);
|
||||
break;
|
||||
|
||||
case SecuritySettings:
|
||||
ui->stackedWidget->setCurrentWidget(ui->securityPage);
|
||||
break;
|
||||
|
@ -148,6 +157,12 @@ void PDFViewerSettingsDialog::loadData()
|
|||
ui->minimalMeshResolutionEdit->setValue(m_settings.m_minimalMeshResolutionRatio);
|
||||
ui->colorToleranceEdit->setValue(m_settings.m_colorTolerance);
|
||||
|
||||
// Cache
|
||||
ui->compiledPageCacheSizeEdit->setValue(m_settings.m_compiledPageCacheLimit);
|
||||
ui->thumbnailCacheSizeEdit->setValue(m_settings.m_thumbnailsCacheLimit);
|
||||
ui->cachedFontLimitEdit->setValue(m_settings.m_fontCacheLimit);
|
||||
ui->cachedInstancedFontLimitEdit->setValue(m_settings.m_instancedFontCacheLimit);
|
||||
|
||||
// Security
|
||||
ui->allowLaunchCheckBox->setChecked(m_settings.m_allowLaunchApplications);
|
||||
ui->allowRunURICheckBox->setChecked(m_settings.m_allowLaunchURI);
|
||||
|
@ -222,6 +237,22 @@ void PDFViewerSettingsDialog::saveData()
|
|||
{
|
||||
m_settings.m_allowLaunchURI = ui->allowRunURICheckBox->isChecked();
|
||||
}
|
||||
else if (sender == ui->compiledPageCacheSizeEdit)
|
||||
{
|
||||
m_settings.m_compiledPageCacheLimit = ui->compiledPageCacheSizeEdit->value();
|
||||
}
|
||||
else if (sender == ui->thumbnailCacheSizeEdit)
|
||||
{
|
||||
m_settings.m_thumbnailsCacheLimit = ui->thumbnailCacheSizeEdit->value();
|
||||
}
|
||||
else if (sender == ui->cachedFontLimitEdit)
|
||||
{
|
||||
m_settings.m_fontCacheLimit = ui->cachedFontLimitEdit->value();
|
||||
}
|
||||
else if (sender == ui->cachedInstancedFontLimitEdit)
|
||||
{
|
||||
m_settings.m_instancedFontCacheLimit = ui->cachedInstancedFontLimitEdit->value();
|
||||
}
|
||||
|
||||
loadData();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
EngineSettings,
|
||||
RenderingSettings,
|
||||
ShadingSettings,
|
||||
CacheSettings,
|
||||
SecuritySettings
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="enginePage">
|
||||
<layout class="QVBoxLayout" name="enginePageLayout">
|
||||
|
@ -394,6 +394,144 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="cachePage">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="cacheGroupBox">
|
||||
<property name="title">
|
||||
<string>Cache Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="cacheGroupBoxLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="cacheSettingsGridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="thumbnailCacheSizeLabel">
|
||||
<property name="text">
|
||||
<string>Thumbnail image cache size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="cachedFontLabel">
|
||||
<property name="text">
|
||||
<string>Cached font limit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="cachedFontLimitEdit">
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::PlusMinus</enum>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="compiledPageCacheSizeEdit">
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::PlusMinus</enum>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> kB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>65536</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1048576</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1024</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="compiledPageCacheLabel">
|
||||
<property name="text">
|
||||
<string>Compiled page cache size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="thumbnailCacheSizeEdit">
|
||||
<property name="suffix">
|
||||
<string> kB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1024</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65536</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1024</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="cachedInstancedFontLimitLabel">
|
||||
<property name="text">
|
||||
<string>Cached instanced font limit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="cachedInstancedFontLimitEdit">
|
||||
<property name="minimum">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>256</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="cacheInfoLabel">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Rendering engine first compiles page for fast drawing, and then stores them in the cache. Stored compiled pages are usually drawn much faster than direct drawing. <span style=" font-weight:600;">Compiled page cache size</span> sets limits for compiled pages in kB. This limit should be at least two times large than largest compiled page size. If compiled page can't be inserted, then error is displayed during rendering. The higher this value is set, the faster the engine will be, at the cost of consumed operating memory.</p><p>Also, there is cache for thumbnails images. <span style=" font-weight:600;">Thumbnail image cache size </span>determines, how much space there is for thumbnail images. Set this value to at least fill space for thumbnails images on the screen. Again, the higher value is, the faster displaying of thumbnails is, at the cost of consumed operating memory. Thumbnails are stored as bitmaps for fast drawing, not as precompiled pages.</p><p>During rendering, fonts are cached. There is a two-level cache, one for general fonts, one for instanced fonts (fonts with given size). The <span style=" font-weight:600;">cached font limit</span> sets font cache limit (number of fonts) which can be stored in the cache. The <span style=" font-weight:600;">instanced font cache limit</span> sets font cache limit for instanced fonts (number of fonts with determined size), which can be stored in the cache. When cache limit is exceeded, then fonts are erased from the cache, but only if no operation in another thread is performed (for example, compiling pages), to avoid race conditions.</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="cachePageVerticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>74</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="securityPage">
|
||||
<layout class="QVBoxLayout" name="securityPageLayout">
|
||||
<property name="leftMargin">
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="30mm"
|
||||
height="30mm"
|
||||
viewBox="0 0 30 30"
|
||||
version="1.1"
|
||||
id="svg5291"
|
||||
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||
sodipodi:docname="cache.svg">
|
||||
<defs
|
||||
id="defs5285">
|
||||
<inkscape:path-effect
|
||||
effect="skeletal"
|
||||
id="path-effect853"
|
||||
is_visible="true"
|
||||
pattern="M 0,5 C 0,2.24 2.24,0 5,0 7.76,0 10,2.24 10,5 10,7.76 7.76,10 5,10 2.24,10 0,7.76 0,5 Z"
|
||||
copytype="single_stretched"
|
||||
prop_scale="0.26458333"
|
||||
scale_y_rel="false"
|
||||
spacing="0"
|
||||
normal_offset="0"
|
||||
tang_offset="0"
|
||||
prop_units="false"
|
||||
vertical_pattern="false"
|
||||
fuse_tolerance="0" />
|
||||
<inkscape:path-effect
|
||||
effect="skeletal"
|
||||
id="path-effect849"
|
||||
is_visible="true"
|
||||
pattern="M 0,5 C 0,2.24 2.24,0 5,0 7.76,0 10,2.24 10,5 10,7.76 7.76,10 5,10 2.24,10 0,7.76 0,5 Z"
|
||||
copytype="single_stretched"
|
||||
prop_scale="0.26458333"
|
||||
scale_y_rel="false"
|
||||
spacing="0"
|
||||
normal_offset="0"
|
||||
tang_offset="0"
|
||||
prop_units="false"
|
||||
vertical_pattern="false"
|
||||
fuse_tolerance="0" />
|
||||
<linearGradient
|
||||
id="linearGradient841"
|
||||
osb:paint="solid">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop839" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.98994949"
|
||||
inkscape:cx="-375.5706"
|
||||
inkscape:cy="-30.46167"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="3840"
|
||||
inkscape:window-height="2035"
|
||||
inkscape:window-x="-13"
|
||||
inkscape:window-y="-13"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata5288">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Jakub Melka</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
|
||||
</cc:Work>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Notice" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Vrstva 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-267)">
|
||||
<ellipse
|
||||
style="fill:#dcdcdc;fill-opacity:1;stroke:#000000;stroke-width:0.6;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path831"
|
||||
cx="13.087426"
|
||||
cy="280.41635"
|
||||
rx="11.114326"
|
||||
ry="10.500114" />
|
||||
<ellipse
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.86595404;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path835"
|
||||
cx="51.361652"
|
||||
cy="275.41348"
|
||||
rx="2.5243223"
|
||||
ry="2.5364435"
|
||||
transform="matrix(0.9883438,0.15223844,-0.13518619,0.99082021,0,0)" />
|
||||
<ellipse
|
||||
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.67466593;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path837"
|
||||
cx="13.479585"
|
||||
cy="280.6969"
|
||||
rx="4.051156"
|
||||
ry="3.999856" />
|
||||
<ellipse
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.80000001;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path845"
|
||||
cx="24.667669"
|
||||
cy="290.52716"
|
||||
rx="1.8662573"
|
||||
ry="1.842634" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 25.966964,289.0625 -7.748512,-4.25223 5.055431,7.1343"
|
||||
id="path871"
|
||||
inkscape:connector-curvature="0" />
|
||||
<ellipse
|
||||
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.69999999;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
id="path876"
|
||||
cx="18.023989"
|
||||
cy="284.6889"
|
||||
rx="0.88533032"
|
||||
ry="0.81851292" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 5.4 KiB |
Loading…
Reference in New Issue