internal/ui: optimize GPU usages when the screen doesn't have to be updated

This change skips rendering when 1) the screen is not cleared every frame
(`SetScreenClearedEveryFrame(false)`) and 2) Draw doesn't draw anything
onto the screen. The GPU usages decreased on some machines (e.g. GPU usage
was 10% with an empty Ebitengine project and became 2-3 % on a Windows
machine).

Updates #2341
This commit is contained in:
Hajime Hoshi
2022-10-24 01:51:37 +09:00
parent fcda4143a5
commit b019a3723a
6 changed files with 152 additions and 16 deletions

View File

@@ -147,7 +147,7 @@ func (g *gameForUI) DrawOffscreen() error {
return nil
}
func (g *gameForUI) DrawScreen() {
func (g *gameForUI) DrawFinalScreen() {
scale, offsetX, offsetY := g.ScreenScaleAndOffsets()
var geoM GeoM
geoM.Scale(scale, scale)