Add hardware acceleartion video decoding setting.
This commit is contained in:
parent
27d9f78566
commit
5167eb47ae
|
@ -492,6 +492,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_system_integration" = "System integration";
|
"lng_settings_system_integration" = "System integration";
|
||||||
"lng_settings_performance" = "Performance";
|
"lng_settings_performance" = "Performance";
|
||||||
"lng_settings_enable_animations" = "Enable animations";
|
"lng_settings_enable_animations" = "Enable animations";
|
||||||
|
"lng_settings_enable_hwaccel" = "Hardware accelerated video decoding";
|
||||||
"lng_settings_enable_opengl" = "Enable OpenGL rendering for media";
|
"lng_settings_enable_opengl" = "Enable OpenGL rendering for media";
|
||||||
"lng_settings_angle_backend" = "ANGLE graphics backend";
|
"lng_settings_angle_backend" = "ANGLE graphics backend";
|
||||||
"lng_settings_angle_backend_auto" = "Auto";
|
"lng_settings_angle_backend_auto" = "Auto";
|
||||||
|
|
|
@ -128,7 +128,7 @@ QByteArray Settings::serialize() const {
|
||||||
+ Serialize::bytearraySize(_photoEditorBrush)
|
+ Serialize::bytearraySize(_photoEditorBrush)
|
||||||
+ sizeof(qint32) * 3
|
+ sizeof(qint32) * 3
|
||||||
+ Serialize::stringSize(_customDeviceModel.current())
|
+ Serialize::stringSize(_customDeviceModel.current())
|
||||||
+ sizeof(qint32) * 2;
|
+ sizeof(qint32) * 4;
|
||||||
|
|
||||||
auto result = QByteArray();
|
auto result = QByteArray();
|
||||||
result.reserve(size);
|
result.reserve(size);
|
||||||
|
@ -236,6 +236,9 @@ QByteArray Settings::serialize() const {
|
||||||
for (const auto &id : _accountsOrder) {
|
for (const auto &id : _accountsOrder) {
|
||||||
stream << quint64(id);
|
stream << quint64(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stream
|
||||||
|
<< qint32(_hardwareAcceleratedVideo ? 1 : 0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -325,6 +328,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
qint32 macWarnBeforeQuit = _macWarnBeforeQuit ? 1 : 0;
|
qint32 macWarnBeforeQuit = _macWarnBeforeQuit ? 1 : 0;
|
||||||
qint32 accountsOrderCount = 0;
|
qint32 accountsOrderCount = 0;
|
||||||
std::vector<uint64> accountsOrder;
|
std::vector<uint64> accountsOrder;
|
||||||
|
qint32 hardwareAcceleratedVideo = _hardwareAcceleratedVideo ? 1 : 0;
|
||||||
|
|
||||||
stream >> themesAccentColors;
|
stream >> themesAccentColors;
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
|
@ -506,6 +510,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
stream >> hardwareAcceleratedVideo;
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||||
|
@ -661,7 +668,8 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
case Media::Player::OrderMode::Reverse:
|
case Media::Player::OrderMode::Reverse:
|
||||||
case Media::Player::OrderMode::Shuffle: _playerOrderMode = uncheckedPlayerOrderMode; break;
|
case Media::Player::OrderMode::Shuffle: _playerOrderMode = uncheckedPlayerOrderMode; break;
|
||||||
}
|
}
|
||||||
_macWarnBeforeQuit = macWarnBeforeQuit ? 1 : 0;
|
_macWarnBeforeQuit = (macWarnBeforeQuit == 1);
|
||||||
|
_hardwareAcceleratedVideo = (hardwareAcceleratedVideo == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getSoundPath(const QString &key) const {
|
QString Settings::getSoundPath(const QString &key) const {
|
||||||
|
|
|
@ -663,6 +663,13 @@ public:
|
||||||
_accountsOrder = order;
|
_accountsOrder = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool hardwareAcceleratedVideo() const {
|
||||||
|
return _hardwareAcceleratedVideo;
|
||||||
|
}
|
||||||
|
void setHardwareAcceleratedVideo(bool value) {
|
||||||
|
_hardwareAcceleratedVideo = value;
|
||||||
|
}
|
||||||
|
|
||||||
void setMacWarnBeforeQuit(bool value) {
|
void setMacWarnBeforeQuit(bool value) {
|
||||||
_macWarnBeforeQuit = value;
|
_macWarnBeforeQuit = value;
|
||||||
}
|
}
|
||||||
|
@ -775,6 +782,7 @@ private:
|
||||||
rpl::variable<Media::Player::OrderMode> _playerOrderMode;
|
rpl::variable<Media::Player::OrderMode> _playerOrderMode;
|
||||||
bool _macWarnBeforeQuit = true;
|
bool _macWarnBeforeQuit = true;
|
||||||
std::vector<uint64> _accountsOrder;
|
std::vector<uint64> _accountsOrder;
|
||||||
|
bool _hardwareAcceleratedVideo = true;
|
||||||
|
|
||||||
bool _tabbedReplacedWithInfo = false; // per-window
|
bool _tabbedReplacedWithInfo = false; // per-window
|
||||||
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window
|
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window
|
||||||
|
|
|
@ -3116,7 +3116,7 @@ void OverlayWidget::restartAtSeekPosition(crl::time position) {
|
||||||
}
|
}
|
||||||
auto options = Streaming::PlaybackOptions();
|
auto options = Streaming::PlaybackOptions();
|
||||||
options.position = position;
|
options.position = position;
|
||||||
options.hwAllowed = true;
|
options.hwAllowed = Core::App().settings().hardwareAcceleratedVideo();
|
||||||
if (!_streamed->withSound) {
|
if (!_streamed->withSound) {
|
||||||
options.mode = Streaming::Mode::Video;
|
options.mode = Streaming::Mode::Video;
|
||||||
options.loop = true;
|
options.loop = true;
|
||||||
|
|
|
@ -1604,7 +1604,7 @@ void Pip::restartAtSeekPosition(crl::time position) {
|
||||||
|
|
||||||
auto options = Streaming::PlaybackOptions();
|
auto options = Streaming::PlaybackOptions();
|
||||||
options.position = position;
|
options.position = position;
|
||||||
options.hwAllowed = true;
|
options.hwAllowed = Core::App().settings().hardwareAcceleratedVideo();
|
||||||
options.audioId = _instance.player().prepareLegacyState().id;
|
options.audioId = _instance.player().prepareLegacyState().id;
|
||||||
|
|
||||||
Assert(8 && _delegate->pipPlaybackSpeed() >= 0.5
|
Assert(8 && _delegate->pipPlaybackSpeed() >= 0.5
|
||||||
|
|
|
@ -582,6 +582,23 @@ void SetupAnimations(not_null<Ui::VerticalLayout*> container) {
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupHardwareAcceleration(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
const auto settings = &Core::App().settings();
|
||||||
|
AddButton(
|
||||||
|
container,
|
||||||
|
tr::lng_settings_enable_hwaccel(),
|
||||||
|
st::settingsButtonNoIcon
|
||||||
|
)->toggleOn(
|
||||||
|
rpl::single(settings->hardwareAcceleratedVideo())
|
||||||
|
)->toggledValue(
|
||||||
|
) | rpl::filter([=](bool enabled) {
|
||||||
|
return (enabled != settings->hardwareAcceleratedVideo());
|
||||||
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
|
settings->setHardwareAcceleratedVideo(enabled);
|
||||||
|
Core::App().saveSettingsDelayed();
|
||||||
|
}, container->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
void SetupANGLE(
|
void SetupANGLE(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
@ -695,6 +712,7 @@ void SetupPerformance(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container) {
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
SetupAnimations(container);
|
SetupAnimations(container);
|
||||||
|
SetupHardwareAcceleration(container);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
SetupANGLE(controller, container);
|
SetupANGLE(controller, container);
|
||||||
#else // Q_OS_WIN
|
#else // Q_OS_WIN
|
||||||
|
|
Loading…
Reference in New Issue