For surface with parent backend should be fixed.

This commit is contained in:
John Preston 2021-06-08 15:51:52 +04:00
parent e41fb0d8fd
commit c5a46d9d1b
11 changed files with 91 additions and 55 deletions

View File

@ -56,7 +56,8 @@ class Panel::Incoming final {
public:
Incoming(
not_null<QWidget*> parent,
not_null<Webrtc::VideoTrack*> track);
not_null<Webrtc::VideoTrack*> track,
Ui::GL::Backend backend);
[[nodiscard]] not_null<QWidget*> widget() const;
[[nodiscard]] not_null<Ui::RpWidgetWrap* > rp() const;
@ -69,7 +70,7 @@ private:
void fillBottomShadow(QPainter &p);
[[nodiscard]] Ui::GL::ChosenRenderer chooseRenderer(
Ui::GL::Capabilities capabilities);
Ui::GL::Backend backend);
const std::unique_ptr<Ui::RpWidgetWrap> _surface;
const not_null<Webrtc::VideoTrack*> _track;
@ -79,12 +80,9 @@ private:
Panel::Incoming::Incoming(
not_null<QWidget*> parent,
not_null<Webrtc::VideoTrack*> track)
: _surface(Ui::GL::CreateSurface(
parent,
[=](Ui::GL::Capabilities capabilities) {
return chooseRenderer(capabilities);
}))
not_null<Webrtc::VideoTrack*> track,
Ui::GL::Backend backend)
: _surface(Ui::GL::CreateSurface(parent, chooseRenderer(backend)))
, _track(track) {
initBottomShadow();
widget()->setAttribute(Qt::WA_OpaquePaintEvent);
@ -100,7 +98,7 @@ not_null<Ui::RpWidgetWrap*> Panel::Incoming::rp() const {
}
Ui::GL::ChosenRenderer Panel::Incoming::chooseRenderer(
Ui::GL::Capabilities capabilities) {
Ui::GL::Backend backend) {
class Renderer : public Ui::GL::Renderer {
public:
Renderer(not_null<Panel::Incoming*> owner) : _owner(owner) {
@ -121,15 +119,9 @@ Ui::GL::ChosenRenderer Panel::Incoming::chooseRenderer(
};
const auto use = Platform::IsMac()
? true
: Platform::IsWindows()
? capabilities.supported
: capabilities.transparency;
LOG(("OpenGL: %1 (Incoming)").arg(Logs::b(use)));
return {
.renderer = std::make_unique<Renderer>(this),
.backend = (use ? Ui::GL::Backend::OpenGL : Ui::GL::Backend::Raster),
.backend = backend,
};
}
@ -258,6 +250,25 @@ Panel::Panel(not_null<Call*> call)
Panel::~Panel() = default;
std::unique_ptr<Ui::Window> Panel::createWindow() {
auto result = std::make_unique<Ui::Window>();
const auto capabilities = Ui::GL::CheckCapabilities(result.get());
const auto use = Platform::IsMac()
? true
: Platform::IsWindows()
? capabilities.supported
: capabilities.transparency;
LOG(("OpenGL: %1 (Incoming)").arg(Logs::b(use)));
_backend = use ? Ui::GL::Backend::OpenGL : Ui::GL::Backend::Raster;
if (use) {
return result;
}
// We have to create a new window, if OpenGL initialization failed.
return std::make_unique<Ui::Window>();
}
bool Panel::isActive() const {
return _window->isActiveWindow()
&& _window->isVisible()
@ -491,7 +502,8 @@ void Panel::reinitWithCall(Call *call) {
_call->videoOutgoing());
_incoming = std::make_unique<Incoming>(
widget(),
_call->videoIncoming());
_call->videoIncoming(),
_backend);
_incoming->widget()->hide();
_call->mutedValue(

View File

@ -30,6 +30,9 @@ class FadeWrap;
template <typename Widget>
class PaddingWrap;
class Window;
namespace GL {
enum class Backend;
} // namespace GL
namespace Platform {
class TitleControls;
} // namespace Platform
@ -67,6 +70,7 @@ private:
Redial,
};
std::unique_ptr<Ui::Window> createWindow();
[[nodiscard]] not_null<Ui::RpWidget*> widget() const;
void paint(QRect clip);
@ -80,9 +84,6 @@ private:
void handleClose();
QRect signalBarsRect() const;
void paintSignalBarsBg(Painter &p);
void updateControlsGeometry();
void updateHangupGeometry();
void updateStatusGeometry();
@ -105,6 +106,7 @@ private:
Call *_call = nullptr;
not_null<UserData*> _user;
Ui::GL::Backend _backend = Ui::GL::Backend();
const std::unique_ptr<Ui::Window> _window;
std::unique_ptr<Incoming> _incoming;

View File

@ -1461,7 +1461,8 @@ std::unique_ptr<Row> Members::Controller::createInvitedRow(
Members::Members(
not_null<QWidget*> parent,
not_null<GroupCall*> call,
PanelMode mode)
PanelMode mode,
Ui::GL::Backend backend)
: RpWidget(parent)
, _call(call)
, _mode(mode)
@ -1473,7 +1474,8 @@ Members::Members(
, _viewport(
std::make_unique<Viewport>(
_videoWrap.get(),
PanelMode::Default)) {
PanelMode::Default,
backend)) {
setupList();
setupAddMember(call);
setContent(_list);

View File

@ -14,6 +14,9 @@ class RpWidget;
class ScrollArea;
class VerticalLayout;
class SettingsButton;
namespace GL {
enum class Backend;
} // namespace GL
} // namespace Ui
namespace Data {
@ -39,7 +42,8 @@ public:
Members(
not_null<QWidget*> parent,
not_null<GroupCall*> call,
PanelMode mode);
PanelMode mode,
Ui::GL::Backend backend);
~Members();
[[nodiscard]] not_null<Viewport*> viewport() const;

View File

@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/dropdown_menu.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/tooltip.h"
#include "ui/gl/gl_detection.h"
#include "ui/chat/group_call_bar.h"
#include "ui/layers/layer_manager.h"
#include "ui/layers/generic_box.h"
@ -46,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "base/event_filter.h"
#include "base/unixtime.h"
#include "base/platform/base_platform_info.h"
#include "base/qt_signal_producer.h"
#include "base/timer_rpl.h"
#include "app.h"
@ -85,14 +87,14 @@ struct Panel::ControlsBackgroundNarrow {
Panel::Panel(not_null<GroupCall*> call)
: _call(call)
, _peer(call->peer())
, _window(std::make_unique<Ui::Window>())
, _window(createWindow())
, _layerBg(std::make_unique<Ui::LayerManager>(_window->body()))
#ifndef Q_OS_MAC
, _controls(std::make_unique<Ui::Platform::TitleControls>(
_window->body(),
st::groupCallTitle))
#endif // !Q_OS_MAC
, _viewport(std::make_unique<Viewport>(widget(), PanelMode::Wide))
, _viewport(std::make_unique<Viewport>(widget(), PanelMode::Wide, _backend))
, _mute(std::make_unique<Ui::CallMuteButton>(
widget(),
st::callMuteButton,
@ -137,6 +139,25 @@ Panel::~Panel() {
_viewport = nullptr;
}
std::unique_ptr<Ui::Window> Panel::createWindow() {
auto result = std::make_unique<Ui::Window>();
const auto capabilities = Ui::GL::CheckCapabilities(result.get());
const auto use = Platform::IsMac()
? true
: Platform::IsWindows()
? capabilities.supported
: capabilities.transparency;
LOG(("OpenGL: %1 (Calls::Group::Viewport)").arg(Logs::b(use)));
_backend = use ? Ui::GL::Backend::OpenGL : Ui::GL::Backend::Raster;
if (use) {
return result;
}
// We have to create a new window, if OpenGL initialization failed.
return std::make_unique<Ui::Window>();
}
void Panel::setupRealCallViewers() {
_call->real(
) | rpl::start_with_next([=](not_null<Data::GroupCall*> real) {
@ -679,7 +700,7 @@ void Panel::setupMembers() {
_countdown.destroy();
_startsWhen.destroy();
_members.create(widget(), _call, mode());
_members.create(widget(), _call, mode(), _backend);
setupVideo(_viewport.get());
setupVideo(_members->viewport());

View File

@ -42,6 +42,9 @@ class ScrollArea;
class GenericBox;
class LayerManager;
class GroupCallScheduledLeft;
namespace GL {
enum class Backend;
} // namespace GL
namespace Toast {
class Instance;
} // namespace Toast
@ -81,6 +84,7 @@ private:
using State = GroupCall::State;
struct ControlsBackgroundNarrow;
std::unique_ptr<Ui::Window> createWindow();
[[nodiscard]] not_null<Ui::RpWidget*> widget() const;
[[nodiscard]] PanelMode mode() const;
@ -151,6 +155,7 @@ private:
const not_null<GroupCall*> _call;
not_null<PeerData*> _peer;
Ui::GL::Backend _backend = Ui::GL::Backend();
const std::unique_ptr<Ui::Window> _window;
const std::unique_ptr<Ui::LayerManager> _layerBg;
rpl::variable<PanelMode> _mode;

View File

@ -47,13 +47,12 @@ namespace {
} // namespace
Viewport::Viewport(not_null<QWidget*> parent, PanelMode mode)
Viewport::Viewport(
not_null<QWidget*> parent,
PanelMode mode,
Ui::GL::Backend backend)
: _mode(mode)
, _content(Ui::GL::CreateSurface(
parent,
[=](Ui::GL::Capabilities capabilities) {
return chooseRenderer(capabilities);
})) {
, _content(Ui::GL::CreateSurface(parent, chooseRenderer(backend))) {
setup();
}
@ -796,25 +795,14 @@ void Viewport::setPressed(Selection value) {
_pressed = value;
}
Ui::GL::ChosenRenderer Viewport::chooseRenderer(
Ui::GL::Capabilities capabilities) {
const auto use = Platform::IsMac()
? true
: Platform::IsWindows()
? capabilities.supported
: capabilities.transparency;
LOG(("OpenGL: %1 (Calls::Group::Viewport)").arg(Logs::b(use)));
if (use) {
auto renderer = std::make_unique<RendererGL>(this);
_opengl = true;
return {
.renderer = std::move(renderer),
.backend = Ui::GL::Backend::OpenGL,
};
}
Ui::GL::ChosenRenderer Viewport::chooseRenderer(Ui::GL::Backend backend) {
_opengl = (backend == Ui::GL::Backend::OpenGL);
return {
.renderer = std::make_unique<RendererSW>(this),
.backend = Ui::GL::Backend::Raster,
.renderer = (_opengl
? std::unique_ptr<Ui::GL::Renderer>(
std::make_unique<RendererGL>(this))
: std::make_unique<RendererSW>(this)),
.backend = backend,
};
}

View File

@ -14,6 +14,7 @@ namespace Ui {
class AbstractButton;
class RpWidgetWrap;
namespace GL {
enum class Backend;
struct Capabilities;
struct ChosenRenderer;
} // namespace GL
@ -58,7 +59,10 @@ struct VideoTileTrack {
class Viewport final {
public:
Viewport(not_null<QWidget*> parent, PanelMode mode);
Viewport(
not_null<QWidget*> parent,
PanelMode mode,
Ui::GL::Backend backend);
~Viewport();
[[nodiscard]] not_null<QWidget*> widget() const;
@ -159,7 +163,7 @@ private:
void updateSelected();
[[nodiscard]] Ui::GL::ChosenRenderer chooseRenderer(
Ui::GL::Capabilities capabilities);
Ui::GL::Backend backend);
PanelMode _mode = PanelMode();
bool _opengl = false;

View File

@ -289,7 +289,6 @@ OverlayWidget::PipWrap::PipWrap(
OverlayWidget::OverlayWidget()
: _surface(Ui::GL::CreateSurface(
nullptr, // No parent for the window in Qt parent-child sense.
[=](Ui::GL::Capabilities capabilities) {
return chooseRenderer(capabilities);
}))

View File

@ -375,7 +375,6 @@ PipPanel::PipPanel(
QWidget *parent,
Fn<void(QPainter&, FrameRequest, bool)> paint)
: _content(Ui::GL::CreateSurface(
nullptr, // No parent for the window in Qt parent-child sense.
[=](Ui::GL::Capabilities capabilities) {
return chooseRenderer(capabilities);
}))

@ -1 +1 @@
Subproject commit cbb65009ffc443bc88137f2758228c1b185d8d20
Subproject commit 7bc9e1261498af07475f4bac0d8bcd8721202177