Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
url = https://github.com/desktop-app/codegen.git
[submodule "Telegram/lib_ui"]
path = Telegram/lib_ui
url = https://github.com/desktop-app/lib_ui.git
url = git@github.com:zvova7890/lib_ui.git
[submodule "Telegram/lib_lottie"]
path = Telegram/lib_lottie
url = https://github.com/desktop-app/lib_lottie.git
url = git@github.com:zvova7890/lib_lottie.git
[submodule "Telegram/lib_tl"]
path = Telegram/lib_tl
url = https://github.com/desktop-app/lib_tl.git
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/api/api_chat_invite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void ConfirmSubscriptionBox(
creditsIconSize,
1.5);
state->frame = QImage(
Size(photoSize * style::DevicePixelRatio()),
Size(style::DevicePixels(photoSize)),
QImage::Format_ARGB32_Premultiplied);
state->frame.setDevicePixelRatio(style::DevicePixelRatio());
const auto options = Images::Option::RoundCircle;
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/boxes/background_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ void BackgroundBox::Inner::validatePaperThumbnail(
} else if (!paper.data.backgroundColors().empty()) {
paper.thumbnail = Ui::PixmapFromImage(
Ui::GenerateBackgroundImage(
st::backgroundSize * style::DevicePixelRatio(),
style::DevicePixels(st::backgroundSize),
paper.data.backgroundColors(),
paper.data.gradientRotation()));
paper.thumbnail.setDevicePixelRatio(style::DevicePixelRatio());
Expand Down
7 changes: 4 additions & 3 deletions Telegram/SourceFiles/boxes/background_preview_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ constexpr auto kMaxWallPaperSlugLength = 255;
const auto takeHeight = (width > height)
? size
: (height * size / width);
const auto ratio = style::DevicePixelRatio();
return Images::Prepare(image, QSize(takeWidth, takeHeight) * ratio, {
return Images::Prepare(image, QSize(
style::DevicePixels(takeWidth),
style::DevicePixels(takeHeight)), {
.options = Images::Option::TransparentBackground | blur,
.outer = { size, size },
});
Expand Down Expand Up @@ -725,7 +726,7 @@ void BackgroundPreviewBox::applyForPeer() {
} else if (_forBothOverlay) {
return;
}
const auto size = this->size() * style::DevicePixelRatio();
const auto size = style::DevicePixels(this->size());
const auto bg = Images::DitherImage(
Images::BlurLargeImage(
Ui::GrabWidgetToImage(this).scaled(
Expand Down
6 changes: 4 additions & 2 deletions Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@ PaintRoundImageCallback ChatRow::generatePaintUserpicCallback(
int outerWidth,
int size) mutable {
const auto wide = size + style::ConvertScale(3);
const auto full = QSize(wide, wide) * style::DevicePixelRatio();
const auto full = QSize(
style::DevicePixels(wide),
style::DevicePixels(wide));
auto repaint = false;
if (_disabledFrame.size() != full) {
repaint = true;
Expand Down Expand Up @@ -967,7 +969,7 @@ void LinksController::rowPaintIcon(
auto &icon = _icons[int(color)];
if (icon.isNull()) {
icon = QImage(
QSize(inner, inner) * style::DevicePixelRatio(),
style::DevicePixels(QSize(inner, inner)),
QImage::Format_ARGB32_Premultiplied);
icon.fill(Qt::transparent);
icon.setDevicePixelRatio(style::DevicePixelRatio());
Expand Down
11 changes: 5 additions & 6 deletions Telegram/SourceFiles/boxes/gift_premium_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,12 @@ using SpinnerState = Data::GiftUpgradeSpinner::State;
return;
}
}
const auto ratio = style::DevicePixelRatio();
const auto h = raw->height();
if (state->fading.height() != h * ratio) {
state->fading = QImage(
QSize(1, h) * ratio,
const auto pixelHeight = style::DevicePixels(h);
if (state->fading.height() != pixelHeight) {
state->fading = QImage(style::DevicePixels(QSize(1, h)),
QImage::Format_ARGB32_Premultiplied);
state->fading.setDevicePixelRatio(ratio);
state->fading.setDevicePixelRatio(style::DevicePixelRatio());
state->fading.fill(Qt::transparent);
auto q = QPainter(&state->fading);
auto brush = QLinearGradient(0, 0, 0, margin.top());
Expand All @@ -439,7 +438,7 @@ using SpinnerState = Data::GiftUpgradeSpinner::State;
auto &now = state->rows[state->nowIndex];
const auto validate = [&](Row &row) {
const auto size = row.widget->size();
if (row.frame.size() != size * ratio) {
if (row.frame.size() != style::DevicePixels(size)) {
row.frame = Ui::GrabWidgetToImage(row.widget.get());
}
};
Expand Down
7 changes: 4 additions & 3 deletions Telegram/SourceFiles/boxes/peer_list_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ PaintRoundImageCallback ForceRoundUserpicCallback(not_null<PeerData*> peer) {
auto userpic = Ui::PeerUserpicView();
auto cache = std::make_shared<QImage>();
return [=](Painter &p, int x, int y, int outerWidth, int size) mutable {
const auto ratio = style::DevicePixelRatio();
const auto cacheSize = QSize(size, size) * ratio;
const auto cacheSize = QSize(
style::DevicePixels(size),
style::DevicePixels(size));
if (cache->size() != cacheSize) {
*cache = QImage(cacheSize, QImage::Format_ARGB32_Premultiplied);
cache->setDevicePixelRatio(ratio);
cache->setDevicePixelRatio(style::DevicePixelRatio());
}
auto q = Painter(cache.get());
peer->paintUserpicLeft(q, userpic, 0, 0, outerWidth, size);
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/boxes/peers/add_participants_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ PaintRoundImageCallback ForbiddenRow::generatePaintUserpicCallback(
int outerWidth,
int size) mutable {
const auto wide = size + style::ConvertScale(3);
const auto full = QSize(wide, wide) * style::DevicePixelRatio();
const auto full = style::DevicePixels(QSize(wide, wide));
auto repaint = false;
if (_disabledFrame.size() != full) {
repaint = true;
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2827,9 +2827,9 @@ void CheckBoostLevel(
ButtonWithEmoji ButtonStyleWithRightEmoji(
not_null<Ui::RpWidget*> parent,
const QString &noneString,
const style::SettingsButton &parentSt) {
const style::SettingsButton &parentSt) {
const auto ratio = style::DevicePixelRatio();
const auto emojiWidth = Data::FrameSizeFromTag({}) / ratio;
const auto emojiWidth = qRound(Data::FrameSizeFromTag({}) / ratio);

const auto noneWidth = st::normalFont->width(noneString);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ void LinksController::rowPaintIcon(
auto &icon = _icons[int(color)];
if (icon.isNull()) {
icon = QImage(
QSize(inner, inner) * style::DevicePixelRatio(),
style::DevicePixels(QSize(inner, inner)),
QImage::Format_ARGB32_Premultiplied);
icon.fill(Qt::transparent);
icon.setDevicePixelRatio(style::DevicePixelRatio());
Expand Down
14 changes: 7 additions & 7 deletions Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ PeerShortInfoCover::PeerShortInfoCover(

refreshLabelsGeometry();

_roundedTopImage = QImage(
QSize(_st.size, _st.radius) * style::DevicePixelRatio(),
_roundedTopImage = QImage(style::DevicePixels(QSize(_st.size, _st.radius)),
QImage::Format_ARGB32_Premultiplied);
_roundedTopImage.setDevicePixelRatio(style::DevicePixelRatio());
_roundedTopImage.fill(Qt::transparent);
Expand Down Expand Up @@ -196,7 +195,7 @@ void PeerShortInfoCover::paint(QPainter &p) {
RectPart::TopLeft | RectPart::TopRight);
} else if (_userpicImage.isNull()) {
auto image = QImage(
_widget->size() * style::DevicePixelRatio(),
style::DevicePixels(_widget->size()),
QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::black);
_userpicImage = Images::Round(
Expand Down Expand Up @@ -602,9 +601,10 @@ void PeerShortInfoCover::refreshBarImages() {
_largeWidth = _smallWidth + 1;
const auto makeBar = [&](int size) {
const auto radius = _st.line / 2.;
auto result = QImage(
QSize(size, _st.line) * style::DevicePixelRatio(),
QImage::Format_ARGB32_Premultiplied);
const auto resultSize = QSize(
style::DevicePixels(size),
style::DevicePixels(_st.line));
auto result = QImage(resultSize, QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(style::DevicePixelRatio());
result.fill(Qt::transparent);
auto p = QPainter(&result);
Expand Down Expand Up @@ -733,7 +733,7 @@ void PeerShortInfoBox::prepare() {
}, _topRoundBackground->lifetime());

_roundedTop = QImage(
_topRoundBackground->size() * style::DevicePixelRatio(),
style::DevicePixels(_topRoundBackground->size()),
QImage::Format_ARGB32_Premultiplied);
_roundedTop.setDevicePixelRatio(style::DevicePixelRatio());
refreshRoundedTopImage(getDelegate()->style().bg->c);
Expand Down
3 changes: 1 addition & 2 deletions Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ void GenerateImage(
bool blurred = false) {
using namespace Images;
const auto size = state->size;
const auto ratio = style::DevicePixelRatio();
const auto options = blurred ? Option::Blur : Option();
state->current.photo = Images::Round(
Images::Prepare(
std::move(image),
QSize(size, size) * ratio,
style::DevicePixels(QSize(size, size)),
{ .options = options, .outer = { size, size } }),
state->roundMask,
RectPart::TopLeft | RectPart::TopRight);
Expand Down
37 changes: 18 additions & 19 deletions Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,12 +668,12 @@ object_ptr<Ui::RpWidget> CreateUserpicsTransfer(
return !state->buttons.empty();
}) | rpl::on_next([=] {
const auto outerw = overlay->width();
const auto ratio = style::DevicePixelRatio();
if (state->layer.size() != QSize(outerw, full) * ratio) {
const auto layerSize = style::DevicePixels(QSize(outerw, full));
if (state->layer.size() != layerSize) {
state->layer = QImage(
QSize(outerw, full) * ratio,
layerSize,
QImage::Format_ARGB32_Premultiplied);
state->layer.setDevicePixelRatio(ratio);
state->layer.setDevicePixelRatio(style::DevicePixelRatio());
}
state->layer.fill(Qt::transparent);

Expand Down Expand Up @@ -821,12 +821,12 @@ object_ptr<Ui::RpWidget> CreateUserpicsWithMoreBadge(
return !state->buttons.empty();
}) | rpl::on_next([=, &st] {
const auto outerw = overlay->width();
const auto ratio = style::DevicePixelRatio();
if (state->layer.size() != QSize(outerw, full) * ratio) {
const auto layerSize = style::DevicePixels(QSize(outerw, full));
if (state->layer.size() != layerSize) {
state->layer = QImage(
QSize(outerw, full) * ratio,
layerSize,
QImage::Format_ARGB32_Premultiplied);
state->layer.setDevicePixelRatio(ratio);
state->layer.setDevicePixelRatio(style::DevicePixelRatio());
}
state->layer.fill(Qt::transparent);

Expand Down Expand Up @@ -922,13 +922,12 @@ class UniqueGiftBackground final : public Ui::DynamicImage {
[[maybe_unused]] const auto preload = _patternEmoji->ready();
}
const auto inner = QRect(0, 0, size, size);
const auto ratio = style::DevicePixelRatio();
if (_backgroundCache.size() != inner.size() * ratio) {
if (_backgroundCache.size() != style::DevicePixels(inner.size())) {
_backgroundCache = QImage(
inner.size() * ratio,
style::DevicePixels(inner.size()),
QImage::Format_ARGB32_Premultiplied);
_backgroundCache.fill(Qt::transparent);
_backgroundCache.setDevicePixelRatio(ratio);
_backgroundCache.setDevicePixelRatio(style::DevicePixelRatio());

const auto radius = st::giftBoxGiftRadius;
auto p = QPainter(&_backgroundCache);
Expand Down Expand Up @@ -1005,9 +1004,10 @@ class UniqueGiftBackground final : public Ui::DynamicImage {
const auto ideal = st::boostReplaceUserpic.photoSize;
const auto scale = size / float64(ideal);
const auto ratio = style::DevicePixelRatio();
if (state->layer.size() != QSize(ideal, ideal) * ratio) {
const auto layerSize = style::DevicePixels(QSize(ideal, ideal));
if (state->layer.size() != layerSize) {
state->layer = QImage(
QSize(ideal, ideal) * ratio,
layerSize,
QImage::Format_ARGB32_Premultiplied);
state->layer.setDevicePixelRatio(ratio);
}
Expand Down Expand Up @@ -1074,12 +1074,12 @@ object_ptr<Ui::RpWidget> CreateGiftTransfer(
overlay->paintRequest(
) | rpl::on_next([=] {
const auto outerw = overlay->width();
const auto ratio = style::DevicePixelRatio();
if (state->layer.size() != QSize(outerw, full) * ratio) {
const auto layerSize = style::DevicePixels(QSize(outerw, full));
if (state->layer.size() != layerSize) {
state->layer = QImage(
QSize(outerw, full) * ratio,
layerSize,
QImage::Format_ARGB32_Premultiplied);
state->layer.setDevicePixelRatio(ratio);
state->layer.setDevicePixelRatio(style::DevicePixelRatio());
}
state->layer.fill(Qt::transparent);

Expand Down Expand Up @@ -1108,4 +1108,3 @@ object_ptr<Ui::RpWidget> CreateGiftTransfer(
}, overlay->lifetime());
return result;
}

2 changes: 1 addition & 1 deletion Telegram/SourceFiles/boxes/peers/tag_info_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ constexpr auto kTextLinesAlpha = 0.1;
const auto ratio = style::DevicePixelRatio();

auto result = QImage(
QSize(imgWidth, imgHeight) * ratio,
style::DevicePixels(QSize(imgWidth, imgHeight)),
QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(ratio);
result.fill(Qt::transparent);
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/boxes/premium_preview_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ struct VideoPreviewDocument {
| Option::RoundSkipTopRight);
state->blurred = Images::Prepare(
image->original(),
QSize(width, height) * style::DevicePixelRatio(),
style::DevicePixels(QSize(width, height)),
{ .options = (Option::Blur | Option::RoundLarge | corners) });
}
}
Expand Down Expand Up @@ -752,7 +752,7 @@ struct VideoPreviewDocument {
check();
const auto ready = state->instance.player().ready()
&& !state->instance.player().videoSize().isEmpty();
const auto size = QSize(width, height) * style::DevicePixelRatio();
const auto size = style::DevicePixels(QSize(width, height));

using namespace Images;
auto rounding = CornersMaskRef(
Expand Down
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/boxes/send_files_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,8 @@ QImage SendFilesBox::preparePriceTagBg(QSize size) const {
bg.fill(Qt::black);
}

auto result = QImage(size * ratio, QImage::Format_ARGB32_Premultiplied);
auto result = QImage(style::DevicePixels(size),
QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(ratio);
result.fill(Qt::black);
auto p = QPainter(&result);
Expand Down
12 changes: 7 additions & 5 deletions Telegram/SourceFiles/boxes/star_gift_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,9 @@ void ShowSentToast(

const auto bytes = document->createMediaView()->bytes();
const auto filepath = document->filepath();
const auto ratio = style::DevicePixelRatio();
const auto player = preview->lifetime().make_state<Lottie::SinglePlayer>(
Lottie::ReadContent(bytes, filepath),
Lottie::FrameRequest{ QSize(size, size) * ratio },
Lottie::FrameRequest{ style::DevicePixels(QSize(size, size)) },
Lottie::Quality::Default);

preview->paintRequest(
Expand All @@ -665,7 +664,11 @@ void ShowSentToast(
}
const auto image = player->frame();
QPainter(preview).drawImage(
QRect(QPoint(), image.size() / ratio),
QRect(
QPoint(),
QSize(
style::LogicalPixels(image.width()),
style::LogicalPixels(image.height()))),
image);
if (player->frameIndex() + 1 != player->framesCount()) {
player->markFrameShown();
Expand Down Expand Up @@ -2488,8 +2491,7 @@ void AddWearGiftCover(

const auto width = cover->width();
const auto pointsHeight = st::uniqueGiftSubtitleTop;
const auto ratio = style::DevicePixelRatio();
if (state->gradient.size() != cover->size() * ratio) {
if (state->gradient.size() != style::DevicePixels(cover->size())) {
state->gradient = Ui::CreateTopBgGradient(
cover->size(),
state->gift);
Expand Down
Loading