mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
655cd4bf68
Updates #1415
73 lines
2.1 KiB
Go
73 lines
2.1 KiB
Go
// 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.
|
|
|
|
package metal
|
|
|
|
// Suppress the warnings about availability guard with -Wno-unguarded-availability-new.
|
|
// It is because old Xcode (8 or older?) does not accept @available syntax.
|
|
|
|
// #cgo CFLAGS: -Wno-unguarded-availability-new -x objective-c
|
|
// #cgo LDFLAGS: -framework UIKit -framework QuartzCore -framework Foundation -framework CoreGraphics
|
|
//
|
|
// #import <UIKit/UIKit.h>
|
|
//
|
|
// static void addSublayer(void* view, void* sublayer) {
|
|
// CALayer* layer = ((UIView*)view).layer;
|
|
// [layer addSublayer:(CALayer*)sublayer];
|
|
// }
|
|
//
|
|
// static void setFrame(void* cametal, void* uiview) {
|
|
// CGSize size = ((UIView*)uiview).frame.size;
|
|
// ((CALayer*)cametal).frame = CGRectMake(0, 0, size.width, size.height);
|
|
// }
|
|
import "C"
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/mtl"
|
|
)
|
|
|
|
func (v *view) setWindow(window uintptr) {
|
|
panic("metal: setWindow is not available on iOS")
|
|
}
|
|
|
|
func (v *view) setUIView(uiview uintptr) {
|
|
v.uiview = uiview
|
|
}
|
|
|
|
func (v *view) update() {
|
|
v.once.Do(func() {
|
|
if v.ml.Layer() == nil {
|
|
panic("metal: CAMetalLayer is not initialized yet")
|
|
}
|
|
C.addSublayer(unsafe.Pointer(v.uiview), v.ml.Layer())
|
|
})
|
|
C.setFrame(v.ml.Layer(), unsafe.Pointer(v.uiview))
|
|
}
|
|
|
|
func (v *view) usePresentsWithTransaction() bool {
|
|
// Do not use presentsWithTransaction on iOS (#1799).
|
|
return false
|
|
}
|
|
|
|
func (v *view) maximumDrawableCount() int {
|
|
return 3
|
|
}
|
|
|
|
const (
|
|
storageMode = mtl.StorageModeShared
|
|
resourceStorageMode = mtl.ResourceStorageModeShared
|
|
)
|