fix: set window contents as opaque to decrease DWM GPU usage (#39895)

* set window contents as opaque to decrease DWM GPU usage

* chore: add more context to ShouldWindowContentsBeTransparent
This commit is contained in:
Bruno Henrique da Silva 2023-09-27 11:42:46 -03:00 коммит произвёл GitHub
Родитель b7c9c895b5
Коммит f943b8c940
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 11 добавлений и 0 удалений

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

@ -133,4 +133,14 @@ void ElectronDesktopWindowTreeHostWin::OnNativeThemeUpdated(
}
}
bool ElectronDesktopWindowTreeHostWin::ShouldWindowContentsBeTransparent()
const {
// Window should be marked as opaque if no transparency setting has been set,
// otherwise videos rendered in the window will trigger a DirectComposition
// redraw for every frame.
// https://github.com/electron/electron/pull/39895
return native_window_view_->GetOpacity() < 1.0 ||
native_window_view_->transparent();
}
} // namespace electron

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

@ -40,6 +40,7 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin,
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
bool ShouldWindowContentsBeTransparent() const override;
private:
raw_ptr<NativeWindowViews> native_window_view_; // weak ref