Commit 7408d2bb authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Merge remote-tracking branch 'origin/release/19.12'

parents 96de699e 05291236
......@@ -75,6 +75,7 @@ void RenderingThread::run()
d->renderer();
}
const auto size = m_size * qApp->devicePixelRatio();
foreach ( const QString & element, m_elementsToRender )
{
{
......@@ -83,11 +84,11 @@ void RenderingThread::run()
return;
}
QString key = keyForPixmap( element, m_size );
QString key = keyForPixmap( element, size );
if ( !d->cache->contains( key ) )
{
//qCDebug(LIBKCARDGAME_LOG) << "Renderering" << key << "in rendering thread.";
QImage img = d->renderCard( element, m_size );
QImage img = d->renderCard( element, size );
d->cache->insertImage( key, img );
emit renderingDone( element, img );
}
......@@ -197,24 +198,27 @@ QPixmap KAbstractCardDeckPrivate::requestPixmap( quint32 id, bool faceUp )
return QPixmap();
QPixmap & stored = it.value().cardPixmap;
if ( stored.size() != currentCardSize )
const auto dpr = qApp->devicePixelRatio();
QSize requestedCardSize = currentCardSize * dpr;
if ( stored.size() != requestedCardSize )
{
QString key = keyForPixmap( elementId , currentCardSize );
QString key = keyForPixmap( elementId , requestedCardSize );
if ( !cache->findPixmap( key, &stored ) )
{
if ( stored.isNull() )
{
//qCDebug(LIBKCARDGAME_LOG) << "Renderering" << key << "in main thread.";
QImage img = renderCard( elementId, currentCardSize );
QImage img = renderCard( elementId, requestedCardSize );
cache->insertImage( key, img );
stored = QPixmap::fromImage( img );
}
else
{
stored = stored.scaled( currentCardSize );
stored = stored.scaled( requestedCardSize );
}
}
Q_ASSERT( stored.size() == currentCardSize );
Q_ASSERT( stored.size() == requestedCardSize );
stored.setDevicePixelRatio( dpr );
}
return stored;
}
......@@ -235,16 +239,19 @@ void KAbstractCardDeckPrivate::submitRendering( const QString & elementId, const
// If the currentCardSize has changed since the rendering was performed,
// we sadly just have to throw it away.
if ( image.size() != currentCardSize )
const auto dpr = qApp->devicePixelRatio();
if ( image.size() != currentCardSize * dpr)
return;
// The RenderingThread just put the image in the cache, but due to the
// volatility of the cache there's no guarantee that it'll still be there
// by the time this slot is called, in which case we convert the QImage
// passed in the signal.
if ( !cache->findPixmap( keyForPixmap( elementId, currentCardSize ), &pix ) )
if ( !cache->findPixmap( keyForPixmap( elementId, currentCardSize * dpr ), &pix ) )
pix = QPixmap::fromImage( image );
pix.setDevicePixelRatio( dpr );
QHash<QString,CardElementData>::iterator it;
it = frontIndex.find( elementId );
if ( it != frontIndex.end() )
......
......@@ -312,7 +312,7 @@ void KCard::paint( QPainter * painter, const QStyleOptionGraphicsItem * option,
Q_UNUSED( option );
Q_UNUSED( widget );
if ( pixmap().size() != d->deck->cardSize() )
if ( pixmap().size() != d->deck->cardSize() * pixmap().devicePixelRatio() )
{
QPixmap newPix = d->deck->cardPixmap( d->id, d->faceUp );
if ( d->faceUp )
......
......@@ -79,7 +79,9 @@ void PreviewThread::run()
return;
}
QImage img( d->previewSize, QImage::Format_ARGB32 );
const auto dpr = qApp->devicePixelRatio();
QImage img( d->previewSize * dpr, QImage::Format_ARGB32 );
img.setDevicePixelRatio( dpr );
img.fill( Qt::transparent );
QPainter p( &img );
......@@ -145,6 +147,7 @@ void CardThemeModel::reload()
m_previews.clear();
QList<KCardTheme> previewsNeeded;
const auto dpr = qApp->devicePixelRatio();
foreach( const KCardTheme & theme, KCardTheme::findAllWithFeatures( d->requiredFeatures ) )
{
......@@ -155,8 +158,10 @@ void CardThemeModel::reload()
QDateTime timestamp;
if ( cacheFind( d->cache, timestampKey( theme ), &timestamp )
&& timestamp >= theme.lastModified()
&& d->cache->findPixmap( previewKey( theme, d->previewString ), pix ) )
&& d->cache->findPixmap( previewKey( theme, d->previewString ), pix )
&& pix->size() == d->previewSize * dpr )
{
pix->setDevicePixelRatio( dpr );
m_previews.insert( theme.displayName(), pix );
}
else
......
......@@ -101,6 +101,8 @@ QString lowerAlphaNum( const QString & string )
int main( int argc, char **argv )
{
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication app(argc, argv);
KLocalizedString::setApplicationDomain("kpat");
......
......@@ -114,4 +114,8 @@
<provides>
<binary>kpat</binary>
</provides>
<content_rating type="oars-1.1"/>
<releases>
<release version="19.12.0" date="2019-12-12"/>
</releases>
</component>
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