Bug 1768495 Part 1: Add a method nsIWidget::PauseOrResumeCompositor, and override it in nsCocoaWindow. r=gfx-reviewers,emilio,ahale

This change does not affect behavior, it's just prepatory for a later
caller to the newly-defined method.

Differential Revision: https://phabricator.services.mozilla.com/D169344
This commit is contained in:
Brad Werth 2023-02-09 23:44:19 +00:00
Родитель 0bcd46b1b0
Коммит 5a99e78cfc
4 изменённых файлов: 25 добавлений и 31 удалений

Просмотреть файл

@ -354,8 +354,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
bool InFullScreenMode() const { return mInFullScreenMode; }
void PauseCompositor();
void ResumeCompositor();
void PauseOrResumeCompositor(bool aPause) override;
bool AsyncPanZoomEnabled() const override;

Просмотреть файл

@ -2111,11 +2111,7 @@ void nsCocoaWindow::DispatchSizeModeEvent() {
}
if (StaticPrefs::widget_pause_compositor_when_minimized()) {
if (newMode == nsSizeMode_Minimized) {
PauseCompositor();
} else {
ResumeCompositor();
}
PauseOrResumeCompositor(newMode == nsSizeMode_Minimized);
}
}
@ -2155,30 +2151,6 @@ void nsCocoaWindow::ReportSizeEvent() {
NS_OBJC_END_TRY_IGNORE_BLOCK;
}
void nsCocoaWindow::PauseCompositor() {
nsIWidget* mainChildView = static_cast<nsIWidget*>([[mWindow mainChildView] widget]);
if (!mainChildView) {
return;
}
CompositorBridgeChild* remoteRenderer = mainChildView->GetRemoteRenderer();
if (!remoteRenderer) {
return;
}
remoteRenderer->SendPause();
}
void nsCocoaWindow::ResumeCompositor() {
nsIWidget* mainChildView = static_cast<nsIWidget*>([[mWindow mainChildView] widget]);
if (!mainChildView) {
return;
}
CompositorBridgeChild* remoteRenderer = mainChildView->GetRemoteRenderer();
if (!remoteRenderer) {
return;
}
remoteRenderer->SendResume();
}
void nsCocoaWindow::SetMenuBar(RefPtr<nsMenuBarX>&& aMenuBar) {
if (!mWindow) {
mMenuBar = nullptr;
@ -2598,6 +2570,12 @@ bool nsCocoaWindow::GetEditCommands(NativeKeyBindingsType aType, const WidgetKey
return true;
}
void nsCocoaWindow::PauseOrResumeCompositor(bool aPause) {
if (auto* mainChildView = static_cast<nsIWidget*>([[mWindow mainChildView] widget])) {
mainChildView->PauseOrResumeCompositor(aPause);
}
}
bool nsCocoaWindow::AsyncPanZoomEnabled() const {
if (mPopupContentView) {
return mPopupContentView->AsyncPanZoomEnabled();

Просмотреть файл

@ -988,6 +988,18 @@ void nsBaseWidget::CreateCompositor() {
CreateCompositor(rect.Width(), rect.Height());
}
void nsIWidget::PauseOrResumeCompositor(bool aPause) {
auto* renderer = GetRemoteRenderer();
if (!renderer) {
return;
}
if (aPause) {
renderer->SendPause();
} else {
renderer->SendResume();
}
}
already_AddRefed<GeckoContentController>
nsBaseWidget::CreateRootContentController() {
RefPtr<GeckoContentController> controller =

Просмотреть файл

@ -1973,6 +1973,11 @@ class nsIWidget : public nsISupports {
*/
virtual CompositorBridgeChild* GetRemoteRenderer() { return nullptr; }
/**
* If there is a remote renderer, pause or resume it.
*/
virtual void PauseOrResumeCompositor(bool aPause);
/**
* Clear WebRender resources
*/