mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +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
|
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.appendIndices(indices, uint16(q.nextIndex))
|
||||||
q.nextIndex += n
|
q.nextIndex += n
|
||||||
q.tmpNumIndices += len(indices)
|
q.tmpNumIndices += len(indices)
|
||||||
|
@ -37,11 +37,13 @@ const (
|
|||||||
|
|
||||||
// Image represents an image that is implemented with OpenGL.
|
// Image represents an image that is implemented with OpenGL.
|
||||||
type Image struct {
|
type Image struct {
|
||||||
image driver.Image
|
image driver.Image
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
screen bool
|
internalWidth int
|
||||||
id int
|
internalHeight int
|
||||||
|
screen bool
|
||||||
|
id int
|
||||||
|
|
||||||
lastCommand lastCommand
|
lastCommand lastCommand
|
||||||
}
|
}
|
||||||
@ -96,7 +98,13 @@ func (i *Image) Dispose() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) InternalSize() (int, int) {
|
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.
|
// DrawTriangles draws triangles with the given image.
|
||||||
|
Loading…
Reference in New Issue
Block a user