Move graphicsdriver.GrapahicsDriver to driver.Graphics

This commit is contained in:
Hajime Hoshi 2019-03-30 22:26:27 +09:00
parent 747d1be54e
commit 7445144194
11 changed files with 31 additions and 31 deletions

View File

@ -29,7 +29,7 @@ package ebiten
import "C"
import (
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
@ -52,7 +52,7 @@ func init() {
}
}
func graphicsDriver() graphicsdriver.GraphicsDriver {
func graphicsDriver() driver.Graphics {
if isMetalSupported {
return metal.Get()
}

View File

@ -17,10 +17,10 @@
package ebiten
import (
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
)
func graphicsDriver() graphicsdriver.GraphicsDriver {
func graphicsDriver() driver.Graphics {
return opengl.Get()
}

View File

@ -19,8 +19,8 @@ import (
"math"
"github.com/hajimehoshi/ebiten/internal/clock"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/internal/hooks"
"github.com/hajimehoshi/ebiten/internal/shareable"
"github.com/hajimehoshi/ebiten/internal/ui"
@ -128,12 +128,12 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
op := &DrawImageOptions{}
switch vd := graphicsDriver().VDirection(); vd {
case graphicsdriver.VDownward:
case driver.VDownward:
// c.screen is special: its Y axis is down to up,
// and the origin point is lower left.
op.GeoM.Scale(c.screenScale, -c.screenScale)
op.GeoM.Translate(0, float64(c.screenHeight))
case graphicsdriver.VUpward:
case driver.VUpward:
op.GeoM.Scale(c.screenScale, c.screenScale)
default:
panic(fmt.Sprintf("ebiten: invalid v-direction: %d", vd))

View File

@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package graphicsdriver
package driver
import (
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/graphics"
)
type GraphicsDriver interface {
type Graphics interface {
SetWindow(window uintptr)
SetVertices(vertices []float32, indices []uint16)
Flush()

View File

@ -18,13 +18,13 @@ import (
"fmt"
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
)
var theGraphicsDriver graphicsdriver.GraphicsDriver
var theGraphicsDriver driver.Graphics
func SetGraphicsDriver(driver graphicsdriver.GraphicsDriver) {
func SetGraphicsDriver(driver driver.Graphics) {
theGraphicsDriver = driver
}

View File

@ -16,8 +16,8 @@ package graphicscommand
import (
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
)
type lastCommand int
@ -31,7 +31,7 @@ const (
// Image represents an image that is implemented with OpenGL.
type Image struct {
image graphicsdriver.Image
image driver.Image
width int
height int
screen bool

View File

@ -22,8 +22,8 @@ import (
"unsafe"
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ns"
@ -392,7 +392,7 @@ func (d *Driver) checkSize(width, height int) {
}
}
func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) {
func (d *Driver) NewImage(width, height int) (driver.Image, error) {
d.checkSize(width, height)
td := mtl.TextureDescriptor{
PixelFormat: mtl.PixelFormatRGBA8UNorm,
@ -417,7 +417,7 @@ func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) {
}, nil
}
func (d *Driver) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) {
func (d *Driver) NewScreenFramebufferImage(width, height int) (driver.Image, error) {
mainthread.Run(func() error {
d.ml.SetDrawableSize(width, height)
return nil
@ -672,8 +672,8 @@ func (d *Driver) SetVsyncEnabled(enabled bool) {
d.ml.SetDisplaySyncEnabled(enabled)
}
func (d *Driver) VDirection() graphicsdriver.VDirection {
return graphicsdriver.VUpward
func (d *Driver) VDirection() driver.VDirection {
return driver.VUpward
}
func (d *Driver) IsGL() bool {

View File

@ -18,8 +18,8 @@ import (
"fmt"
"github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
)
var theDriver Driver
@ -53,7 +53,7 @@ func (d *Driver) checkSize(width, height int) {
}
}
func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) {
func (d *Driver) NewImage(width, height int) (driver.Image, error) {
i := &Image{
driver: d,
width: width,
@ -70,7 +70,7 @@ func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) {
return i, nil
}
func (d *Driver) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) {
func (d *Driver) NewScreenFramebufferImage(width, height int) (driver.Image, error) {
d.checkSize(width, height)
i := &Image{
driver: d,
@ -114,8 +114,8 @@ func (d *Driver) SetVsyncEnabled(enabled bool) {
// Do nothing
}
func (d *Driver) VDirection() graphicsdriver.VDirection {
return graphicsdriver.VDownward
func (d *Driver) VDirection() driver.VDirection {
return driver.VDownward
}
func (d *Driver) IsGL() bool {

View File

@ -27,8 +27,8 @@ import (
"time"
"github.com/hajimehoshi/ebiten/internal/devicescale"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/glfw"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/internal/hooks"
"github.com/hajimehoshi/ebiten/internal/input"
"github.com/hajimehoshi/ebiten/internal/mainthread"
@ -65,7 +65,7 @@ type userInterface struct {
reqWidth int
reqHeight int
driver graphicsdriver.GraphicsDriver
driver driver.Graphics
m sync.Mutex
}
@ -577,7 +577,7 @@ func DeviceScaleFactor() float64 {
return f
}
func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver graphicsdriver.GraphicsDriver) error {
func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver driver.Graphics) error {
u := currentUI
_ = mainthread.Run(func() error {
u.driver = driver

View File

@ -25,7 +25,7 @@ import (
"github.com/gopherjs/gopherwasm/js"
"github.com/hajimehoshi/ebiten/internal/devicescale"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/hooks"
"github.com/hajimehoshi/ebiten/internal/input"
)
@ -373,7 +373,7 @@ func Loop(ch <-chan error) error {
return <-ch
}
func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver graphicsdriver.GraphicsDriver) error {
func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver driver.Graphics) error {
u := currentUI
document.Set("title", title)
u.setScreenSize(width, height, scale, u.fullscreen)

View File

@ -31,7 +31,7 @@ import (
"golang.org/x/mobile/gl"
"github.com/hajimehoshi/ebiten/internal/devicescale"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
"github.com/hajimehoshi/ebiten/internal/hooks"
"github.com/hajimehoshi/ebiten/internal/input"
@ -142,7 +142,7 @@ func appMain(a app.App) {
}
}
func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver graphicsdriver.GraphicsDriver) error {
func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver driver.Graphics) error {
u := currentUI
u.m.Lock()