mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Leverage QImage's CoW in Linux native notifications
This commit is contained in:
parent
e946bf5338
commit
0b4ef3214e
1 changed files with 14 additions and 12 deletions
|
@ -355,7 +355,7 @@ public:
|
||||||
|
|
||||||
void show();
|
void show();
|
||||||
void close();
|
void close();
|
||||||
void setImage(const QImage &image);
|
void setImage(QImage image);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const not_null<Manager*> _manager;
|
const not_null<Manager*> _manager;
|
||||||
|
@ -695,7 +695,7 @@ void NotificationData::close() {
|
||||||
_manager->clearNotification(_id);
|
_manager->clearNotification(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationData::setImage(const QImage &image) {
|
void NotificationData::setImage(QImage image) {
|
||||||
if (_notification) {
|
if (_notification) {
|
||||||
const auto imageData = [&] {
|
const auto imageData = [&] {
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
|
@ -718,20 +718,22 @@ void NotificationData::setImage(const QImage &image) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto convertedImage = image.hasAlphaChannel()
|
if (image.hasAlphaChannel()) {
|
||||||
? image.convertToFormat(QImage::Format_RGBA8888)
|
image.convertTo(QImage::Format_RGBA8888);
|
||||||
: image.convertToFormat(QImage::Format_RGB888);
|
} else {
|
||||||
|
image.convertTo(QImage::Format_RGB888);
|
||||||
|
}
|
||||||
|
|
||||||
_hints[_imageKey] = Glib::create_variant(std::tuple{
|
_hints[_imageKey] = Glib::create_variant(std::tuple{
|
||||||
convertedImage.width(),
|
image.width(),
|
||||||
convertedImage.height(),
|
image.height(),
|
||||||
int(convertedImage.bytesPerLine()),
|
int(image.bytesPerLine()),
|
||||||
convertedImage.hasAlphaChannel(),
|
image.hasAlphaChannel(),
|
||||||
8,
|
8,
|
||||||
convertedImage.hasAlphaChannel() ? 4 : 3,
|
image.hasAlphaChannel() ? 4 : 3,
|
||||||
std::vector<uchar>(
|
std::vector<uchar>(
|
||||||
convertedImage.constBits(),
|
image.constBits(),
|
||||||
convertedImage.constBits() + convertedImage.sizeInBytes()),
|
image.constBits() + image.sizeInBytes()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue