diff --git a/Telegram/SourceFiles/calls/calls_video_bubble.cpp b/Telegram/SourceFiles/calls/calls_video_bubble.cpp index aecabfd55..043ee8c41 100644 --- a/Telegram/SourceFiles/calls/calls_video_bubble.cpp +++ b/Telegram/SourceFiles/calls/calls_video_bubble.cpp @@ -127,12 +127,13 @@ void VideoBubble::paint() { const auto inner = _content.rect().marginsRemoved(padding); Ui::Shadow::paint(p, inner, _content.width(), st::boxRoundShadow); const auto factor = cIntRetinaFactor(); + const auto left = _mirrored + ? (_frame.width() - (inner.width() * factor)) + : 0; p.drawImage( inner, _frame, - QRect( - QPoint(_frame.width() - (inner.width() * factor), 0), - inner.size() * factor)); + QRect(QPoint(left, 0), inner.size() * factor)); } _track->markFrameShown(); } @@ -152,11 +153,10 @@ void VideoBubble::prepareFrame() { .resize = size, .outer = size, }; - const auto frame = _track->frame(request).mirrored(!_mirrored, false); + const auto frame = _track->frame(request); if (_frame.width() < size.width() || _frame.height() < size.height()) { - _frame = QImage( - size * cIntRetinaFactor(), - QImage::Format_ARGB32_Premultiplied); + _frame = QImage(size, QImage::Format_ARGB32_Premultiplied); + _frame.fill(Qt::transparent); } Assert(_frame.width() >= frame.width() && _frame.height() >= frame.height()); @@ -174,7 +174,7 @@ void VideoBubble::prepareFrame() { ImageRoundRadius::Large, RectPart::AllCorners, QRect(QPoint(), size) - ).mirrored(true, false); + ).mirrored(_mirrored, false); } void VideoBubble::setState(Webrtc::VideoState state) { diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index d3bac6aeb..6455ad040 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -1060,11 +1060,13 @@ void Panel::setupVideo(not_null viewport) { _call->videoEndpointLargeValue(), _call->videoEndpointPinnedValue() ) | rpl::map(_1 == endpoint && _2); + const auto self = (endpoint.peer == _call->joinAs()); viewport->add( endpoint, VideoTileTrack{ GroupCall::TrackPointer(track), row }, GroupCall::TrackSizeValue(track), - std::move(pinned)); + std::move(pinned), + self); }; for (const auto &[endpoint, track] : _call->activeVideoTracks()) { setupTile(endpoint, track); diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp index 48c76d0ae..9623171b9 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp @@ -237,13 +237,15 @@ void Viewport::add( const VideoEndpoint &endpoint, VideoTileTrack track, rpl::producer trackSize, - rpl::producer pinned) { + rpl::producer pinned, + bool self) { _tiles.push_back(std::make_unique( endpoint, track, std::move(trackSize), std::move(pinned), - [=] { widget()->update(); })); + [=] { widget()->update(); }, + self)); _tiles.back()->trackSizeValue( ) | rpl::filter([](QSize size) { diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport.h b/Telegram/SourceFiles/calls/group/calls_group_viewport.h index c6567e037..9d5021f85 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport.h +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport.h @@ -80,7 +80,8 @@ public: const VideoEndpoint &endpoint, VideoTileTrack track, rpl::producer trackSize, - rpl::producer pinned); + rpl::producer pinned, + bool self); void remove(const VideoEndpoint &endpoint); void showLarge(const VideoEndpoint &endpoint); diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp index 946c6dca8..e11644e68 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp @@ -531,6 +531,12 @@ void Viewport::RendererGL::paintTile( { { 1.f, 0.f } }, { { 0.f, 0.f } }, } }; + if (tile->mirror()) { + std::swap(toBlurTexCoords[0], toBlurTexCoords[1]); + std::swap(toBlurTexCoords[2], toBlurTexCoords[3]); + std::swap(texCoords[0], texCoords[1]); + std::swap(texCoords[2], texCoords[3]); + } if (const auto shift = (frameRotation / 90); shift > 0) { std::rotate( toBlurTexCoords.begin(), diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp index f85929ea1..ab335c55c 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp @@ -105,14 +105,14 @@ void Viewport::RendererSW::paintTile( tileData.blurredFrame = Images::BlurLargeImage( data.original.scaled( VideoTile::PausedVideoSize(), - Qt::KeepAspectRatio), + Qt::KeepAspectRatio).mirrored(tile->mirror(), false), kBlurRadius); } const auto &image = _userpicFrame ? tileData.userpicFrame : _pausedFrame ? tileData.blurredFrame - : data.original; + : data.original.mirrored(tile->mirror(), false); const auto frameRotation = _userpicFrame ? 0 : data.rotation; Assert(!image.isNull()); diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_tile.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport_tile.cpp index 58ac0fb9d..1b31a2012 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_tile.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_tile.cpp @@ -28,12 +28,14 @@ Viewport::VideoTile::VideoTile( VideoTileTrack track, rpl::producer trackSize, rpl::producer pinned, - Fn update) + Fn update, + bool self) : _endpoint(endpoint) , _update(std::move(update)) , _track(std::move(track)) , _trackSize(std::move(trackSize)) -, _rtmp(endpoint.rtmp()) { +, _rtmp(endpoint.rtmp()) +, _self(self) { Expects(_track.track != nullptr); Expects(_track.row != nullptr); @@ -48,6 +50,10 @@ Viewport::VideoTile::VideoTile( setup(std::move(pinned)); } +bool Viewport::VideoTile::mirror() const { + return _self && (_endpoint.type == VideoEndpointType::Camera); +} + QRect Viewport::VideoTile::pinOuter() const { return _pinOuter; } diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_tile.h b/Telegram/SourceFiles/calls/group/calls_group_viewport_tile.h index 445bf2d7e..6f85f4a01 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_tile.h +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_tile.h @@ -28,7 +28,8 @@ public: VideoTileTrack track, rpl::producer trackSize, rpl::producer pinned, - Fn update); + Fn update, + bool self); [[nodiscard]] not_null track() const { return _track.track; @@ -54,6 +55,10 @@ public: [[nodiscard]] bool visible() const { return !_hidden && !_geometry.isEmpty(); } + [[nodiscard]] bool self() const { + return _self; + } + [[nodiscard]] bool mirror() const; [[nodiscard]] QRect pinOuter() const; [[nodiscard]] QRect pinInner() const; [[nodiscard]] QRect backOuter() const; @@ -123,6 +128,7 @@ private: bool _pinned = false; bool _hidden = true; bool _rtmp = false; + bool _self = false; std::optional _quality; rpl::lifetime _lifetime;