graphicsdriver/metal: Add setView for iOS and non-iOS

This commit is contained in:
Hajime Hoshi 2019-05-03 03:08:46 +09:00
parent 3ce8babd9b
commit ea284d86fd
3 changed files with 58 additions and 4 deletions

View File

@ -26,7 +26,6 @@ import (
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ns"
"github.com/hajimehoshi/ebiten/internal/mainthread"
)
@ -617,9 +616,7 @@ func (d *Driver) Reset() error {
func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter, address graphics.Address) error {
if err := mainthread.Run(func() error {
// NSView can be changed anytime (probably). Set this everyframe.
cocoaWindow := ns.NewWindow(unsafe.Pointer(d.window))
cocoaWindow.ContentView().SetLayer(d.ml)
cocoaWindow.ContentView().SetWantsLayer(true)
setView(d.window, d.ml)
rpd := mtl.RenderPassDescriptor{}
if d.dst.screen {

View File

@ -0,0 +1,26 @@
// 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.
// +build darwin
// +build ios
package metal
import (
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca"
)
func setView(window uintptr, layer ca.MetalLayer) {
// TODO: Implement this
}

View File

@ -0,0 +1,31 @@
// 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.
// +build darwin
// +build !ios
package metal
import (
"unsafe"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ns"
)
func setView(window uintptr, layer ca.MetalLayer) {
cocoaWindow := ns.NewWindow(unsafe.Pointer(window))
cocoaWindow.ContentView().SetLayer(layer)
cocoaWindow.ContentView().SetWantsLayer(true)
}