graphics: Revert transitionImageParts since this didn't affect the speed

This commit is contained in:
Hajime Hoshi 2016-06-06 00:23:18 +09:00
parent 33b50ed294
commit 8d17d1876c
2 changed files with 2 additions and 43 deletions

View File

@ -272,28 +272,6 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
parts = &wholeImage{image.impl.width, image.impl.height}
}
}
geom := &options.GeoM
colorm := &options.ColorM
scaleX := geom.Element(0, 0)
scaleY := geom.Element(1, 1)
dx := geom.Element(0, 2)
dy := geom.Element(1, 2)
// If possible, avoid using a geometry matrix so that we can reduce calls of
// glUniformMatrix4fv.
if isWholeNumber(scaleX) && geom.Element(1, 0) == 0 &&
geom.Element(0, 1) == 0 && isWholeNumber(scaleY) &&
isWholeNumber(dx) && isWholeNumber(dy) {
if scaleX != 1 || scaleY != 1 || dx != 0 || dy != 0 {
parts = &transitionImageParts{
parts: parts,
scaleX: int(scaleX),
scaleY: int(scaleY),
dx: int(dx),
dy: int(dy),
}
geom = &GeoM{}
}
}
quads := &textureQuads{parts: parts, width: image.impl.width, height: image.impl.height}
// TODO: Reuse one vertices instead of making here, but this would need locking.
vertices := make([]int16, parts.Len()*16)
@ -311,6 +289,8 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
return errors.New("ebiten: image is already disposed")
}
i.pixels = nil
geom := &options.GeoM
colorm := &options.ColorM
mode := opengl.CompositeMode(options.CompositeMode)
if err := i.framebuffer.DrawTexture(ui.GLContext(), image.impl.texture, vertices[:16*n], geom, colorm, mode); err != nil {
return err

View File

@ -124,24 +124,3 @@ func (t *textureQuads) vertices(vertices []int16) int {
}
return n
}
type transitionImageParts struct {
parts ImageParts
scaleX int
scaleY int
dx int
dy int
}
func (t *transitionImageParts) Len() int {
return t.parts.Len()
}
func (t *transitionImageParts) Dst(index int) (int, int, int, int) {
x0, y0, x1, y1 := t.parts.Dst(index)
return x0*t.scaleX + t.dx, y0*t.scaleY + t.dy, x1*t.scaleX + t.dx, y1*t.scaleY + t.dy
}
func (t *transitionImageParts) Src(index int) (int, int, int, int) {
return t.parts.Src(index)
}