From bde3da53b6b821dca1e477eaaa4280204836bcf2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 15 Mar 2022 19:41:16 +0400 Subject: [PATCH] Improve fullscreen RTMP streams. --- .../calls/group/calls_group_panel.cpp | 32 +++++++++++++++---- .../calls/group/calls_group_panel.h | 1 + .../calls/group/calls_group_viewport.cpp | 13 +++++++- .../calls/group/calls_group_viewport.h | 2 ++ .../group/calls_group_viewport_opengl.cpp | 16 ++++++---- .../group/calls_group_viewport_raster.cpp | 9 ++++-- Telegram/lib_ui | 2 +- 7 files changed, 58 insertions(+), 17 deletions(-) diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index f5e9c75de..3b6442175 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -92,7 +92,9 @@ Panel::Panel(not_null call) #ifndef Q_OS_MAC , _controls(Ui::Platform::SetupSeparateTitleControls( window(), - st::callTitle)) + st::groupCallTitle, + nullptr, + _controlsTop.value())) #endif // !Q_OS_MAC , _powerSaveBlocker(std::make_unique( base::PowerSaveBlockType::PreventDisplaySleep, @@ -802,7 +804,9 @@ void Panel::setupMembers() { setupVideo(_viewport.get()); setupVideo(_members->viewport()); _viewport->mouseInsideValue( - ) | rpl::start_with_next([=](bool inside) { + ) | rpl::filter([=] { + return !_fullScreenOrMaximized.current(); + }) | rpl::start_with_next([=](bool inside) { toggleWideControls(inside); }, _viewport->lifetime()); @@ -1027,6 +1031,7 @@ void Panel::updateWideControlsVisibility() { if (_wideControlsShown == shown) { return; } + _viewport->setCursorShown(!_fullScreenOrMaximized.current() || shown); _wideControlsShown = shown; _wideControlsAnimation.start( [=] { updateButtonsGeometry(); }, @@ -1168,6 +1173,12 @@ void Panel::createPinOnTop() { }; _fullScreenOrMaximized.value( ) | rpl::start_with_next([=](bool fullScreenOrMaximized) { +#ifndef Q_OS_MAC + _controls->controls.setStyle(fullScreenOrMaximized + ? st::callTitle + : st::groupCallTitle); +#endif // Q_OS_MAC + _pinOnTop->setVisible(!fullScreenOrMaximized); if (fullScreenOrMaximized) { pin(false); @@ -1853,7 +1864,9 @@ void Panel::trackControl(Ui::RpWidget *widget, rpl::lifetime &lifetime) { } void Panel::trackControlOver(not_null control, bool over) { - if (_stickedTooltipClose) { + if (_fullScreenOrMaximized.current()) { + return; + } else if (_stickedTooltipClose) { if (!over) { return; } @@ -2428,13 +2441,14 @@ void Panel::refreshTitleGeometry() { ? st::groupCallTitleTop : (st::groupCallWideVideoTop - st::groupCallTitleLabel.style.font->height) / 2; + const auto shown = _fullScreenOrMaximized.current() + ? _wideControlsAnimation.value( + _wideControlsShown ? 1. : 0.) + : 1.; const auto top = anim::interpolate( -_title->height() - st::boxRadius, shownTop, - (_fullScreenOrMaximized.current() - ? _wideControlsAnimation.value( - _wideControlsShown ? 1. : 0.) - : 1.)); + shown); const auto left = titleRect.x(); const auto notEnough = std::max(0, best - titleRect.width()); @@ -2493,6 +2507,10 @@ void Panel::refreshTitleGeometry() { } else { layout(left + titleRect.width() - best); } + +#ifndef Q_OS_MAC + _controlsTop = anim::interpolate(-_controls->wrap.height(), 0, shown); +#endif // Q_OS_MAC } void Panel::refreshTitleColors() { diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.h b/Telegram/SourceFiles/calls/group/calls_group_panel.h index a2246a32d..731bb874d 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.h +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.h @@ -204,6 +204,7 @@ private: rpl::variable _fullScreenOrMaximized = false; #ifndef Q_OS_MAC + rpl::variable _controlsTop = 0; const std::unique_ptr _controls; #endif // !Q_OS_MAC diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp index a1c8550eb..48c76d0ae 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp @@ -226,6 +226,13 @@ void Viewport::setControlsShown(float64 shown) { widget()->update(); } +void Viewport::setCursorShown(bool shown) { + if (_cursorHidden == shown) { + _cursorHidden = !shown; + updateCursor(); + } +} + void Viewport::add( const VideoEndpoint &endpoint, VideoTileTrack track, @@ -798,7 +805,11 @@ void Viewport::setSelected(Selection value) { void Viewport::updateCursor() { const auto pointer = _selected.tile && (!wide() || _hasTwoOrMore); - widget()->setCursor(pointer ? style::cur_pointer : style::cur_default); + widget()->setCursor(_cursorHidden + ? Qt::BlankCursor + : pointer + ? style::cur_pointer + : style::cur_default); } void Viewport::setPressed(Selection value) { diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport.h b/Telegram/SourceFiles/calls/group/calls_group_viewport.h index e99361a4d..c6567e037 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport.h +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport.h @@ -71,6 +71,7 @@ public: void setMode(PanelMode mode, not_null parent); void setControlsShown(float64 shown); + void setCursorShown(bool shown); void setGeometry(bool fullscreen, QRect geometry); void resizeToWidth(int newWidth); void setScrollTop(int scrollTop); @@ -176,6 +177,7 @@ private: rpl::variable _fullHeight = 0; bool _hasTwoOrMore = false; bool _fullscreen = false; + bool _cursorHidden = false; int _scrollTop = 0; QImage _shadow; rpl::event_stream _clicks; diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp index ca4547f63..e4ff684f2 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp @@ -185,12 +185,11 @@ uniform sampler2D n_texture; return { .header = R"( uniform vec4 frameBg; -uniform vec3 shadow; // fullHeight, shown, maxOpacity +uniform vec4 shadow; // fullHeight, shown, maxOpacity, blur opacity uniform float paused; // 0. <-> 1. )" + blur.header + round.header + noise.header + R"( -const float backgroundOpacity = )" + QString::number(kBlurOpacity) + R"(; const float noiseGrain = )" + QString::number(kDitherNoiseAmount) + R"(; float insideTexture() { @@ -211,6 +210,7 @@ vec4 background() { )", .body = R"( float inside = insideTexture() * (1. - paused); + float backgroundOpacity = shadow.w; result = result * inside + (1. - inside) * (backgroundOpacity * background() + (1. - backgroundOpacity) * frameBg); @@ -780,7 +780,9 @@ void Viewport::RendererGL::paintTile( const auto uniformViewport = QSizeF(_viewport * _factor); program->setUniformValue("viewport", uniformViewport); - program->setUniformValue("frameBg", st::groupCallBg->c); + program->setUniformValue( + "frameBg", + fullscreen ? QColor(0, 0, 0) : st::groupCallBg->c); program->setUniformValue("radiusOutline", QVector2D( GLfloat(st::roundRadiusLarge * _factor * (fullscreen ? 0. : 1.)), (outline > 0) ? (st::groupCallOutline * _factor) : 0.f)); @@ -794,9 +796,11 @@ void Viewport::RendererGL::paintTile( const auto shadowHeight = st.shadowHeight * _factor; const auto shadowAlpha = kShadowMaxAlpha / 255.f; - program->setUniformValue( - "shadow", - QVector3D(shadowHeight, shown, shadowAlpha)); + program->setUniformValue("shadow", QVector4D( + shadowHeight, + shown, + shadowAlpha, + fullscreen ? 0. : kBlurOpacity)); program->setUniformValue("paused", GLfloat(paused)); f.glActiveTexture(_rgbaFrame ? GL_TEXTURE1 : GL_TEXTURE3); diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp index 3add8cc63..6987f7c12 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp @@ -51,8 +51,10 @@ void Viewport::RendererSW::paintFallback( } paintTile(p, tile.get(), bounding, bg); } + const auto fullscreen = _owner->_fullscreen; + const auto color = fullscreen ? QColor(0, 0, 0) : st::groupCallBg->c; for (const auto &rect : bg) { - p.fillRect(rect, st::groupCallBg); + p.fillRect(rect, color); } for (auto i = _tileData.begin(); i != _tileData.end();) { if (i->second.stale) { @@ -113,10 +115,13 @@ void Viewport::RendererSW::paintTile( const auto frameRotation = _userpicFrame ? 0 : data.rotation; Assert(!image.isNull()); + const auto background = _owner->_fullscreen + ? QColor(0, 0, 0) + : st::groupCallMembersBg->c; const auto fill = [&](QRect rect) { const auto intersected = rect.intersected(clip); if (!intersected.isEmpty()) { - p.fillRect(intersected, st::groupCallMembersBg); + p.fillRect(intersected, background); bg -= intersected; } }; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index ba4097947..d98c3d539 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit ba40979470132db759fe8b8e7ff8ca70845f92c1 +Subproject commit d98c3d539b0eb7c00f664c445ab4194c28e8cef7