mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
Revert "internal/graphicsdriver/metal: bug fix: use 3 drawables for fullscreen"
This reverts commit 3c7bcf3035
.
Reason: the window unexpectedly blinks when exiting from fullscreen
Updates #2880
This commit is contained in:
parent
3c7bcf3035
commit
ec9613dd94
@ -22,16 +22,16 @@ import (
|
||||
)
|
||||
|
||||
type view struct {
|
||||
window uintptr
|
||||
uiview uintptr
|
||||
|
||||
windowChanged bool
|
||||
vsyncDisabled bool
|
||||
|
||||
device mtl.Device
|
||||
ml ca.MetalLayer
|
||||
|
||||
maximumDrawableCount int
|
||||
|
||||
once sync.Once
|
||||
|
||||
viewPlatform
|
||||
}
|
||||
|
||||
func (v *view) setDrawableSize(width, height int) {
|
||||
@ -52,24 +52,14 @@ func (v *view) setDisplaySyncEnabled(enabled bool) {
|
||||
func (v *view) forceSetDisplaySyncEnabled(enabled bool) {
|
||||
v.ml.SetDisplaySyncEnabled(enabled)
|
||||
v.vsyncDisabled = !enabled
|
||||
v.updateMaximumDrawableCount()
|
||||
}
|
||||
|
||||
func (v *view) updateMaximumDrawableCount() {
|
||||
var count int
|
||||
if v.vsyncDisabled || v.isFullscreen() {
|
||||
if v.vsyncDisabled {
|
||||
// Apparently 2 makes FPS half. Use 3.
|
||||
count = 3
|
||||
v.ml.SetMaximumDrawableCount(3)
|
||||
} else {
|
||||
// Use 2 in a usual case not to cause rendering delays (#2822).
|
||||
count = 2
|
||||
v.ml.SetMaximumDrawableCount(2)
|
||||
}
|
||||
|
||||
if v.maximumDrawableCount == count {
|
||||
return
|
||||
}
|
||||
v.ml.SetMaximumDrawableCount(count)
|
||||
v.maximumDrawableCount = count
|
||||
}
|
||||
|
||||
func (v *view) colorPixelFormat() mtl.PixelFormat {
|
||||
|
@ -42,10 +42,6 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/mtl"
|
||||
)
|
||||
|
||||
type viewPlatform struct {
|
||||
uiview uintptr
|
||||
}
|
||||
|
||||
func (v *view) setWindow(window uintptr) {
|
||||
panic("metal: setWindow is not available on iOS")
|
||||
}
|
||||
@ -64,10 +60,6 @@ func (v *view) update() {
|
||||
C.setFrame(v.ml.Layer(), unsafe.Pointer(v.uiview))
|
||||
}
|
||||
|
||||
func (v *view) isFullscreen() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
const (
|
||||
storageMode = mtl.StorageModeShared
|
||||
resourceStorageMode = mtl.ResourceStorageModeShared
|
||||
|
@ -23,15 +23,9 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/mtl"
|
||||
)
|
||||
|
||||
type viewPlatform struct {
|
||||
window cocoa.NSWindow
|
||||
windowChanged bool
|
||||
fullscreen bool
|
||||
}
|
||||
|
||||
func (v *view) setWindow(window uintptr) {
|
||||
// NSView can be updated e.g., fullscreen-state is switched.
|
||||
v.window = cocoa.NSWindow{ID: objc.ID(window)}
|
||||
v.window = window
|
||||
v.windowChanged = true
|
||||
}
|
||||
|
||||
@ -40,22 +34,15 @@ func (v *view) setUIView(uiview uintptr) {
|
||||
}
|
||||
|
||||
func (v *view) update() {
|
||||
if v.windowChanged {
|
||||
// TODO: Should this be called on the main thread?
|
||||
v.window.ContentView().SetLayer(uintptr(v.ml.Layer()))
|
||||
v.window.ContentView().SetWantsLayer(true)
|
||||
v.windowChanged = false
|
||||
if !v.windowChanged {
|
||||
return
|
||||
}
|
||||
|
||||
fullscreen := v.window.StyleMask()&cocoa.NSWindowStyleMaskFullScreen != 0
|
||||
if v.fullscreen != fullscreen {
|
||||
v.fullscreen = fullscreen
|
||||
v.updateMaximumDrawableCount()
|
||||
}
|
||||
}
|
||||
|
||||
func (v *view) isFullscreen() bool {
|
||||
return v.fullscreen
|
||||
// TODO: Should this be called on the main thread?
|
||||
cocoaWindow := cocoa.NSWindow{ID: objc.ID(v.window)}
|
||||
cocoaWindow.ContentView().SetLayer(uintptr(v.ml.Layer()))
|
||||
cocoaWindow.ContentView().SetWantsLayer(true)
|
||||
v.windowChanged = false
|
||||
}
|
||||
|
||||
const (
|
||||
|
Loading…
Reference in New Issue
Block a user