Settings of cache size

This commit is contained in:
Jakub Melka
2019-12-15 19:28:25 +01:00
parent 3cd2dd5104
commit 7dbae1c3dc
17 changed files with 467 additions and 24 deletions

View File

@ -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()));