mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/graphicsdriver/metal, internal/graphicsdriver/opengl: change the return type to pointers
On second thought, returning pointers is more natural. Handling nil is a caller's responsibility.
This commit is contained in:
parent
7bb7e45522
commit
eeb5687b73
@ -367,7 +367,7 @@ func init() {
|
|||||||
|
|
||||||
var theGraphics Graphics
|
var theGraphics Graphics
|
||||||
|
|
||||||
func Get() graphicsdriver.Graphics {
|
func Get() *Graphics {
|
||||||
if !isMetalAvailable {
|
if !isMetalAvailable {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
var theGraphics Graphics
|
var theGraphics Graphics
|
||||||
|
|
||||||
func Get() graphicsdriver.Graphics {
|
func Get() *Graphics {
|
||||||
return &theGraphics
|
return &theGraphics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,14 @@ type graphicsDriverGetterImpl struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
func (g *graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
return g.getOpenGL()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
if g := opengl.Get(); g != nil {
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
||||||
|
@ -27,12 +27,15 @@ import (
|
|||||||
|
|
||||||
type graphicsDriverGetterImpl struct{}
|
type graphicsDriverGetterImpl struct{}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
func (g *graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
return g.getOpenGL()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
if g := opengl.Get(); g != nil {
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
||||||
|
@ -242,11 +242,17 @@ func (g *graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
if g := opengl.Get(); g != nil {
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
||||||
return metal.Get()
|
if m := metal.Get(); m != nil {
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// clearVideoModeScaleCache must be called from the main thread.
|
// clearVideoModeScaleCache must be called from the main thread.
|
||||||
|
@ -33,12 +33,15 @@ import (
|
|||||||
|
|
||||||
type graphicsDriverGetterImpl struct{}
|
type graphicsDriverGetterImpl struct{}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
func (g *graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
return g.getOpenGL()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
if g := opengl.Get(); g != nil {
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
||||||
|
@ -31,12 +31,15 @@ import (
|
|||||||
|
|
||||||
type graphicsDriverGetterImpl struct{}
|
type graphicsDriverGetterImpl struct{}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
func (g *graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
return g.getOpenGL()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
if g := opengl.Get(); g != nil {
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
||||||
|
@ -35,7 +35,10 @@ func (g *graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
if g := opengl.Get(); g != nil {
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
func (g *graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
||||||
|
@ -27,12 +27,15 @@ import (
|
|||||||
|
|
||||||
type graphicsDriverGetterImpl struct{}
|
type graphicsDriverGetterImpl struct{}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
func (g *graphicsDriverGetterImpl) getAuto() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
return g.getOpenGL()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getOpenGL() graphicsdriver.Graphics {
|
||||||
return opengl.Get()
|
if g := opengl.Get(); g != nil {
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
func (*graphicsDriverGetterImpl) getMetal() graphicsdriver.Graphics {
|
||||||
|
Loading…
Reference in New Issue
Block a user