mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-12 22:17:26 +01:00
graphics: Revert transitionImageParts since this didn't affect the speed
This commit is contained in:
parent
33b50ed294
commit
8d17d1876c
24
image.go
24
image.go
@ -272,28 +272,6 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
|
|||||||
parts = &wholeImage{image.impl.width, image.impl.height}
|
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}
|
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.
|
// TODO: Reuse one vertices instead of making here, but this would need locking.
|
||||||
vertices := make([]int16, parts.Len()*16)
|
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")
|
return errors.New("ebiten: image is already disposed")
|
||||||
}
|
}
|
||||||
i.pixels = nil
|
i.pixels = nil
|
||||||
|
geom := &options.GeoM
|
||||||
|
colorm := &options.ColorM
|
||||||
mode := opengl.CompositeMode(options.CompositeMode)
|
mode := opengl.CompositeMode(options.CompositeMode)
|
||||||
if err := i.framebuffer.DrawTexture(ui.GLContext(), image.impl.texture, vertices[:16*n], geom, colorm, mode); err != nil {
|
if err := i.framebuffer.DrawTexture(ui.GLContext(), image.impl.texture, vertices[:16*n], geom, colorm, mode); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -124,24 +124,3 @@ func (t *textureQuads) vertices(vertices []int16) int {
|
|||||||
}
|
}
|
||||||
return n
|
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)
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user