Make the default rendering backend choosing logic public
This commit is contained in:
parent
85b73e98ec
commit
d2fddd8da6
3 changed files with 22 additions and 12 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include "ui/integration.h"
|
#include "ui/integration.h"
|
||||||
#include "base/debug_log.h"
|
#include "base/debug_log.h"
|
||||||
#include "base/options.h"
|
#include "base/options.h"
|
||||||
|
#include "base/platform/base_platform_info.h"
|
||||||
|
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
|
|
@ -206,6 +207,15 @@ Capabilities CheckCapabilities(QWidget *widget) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Backend ChooseBackendDefault(Capabilities capabilities) {
|
||||||
|
const auto use = ::Platform::IsMac()
|
||||||
|
? true
|
||||||
|
: ::Platform::IsWindows()
|
||||||
|
? capabilities.supported
|
||||||
|
: capabilities.transparency;
|
||||||
|
return use ? Backend::OpenGL : Backend::Raster;
|
||||||
|
}
|
||||||
|
|
||||||
bool LastCrashCheckFailed() {
|
bool LastCrashCheckFailed() {
|
||||||
return QFile::exists(Integration::Instance().openglCheckFilePath());
|
return QFile::exists(Integration::Instance().openglCheckFilePath());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ struct Capabilities {
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] Capabilities CheckCapabilities(QWidget *widget = nullptr);
|
[[nodiscard]] Capabilities CheckCapabilities(QWidget *widget = nullptr);
|
||||||
|
[[nodiscard]] Backend ChooseBackendDefault(Capabilities capabilities);
|
||||||
|
|
||||||
void ForceDisable(bool disable);
|
void ForceDisable(bool disable);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,25 +23,24 @@ namespace Ui::GL {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kUseNativeChild = false;// ::Platform::IsWindows();
|
constexpr auto kUseNativeChild = false;// ::Platform::IsWindows();
|
||||||
|
[[nodiscard]] Fn<Backend(Capabilities)> ChooseBackendWrap(
|
||||||
[[nodiscard]] Backend DefaultChooseBackend(Capabilities capabilities) {
|
Fn<Backend(Capabilities)> chooseBackend) {
|
||||||
const auto use = ::Platform::IsMac()
|
return [=](Capabilities capabilities) {
|
||||||
? true
|
const auto backend = chooseBackend(capabilities);
|
||||||
: ::Platform::IsWindows()
|
const auto use = backend == Backend::OpenGL;
|
||||||
? capabilities.supported
|
LOG(("OpenGL: %1 (Window)").arg(use ? "[TRUE]" : "[FALSE]"));
|
||||||
: capabilities.transparency;
|
return backend;
|
||||||
LOG(("OpenGL: %1 (Window)").arg(use ? "[TRUE]" : "[FALSE]"));
|
};
|
||||||
return use ? Backend::OpenGL : Backend::Raster;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Window::Window() : Window(DefaultChooseBackend) {
|
Window::Window() : Window(ChooseBackendDefault) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::Window(Fn<Backend(Capabilities)> chooseBackend)
|
Window::Window(Fn<Backend(Capabilities)> chooseBackend)
|
||||||
: _window(createWindow(chooseBackend))
|
: _window(createWindow(ChooseBackendWrap(chooseBackend)))
|
||||||
, _bodyNativeWrap(createNativeBodyWrap(chooseBackend))
|
, _bodyNativeWrap(createNativeBodyWrap(ChooseBackendWrap(chooseBackend)))
|
||||||
, _body(_bodyNativeWrap ? _bodyNativeWrap.get() : _window->body().get()) {
|
, _body(_bodyNativeWrap ? _bodyNativeWrap.get() : _window->body().get()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue