From e0978f86d1ccc9e53b523459590b10e1ea23c327 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 24 May 2017 17:36:58 +0300 Subject: [PATCH] Alpha 1.1.3: Fix some render in macOS. --- .../SourceFiles/history/history_media_types.cpp | 2 +- .../SourceFiles/media/player/media_player_float.cpp | 4 ++-- .../SourceFiles/media/view/media_clip_playback.cpp | 5 +++++ .../SourceFiles/media/view/media_clip_playback.h | 1 + Telegram/SourceFiles/overview/overview_layout.cpp | 4 ++-- Telegram/SourceFiles/ui/images.cpp | 13 ++++++++----- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index 5e46415da..3c851157d 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -1972,7 +1972,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM if (displayMute) { _roundPlayback.reset(); } else if (_roundPlayback) { - auto value = _roundPlayback->value(); + auto value = _roundPlayback->value(ms); if (value > 0.) { auto pen = st::historyVideoMessageProgressFg->p; auto was = p.pen(); diff --git a/Telegram/SourceFiles/media/player/media_player_float.cpp b/Telegram/SourceFiles/media/player/media_player_float.cpp index 4f61129d6..f8590854c 100644 --- a/Telegram/SourceFiles/media/player/media_player_float.cpp +++ b/Telegram/SourceFiles/media/player/media_player_float.cpp @@ -140,7 +140,7 @@ void Float::prepareShadow() { auto extend = 2 * st::lineWidth; p.drawEllipse(getInnerRect().marginsAdded(QMargins(extend, extend, extend, extend))); } - _shadow = App::pixmapFromImageInPlace(Images::prepareBlur(shadow)); + _shadow = App::pixmapFromImageInPlace(Images::prepareBlur(std::move(shadow))); } QRect Float::getInnerRect() const { @@ -161,7 +161,7 @@ void Float::paintEvent(QPaintEvent *e) { auto inner = getInnerRect(); p.drawImage(inner.topLeft(), _frame); - auto progress = _roundPlayback ? _roundPlayback->value() : 1.; + auto progress = _roundPlayback ? _roundPlayback->value(getms()) : 1.; if (progress > 0.) { auto pen = st::historyVideoMessageProgressFg->p; auto was = p.pen(); diff --git a/Telegram/SourceFiles/media/view/media_clip_playback.cpp b/Telegram/SourceFiles/media/view/media_clip_playback.cpp index 173ad568c..9b3c2f1a2 100644 --- a/Telegram/SourceFiles/media/view/media_clip_playback.cpp +++ b/Telegram/SourceFiles/media/view/media_clip_playback.cpp @@ -88,6 +88,11 @@ float64 Playback::value() const { return qMin(a_value.current(), 1.); } +float64 Playback::value(TimeMs ms) { + _a_value.step(ms); + return value(); +} + void Playback::setValue(float64 value, bool animated) { if (animated) { a_value.start(value); diff --git a/Telegram/SourceFiles/media/view/media_clip_playback.h b/Telegram/SourceFiles/media/view/media_clip_playback.h index 03439051c..4ff8444b0 100644 --- a/Telegram/SourceFiles/media/view/media_clip_playback.h +++ b/Telegram/SourceFiles/media/view/media_clip_playback.h @@ -41,6 +41,7 @@ public: } void setValue(float64 value, bool animated); float64 value() const; + float64 value(TimeMs ms); void updateState(const Player::TrackState &state); void updateLoadingState(float64 progress); diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index e9e183769..4faaf5b81 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -242,7 +242,7 @@ void Photo::paint(Painter &p, const QRect &clip, TextSelection selection, const if (_goodLoaded || _data->thumb->loaded()) { auto img = (_data->loaded() ? _data->full : (_data->medium->loaded() ? _data->medium : _data->thumb))->pix().toImage(); if (!_goodLoaded) { - img = Images::prepareBlur(img); + img = Images::prepareBlur(std::move(img)); } if (img.width() == img.height()) { if (img.width() != size) { @@ -344,7 +344,7 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const _thumbLoaded = thumbLoaded; if (_thumbLoaded && !_data->thumb->isNull()) { - int32 size = _width * cIntRetinaFactor(); + auto size = _width * cIntRetinaFactor(); auto img = Images::prepareBlur(_data->thumb->pix().toImage()); if (img.width() == img.height()) { if (img.width() != size) { diff --git a/Telegram/SourceFiles/ui/images.cpp b/Telegram/SourceFiles/ui/images.cpp index 663b2ea6e..389a088a7 100644 --- a/Telegram/SourceFiles/ui/images.cpp +++ b/Telegram/SourceFiles/ui/images.cpp @@ -60,9 +60,11 @@ const QPixmap &circleMask(int width, int height) { } // namespace QImage prepareBlur(QImage img) { - QImage::Format fmt = img.format(); + auto ratio = img.devicePixelRatio(); + auto fmt = img.format(); if (fmt != QImage::Format_RGB32 && fmt != QImage::Format_ARGB32_Premultiplied) { img = img.convertToFormat(QImage::Format_ARGB32_Premultiplied); + img.setDevicePixelRatio(ratio); t_assert(!img.isNull()); } @@ -85,8 +87,9 @@ QImage prepareBlur(QImage img) { p.fillRect(0, 0, w, h, Qt::transparent); p.drawImage(QRect(radius, radius, w - 2 * radius, h - 2 * radius), img, QRect(0, 0, w, h)); } - QImage was = img; - img = imgsmall; + imgsmall.setDevicePixelRatio(ratio); + auto was = img; + img = std::move(imgsmall); imgsmall = QImage(); t_assert(!img.isNull()); @@ -293,7 +296,7 @@ QImage prepareOpaque(QImage image) { QImage prepare(QImage img, int w, int h, Images::Options options, int outerw, int outerh) { t_assert(!img.isNull()); if (options.testFlag(Images::Option::Blurred)) { - img = prepareBlur(img); + img = prepareBlur(std::move(img)); t_assert(!img.isNull()); } if (w <= 0 || (w == img.width() && (h <= 0 || h == img.height()))) { @@ -752,7 +755,7 @@ QPixmap Image::pixBlurredColoredNoCache(style::color add, int32 w, int32 h) cons restore(); if (_data.isNull()) return blank()->pix(); - QImage img = Images::prepareBlur(_data.toImage()); + auto img = Images::prepareBlur(_data.toImage()); if (h <= 0) { img = img.scaledToWidth(w, Qt::SmoothTransformation); } else {