mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
graphicscommand: Reduce calling InternalWidth/InternalHeight
This commit is contained in:
parent
74f1e5519f
commit
f873b66267
@ -158,7 +158,8 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst, src *Image, vertices []f
|
||||
}
|
||||
|
||||
n := len(vertices) / graphics.VertexFloatNum
|
||||
q.appendVertices(vertices, float32(graphics.InternalImageSize(src.width)), float32(graphics.InternalImageSize(src.height)))
|
||||
iw, ih := src.InternalSize()
|
||||
q.appendVertices(vertices, float32(iw), float32(ih))
|
||||
q.appendIndices(indices, uint16(q.nextIndex))
|
||||
q.nextIndex += n
|
||||
q.tmpNumIndices += len(indices)
|
||||
|
@ -40,6 +40,8 @@ type Image struct {
|
||||
image driver.Image
|
||||
width int
|
||||
height int
|
||||
internalWidth int
|
||||
internalHeight int
|
||||
screen bool
|
||||
id int
|
||||
|
||||
@ -96,7 +98,13 @@ func (i *Image) Dispose() {
|
||||
}
|
||||
|
||||
func (i *Image) InternalSize() (int, int) {
|
||||
return graphics.InternalImageSize(i.width), graphics.InternalImageSize(i.height)
|
||||
if i.internalWidth == 0 {
|
||||
i.internalWidth = graphics.InternalImageSize(i.width)
|
||||
}
|
||||
if i.internalHeight == 0 {
|
||||
i.internalHeight = graphics.InternalImageSize(i.height)
|
||||
}
|
||||
return i.internalWidth, i.internalHeight
|
||||
}
|
||||
|
||||
// DrawTriangles draws triangles with the given image.
|
||||
|
Loading…
Reference in New Issue
Block a user