mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/mipmap: refactoring
This commit is contained in:
parent
6389db14a2
commit
cbecbe2bad
@ -164,24 +164,28 @@ func (m *Mipmap) level(level int) *buffered.Image {
|
|||||||
return img.img
|
return img.img
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var w, h int
|
||||||
var src *buffered.Image
|
var src *buffered.Image
|
||||||
vs := make([]float32, 4*graphics.VertexFloatCount)
|
vs := make([]float32, 4*graphics.VertexFloatCount)
|
||||||
switch {
|
switch {
|
||||||
case level == 1:
|
case level == 1:
|
||||||
src = m.orig
|
src = m.orig
|
||||||
graphics.QuadVerticesFromSrcAndMatrix(vs, 0, 0, float32(m.width), float32(m.height), 0.5, 0, 0, 0.5, 0, 0, 1, 1, 1, 1)
|
w = m.width
|
||||||
|
h = m.height
|
||||||
case level > 1:
|
case level > 1:
|
||||||
src = m.level(level - 1)
|
src = m.level(level - 1)
|
||||||
if src == nil {
|
if src == nil {
|
||||||
m.setImg(level, nil)
|
m.setImg(level, nil)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
w := sizeForLevel(m.width, level-1)
|
w = sizeForLevel(m.width, level-1)
|
||||||
h := sizeForLevel(m.height, level-1)
|
h = sizeForLevel(m.height, level-1)
|
||||||
graphics.QuadVerticesFromSrcAndMatrix(vs, 0, 0, float32(w), float32(h), 0.5, 0, 0, 0.5, 0, 0, 1, 1, 1, 1)
|
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("mipmap: invalid level: %d", level))
|
panic(fmt.Sprintf("mipmap: invalid level: %d", level))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
graphics.QuadVerticesFromSrcAndMatrix(vs, 0, 0, float32(w), float32(h), 0.5, 0, 0, 0.5, 0, 0, 1, 1, 1, 1)
|
||||||
|
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
|
|
||||||
w2 := sizeForLevel(m.width, level)
|
w2 := sizeForLevel(m.width, level)
|
||||||
@ -207,8 +211,6 @@ func (m *Mipmap) level(level int) *buffered.Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dstRegion := image.Rect(0, 0, w2, h2)
|
dstRegion := image.Rect(0, 0, w2, h2)
|
||||||
w := sizeForLevel(m.width, level-1)
|
|
||||||
h := sizeForLevel(m.height, level-1)
|
|
||||||
srcRegion := image.Rect(0, 0, w, h)
|
srcRegion := image.Rect(0, 0, w, h)
|
||||||
s.DrawTriangles([graphics.ShaderSrcImageCount]*buffered.Image{src}, vs, is, graphicsdriver.BlendCopy, dstRegion, [graphics.ShaderSrcImageCount]image.Rectangle{srcRegion}, atlas.LinearFilterShader, nil, graphicsdriver.FillRuleFillAll, restorable.HintOverwriteDstRegion)
|
s.DrawTriangles([graphics.ShaderSrcImageCount]*buffered.Image{src}, vs, is, graphicsdriver.BlendCopy, dstRegion, [graphics.ShaderSrcImageCount]image.Rectangle{srcRegion}, atlas.LinearFilterShader, nil, graphicsdriver.FillRuleFillAll, restorable.HintOverwriteDstRegion)
|
||||||
m.setImg(level, s)
|
m.setImg(level, s)
|
||||||
|
Loading…
Reference in New Issue
Block a user