Fixed display of video userpic in short box on Retina.

This commit is contained in:
23rd 2025-01-28 09:58:42 +03:00
parent 678527254b
commit bbdd5feaa4
2 changed files with 9 additions and 5 deletions

View file

@ -106,6 +106,8 @@ PeerShortInfoCover::PeerShortInfoCover(
, _statusStyle(std::make_unique<CustomLabelStyle>(_st.status)) , _statusStyle(std::make_unique<CustomLabelStyle>(_st.status))
, _status(_widget.get(), std::move(status), _statusStyle->st) , _status(_widget.get(), std::move(status), _statusStyle->st)
, _roundMask(Images::CornersMask(_st.radius)) , _roundMask(Images::CornersMask(_st.radius))
, _roundMaskRetina(
Images::CornersMask(_st.radius / style::DevicePixelRatio()))
, _videoPaused(std::move(videoPaused)) { , _videoPaused(std::move(videoPaused)) {
_widget->setCursor(_cursor); _widget->setCursor(_cursor);
@ -190,7 +192,7 @@ void PeerShortInfoCover::paint(QPainter &p) {
if (!frame.isNull()) { if (!frame.isNull()) {
frame = Images::Round( frame = Images::Round(
std::move(frame), std::move(frame),
_roundMask, _roundMaskRetina,
RectPart::TopLeft | RectPart::TopRight); RectPart::TopLeft | RectPart::TopRight);
} else if (_userpicImage.isNull()) { } else if (_userpicImage.isNull()) {
auto image = QImage( auto image = QImage(
@ -226,10 +228,11 @@ void PeerShortInfoCover::paintCoverImage(QPainter &p, const QImage &image) {
const auto top = _widget->height() - fill; const auto top = _widget->height() - fill;
const auto factor = style::DevicePixelRatio(); const auto factor = style::DevicePixelRatio();
if (fill > 0) { if (fill > 0) {
const auto t = roundedHeight + _scrollTop;
p.drawImage( p.drawImage(
QRect(0, top, roundedWidth, fill), QRect(0, t, roundedWidth * factor, (roundedWidth - t) * factor),
image, image,
QRect(0, top * factor, roundedWidth * factor, fill * factor)); QRect(0, t, roundedWidth * factor, (roundedWidth - t) * factor));
} }
if (covered <= 0) { if (covered <= 0) {
return; return;
@ -238,9 +241,9 @@ void PeerShortInfoCover::paintCoverImage(QPainter &p, const QImage &image) {
const auto from = top - rounded; const auto from = top - rounded;
auto q = QPainter(&_roundedTopImage); auto q = QPainter(&_roundedTopImage);
q.drawImage( q.drawImage(
QRect(0, 0, roundedWidth, rounded), QRect(0, 0, roundedWidth * factor, rounded * factor),
image, image,
QRect(0, from * factor, roundedWidth * factor, rounded * factor)); QRect(0, _scrollTop, roundedWidth * factor, rounded * factor));
q.end(); q.end();
_roundedTopImage = Images::Round( _roundedTopImage = Images::Round(
std::move(_roundedTopImage), std::move(_roundedTopImage),

View file

@ -123,6 +123,7 @@ private:
object_ptr<Ui::FlatLabel> _additionalStatus = { nullptr }; object_ptr<Ui::FlatLabel> _additionalStatus = { nullptr };
std::array<QImage, 4> _roundMask; std::array<QImage, 4> _roundMask;
std::array<QImage, 4> _roundMaskRetina;
QImage _userpicImage; QImage _userpicImage;
QImage _roundedTopImage; QImage _roundedTopImage;
QImage _barSmall; QImage _barSmall;