mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Add hardware acceleartion video decoding setting.
This commit is contained in:
parent
27d9f78566
commit
5167eb47ae
6 changed files with 39 additions and 4 deletions
Telegram
Resources/langs
SourceFiles
|
@ -492,6 +492,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_settings_system_integration" = "System integration";
|
||||
"lng_settings_performance" = "Performance";
|
||||
"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_angle_backend" = "ANGLE graphics backend";
|
||||
"lng_settings_angle_backend_auto" = "Auto";
|
||||
|
|
|
@ -128,7 +128,7 @@ QByteArray Settings::serialize() const {
|
|||
+ Serialize::bytearraySize(_photoEditorBrush)
|
||||
+ sizeof(qint32) * 3
|
||||
+ Serialize::stringSize(_customDeviceModel.current())
|
||||
+ sizeof(qint32) * 2;
|
||||
+ sizeof(qint32) * 4;
|
||||
|
||||
auto result = QByteArray();
|
||||
result.reserve(size);
|
||||
|
@ -236,6 +236,9 @@ QByteArray Settings::serialize() const {
|
|||
for (const auto &id : _accountsOrder) {
|
||||
stream << quint64(id);
|
||||
}
|
||||
|
||||
stream
|
||||
<< qint32(_hardwareAcceleratedVideo ? 1 : 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -325,6 +328,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
qint32 macWarnBeforeQuit = _macWarnBeforeQuit ? 1 : 0;
|
||||
qint32 accountsOrderCount = 0;
|
||||
std::vector<uint64> accountsOrder;
|
||||
qint32 hardwareAcceleratedVideo = _hardwareAcceleratedVideo ? 1 : 0;
|
||||
|
||||
stream >> themesAccentColors;
|
||||
if (!stream.atEnd()) {
|
||||
|
@ -506,6 +510,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> hardwareAcceleratedVideo;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"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::Shuffle: _playerOrderMode = uncheckedPlayerOrderMode; break;
|
||||
}
|
||||
_macWarnBeforeQuit = macWarnBeforeQuit ? 1 : 0;
|
||||
_macWarnBeforeQuit = (macWarnBeforeQuit == 1);
|
||||
_hardwareAcceleratedVideo = (hardwareAcceleratedVideo == 1);
|
||||
}
|
||||
|
||||
QString Settings::getSoundPath(const QString &key) const {
|
||||
|
|
|
@ -663,6 +663,13 @@ public:
|
|||
_accountsOrder = order;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool hardwareAcceleratedVideo() const {
|
||||
return _hardwareAcceleratedVideo;
|
||||
}
|
||||
void setHardwareAcceleratedVideo(bool value) {
|
||||
_hardwareAcceleratedVideo = value;
|
||||
}
|
||||
|
||||
void setMacWarnBeforeQuit(bool value) {
|
||||
_macWarnBeforeQuit = value;
|
||||
}
|
||||
|
@ -775,6 +782,7 @@ private:
|
|||
rpl::variable<Media::Player::OrderMode> _playerOrderMode;
|
||||
bool _macWarnBeforeQuit = true;
|
||||
std::vector<uint64> _accountsOrder;
|
||||
bool _hardwareAcceleratedVideo = true;
|
||||
|
||||
bool _tabbedReplacedWithInfo = false; // per-window
|
||||
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window
|
||||
|
|
|
@ -3116,7 +3116,7 @@ void OverlayWidget::restartAtSeekPosition(crl::time position) {
|
|||
}
|
||||
auto options = Streaming::PlaybackOptions();
|
||||
options.position = position;
|
||||
options.hwAllowed = true;
|
||||
options.hwAllowed = Core::App().settings().hardwareAcceleratedVideo();
|
||||
if (!_streamed->withSound) {
|
||||
options.mode = Streaming::Mode::Video;
|
||||
options.loop = true;
|
||||
|
|
|
@ -1604,7 +1604,7 @@ void Pip::restartAtSeekPosition(crl::time position) {
|
|||
|
||||
auto options = Streaming::PlaybackOptions();
|
||||
options.position = position;
|
||||
options.hwAllowed = true;
|
||||
options.hwAllowed = Core::App().settings().hardwareAcceleratedVideo();
|
||||
options.audioId = _instance.player().prepareLegacyState().id;
|
||||
|
||||
Assert(8 && _delegate->pipPlaybackSpeed() >= 0.5
|
||||
|
|
|
@ -582,6 +582,23 @@ void SetupAnimations(not_null<Ui::VerticalLayout*> container) {
|
|||
}, 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
|
||||
void SetupANGLE(
|
||||
not_null<Window::SessionController*> controller,
|
||||
|
@ -695,6 +712,7 @@ void SetupPerformance(
|
|||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
SetupAnimations(container);
|
||||
SetupHardwareAcceleration(container);
|
||||
#ifdef Q_OS_WIN
|
||||
SetupANGLE(controller, container);
|
||||
#else // Q_OS_WIN
|
||||
|
|
Loading…
Add table
Reference in a new issue