mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
graphicsdriver/metal: Reduce calls of SetLayer
This commit is contained in:
parent
1395ab5e84
commit
e023425be0
@ -28,6 +28,8 @@ type view struct {
|
||||
window unsafe.Pointer
|
||||
uiview uintptr
|
||||
|
||||
windowChanged bool
|
||||
|
||||
device mtl.Device
|
||||
ml ca.MetalLayer
|
||||
|
||||
|
@ -25,7 +25,9 @@ import (
|
||||
)
|
||||
|
||||
func (v *view) setWindow(window unsafe.Pointer) {
|
||||
// NSView can be updated e.g., fullscreen-state is switched.
|
||||
v.window = window
|
||||
v.windowChanged = true
|
||||
}
|
||||
|
||||
func (v *view) setUIView(uiview uintptr) {
|
||||
@ -33,10 +35,14 @@ func (v *view) setUIView(uiview uintptr) {
|
||||
}
|
||||
|
||||
func (v *view) update() {
|
||||
// NSView can be changed anytime (probably). Set this everyframe.
|
||||
if !v.windowChanged {
|
||||
return
|
||||
}
|
||||
|
||||
cocoaWindow := ns.NewWindow(v.window)
|
||||
cocoaWindow.ContentView().SetLayer(v.ml)
|
||||
cocoaWindow.ContentView().SetWantsLayer(true)
|
||||
v.windowChanged = false
|
||||
}
|
||||
|
||||
const (
|
||||
|
Loading…
Reference in New Issue
Block a user