UI/Qt: Keep macOS chrome out of RHI flushes
Stop forcing RHI for every QWidget on macOS. The web content view is the only widget that needs Metal, and QRhiWidget already requests that. Make the web content view a native child before parenting it into the tab UI so Qt does not propagate its RHI config to the browser window backing store. This keeps chrome repaints on the normal Cocoa backing store path instead of copying the full window backing store into a texture.
This commit is contained in:
parent
7c34917677
commit
4cc0ee5f47
2 changed files with 21 additions and 6 deletions
|
|
@ -53,10 +53,25 @@ namespace Ladybird {
|
|||
|
||||
bool is_using_dark_system_theme(QWidget&);
|
||||
|
||||
WebContentView::WebContentView(QWidget* window, RefPtr<WebView::WebContentClient> parent_client, size_t page_index, WebContentViewInitialState initial_state)
|
||||
: WebContentViewBase(window)
|
||||
static QWidget* initial_web_content_view_parent([[maybe_unused]] QWidget* window)
|
||||
{
|
||||
#ifdef AK_OS_MACOS
|
||||
return nullptr;
|
||||
#else
|
||||
return window;
|
||||
#endif
|
||||
}
|
||||
|
||||
WebContentView::WebContentView(QWidget* window, RefPtr<WebView::WebContentClient> parent_client, size_t page_index, WebContentViewInitialState initial_state)
|
||||
: WebContentViewBase(initial_web_content_view_parent(window))
|
||||
{
|
||||
#ifdef AK_OS_MACOS
|
||||
// Keep the QRhiWidget out of the top-level QWidget backing store. If it is
|
||||
// parented before becoming native, Qt propagates its RHI config to the whole
|
||||
// browser window and uploads the full backing store texture on chrome repaints.
|
||||
setAttribute(Qt::WA_DontCreateNativeAncestors);
|
||||
setAttribute(Qt::WA_NativeWindow);
|
||||
setParent(window);
|
||||
setApi(QRhiWidget::Api::Metal);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <UI/Qt/BrowserWindow.h>
|
||||
#include <UI/Qt/Settings.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
|
|
@ -46,10 +47,9 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
|||
AK::set_rich_debug_enabled(true);
|
||||
|
||||
#ifdef AK_OS_MACOS
|
||||
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI"))
|
||||
qputenv("QT_WIDGETS_RHI", "1");
|
||||
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI_BACKEND"))
|
||||
qputenv("QT_WIDGETS_RHI_BACKEND", "metal");
|
||||
// The web content view is a native QRhiWidget child. Keep it from forcing
|
||||
// every sibling in the tab UI to become native as well.
|
||||
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
#endif
|
||||
|
||||
auto app = TRY(Ladybird::Application::create(arguments));
|
||||
|
|
|
|||
Loading…
Reference in a new issue