aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-09-09 17:33:11 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-09-09 17:33:11 +0900
commit3dfcd0f4f4501dba5925d894b7f0fbc9414549c8 (patch)
treea36079da82a6898ccecf695372e9d95de01d2e33 /lib
parent9c9401ecadda1273395576634882b4917b961482 (diff)
downloadlibquotient-3dfcd0f4f4501dba5925d894b7f0fbc9414549c8.tar.gz
libquotient-3dfcd0f4f4501dba5925d894b7f0fbc9414549c8.zip
Avatar: don't paint on null images; optimise initial placeholder generation
Diffstat (limited to 'lib')
-rw-r--r--lib/avatar.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/avatar.cpp b/lib/avatar.cpp
index 7e6dc50b..be9b6a78 100644
--- a/lib/avatar.cpp
+++ b/lib/avatar.cpp
@@ -126,6 +126,14 @@ QImage Avatar::Private::get(Connection* connection, QSize size,
if (callback)
callbacks.emplace_back(move(callback));
_thumbnailRequest = connection->getThumbnail(_url, size);
+ if (_originalImage.isNull() && !_defaultIcon.isNull())
+ {
+ _originalImage = QImage(_defaultIcon.actualSize(size),
+ QImage::Format_ARGB32_Premultiplied);
+ _originalImage.fill(Qt::transparent);
+ QPainter p { &_originalImage };
+ _defaultIcon.paint(&p, { QPoint(), _defaultIcon.actualSize(size) });
+ }
QObject::connect( _thumbnailRequest, &MediaThumbnailJob::success,
_thumbnailRequest, [this] {
_fetched = true;
@@ -138,15 +146,6 @@ QImage Avatar::Private::get(Connection* connection, QSize size,
});
}
- if( _originalImage.isNull() )
- {
- if (_defaultIcon.isNull())
- return _originalImage;
-
- QPainter p { &_originalImage };
- _defaultIcon.paint(&p, { QPoint(), _defaultIcon.actualSize(size) });
- }
-
for (const auto& p: _scaledImages)
if (p.first == size)
return p.second;