graphics: Use affine.ColorM instead of graphics.Matrix

This commit is contained in:
Hajime Hoshi 2016-11-01 00:20:27 +09:00
parent 84baee8ca7
commit d02c67a996
5 changed files with 11 additions and 12 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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,

View File

@ -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 {

View File

@ -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
}