view_macos.go (1373B)
1 // Copyright 2019 The Ebiten Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // +build darwin 16 // +build !ios 17 18 package metal 19 20 import ( 21 "github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/mtl" 22 "github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/ns" 23 ) 24 25 func (v *view) setWindow(window uintptr) { 26 // NSView can be updated e.g., fullscreen-state is switched. 27 v.window = window 28 v.windowChanged = true 29 } 30 31 func (v *view) setUIView(uiview uintptr) { 32 panic("metal: setUIView is not available on macOS") 33 } 34 35 func (v *view) update() { 36 if !v.windowChanged { 37 return 38 } 39 40 cocoaWindow := ns.NewWindow(v.window) 41 cocoaWindow.ContentView().SetLayer(v.ml) 42 cocoaWindow.ContentView().SetWantsLayer(true) 43 v.windowChanged = false 44 } 45 46 const ( 47 storageMode = mtl.StorageModeManaged 48 resourceStorageMode = mtl.ResourceStorageModeManaged 49 )