From d02c67a996556d2ee502291bf6614f7f36a186b3 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 1 Nov 2016 00:20:27 +0900 Subject: [PATCH] graphics: Use affine.ColorM instead of graphics.Matrix --- imageimpl.go | 3 +-- internal/graphics/command.go | 7 ++----- internal/graphics/image.go | 3 ++- internal/graphics/program.go | 3 ++- internal/restorable/image.go | 7 ++++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/imageimpl.go b/imageimpl.go index db21f970e..ff9332c53 100644 --- a/imageimpl.go +++ b/imageimpl.go @@ -140,9 +140,8 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error { if i.restorable == nil { return errors.New("ebiten: image is already disposed") } - colorm := options.ColorM mode := opengl.CompositeMode(options.CompositeMode) - if err := i.restorable.DrawImage(image.impl.restorable, vs, &colorm, mode); err != nil { + if err := i.restorable.DrawImage(image.impl.restorable, vs, options.ColorM.impl, mode); err != nil { return err } return nil diff --git a/internal/graphics/command.go b/internal/graphics/command.go index 97bde87e7..9ba31f54c 100644 --- a/internal/graphics/command.go +++ b/internal/graphics/command.go @@ -23,13 +23,10 @@ import ( "math" "sync" + "github.com/hajimehoshi/ebiten/internal/affine" "github.com/hajimehoshi/ebiten/internal/graphics/opengl" ) -type Matrix interface { - Element(i, j int) float64 -} - type command interface { Exec(context *opengl.Context, indexOffsetInBytes int) error } @@ -185,7 +182,7 @@ type drawImageCommand struct { dst *Image src *Image vertices []int16 - color Matrix + color affine.ColorM mode opengl.CompositeMode } diff --git a/internal/graphics/image.go b/internal/graphics/image.go index fd962a93b..e44056041 100644 --- a/internal/graphics/image.go +++ b/internal/graphics/image.go @@ -18,6 +18,7 @@ import ( "image" "image/color" + "github.com/hajimehoshi/ebiten/internal/affine" "github.com/hajimehoshi/ebiten/internal/graphics/opengl" ) @@ -94,7 +95,7 @@ func (i *Image) Fill(clr color.RGBA) error { return nil } -func (i *Image) DrawImage(src *Image, vertices []int16, clr Matrix, mode opengl.CompositeMode) error { +func (i *Image) DrawImage(src *Image, vertices []int16, clr affine.ColorM, mode opengl.CompositeMode) error { c := &drawImageCommand{ dst: i, src: src, diff --git a/internal/graphics/program.go b/internal/graphics/program.go index 5e3a2719d..3db2ff484 100644 --- a/internal/graphics/program.go +++ b/internal/graphics/program.go @@ -17,6 +17,7 @@ package graphics import ( "fmt" + "github.com/hajimehoshi/ebiten/internal/affine" "github.com/hajimehoshi/ebiten/internal/graphics/opengl" ) @@ -201,7 +202,7 @@ type programContext struct { context *opengl.Context projectionMatrix []float32 texture opengl.Texture - colorM Matrix + colorM affine.ColorM } func (p *programContext) begin() error { diff --git a/internal/restorable/image.go b/internal/restorable/image.go index c090f44f3..a7ad26adb 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -19,6 +19,7 @@ import ( "image" "image/color" + "github.com/hajimehoshi/ebiten/internal/affine" "github.com/hajimehoshi/ebiten/internal/graphics" "github.com/hajimehoshi/ebiten/internal/graphics/opengl" ) @@ -26,7 +27,7 @@ import ( type drawImageHistoryItem struct { image *graphics.Image vertices []int16 - colorm graphics.Matrix + colorm affine.ColorM mode opengl.CompositeMode } @@ -144,7 +145,7 @@ func (p *Image) ReplacePixels(pixels []uint8) error { return nil } -func (p *Image) DrawImage(img *Image, vertices []int16, colorm graphics.Matrix, mode opengl.CompositeMode) error { +func (p *Image) DrawImage(img *Image, vertices []int16, colorm affine.ColorM, mode opengl.CompositeMode) error { if img.stale || img.volatile { p.makeStale() } else { @@ -156,7 +157,7 @@ func (p *Image) DrawImage(img *Image, vertices []int16, colorm graphics.Matrix, return nil } -func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []int16, colorm graphics.Matrix, mode opengl.CompositeMode) { +func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []int16, colorm affine.ColorM, mode opengl.CompositeMode) { if p.stale { return }