Rp{Widget,Window}NoRhi ->Rp{Widget,Window}OpenGL

This is more explicit
This commit is contained in:
Ilya Fedin 2023-11-01 08:02:56 +04:00 committed by John Preston
parent d7f12b083e
commit 23ce4f09df

View file

@ -24,20 +24,20 @@ namespace {
constexpr auto kUseNativeChild = false;// ::Platform::IsWindows(); constexpr auto kUseNativeChild = false;// ::Platform::IsWindows();
class RpWidgetNoRhi : public RpWidget { class RpWidgetOpenGL : public RpWidget {
protected: protected:
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
std::optional<QPlatformBackingStoreRhiConfig> rhiConfig() const override { std::optional<QPlatformBackingStoreRhiConfig> rhiConfig() const override {
return QPlatformBackingStoreRhiConfig(); return { QPlatformBackingStoreRhiConfig::OpenGL };
} }
#endif // Qt >= 6.4.0 #endif // Qt >= 6.4.0
}; };
class RpWindowNoRhi : public RpWindow { class RpWindowOpenGL : public RpWindow {
protected: protected:
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
std::optional<QPlatformBackingStoreRhiConfig> rhiConfig() const override { std::optional<QPlatformBackingStoreRhiConfig> rhiConfig() const override {
return QPlatformBackingStoreRhiConfig(); return { QPlatformBackingStoreRhiConfig::OpenGL };
} }
#endif // Qt >= 6.4.0 #endif // Qt >= 6.4.0
}; };
@ -79,7 +79,7 @@ not_null<RpWidget*> Window::widget() const {
std::unique_ptr<RpWindow> Window::createWindow( std::unique_ptr<RpWindow> Window::createWindow(
const Fn<Backend(Capabilities)> &chooseBackend) { const Fn<Backend(Capabilities)> &chooseBackend) {
std::unique_ptr<RpWindow> result = std::make_unique<RpWindowNoRhi>(); std::unique_ptr<RpWindow> result = std::make_unique<RpWindowOpenGL>();
if constexpr (!kUseNativeChild) { if constexpr (!kUseNativeChild) {
_backend = chooseBackend(CheckCapabilities(result.get())); _backend = chooseBackend(CheckCapabilities(result.get()));
if (_backend != Backend::OpenGL) { if (_backend != Backend::OpenGL) {
@ -96,7 +96,7 @@ std::unique_ptr<RpWidget> Window::createNativeBodyWrap(
return nullptr; return nullptr;
} }
const auto create = [] { const auto create = [] {
auto result = std::make_unique<RpWidgetNoRhi>(); auto result = std::make_unique<RpWidgetOpenGL>();
result->setWindowFlags(Qt::FramelessWindowHint | Qt::Window); result->setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
result->setAttribute(Qt::WA_NativeWindow); result->setAttribute(Qt::WA_NativeWindow);
result->setAttribute(Qt::WA_DontCreateNativeAncestors); result->setAttribute(Qt::WA_DontCreateNativeAncestors);