Allow force-disabling OpenGL.

This commit is contained in:
John Preston 2021-05-20 16:07:53 +04:00
parent c64e953174
commit c12a50544e
5 changed files with 55 additions and 1 deletions

View File

@ -451,6 +451,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_opengl" = "Enable OpenGL rendering for video";
"lng_settings_sensitive_title" = "Sensitive content";
"lng_settings_sensitive_disable_filtering" = "Disable filtering";
"lng_settings_sensitive_about" = "Display sensitive media in public channels on all your Telegram devices.";

View File

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/section_widget.h"
#include "base/platform/base_platform_info.h"
#include "webrtc/webrtc_create_adm.h"
#include "ui/gl/gl_detection.h"
#include "facades.h"
namespace Core {
@ -194,6 +195,7 @@ QByteArray Settings::serialize() const {
for (const auto &[id, variant] : _emojiVariants) {
stream << id << quint8(variant);
}
stream << qint32(_disableOpenGL ? 1 : 0);
}
return result;
}
@ -269,6 +271,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
QByteArray windowPosition;
std::vector<RecentEmojiId> recentEmojiPreload;
base::flat_map<QString, uint8> emojiVariants;
qint32 disableOpenGL = _disableOpenGL ? 1 : 0;
stream >> themesAccentColors;
if (!stream.atEnd()) {
@ -397,6 +400,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
}
}
}
if (!stream.atEnd()) {
stream >> disableOpenGL;
}
if (stream.status() != QDataStream::Ok) {
LOG(("App Error: "
"Bad data for Core::Settings::constructFromSerialized()"));
@ -502,6 +508,10 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
}
_recentEmojiPreload = std::move(recentEmojiPreload);
_emojiVariants = std::move(emojiVariants);
_disableOpenGL = (disableOpenGL == 1);
if (!Platform::IsMac()) {
Ui::GL::ForceDisable(_disableOpenGL);
}
}
bool Settings::chatWide() const {

View File

@ -532,6 +532,13 @@ public:
void saveEmojiVariant(EmojiPtr emoji);
void setLegacyEmojiVariants(QMap<QString, int> data);
[[nodiscard]] bool disableOpenGL() const {
return _disableOpenGL;
}
void setDisableOpenGL(bool value) {
_disableOpenGL = value;
}
[[nodiscard]] static bool ThirdColumnByDefault();
[[nodiscard]] static float64 DefaultDialogsWidthRatio();
[[nodiscard]] static qint32 SerializePlaybackSpeed(float64 speed) {
@ -624,6 +631,7 @@ private:
rpl::variable<std::optional<bool>> _systemDarkMode = std::nullopt;
rpl::variable<bool> _systemDarkModeEnabled = false;
WindowPosition _windowPosition; // per-window
bool _disableOpenGL = false;
bool _tabbedReplacedWithInfo = false; // per-window
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window

View File

@ -502,10 +502,45 @@ void SetupAnimations(not_null<Ui::VerticalLayout*> container) {
}, container->lifetime());
}
void SetupOpenGL(not_null<Ui::VerticalLayout*> container) {
const auto toggles = container->lifetime().make_state<
rpl::event_stream<bool>
>();
const auto button = AddButton(
container,
tr::lng_settings_enable_opengl(),
st::settingsButton
)->toggleOn(
toggles->events_starting_with_copy(
!Core::App().settings().disableOpenGL())
);
button->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled == Core::App().settings().disableOpenGL());
}) | rpl::start_with_next([=](bool enabled) {
const auto confirmed = crl::guard(button, [=] {
Core::App().settings().setDisableOpenGL(!enabled);
Local::writeSettings();
App::restart();
});
const auto cancelled = crl::guard(button, [=] {
toggles->fire(!enabled);
});
Ui::show(Box<ConfirmBox>(
tr::lng_settings_need_restart(tr::now),
tr::lng_settings_restart_now(tr::now),
confirmed,
cancelled));
}, container->lifetime());
}
void SetupPerformance(
not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> container) {
SetupAnimations(container);
if (!Platform::IsMac()) {
SetupOpenGL(container);
}
}
void SetupSystemIntegration(

@ -1 +1 @@
Subproject commit ca5b2e6746447e39fc1e7deb1fa97e28d518bc7f
Subproject commit 5e38964fbfed38efdcf5c1628ca65d7e3469764a