From a70f61b1d57f2e6039eb61ab28dd66fba092043d Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 25 Oct 2016 10:42:49 +0900 Subject: [PATCH] graphics: Remove passing GeoM to the lower layers --- imageimpl.go | 3 +-- internal/graphics/command.go | 2 -- internal/graphics/image.go | 3 +-- internal/graphics/program.go | 23 ----------------------- internal/restorable/image.go | 12 +++++------- 5 files changed, 7 insertions(+), 36 deletions(-) diff --git a/imageimpl.go b/imageimpl.go index 08f0a1eac..db21f970e 100644 --- a/imageimpl.go +++ b/imageimpl.go @@ -140,10 +140,9 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error { if i.restorable == nil { return errors.New("ebiten: image is already disposed") } - geom := options.GeoM colorm := options.ColorM mode := opengl.CompositeMode(options.CompositeMode) - if err := i.restorable.DrawImage(image.impl.restorable, vs, &geom, &colorm, mode); err != nil { + if err := i.restorable.DrawImage(image.impl.restorable, vs, &colorm, mode); err != nil { return err } return nil diff --git a/internal/graphics/command.go b/internal/graphics/command.go index f71cba871..d1269abd4 100644 --- a/internal/graphics/command.go +++ b/internal/graphics/command.go @@ -156,7 +156,6 @@ type drawImageCommand struct { dst *Image src *Image vertices []uint8 - geo Matrix color Matrix mode opengl.CompositeMode } @@ -183,7 +182,6 @@ func (c *drawImageCommand) Exec(context *opengl.Context, indexOffsetInBytes int) context: context, projectionMatrix: proj, texture: c.src.texture.native, - geoM: c.geo, colorM: c.color, } if err := p.begin(); err != nil { diff --git a/internal/graphics/image.go b/internal/graphics/image.go index 42dc21adf..7b89903d1 100644 --- a/internal/graphics/image.go +++ b/internal/graphics/image.go @@ -94,12 +94,11 @@ func (i *Image) Fill(clr color.RGBA) error { return nil } -func (i *Image) DrawImage(src *Image, vertices []uint8, geo, clr Matrix, mode opengl.CompositeMode) error { +func (i *Image) DrawImage(src *Image, vertices []uint8, clr Matrix, mode opengl.CompositeMode) error { c := &drawImageCommand{ dst: i, src: src, vertices: vertices, - geo: geo, color: clr, mode: mode, } diff --git a/internal/graphics/program.go b/internal/graphics/program.go index 6145ce9e4..0d6f72f96 100644 --- a/internal/graphics/program.go +++ b/internal/graphics/program.go @@ -102,7 +102,6 @@ type openGLState struct { lastProgram opengl.Program lastProjectionMatrix []float32 - lastModelviewMatrix []float32 lastColorMatrix []float32 lastColorMatrixTranslation []float32 } @@ -130,7 +129,6 @@ func (s *openGLState) reset(context *opengl.Context) error { } s.lastProgram = zeroProgram s.lastProjectionMatrix = nil - s.lastModelviewMatrix = nil s.lastColorMatrix = nil s.lastColorMatrixTranslation = nil @@ -198,7 +196,6 @@ type programContext struct { context *opengl.Context projectionMatrix []float32 texture opengl.Texture - geoM Matrix colorM Matrix } @@ -213,7 +210,6 @@ func (p *programContext) begin() error { p.state.lastProgram = p.state.programTexture p.state.lastProjectionMatrix = nil - p.state.lastModelviewMatrix = nil p.state.lastColorMatrix = nil p.state.lastColorMatrixTranslation = nil c.BindElementArrayBuffer(p.state.indexBufferQuads) @@ -228,25 +224,6 @@ func (p *programContext) begin() error { copy(p.state.lastProjectionMatrix, p.projectionMatrix) } - ma := float32(p.geoM.Element(0, 0)) - mb := float32(p.geoM.Element(0, 1)) - mc := float32(p.geoM.Element(1, 0)) - md := float32(p.geoM.Element(1, 1)) - tx := float32(p.geoM.Element(0, 2)) - ty := float32(p.geoM.Element(1, 2)) - modelviewMatrix := []float32{ - ma, mc, 0, 0, - mb, md, 0, 0, - 0, 0, 1, 0, - tx, ty, 0, 1, - } - if !areSameFloat32Array(p.state.lastModelviewMatrix, modelviewMatrix) { - if p.state.lastModelviewMatrix == nil { - p.state.lastModelviewMatrix = make([]float32, 16) - } - copy(p.state.lastModelviewMatrix, modelviewMatrix) - } - e := [4][5]float32{} for i := 0; i < 4; i++ { for j := 0; j < 5; j++ { diff --git a/internal/restorable/image.go b/internal/restorable/image.go index b892ae1c1..8a6ed9a6b 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -26,7 +26,6 @@ import ( type drawImageHistoryItem struct { image *graphics.Image vertices []uint8 - geom graphics.Matrix colorm graphics.Matrix mode opengl.CompositeMode } @@ -145,19 +144,19 @@ func (p *Image) ReplacePixels(pixels []uint8) error { return nil } -func (p *Image) DrawImage(img *Image, vertices []uint8, geom graphics.Matrix, colorm graphics.Matrix, mode opengl.CompositeMode) error { +func (p *Image) DrawImage(img *Image, vertices []uint8, colorm graphics.Matrix, mode opengl.CompositeMode) error { if img.stale || img.volatile { p.makeStale() } else { - p.appendDrawImageHistory(img.image, vertices, geom, colorm, mode) + p.appendDrawImageHistory(img.image, vertices, colorm, mode) } - if err := p.image.DrawImage(img.image, vertices, geom, colorm, mode); err != nil { + if err := p.image.DrawImage(img.image, vertices, colorm, mode); err != nil { return err } return nil } -func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []uint8, geom graphics.Matrix, colorm graphics.Matrix, mode opengl.CompositeMode) { +func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []uint8, colorm graphics.Matrix, mode opengl.CompositeMode) { if p.stale { return } @@ -166,7 +165,6 @@ func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []uint8, item := &drawImageHistoryItem{ image: image, vertices: vertices, - geom: geom, colorm: colorm, mode: mode, } @@ -284,7 +282,7 @@ func (p *Image) Restore(context *opengl.Context) error { /*if c.image.impl.hasHistory() { panic("not reach") }*/ - if err := gimg.DrawImage(c.image, c.vertices, c.geom, c.colorm, c.mode); err != nil { + if err := gimg.DrawImage(c.image, c.vertices, c.colorm, c.mode); err != nil { return err } }