зеркало из https://github.com/electron/electron.git
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:
Родитель
b7c9c895b5
Коммит
f943b8c940
|
@ -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
|
} // namespace electron
|
||||||
|
|
|
@ -40,6 +40,7 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin,
|
||||||
|
|
||||||
// ui::NativeThemeObserver:
|
// ui::NativeThemeObserver:
|
||||||
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
|
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
|
||||||
|
bool ShouldWindowContentsBeTransparent() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
raw_ptr<NativeWindowViews> native_window_view_; // weak ref
|
raw_ptr<NativeWindowViews> native_window_view_; // weak ref
|
||||||
|
|
Загрузка…
Ссылка в новой задаче