2019-06-18 17:34:05 +02:00
|
|
|
// Copyright 2019 The Ebiten Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-06-10 18:03:35 +02:00
|
|
|
//go:build darwin && !ios
|
|
|
|
// +build darwin,!ios
|
2019-06-18 17:34:05 +02:00
|
|
|
|
|
|
|
package metal
|
|
|
|
|
|
|
|
import (
|
2020-10-03 19:35:13 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/mtl"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/ns"
|
2019-06-18 17:34:05 +02:00
|
|
|
)
|
|
|
|
|
2020-09-03 17:43:51 +02:00
|
|
|
func (v *view) setWindow(window uintptr) {
|
2020-06-13 22:06:40 +02:00
|
|
|
// NSView can be updated e.g., fullscreen-state is switched.
|
2019-06-18 17:34:05 +02:00
|
|
|
v.window = window
|
2020-06-13 22:06:40 +02:00
|
|
|
v.windowChanged = true
|
2019-06-18 17:34:05 +02:00
|
|
|
}
|
|
|
|
|
2019-09-02 21:08:58 +02:00
|
|
|
func (v *view) setUIView(uiview uintptr) {
|
|
|
|
panic("metal: setUIView is not available on macOS")
|
2019-06-18 17:34:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *view) update() {
|
2020-06-13 22:06:40 +02:00
|
|
|
if !v.windowChanged {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-07-22 13:02:37 +02:00
|
|
|
cocoaWindow := ns.NewWindow(v.window)
|
2019-06-18 17:34:05 +02:00
|
|
|
cocoaWindow.ContentView().SetLayer(v.ml)
|
|
|
|
cocoaWindow.ContentView().SetWantsLayer(true)
|
2020-06-13 22:06:40 +02:00
|
|
|
v.windowChanged = false
|
2019-06-18 17:34:05 +02:00
|
|
|
}
|
|
|
|
|
2021-09-06 17:02:55 +02:00
|
|
|
func (v *view) usePresentsWithTransaction() bool {
|
|
|
|
// Disable presentsWithTransaction on the fullscreen mode (#1745).
|
|
|
|
return !v.vsyncDisabled && !v.fullscreen
|
|
|
|
}
|
|
|
|
|
2019-09-02 21:08:58 +02:00
|
|
|
const (
|
|
|
|
storageMode = mtl.StorageModeManaged
|
|
|
|
resourceStorageMode = mtl.ResourceStorageModeManaged
|
|
|
|
)
|