mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +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
|
window unsafe.Pointer
|
||||||
uiview uintptr
|
uiview uintptr
|
||||||
|
|
||||||
|
windowChanged bool
|
||||||
|
|
||||||
device mtl.Device
|
device mtl.Device
|
||||||
ml ca.MetalLayer
|
ml ca.MetalLayer
|
||||||
|
|
||||||
|
@ -25,7 +25,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (v *view) setWindow(window unsafe.Pointer) {
|
func (v *view) setWindow(window unsafe.Pointer) {
|
||||||
|
// NSView can be updated e.g., fullscreen-state is switched.
|
||||||
v.window = window
|
v.window = window
|
||||||
|
v.windowChanged = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *view) setUIView(uiview uintptr) {
|
func (v *view) setUIView(uiview uintptr) {
|
||||||
@ -33,10 +35,14 @@ func (v *view) setUIView(uiview uintptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *view) update() {
|
func (v *view) update() {
|
||||||
// NSView can be changed anytime (probably). Set this everyframe.
|
if !v.windowChanged {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cocoaWindow := ns.NewWindow(v.window)
|
cocoaWindow := ns.NewWindow(v.window)
|
||||||
cocoaWindow.ContentView().SetLayer(v.ml)
|
cocoaWindow.ContentView().SetLayer(v.ml)
|
||||||
cocoaWindow.ContentView().SetWantsLayer(true)
|
cocoaWindow.ContentView().SetWantsLayer(true)
|
||||||
|
v.windowChanged = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Loading…
Reference in New Issue
Block a user