mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
graphics: Reduce the usage of InternalImageSize
This commit is contained in:
parent
ad3a8bca7f
commit
b4046a795e
@ -117,6 +117,9 @@ func (i *Image) Dispose() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) InternalSize() (int, int) {
|
func (i *Image) InternalSize() (int, int) {
|
||||||
|
if i.screen {
|
||||||
|
return i.width, i.height
|
||||||
|
}
|
||||||
if i.internalWidth == 0 {
|
if i.internalWidth == 0 {
|
||||||
i.internalWidth = graphics.InternalImageSize(i.width)
|
i.internalWidth = graphics.InternalImageSize(i.width)
|
||||||
}
|
}
|
||||||
|
@ -154,8 +154,6 @@ func (g *Graphics) SetVertices(vertices []float32, indices []uint16) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) Draw(dst, src driver.ImageID, indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address, sourceRegion driver.Region) error {
|
func (g *Graphics) Draw(dst, src driver.ImageID, indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address, sourceRegion driver.Region) error {
|
||||||
// TODO: Use sourceRegion.
|
|
||||||
|
|
||||||
destination := g.images[dst]
|
destination := g.images[dst]
|
||||||
source := g.images[src]
|
source := g.images[src]
|
||||||
|
|
||||||
@ -206,9 +204,7 @@ func (g *Graphics) Draw(dst, src driver.ImageID, indexLen int, indexOffset int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if filter != driver.FilterNearest {
|
if filter != driver.FilterNearest {
|
||||||
srcW, srcH := source.width, source.height
|
sw, sh := source.framebufferSize()
|
||||||
sw := graphics.InternalImageSize(srcW)
|
|
||||||
sh := graphics.InternalImageSize(srcH)
|
|
||||||
uniforms = append(uniforms, uniformVariable{
|
uniforms = append(uniforms, uniformVariable{
|
||||||
name: "source_size",
|
name: "source_size",
|
||||||
value: []float32{float32(sw), float32(sh)},
|
value: []float32{float32(sw), float32(sh)},
|
||||||
@ -305,8 +301,7 @@ func (g *Graphics) DrawShader(dst driver.ImageID, srcs [graphics.ShaderImageNum]
|
|||||||
g.context.blendFunc(mode)
|
g.context.blendFunc(mode)
|
||||||
|
|
||||||
us := make([]uniformVariable, graphics.PreservedUniformVariablesNum+len(uniforms))
|
us := make([]uniformVariable, graphics.PreservedUniformVariablesNum+len(uniforms))
|
||||||
vw := graphics.InternalImageSize(d.width)
|
vw, vh := d.framebufferSize()
|
||||||
vh := graphics.InternalImageSize(d.height)
|
|
||||||
us[0].name = "U0"
|
us[0].name = "U0"
|
||||||
us[0].value = []float32{float32(vw), float32(vh)}
|
us[0].value = []float32{float32(vw), float32(vh)}
|
||||||
us[0].typ = s.ir.Uniforms[0]
|
us[0].typ = s.ir.Uniforms[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user