Removed App::pixmapFromImageInPlace.

This commit is contained in:
23rd 2021-05-07 17:33:53 +03:00
parent 7bcb1fc8b2
commit a631a28092
36 changed files with 152 additions and 108 deletions

View file

@ -282,8 +282,4 @@ namespace App {
return result; return result;
} }
QPixmap pixmapFromImageInPlace(QImage &&image) {
return QPixmap::fromImage(std::move(image), Qt::ColorOnly);
}
} }

View file

@ -45,6 +45,5 @@ namespace App {
constexpr auto kImageSizeLimit = 64 * 1024 * 1024; // Open images up to 64mb jpg/png/gif constexpr auto kImageSizeLimit = 64 * 1024 * 1024; // Open images up to 64mb jpg/png/gif
QImage readImage(QByteArray data, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr); QImage readImage(QByteArray data, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr);
QImage readImage(const QString &file, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr, QByteArray *content = 0); QImage readImage(const QString &file, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr, QByteArray *content = 0);
QPixmap pixmapFromImageInPlace(QImage &&image);
}; };

View file

@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/background_preview_box.h" #include "boxes/background_preview_box.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "app.h"
#include "styles/style_overview.h" #include "styles/style_overview.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
@ -337,7 +336,7 @@ void BackgroundBox::Inner::validatePaperThumbnail(
Data::PatternColor(color), Data::PatternColor(color),
paper.data.patternIntensity()); paper.data.patternIntensity());
} }
paper.thumbnail = App::pixmapFromImageInPlace(TakeMiddleSample( paper.thumbnail = Ui::PixmapFromImage(TakeMiddleSample(
original, original,
st::backgroundSize)); st::backgroundSize));
paper.thumbnail.setDevicePixelRatio(cRetinaFactor()); paper.thumbnail.setDevicePixelRatio(cRetinaFactor());

View file

@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "boxes/background_preview_box.h" #include "boxes/background_preview_box.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "app.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
@ -688,8 +687,8 @@ void BackgroundPreviewBox::setScaledFromImage(
if (!_full.isNull()) { if (!_full.isNull()) {
startFadeInFrom(std::move(_scaled)); startFadeInFrom(std::move(_scaled));
} }
_scaled = App::pixmapFromImageInPlace(std::move(image)); _scaled = Ui::PixmapFromImage(std::move(image));
_blurred = App::pixmapFromImageInPlace(std::move(blurred)); _blurred = Ui::PixmapFromImage(std::move(blurred));
if (_blur && (!_paper.document() || !_full.isNull())) { if (_blur && (!_paper.document() || !_full.isNull())) {
_blur->setDisabled(false); _blur->setDisabled(false);
} }

View file

@ -57,10 +57,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/cached_round_corners.h" #include "ui/cached_round_corners.h"
#include "ui/abstract_button.h" #include "ui/abstract_button.h"
#include "ui/ui_utility.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "confirm_box.h" #include "confirm_box.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "app.h" // App::pixmapFromImageInPlace.
#include "facades.h" // App::LambdaDelayed. #include "facades.h" // App::LambdaDelayed.
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
@ -209,7 +209,7 @@ EditCaptionBox::EditCaptionBox(
| Images::Option::RoundedTopRight | Images::Option::RoundedTopRight
| Images::Option::RoundedBottomLeft | Images::Option::RoundedBottomLeft
| Images::Option::RoundedBottomRight; | Images::Option::RoundedBottomRight;
_thumb = App::pixmapFromImageInPlace(Images::prepare( _thumb = Ui::PixmapFromImage(Images::prepare(
image->original(), image->original(),
_thumbw * cIntRetinaFactor(), _thumbw * cIntRetinaFactor(),
0, 0,
@ -339,7 +339,7 @@ EditCaptionBox::EditCaptionBox(
const auto prepareBasicThumb = _refreshThumbnail; const auto prepareBasicThumb = _refreshThumbnail;
const auto scaleThumbDown = [=] { const auto scaleThumbDown = [=] {
_thumb = App::pixmapFromImageInPlace(_thumb.toImage().scaled( _thumb = Ui::PixmapFromImage(_thumb.toImage().scaled(
_thumbw * cIntRetinaFactor(), _thumbw * cIntRetinaFactor(),
_thumbh * cIntRetinaFactor(), _thumbh * cIntRetinaFactor(),
Qt::KeepAspectRatio, Qt::KeepAspectRatio,
@ -661,7 +661,7 @@ void EditCaptionBox::updateEditPreview() {
_photoEditorButton->setVisible(_photo); _photoEditorButton->setVisible(_photo);
if (!_doc) { if (!_doc) {
_thumb = App::pixmapFromImageInPlace( _thumb = Ui::PixmapFromImage(
file->preview.scaled( file->preview.scaled(
st::sendMediaPreviewSize * cIntRetinaFactor(), st::sendMediaPreviewSize * cIntRetinaFactor(),
(st::confirmMaxHeight - (showCheckbox (st::confirmMaxHeight - (showCheckbox

View file

@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "app.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_media_view.h" #include "styles/style_media_view.h"
@ -423,7 +422,7 @@ void EditColorBox::Slider::generatePixmap() {
if (!isHorizontal()) { if (!isHorizontal()) {
image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0)); image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0));
} }
_pixmap = App::pixmapFromImageInPlace(std::move(image)); _pixmap = Ui::PixmapFromImage(std::move(image));
} else if (_type == Type::Opacity) { } else if (_type == Type::Opacity) {
auto color = anim::shifted(QColor(255, 255, 255, 255)); auto color = anim::shifted(QColor(255, 255, 255, 255));
auto transparent = anim::shifted(QColor(255, 255, 255, 0)); auto transparent = anim::shifted(QColor(255, 255, 255, 0));
@ -459,7 +458,7 @@ void EditColorBox::Slider::generatePixmap() {
if (!isHorizontal()) { if (!isHorizontal()) {
image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0)); image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0));
} }
_pixmap = App::pixmapFromImageInPlace(std::move(image)); _pixmap = Ui::PixmapFromImage(std::move(image));
} }
} }
@ -530,7 +529,7 @@ void EditColorBox::Slider::setLightnessLimits(int min, int max) {
} }
void EditColorBox::Slider::updatePixmapFromMask() { void EditColorBox::Slider::updatePixmapFromMask() {
_pixmap = App::pixmapFromImageInPlace(style::colorizeImage(_mask, _color)); _pixmap = Ui::PixmapFromImage(style::colorizeImage(_mask, _color));
} }
void EditColorBox::Slider::updateCurrentPoint(QPoint localPosition) { void EditColorBox::Slider::updateCurrentPoint(QPoint localPosition) {

View file

@ -15,10 +15,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h" #include "ui/effects/animations.h"
#include "ui/effects/radial_animation.h" #include "ui/effects/radial_animation.h"
#include "ui/emoji_config.h" #include "ui/emoji_config.h"
#include "ui/ui_utility.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "app.h"
#include "storage/storage_cloud_blob.h" #include "storage/storage_cloud_blob.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
@ -456,7 +456,7 @@ void Row::setupPreview(const Set &set) {
const auto full = original.height(); const auto full = original.height();
auto &&preview = ranges::views::zip(_preview, ranges::views::ints(0, int(_preview.size()))); auto &&preview = ranges::views::zip(_preview, ranges::views::ints(0, int(_preview.size())));
for (auto &&[pixmap, index] : preview) { for (auto &&[pixmap, index] : preview) {
pixmap = App::pixmapFromImageInPlace(original.copy( pixmap = Ui::PixmapFromImage(original.copy(
{ full * index, 0, full, full } { full * index, 0, full, full }
).scaledToWidth(size, Qt::SmoothTransformation)); ).scaledToWidth(size, Qt::SmoothTransformation));
pixmap.setDevicePixelRatio(cRetinaFactor()); pixmap.setDevicePixelRatio(cRetinaFactor());

View file

@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/empty_userpic.h" #include "ui/empty_userpic.h"
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/toasts/common_toasts.h" #include "ui/toasts/common_toasts.h"
#include "ui/ui_utility.h"
#include "history/history.h" #include "history/history.h"
#include "history/view/history_view_element.h" #include "history/view/history_view_element.h"
#include "history/history_item.h" #include "history/history_item.h"
@ -41,7 +42,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_facade.h" #include "storage/storage_facade.h"
#include "storage/storage_shared_media.h" #include "storage/storage_shared_media.h"
#include "facades.h" // Ui::showPeerProfile #include "facades.h" // Ui::showPeerProfile
#include "app.h"
namespace { namespace {
@ -417,7 +417,7 @@ QPixmap PeerData::genUserpic(
Painter p(&result); Painter p(&result);
paintUserpic(p, view, 0, 0, size); paintUserpic(p, view, 0, 0, size);
} }
return App::pixmapFromImageInPlace(std::move(result)); return Ui::PixmapFromImage(std::move(result));
} }
QPixmap PeerData::genUserpicRounded( QPixmap PeerData::genUserpicRounded(
@ -433,7 +433,7 @@ QPixmap PeerData::genUserpicRounded(
Painter p(&result); Painter p(&result);
paintUserpicRounded(p, view, 0, 0, size); paintUserpicRounded(p, view, 0, 0, size);
} }
return App::pixmapFromImageInPlace(std::move(result)); return Ui::PixmapFromImage(std::move(result));
} }
Data::FileOrigin PeerData::userpicOrigin() const { Data::FileOrigin PeerData::userpicOrigin() const {

View file

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/empty_userpic.h" #include "ui/empty_userpic.h"
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/unread_badge.h" #include "ui/unread_badge.h"
#include "ui/ui_utility.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "support/support_helper.h" #include "support/support_helper.h"
#include "main/main_session.h" #include "main/main_session.h"
@ -29,7 +30,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h" #include "data/data_user.h"
#include "data/data_folder.h" #include "data/data_folder.h"
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
#include "app.h"
namespace Dialogs { namespace Dialogs {
namespace Layout { namespace Layout {
@ -601,8 +601,14 @@ void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st)
if (badgeData->left[index].isNull()) { if (badgeData->left[index].isNull()) {
int imgsize = size * cIntRetinaFactor(), imgsizehalf = sizehalf * cIntRetinaFactor(); int imgsize = size * cIntRetinaFactor(), imgsizehalf = sizehalf * cIntRetinaFactor();
createCircleMask(badgeData, size); createCircleMask(badgeData, size);
badgeData->left[index] = App::pixmapFromImageInPlace(colorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg)); badgeData->left[index] = Ui::PixmapFromImage(
badgeData->right[index] = App::pixmapFromImageInPlace(colorizeCircleHalf(badgeData, imgsize, imgsizehalf, imgsize - imgsizehalf, bg)); colorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg));
badgeData->right[index] = Ui::PixmapFromImage(colorizeCircleHalf(
badgeData,
imgsize,
imgsizehalf,
imgsize - imgsizehalf,
bg));
} }
int bar = rect.width() - 2 * sizehalf; int bar = rect.width() - 2 * sizehalf;

View file

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "ui/wrap/fade_wrap.h" #include "ui/wrap/fade_wrap.h"
#include "ui/effects/radial_animation.h" #include "ui/effects/radial_animation.h"
#include "ui/ui_utility.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "mainwidget.h" #include "mainwidget.h"
@ -651,7 +652,7 @@ void Widget::startWidthAnimation() {
QPainter p(&image); QPainter p(&image);
Ui::RenderWidget(p, _scroll); Ui::RenderWidget(p, _scroll);
} }
_widthAnimationCache = App::pixmapFromImageInPlace(std::move(image)); _widthAnimationCache = Ui::PixmapFromImage(std::move(image));
_scroll->setGeometry(scrollGeometry); _scroll->setGeometry(scrollGeometry);
_scroll->hide(); _scroll->hide();
} }

View file

@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "editor/editor_paint.h" #include "editor/editor_paint.h"
#include "app.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "editor/controllers/controllers.h" #include "editor/controllers/controllers.h"
#include "editor/scene/scene.h" #include "editor/scene/scene.h"
@ -18,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lottie/lottie_single_player.h" #include "lottie/lottie_single_player.h"
#include "storage/storage_media_prepare.h" #include "storage/storage_media_prepare.h"
#include "ui/chat/attach/attach_prepare.h" #include "ui/chat/attach/attach_prepare.h"
#include "ui/ui_utility.h"
#include <QGraphicsView> #include <QGraphicsView>
#include <QtCore/QMimeData> #include <QtCore/QMimeData>
@ -279,7 +279,7 @@ void Paint::handleMimeData(const QMimeData *data) {
} }
const auto item = std::make_shared<ItemImage>( const auto item = std::make_shared<ItemImage>(
App::pixmapFromImageInPlace(std::move(image)), Ui::PixmapFromImage(std::move(image)),
_transform.zoom.value(), _transform.zoom.value(),
_lastZ, _lastZ,
size, size,

View file

@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "editor/scene/scene_item_sticker.h" #include "editor/scene/scene_item_sticker.h"
#include "app.h"
#include "chat_helpers/stickers_lottie.h" #include "chat_helpers/stickers_lottie.h"
#include "data/data_document.h" #include "data/data_document.h"
#include "data/data_document_media.h" #include "data/data_document_media.h"
@ -15,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lottie/lottie_common.h" #include "lottie/lottie_common.h"
#include "lottie/lottie_single_player.h" #include "lottie/lottie_single_player.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "ui/ui_utility.h"
#include "styles/style_editor.h" #include "styles/style_editor.h"
namespace Editor { namespace Editor {
@ -51,7 +51,7 @@ ItemSticker::ItemSticker(
Lottie::Quality::High); Lottie::Quality::High);
_lottie.player->updates( _lottie.player->updates(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
updatePixmap(App::pixmapFromImageInPlace( updatePixmap(Ui::PixmapFromImage(
_lottie.player->frame())); _lottie.player->frame()));
_lottie.player = nullptr; _lottie.player = nullptr;
_lottie.lifetime.destroy(); _lottie.lifetime.destroy();

View file

@ -16,10 +16,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/ui_utility.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "layout.h" #include "layout.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "app.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
namespace HistoryView { namespace HistoryView {
@ -115,7 +115,7 @@ QPixmap circleCorner(int corner, const style::color &bg) {
bg, bg,
part); part);
result.setDevicePixelRatio(cRetinaFactor()); result.setDevicePixelRatio(cRetinaFactor());
currentCorner = App::pixmapFromImageInPlace(std::move(result)); currentCorner = Ui::PixmapFromImage(std::move(result));
} }
return currentCorner; return currentCorner;
} }

View file

@ -19,9 +19,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/qthelp_url.h" #include "base/qthelp_url.h"
#include "ui/text/format_values.h" #include "ui/text/format_values.h"
#include "ui/cached_round_corners.h" #include "ui/cached_round_corners.h"
#include "ui/ui_utility.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "layout.h" // FullSelection #include "layout.h" // FullSelection
#include "app.h" // App::pixmapFromImageInPlace.
#include "styles/style_chat.h" #include "styles/style_chat.h"
namespace HistoryView { namespace HistoryView {
@ -259,7 +259,7 @@ void ThemeDocument::prepareThumbnailFrom(
Data::PatternColor(_background), Data::PatternColor(_background),
_intensity); _intensity);
} }
_thumbnail = App::pixmapFromImageInPlace(std::move(original)); _thumbnail = Ui::PixmapFromImage(std::move(original));
_thumbnailGood = good; _thumbnailGood = good;
} }

View file

@ -26,13 +26,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/wrap/fade_wrap.h" #include "ui/wrap/fade_wrap.h"
#include "ui/effects/slide_animation.h" #include "ui/effects/slide_animation.h"
#include "ui/ui_utility.h"
#include "data/data_user.h" #include "data/data_user.h"
#include "data/data_auto_download.h" #include "data/data_auto_download.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_chat_filters.h" #include "data/data_chat_filters.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "app.h"
#include "styles/style_intro.h" #include "styles/style_intro.h"
#include "styles/style_window.h" #include "styles/style_window.h"
@ -366,7 +366,7 @@ void Step::prepareCoverMask() {
} }
maskInts += maskIntsPerLineAdded; maskInts += maskIntsPerLineAdded;
} }
_coverMask = App::pixmapFromImageInPlace(std::move(mask)); _coverMask = Ui::PixmapFromImage(std::move(mask));
} }
void Step::paintCover(Painter &p, int top) { void Step::paintCover(Painter &p, int top) {

View file

@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/resize_area.h" #include "ui/resize_area.h"
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/emoji_config.h" #include "ui/emoji_config.h"
#include "ui/ui_utility.h"
#include "window/section_memento.h" #include "window/section_memento.h"
#include "window/section_widget.h" #include "window/section_widget.h"
#include "window/window_connecting_widget.h" #include "window/window_connecting_widget.h"
@ -108,7 +109,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_facade.h" #include "storage/storage_facade.h"
#include "storage/storage_shared_media.h" #include "storage/storage_shared_media.h"
#include "storage/storage_user_photos.h" #include "storage/storage_user_photos.h"
#include "app.h"
#include "facades.h" #include "facades.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
@ -815,7 +815,7 @@ void MainWidget::cacheBackground() {
} }
_cachedX = 0; _cachedX = 0;
_cachedY = 0; _cachedY = 0;
_cachedBackground = App::pixmapFromImageInPlace(std::move(result)); _cachedBackground = Ui::PixmapFromImage(std::move(result));
} else { } else {
auto &bg = Window::Theme::Background()->pixmap(); auto &bg = Window::Theme::Background()->pixmap();
@ -823,7 +823,12 @@ void MainWidget::cacheBackground() {
Window::Theme::ComputeBackgroundRects(_willCacheFor, bg.size(), to, from); Window::Theme::ComputeBackgroundRects(_willCacheFor, bg.size(), to, from);
_cachedX = to.x(); _cachedX = to.x();
_cachedY = to.y(); _cachedY = to.y();
_cachedBackground = App::pixmapFromImageInPlace(bg.toImage().copy(from).scaled(to.width() * cIntRetinaFactor(), to.height() * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); _cachedBackground = Ui::PixmapFromImage(
bg.toImage().copy(from).scaled(
to.width() * cIntRetinaFactor(),
to.height() * cIntRetinaFactor(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation));
_cachedBackground.setDevicePixelRatio(cRetinaFactor()); _cachedBackground.setDevicePixelRatio(cRetinaFactor());
} }
_cachedFor = _willCacheFor; _cachedFor = _willCacheFor;

View file

@ -53,7 +53,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_media_preview.h" #include "window/window_media_preview.h"
#include "facades.h" #include "facades.h"
#include "app.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_window.h" #include "styles/style_window.h"
@ -955,7 +954,11 @@ QImage MainWindow::iconWithCounter(int size, int count, style::color bg, style::
placeSmallCounter(img, size, count, bg, QPoint(), fg); placeSmallCounter(img, size, count, bg, QPoint(), fg);
} else { } else {
QPainter p(&img); QPainter p(&img);
p.drawPixmap(size / 2, size / 2, App::pixmapFromImageInPlace(iconWithCounter(-size / 2, count, bg, fg, false))); p.drawPixmap(
size / 2,
size / 2,
Ui::PixmapFromImage(
iconWithCounter(-size / 2, count, bg, fg, false)));
} }
return img; return img;
} }

View file

@ -25,8 +25,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/core_settings.h" #include "core/core_settings.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "ui/ui_utility.h"
#include "facades.h" #include "facades.h"
#include "app.h"
#include "styles/style_media_player.h" #include "styles/style_media_player.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
@ -173,7 +173,7 @@ void Float::prepareShadow() {
auto extend = 2 * st::lineWidth; auto extend = 2 * st::lineWidth;
p.drawEllipse(getInnerRect().marginsAdded(QMargins(extend, extend, extend, extend))); p.drawEllipse(getInnerRect().marginsAdded(QMargins(extend, extend, extend, extend)));
} }
_shadow = App::pixmapFromImageInPlace(Images::prepareBlur(std::move(shadow))); _shadow = Ui::PixmapFromImage(Images::prepareBlur(std::move(shadow)));
} }
QRect Float::getInnerRect() const { QRect Float::getInnerRect() const {

View file

@ -20,9 +20,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h" #include "history/history.h"
#include "history/view/media/history_view_media.h" #include "history/view/media/history_view_media.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "ui/ui_utility.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "core/crash_reports.h" #include "core/crash_reports.h"
#include "app.h"
#include "styles/style_media_view.h" #include "styles/style_media_view.h"
namespace Media { namespace Media {
@ -287,7 +287,7 @@ void GroupThumbs::Thumb::validateImage() {
/ pixSize.width(); / pixSize.width();
auto original = _image->original(); auto original = _image->original();
original.setDevicePixelRatio(cRetinaFactor()); original.setDevicePixelRatio(cRetinaFactor());
_full = App::pixmapFromImageInPlace(original.copy( _full = Ui::PixmapFromImage(original.copy(
(originalWidth - takeWidth) / 2, (originalWidth - takeWidth) / 2,
0, 0,
takeWidth, takeWidth,

View file

@ -44,7 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/format_values.h" #include "ui/text/format_values.h"
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/cached_round_corners.h" #include "ui/cached_round_corners.h"
#include "app.h" #include "ui/ui_utility.h"
namespace Overview { namespace Overview {
namespace Layout { namespace Layout {
@ -368,7 +368,7 @@ void Photo::setPixFrom(not_null<Image*> image) {
delegate()->unregisterHeavyItem(this); delegate()->unregisterHeavyItem(this);
} }
_pix = App::pixmapFromImageInPlace(std::move(img)); _pix = Ui::PixmapFromImage(std::move(img));
} }
void Photo::ensureDataMediaCreated() const { void Photo::ensureDataMediaCreated() const {
@ -459,7 +459,7 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const
} }
img.setDevicePixelRatio(cRetinaFactor()); img.setDevicePixelRatio(cRetinaFactor());
_pix = App::pixmapFromImageInPlace(std::move(img)); _pix = Ui::PixmapFromImage(std::move(img));
_pixBlurred = !(thumbnail || good); _pixBlurred = !(thumbnail || good);
} }

View file

@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/event_filter.h" #include "base/event_filter.h"
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "app.h" #include "ui/ui_utility.h"
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#include "base/platform/linux/base_linux_glibmm_helper.h" #include "base/platform/linux/base_linux_glibmm_helper.h"
@ -355,8 +355,7 @@ QIcon TrayIconGen(int counter, bool muted) {
} }
} }
result.addPixmap(App::pixmapFromImageInPlace( result.addPixmap(Ui::PixmapFromImage(std::move(iconImage)));
std::move(iconImage)));
} }
UpdateIconRegenerationNeeded(result, counter, muted, iconThemeName); UpdateIconRegenerationNeeded(result, counter, muted, iconThemeName);

View file

@ -35,8 +35,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "base/platform/mac/base_utilities_mac.h" #include "base/platform/mac/base_utilities_mac.h"
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "ui/ui_utility.h"
#include "facades.h" #include "facades.h"
#include "app.h"
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtGui/QClipboard> #include <QtGui/QClipboard>
@ -632,10 +632,22 @@ QIcon MainWindow::generateIconForTray(int counter, bool muted) const {
_placeCounter(darkMode, size, counter, bg, muted ? st::trayCounterFgMacInvert : st::trayCounterFg); _placeCounter(darkMode, size, counter, bg, muted ? st::trayCounterFgMacInvert : st::trayCounterFg);
_placeCounter(lightModeActive, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert); _placeCounter(lightModeActive, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert);
_placeCounter(darkModeActive, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert); _placeCounter(darkModeActive, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert);
result.addPixmap(App::pixmapFromImageInPlace(std::move(lightMode)), QIcon::Normal, QIcon::Off); result.addPixmap(Ui::PixmapFromImage(
result.addPixmap(App::pixmapFromImageInPlace(std::move(darkMode)), QIcon::Normal, QIcon::On); std::move(lightMode)),
result.addPixmap(App::pixmapFromImageInPlace(std::move(lightModeActive)), QIcon::Active, QIcon::Off); QIcon::Normal,
result.addPixmap(App::pixmapFromImageInPlace(std::move(darkModeActive)), QIcon::Active, QIcon::On); QIcon::Off);
result.addPixmap(Ui::PixmapFromImage(
std::move(darkMode)),
QIcon::Normal,
QIcon::On);
result.addPixmap(Ui::PixmapFromImage(
std::move(lightModeActive)),
QIcon::Active,
QIcon::Off);
result.addPixmap(Ui::PixmapFromImage(
std::move(darkModeActive)),
QIcon::Active,
QIcon::On);
return result; return result;
} }

View file

@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h" #include "core/application.h"
#include "core/crash_reports.h" #include "core/crash_reports.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "app.h" #include "ui/ui_utility.h"
#include <QtWidgets/QFileDialog> #include <QtWidgets/QFileDialog>
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>
@ -90,7 +90,14 @@ HBITMAP IconToBitmap(LPWSTR icon, int iconindex) {
if (!iconindex) { // try to read image if (!iconindex) { // try to read image
QImage img(QString::fromWCharArray(icon)); QImage img(QString::fromWCharArray(icon));
if (!img.isNull()) { if (!img.isNull()) {
return qt_pixmapToWinHBITMAP(App::pixmapFromImageInPlace(img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)), /* HBitmapAlpha */ 2); return qt_pixmapToWinHBITMAP(
Ui::PixmapFromImage(
img.scaled(
w,
h,
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation)),
/* HBitmapAlpha */ 2);
} }
} }
return 0; return 0;
@ -431,4 +438,4 @@ bool Get(
} }
} // namespace FileDialog } // namespace FileDialog
} // namespace Platform } // namespace Platform

View file

@ -20,9 +20,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "ui/ui_utility.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "history/history.h" #include "history/history.h"
#include "app.h"
#include <QtWidgets/QDesktopWidget> #include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QStyleFactory> #include <QtWidgets/QStyleFactory>
@ -241,7 +241,7 @@ void MainWindow::psSetupTrayIcon() {
if (!trayIcon) { if (!trayIcon) {
trayIcon = new QSystemTrayIcon(this); trayIcon = new QSystemTrayIcon(this);
auto icon = QIcon(App::pixmapFromImageInPlace(Core::App().logoNoMargin())); auto icon = QIcon(Ui::PixmapFromImage(Core::App().logoNoMargin()));
trayIcon->setIcon(icon); trayIcon->setIcon(icon);
connect( connect(
@ -369,13 +369,17 @@ void MainWindow::updateIconCounters() {
auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg); auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg);
auto &fg = st::trayCounterFg; auto &fg = st::trayCounterFg;
auto iconSmallPixmap16 = App::pixmapFromImageInPlace(iconWithCounter(16, counter, bg, fg, true)); auto iconSmallPixmap16 = Ui::PixmapFromImage(
auto iconSmallPixmap32 = App::pixmapFromImageInPlace(iconWithCounter(32, counter, bg, fg, true)); iconWithCounter(16, counter, bg, fg, true));
auto iconSmallPixmap32 = Ui::PixmapFromImage(
iconWithCounter(32, counter, bg, fg, true));
QIcon iconSmall, iconBig; QIcon iconSmall, iconBig;
iconSmall.addPixmap(iconSmallPixmap16); iconSmall.addPixmap(iconSmallPixmap16);
iconSmall.addPixmap(iconSmallPixmap32); iconSmall.addPixmap(iconSmallPixmap32);
iconBig.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(32, taskbarList.Get() ? 0 : counter, bg, fg, false))); iconBig.addPixmap(Ui::PixmapFromImage(
iconBig.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(64, taskbarList.Get() ? 0 : counter, bg, fg, false))); iconWithCounter(32, taskbarList.Get() ? 0 : counter, bg, fg, false)));
iconBig.addPixmap(Ui::PixmapFromImage(
iconWithCounter(64, taskbarList.Get() ? 0 : counter, bg, fg, false)));
if (trayIcon) { if (trayIcon) {
// Force Qt to use right icon size, not the larger one. // Force Qt to use right icon size, not the larger one.
QIcon forTrayIcon; QIcon forTrayIcon;
@ -391,8 +395,10 @@ void MainWindow::updateIconCounters() {
if (taskbarList.Get()) { if (taskbarList.Get()) {
if (counter > 0) { if (counter > 0) {
QIcon iconOverlay; QIcon iconOverlay;
iconOverlay.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(-16, counter, bg, fg, false))); iconOverlay.addPixmap(Ui::PixmapFromImage(
iconOverlay.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(-32, counter, bg, fg, false))); iconWithCounter(-16, counter, bg, fg, false)));
iconOverlay.addPixmap(Ui::PixmapFromImage(
iconWithCounter(-32, counter, bg, fg, false)));
ps_iconOverlay = createHIconFromQIcon(iconOverlay, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); ps_iconOverlay = createHIconFromQIcon(iconOverlay, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
} }
auto description = (counter > 0) ? tr::lng_unread_bar(tr::now, lt_count, counter) : QString(); auto description = (counter > 0) ? tr::lng_unread_bar(tr::now, lt_count, counter) : QString();

View file

@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/radial_animation.h" #include "ui/effects/radial_animation.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "ui/ui_utility.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "export/export_manager.h" #include "export/export_manager.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
@ -590,7 +591,7 @@ void BackgroundRow::updateImage() {
} }
} }
Images::prepareRound(back, ImageRoundRadius::Small); Images::prepareRound(back, ImageRoundRadius::Small);
_background = App::pixmapFromImageInPlace(std::move(back)); _background = Ui::PixmapFromImage(std::move(back));
_background.setDevicePixelRatio(cRetinaFactor()); _background.setDevicePixelRatio(cRetinaFactor());
rtlupdate(radialRect()); rtlupdate(radialRect());

View file

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/discrete_sliders.h" #include "ui/widgets/discrete_sliders.h"
#include "ui/ui_utility.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "window/notifications_manager.h" #include "window/notifications_manager.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
@ -27,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_domain.h" #include "main/main_domain.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "facades.h" #include "facades.h"
#include "app.h"
#include "styles/style_settings.h" #include "styles/style_settings.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_window.h" #include "styles/style_window.h"
@ -251,13 +251,13 @@ void NotificationsCount::prepareNotificationSampleSmall() {
auto closeLeft = width - 2 * padding; auto closeLeft = width - 2 * padding;
p.fillRect(style::rtlrect(closeLeft, padding, padding, padding, width), st::notificationSampleCloseFg); p.fillRect(style::rtlrect(closeLeft, padding, padding, padding, width), st::notificationSampleCloseFg);
} }
_notificationSampleSmall = App::pixmapFromImageInPlace(std::move(sampleImage)); _notificationSampleSmall = Ui::PixmapFromImage(std::move(sampleImage));
_notificationSampleSmall.setDevicePixelRatio(cRetinaFactor()); _notificationSampleSmall.setDevicePixelRatio(cRetinaFactor());
} }
void NotificationsCount::prepareNotificationSampleUserpic() { void NotificationsCount::prepareNotificationSampleUserpic() {
if (_notificationSampleUserpic.isNull()) { if (_notificationSampleUserpic.isNull()) {
_notificationSampleUserpic = App::pixmapFromImageInPlace( _notificationSampleUserpic = Ui::PixmapFromImage(
Core::App().logoNoMargin().scaled( Core::App().logoNoMargin().scaled(
st::notifyPhotoSize * cIntRetinaFactor(), st::notifyPhotoSize * cIntRetinaFactor(),
st::notifyPhotoSize * cIntRetinaFactor(), st::notifyPhotoSize * cIntRetinaFactor(),
@ -303,7 +303,7 @@ void NotificationsCount::prepareNotificationSampleLarge() {
st::notifyClose.icon.paint(p, w - st::notifyClosePos.x() - st::notifyClose.width + st::notifyClose.iconPosition.x(), st::notifyClosePos.y() + st::notifyClose.iconPosition.y(), w); st::notifyClose.icon.paint(p, w - st::notifyClosePos.x() - st::notifyClose.width + st::notifyClose.iconPosition.x(), st::notifyClosePos.y() + st::notifyClose.iconPosition.y(), w);
} }
_notificationSampleLarge = App::pixmapFromImageInPlace(std::move(sampleImage)); _notificationSampleLarge = Ui::PixmapFromImage(std::move(sampleImage));
} }
void NotificationsCount::removeSample(SampleWidget *widget) { void NotificationsCount::removeSample(SampleWidget *widget) {

View file

@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "app.h"
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
@ -79,7 +78,7 @@ QPixmap PrepareOuterWide(const style::RoundCheckbox *st) {
size + 2. * half, size + 2. * half,
size + 2. * half)); size + 2. * half));
} }
return App::pixmapFromImageInPlace(std::move(result)); return Ui::PixmapFromImage(std::move(result));
} }
QPixmap PrepareInner(const style::RoundCheckbox *st, bool displayInactive) { QPixmap PrepareInner(const style::RoundCheckbox *st, bool displayInactive) {
@ -102,7 +101,7 @@ QPixmap PrepareInner(const style::RoundCheckbox *st, bool displayInactive) {
size - (displayInactive ? 0. : 2. * half), size - (displayInactive ? 0. : 2. * half),
size - (displayInactive ? 0. : 2. * half))); size - (displayInactive ? 0. : 2. * half)));
} }
return App::pixmapFromImageInPlace(std::move(result)); return Ui::PixmapFromImage(std::move(result));
} }
QPixmap PrepareCheck(const style::RoundCheckbox *st) { QPixmap PrepareCheck(const style::RoundCheckbox *st) {
@ -116,7 +115,7 @@ QPixmap PrepareCheck(const style::RoundCheckbox *st) {
Painter p(&result); Painter p(&result);
st->check.paint(p, 0, 0, size); st->check.paint(p, 0, 0, size);
} }
return App::pixmapFromImageInPlace(std::move(result)); return Ui::PixmapFromImage(std::move(result));
} }
QRect WideDestRect( QRect WideDestRect(
@ -238,7 +237,7 @@ QPixmap CheckCaches::paintFrame(
remove, remove,
remove)); remove));
} }
return App::pixmapFromImageInPlace(std::move(result)); return Ui::PixmapFromImage(std::move(result));
} }
CheckCaches *FrameCaches() { CheckCaches *FrameCaches() {
@ -286,8 +285,8 @@ void prepareCheckCaches(const style::RoundCheckbox *st, bool displayInactive, QP
auto ellipse = QRect((wideSize - size) / 2, (wideSize - size) / 2, size, size); auto ellipse = QRect((wideSize - size) / 2, (wideSize - size) / 2, size, size);
st->check.paint(p, ellipse.topLeft(), wideSize); st->check.paint(p, ellipse.topLeft(), wideSize);
} }
checkBgCache = App::pixmapFromImageInPlace(std::move(cache)); checkBgCache = Ui::PixmapFromImage(std::move(cache));
checkFullCache = App::pixmapFromImageInPlace(std::move(cacheIcon)); checkFullCache = Ui::PixmapFromImage(std::move(cacheIcon));
} }
} // namespace } // namespace
@ -379,7 +378,7 @@ void RoundCheckbox::prepareInactiveCache() {
p.setBrush(_st.bgInactive); p.setBrush(_st.bgInactive);
p.drawEllipse(ellipse); p.drawEllipse(ellipse);
} }
_inactiveCacheBg = App::pixmapFromImageInPlace(std::move(cacheBg)); _inactiveCacheBg = Ui::PixmapFromImage(std::move(cacheBg));
{ {
Painter p(&cacheFg); Painter p(&cacheFg);
@ -391,7 +390,7 @@ void RoundCheckbox::prepareInactiveCache() {
p.setBrush(Qt::NoBrush); p.setBrush(Qt::NoBrush);
p.drawEllipse(ellipse); p.drawEllipse(ellipse);
} }
_inactiveCacheFg = App::pixmapFromImageInPlace(std::move(cacheFg)); _inactiveCacheFg = Ui::PixmapFromImage(std::move(cacheFg));
} }
RoundImageCheckbox::RoundImageCheckbox(const style::RoundImageCheckbox &st, Fn<void()> updateCallback, PaintRoundImage &&paintRoundImage) RoundImageCheckbox::RoundImageCheckbox(const style::RoundImageCheckbox &st, Fn<void()> updateCallback, PaintRoundImage &&paintRoundImage)
@ -475,7 +474,7 @@ void RoundImageCheckbox::prepareWideCache() {
p.setCompositionMode(QPainter::CompositionMode_SourceOver); p.setCompositionMode(QPainter::CompositionMode_SourceOver);
_paintRoundImage(p, (wideSize - size) / 2, (wideSize - size) / 2, wideSize, size); _paintRoundImage(p, (wideSize - size) / 2, (wideSize - size) / 2, wideSize, size);
} }
_wideCache = App::pixmapFromImageInPlace(std::move(cache)); _wideCache = Ui::PixmapFromImage(std::move(cache));
} }
} }

View file

@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_peer.h" #include "data/data_peer.h"
#include "ui/emoji_config.h" #include "ui/emoji_config.h"
#include "ui/effects/animation_value.h" #include "ui/effects/animation_value.h"
#include "app.h" #include "ui/ui_utility.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_widgets.h" // style::IconButton #include "styles/style_widgets.h" // style::IconButton
@ -171,7 +171,7 @@ template <typename Callback>
Painter p(&result); Painter p(&result);
callback(p); callback(p);
} }
return App::pixmapFromImageInPlace(std::move(result)); return Ui::PixmapFromImage(std::move(result));
} }
} // namespace } // namespace
@ -396,7 +396,7 @@ QPixmap EmptyUserpic::generate(int size) {
Painter p(&result); Painter p(&result);
paint(p, 0, 0, size, size); paint(p, 0, 0, size, size);
} }
return App::pixmapFromImageInPlace(std::move(result)); return Ui::PixmapFromImage(std::move(result));
} }
void EmptyUserpic::fillString(const QString &name) { void EmptyUserpic::fillString(const QString &name) {

View file

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/cache/storage_cache_database.h" #include "storage/cache/storage_cache_database.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "ui/ui_utility.h"
#include "app.h" #include "app.h"
using namespace Images; using namespace Images;
@ -622,10 +623,11 @@ QPixmap Image::pixNoCache(
Assert(colored != nullptr); Assert(colored != nullptr);
result = prepareColored(*colored, std::move(result)); result = prepareColored(*colored, std::move(result));
} }
return App::pixmapFromImageInPlace(std::move(result)); return Ui::PixmapFromImage(std::move(result));
} }
return App::pixmapFromImageInPlace(prepare(_data, w, h, options, outerw, outerh, colored)); return Ui::PixmapFromImage(
prepare(_data, w, h, options, outerw, outerh, colored));
} }
QPixmap Image::pixColoredNoCache( QPixmap Image::pixColoredNoCache(
@ -639,12 +641,19 @@ QPixmap Image::pixColoredNoCache(
auto img = _data; auto img = _data;
if (w <= 0 || !width() || !height() || (w == width() && (h <= 0 || h == height()))) { if (w <= 0 || !width() || !height() || (w == width() && (h <= 0 || h == height()))) {
return App::pixmapFromImageInPlace(prepareColored(add, std::move(img))); return Ui::PixmapFromImage(prepareColored(add, std::move(img)));
} }
const auto transformation = smooth
? Qt::SmoothTransformation
: Qt::FastTransformation;
if (h <= 0) { if (h <= 0) {
return App::pixmapFromImageInPlace(prepareColored(add, img.scaledToWidth(w, smooth ? Qt::SmoothTransformation : Qt::FastTransformation))); return Ui::PixmapFromImage(
prepareColored(add, img.scaledToWidth(w, transformation)));
} }
return App::pixmapFromImageInPlace(prepareColored(add, img.scaled(w, h, Qt::IgnoreAspectRatio, smooth ? Qt::SmoothTransformation : Qt::FastTransformation))); return Ui::PixmapFromImage(
prepareColored(
add,
img.scaled(w, h, Qt::IgnoreAspectRatio, transformation)));
} }
QPixmap Image::pixBlurredColoredNoCache( QPixmap Image::pixBlurredColoredNoCache(
@ -662,5 +671,5 @@ QPixmap Image::pixBlurredColoredNoCache(
img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
} }
return App::pixmapFromImageInPlace(prepareColored(add, img)); return Ui::PixmapFromImage(prepareColored(add, img));
} }

View file

@ -39,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h" #include "apiwrap.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "facades.h" #include "facades.h"
#include "app.h"
namespace Ui { namespace Ui {
namespace { namespace {
@ -66,7 +65,7 @@ QPixmap CreateSquarePixmap(int width, Callback &&paintCallback) {
Painter p(&image); Painter p(&image);
paintCallback(p); paintCallback(p);
} }
return App::pixmapFromImageInPlace(std::move(image)); return Ui::PixmapFromImage(std::move(image));
}; };
} // namespace } // namespace
@ -698,7 +697,7 @@ void UserpicButton::setImage(QImage &&image) {
Qt::IgnoreAspectRatio, Qt::IgnoreAspectRatio,
Qt::SmoothTransformation); Qt::SmoothTransformation);
Images::prepareCircle(small); Images::prepareCircle(small);
_userpic = App::pixmapFromImageInPlace(std::move(small)); _userpic = Ui::PixmapFromImage(std::move(small));
_userpic.setDevicePixelRatio(cRetinaFactor()); _userpic.setDevicePixelRatio(cRetinaFactor());
_userpicCustom = _userpicHasImage = true; _userpicCustom = _userpicHasImage = true;
_result = std::move(image); _result = std::move(image);

View file

@ -13,8 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/scroll_area.h" #include "ui/widgets/scroll_area.h"
#include "ui/effects/cross_animation.h" #include "ui/effects/cross_animation.h"
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/ui_utility.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "app.h"
namespace Ui { namespace Ui {
namespace { namespace {
@ -213,7 +213,7 @@ void MultiSelect::Item::prepareCache() {
Painter p(&data); Painter p(&data);
paintOnce(p, _width * (kWideScale - 1) / 2, _st.height * (kWideScale - 1) / 2, cacheWidth); paintOnce(p, _width * (kWideScale - 1) / 2, _st.height * (kWideScale - 1) / 2, cacheWidth);
} }
_cache = App::pixmapFromImageInPlace(std::move(data)); _cache = Ui::PixmapFromImage(std::move(data));
} }
void MultiSelect::Item::setVisibleAnimated(bool visible) { void MultiSelect::Item::setVisibleAnimated(bool visible) {

View file

@ -113,7 +113,7 @@ QIcon CreateOfficialIcon(Main::Session *session) {
if (session && session->supportMode()) { if (session && session->supportMode()) {
ConvertIconToBlack(image); ConvertIconToBlack(image);
} }
return QIcon(App::pixmapFromImageInPlace(std::move(image))); return QIcon(Ui::PixmapFromImage(std::move(image)));
} }
QIcon CreateIcon(Main::Session *session) { QIcon CreateIcon(Main::Session *session) {

View file

@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/base_platform_last_input.h" #include "base/platform/base_platform_last_input.h"
#include "base/call_delayed.h" #include "base/call_delayed.h"
#include "facades.h" #include "facades.h"
#include "app.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_window.h" #include "styles/style_window.h"
@ -92,7 +91,12 @@ Manager::QueuedNotification::QueuedNotification(
QPixmap Manager::hiddenUserpicPlaceholder() const { QPixmap Manager::hiddenUserpicPlaceholder() const {
if (_hiddenUserpicPlaceholder.isNull()) { if (_hiddenUserpicPlaceholder.isNull()) {
_hiddenUserpicPlaceholder = App::pixmapFromImageInPlace(Core::App().logoNoMargin().scaled(st::notifyPhotoSize, st::notifyPhotoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); _hiddenUserpicPlaceholder = Ui::PixmapFromImage(
Core::App().logoNoMargin().scaled(
st::notifyPhotoSize,
st::notifyPhotoSize,
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation));
_hiddenUserpicPlaceholder.setDevicePixelRatio(cRetinaFactor()); _hiddenUserpicPlaceholder.setDevicePixelRatio(cRetinaFactor());
} }
return _hiddenUserpicPlaceholder; return _hiddenUserpicPlaceholder;
@ -682,7 +686,7 @@ void Notification::prepareActionsCache() {
p.fillRect(style::rtlrect(fadeWidth, 0, actionsCacheWidth - fadeWidth, actionsCacheHeight, actionsCacheWidth), st::notificationBg); p.fillRect(style::rtlrect(fadeWidth, 0, actionsCacheWidth - fadeWidth, actionsCacheHeight, actionsCacheWidth), st::notificationBg);
p.drawPixmapRight(replyRight, _reply->y() - actionsTop, actionsCacheWidth, replyCache); p.drawPixmapRight(replyRight, _reply->y() - actionsTop, actionsCacheWidth, replyCache);
} }
_buttonsCache = App::pixmapFromImageInPlace(std::move(actionsCacheImg)); _buttonsCache = Ui::PixmapFromImage(std::move(actionsCacheImg));
} }
bool Notification::checkLastInput( bool Notification::checkLastInput(
@ -861,7 +865,7 @@ void Notification::updateNotifyDisplay() {
titleText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width()); titleText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
} }
_cache = App::pixmapFromImageInPlace(std::move(img)); _cache = Ui::PixmapFromImage(std::move(img));
if (!canReply()) { if (!canReply()) {
toggleActionButtons(false); toggleActionButtons(false);
} }
@ -889,7 +893,7 @@ void Notification::updatePeerPhoto() {
width(), width(),
st::notifyPhotoSize); st::notifyPhotoSize);
} }
_cache = App::pixmapFromImageInPlace(std::move(img)); _cache = Ui::PixmapFromImage(std::move(img));
_userpicView = nullptr; _userpicView = nullptr;
update(); update();
} }

View file

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_account.h" // Account::local. #include "main/main_account.h" // Account::local.
#include "main/main_domain.h" // Domain::activeSessionValue. #include "main/main_domain.h" // Domain::activeSessionValue.
#include "ui/image/image.h" #include "ui/image/image.h"
#include "ui/ui_utility.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "boxes/background_box.h" #include "boxes/background_box.h"
#include "core/application.h" #include "core/application.h"
@ -754,10 +755,10 @@ void ChatBackground::preparePixmaps(QImage image) {
imageForTiledBytes += imageForTiled.bytesPerLine() - (repeatTimesX * bytesInLine); imageForTiledBytes += imageForTiled.bytesPerLine() - (repeatTimesX * bytesInLine);
} }
} }
_pixmapForTiled = App::pixmapFromImageInPlace(std::move(imageForTiled)); _pixmapForTiled = Ui::PixmapFromImage(std::move(imageForTiled));
} }
_isMonoColorImage = CalculateIsMonoColorImage(image); _isMonoColorImage = CalculateIsMonoColorImage(image);
_pixmap = App::pixmapFromImageInPlace(std::move(image)); _pixmap = Ui::PixmapFromImage(std::move(image));
if (!isSmallForTiled) { if (!isSmallForTiled) {
_pixmapForTiled = _pixmap; _pixmapForTiled = _pixmap;
} }

View file

@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/text/format_values.h" #include "ui/text/format_values.h"
#include "ui/special_fields.h" #include "ui/special_fields.h"
#include "ui/ui_utility.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
@ -169,7 +170,7 @@ void BackgroundSelector::updateThumbnail() {
p.drawImage(QRect(0, 0, size, size), pix, QRect(sx, sy, s, s)); p.drawImage(QRect(0, 0, size, size), pix, QRect(sx, sy, s, s));
} }
Images::prepareRound(back, ImageRoundRadius::Small); Images::prepareRound(back, ImageRoundRadius::Small);
_thumbnail = App::pixmapFromImageInPlace(std::move(back)); _thumbnail = Ui::PixmapFromImage(std::move(back));
_thumbnail.setDevicePixelRatio(cRetinaFactor()); _thumbnail.setDevicePixelRatio(cRetinaFactor());
update(); update();
} }

View file

@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/connection_box.h" #include "boxes/connection_box.h"
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "app.h"
#include "styles/style_window.h" #include "styles/style_window.h"
namespace Window { namespace Window {
@ -169,7 +168,7 @@ void ConnectionState::Widget::ProxyIcon::refreshCacheImages() {
(height() - icon.height()) / 2, (height() - icon.height()) / 2,
width()); width());
} }
return App::pixmapFromImageInPlace(std::move(image)); return Ui::PixmapFromImage(std::move(image));
}; };
_cacheOn = prepareCache(st::connectingProxyOn); _cacheOn = prepareCache(st::connectingProxyOn);
_cacheOff = prepareCache(st::connectingProxyOff); _cacheOff = prepareCache(st::connectingProxyOff);