diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 2fbf4de330..4f60428001 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -2395,44 +2395,44 @@ void OverlayWidget::displayDocument( refreshMediaViewer(); if (_document) { -if (_document->sticker()) { - if (const auto image = _documentMedia->getStickerLarge()) { - setStaticContent(image->original()); - } else if (const auto thumbnail = _documentMedia->thumbnail()) { - setStaticContent(thumbnail->pixBlurred( - _document->dimensions.width(), - _document->dimensions.height() - ).toImage()); - } -} else { - if (_documentMedia->canBePlayed() - && initStreaming(continueStreaming)) { - } else if (_document->isVideoFile()) { - _documentMedia->automaticLoad(fileOrigin(), item); - initStreamingThumbnail(); - } else if (_document->isTheme()) { - _documentMedia->automaticLoad(fileOrigin(), item); - initThemePreview(); - } else { - _documentMedia->automaticLoad(fileOrigin(), item); - _document->saveFromDataSilent(); - auto &location = _document->location(true); - if (location.accessEnable()) { - const auto &path = location.name(); - if (QImageReader(path).canRead()) { - setStaticContent(PrepareStaticImage(path)); - _touchbarDisplay.fire(TouchBarItemType::Photo); + if (_document->sticker()) { + if (const auto image = _documentMedia->getStickerLarge()) { + setStaticContent(image->original()); + } else if (const auto thumbnail = _documentMedia->thumbnail()) { + setStaticContent(thumbnail->pixBlurred( + _document->dimensions.width(), + _document->dimensions.height() + ).toImage()); } - } else if (!_documentMedia->bytes().isEmpty()) { - setStaticContent( - PrepareStaticImage(_documentMedia->bytes())); - if (!_staticContent.isNull()) { - _touchbarDisplay.fire(TouchBarItemType::Photo); + } else { + if (_documentMedia->canBePlayed() + && initStreaming(continueStreaming)) { + } else if (_document->isVideoFile()) { + _documentMedia->automaticLoad(fileOrigin(), item); + initStreamingThumbnail(); + } else if (_document->isTheme()) { + _documentMedia->automaticLoad(fileOrigin(), item); + initThemePreview(); + } else { + _documentMedia->automaticLoad(fileOrigin(), item); + _document->saveFromDataSilent(); + auto &location = _document->location(true); + if (location.accessEnable()) { + const auto &path = location.name(); + if (QImageReader(path).canRead()) { + setStaticContent(PrepareStaticImage(path)); + _touchbarDisplay.fire(TouchBarItemType::Photo); + } + } else if (!_documentMedia->bytes().isEmpty()) { + setStaticContent( + PrepareStaticImage(_documentMedia->bytes())); + if (!_staticContent.isNull()) { + _touchbarDisplay.fire(TouchBarItemType::Photo); + } + } + location.accessDisable(); } } - location.accessDisable(); - } -} } refreshCaption(item); @@ -2503,6 +2503,9 @@ if (_document->sticker()) { _h = contentSize.height(); } contentSizeChanged(); + if (videoShown()) { + applyVideoSize(); + } refreshFromLabel(item); _blurred = false; if (_showAsPip && _streamed && !videoIsGifOrUserpic()) { @@ -2682,8 +2685,9 @@ void OverlayWidget::initStreamingThumbnail() { void OverlayWidget::streamingReady(Streaming::Information &&info) { if (videoShown()) { applyVideoSize(); + } else { + updateContentRect(); } - updateContentRect(); } void OverlayWidget::applyVideoSize() { @@ -2694,6 +2698,7 @@ void OverlayWidget::applyVideoSize() { _h = contentSize.height(); contentSizeChanged(); } + updateContentRect(); } bool OverlayWidget::createStreamingObjects() { @@ -2958,7 +2963,6 @@ void OverlayWidget::playbackControlsRotate() { _rotation = storage.get(_document); if (videoShown()) { applyVideoSize(); - updateContentRect(); } else { redisplayContent(); } diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp index 85a1b61412..a73a6bd0bf 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -1119,6 +1119,7 @@ void Pip::volumeControllerUpdate(QPoint position) { / float64(_volumeController.icon.width()); const auto value = std::clamp(unbound, 0., 1.); volumeChanged(value); + _panel.update(); } void Pip::setupButtons() { @@ -1191,8 +1192,12 @@ void Pip::setupButtons() { rect.y() + (rect.height() - st::pipPlayIcon.height()) / 2, st::pipPlayIcon.width(), st::pipPlayIcon.height()); - _volumeController.icon = _volumeController.area.marginsRemoved( - { volumeSkip, volumeSkip, volumeSkip, volumeSkip }); + const auto volumeArea = _volumeController.area; + _volumeController.icon = (volumeArea.width() > 2 * volumeSkip + && volumeArea.height() > 2 * volumeSkip) + ? volumeArea.marginsRemoved( + { volumeSkip, volumeSkip, volumeSkip, volumeSkip }) + : QRect(); const auto playbackSkip = st::pipPlaybackSkip; const auto playbackHeight = 2 * playbackSkip + st::pipPlaybackWide; _playback.area = QRect( @@ -1258,7 +1263,7 @@ Ui::GL::ChosenRenderer Pip::chooseRenderer( void Pip::paint(not_null renderer) const { const auto controlsShown = _controlsShown.value( (_over != OverState::None) ? 1. : 0.); - const auto geometry = ContentGeometry{ + auto geometry = ContentGeometry{ .inner = _panel.inner(), .attached = (_panel.useTransparency() ? _panel.attached() @@ -1266,12 +1271,17 @@ void Pip::paint(not_null renderer) const { .fade = controlsShown, .outer = _panel.widget()->size(), .rotation = _rotation, + .videoRotation = _instance.info().video.rotation, .useTransparency = _panel.useTransparency(), }; if (canUseVideoFrame()) { renderer->paintTransformedVideoFrame(geometry); _instance.markFrameShown(); } else { + const auto content = staticContent(); + if (_preparedCoverState == ThumbState::Cover) { + geometry.rotation += base::take(geometry.videoRotation); + } renderer->paintTransformedStaticContent(staticContent(), geometry); } if (_instance.waitingShown()) { @@ -1426,7 +1436,7 @@ void Pip::paintPlaybackTexts(QPainter &p, QRect outer) const { void Pip::paintVolumeController( not_null renderer, float64 shown) const { - if (!_volumeController.icon.width()) { + if (_volumeController.icon.isEmpty()) { return; } renderer->paintVolumeController(_volumeController.icon, shown); diff --git a/Telegram/SourceFiles/media/view/media_view_pip.h b/Telegram/SourceFiles/media/view/media_view_pip.h index be35e1a392..5a0cf6c8ba 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.h +++ b/Telegram/SourceFiles/media/view/media_view_pip.h @@ -162,6 +162,7 @@ private: float64 fade = 0.; QSize outer; int rotation = 0; + int videoRotation = 0; bool useTransparency = false; }; struct StaticContent { diff --git a/Telegram/SourceFiles/media/view/media_view_pip_opengl.cpp b/Telegram/SourceFiles/media/view/media_view_pip_opengl.cpp index 2a1b36b540..cbe331e41b 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip_opengl.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip_opengl.cpp @@ -291,6 +291,7 @@ void Pip::RendererGL::paintTransformedVideoFrame( if (data.format == Streaming::FrameFormat::None) { return; } + geometry.rotation = (geometry.rotation + geometry.videoRotation) % 360; if (data.format == Streaming::FrameFormat::ARGB32) { Assert(!data.original.isNull()); paintTransformedStaticContent(data.original, geometry); @@ -378,23 +379,31 @@ void Pip::RendererGL::paintTransformedStaticContent( void Pip::RendererGL::paintTransformedContent( not_null program, ContentGeometry geometry) { - const auto rect = transformRect(geometry.inner); + std::array, 4> rect = { { + { { -1.f, 1.f } }, + { { 1.f, 1.f } }, + { { 1.f, -1.f } }, + { { -1.f, -1.f } }, + } }; + if (const auto shift = (geometry.rotation / 90); shift != 0) { + std::rotate(begin(rect), begin(rect) + shift, end(rect)); + } const auto xscale = 1.f / geometry.inner.width(); const auto yscale = 1.f / geometry.inner.height(); const GLfloat coords[] = { - -1.f, 1.f, + rect[0][0], rect[0][1], -geometry.inner.x() * xscale, -geometry.inner.y() * yscale, - 1.f, 1.f, + rect[1][0], rect[1][1], (geometry.outer.width() - geometry.inner.x()) * xscale, -geometry.inner.y() * yscale, - 1.f, -1.f, + rect[2][0], rect[2][1], (geometry.outer.width() - geometry.inner.x()) * xscale, (geometry.outer.height() - geometry.inner.y()) * yscale, - -1.f, -1.f, + rect[3][0], rect[3][1], -geometry.inner.x() * xscale, (geometry.outer.height() - geometry.inner.y()) * yscale, };