mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
Reland: graphics: mipmap images should be volatile when the base image is volatile
This is not a bug fix, but should improve performance.
This commit is contained in:
parent
9e9a05ee54
commit
d7d02e6d6a
7
image.go
7
image.go
@ -284,7 +284,12 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
|
|||||||
if w2 == 0 || h2 == 0 {
|
if w2 == 0 || h2 == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
s := shareable.NewImage(w2, h2)
|
var s *shareable.Image
|
||||||
|
if img.shareableImages[0].IsVolatile() {
|
||||||
|
s = shareable.NewVolatileImage(w2, h2)
|
||||||
|
} else {
|
||||||
|
s = shareable.NewImage(w2, h2)
|
||||||
|
}
|
||||||
vs := src.QuadVertices(0, 0, w, h, 0.5, 0, 0, 0.5, 0, 0, nil)
|
vs := src.QuadVertices(0, 0, w, h, 0.5, 0, 0, 0.5, 0, 0, nil)
|
||||||
is := graphicsutil.QuadIndices()
|
is := graphicsutil.QuadIndices()
|
||||||
s.DrawImage(src, vs, is, opengl.CompositeModeCopy, graphics.FilterLinear)
|
s.DrawImage(src, vs, is, opengl.CompositeModeCopy, graphics.FilterLinear)
|
||||||
|
@ -99,6 +99,10 @@ func NewScreenFramebufferImage(width, height int) *Image {
|
|||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *Image) IsVolatile() bool {
|
||||||
|
return i.volatile
|
||||||
|
}
|
||||||
|
|
||||||
// BasePixelsForTesting returns the image's basePixels for testing.
|
// BasePixelsForTesting returns the image's basePixels for testing.
|
||||||
func (i *Image) BasePixelsForTesting() []byte {
|
func (i *Image) BasePixelsForTesting() []byte {
|
||||||
return i.basePixels
|
return i.basePixels
|
||||||
|
@ -323,6 +323,16 @@ func (i *Image) dispose(markDisposed bool) {
|
|||||||
theBackends = append(theBackends[:index], theBackends[index+1:]...)
|
theBackends = append(theBackends[:index], theBackends[index+1:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *Image) IsVolatile() bool {
|
||||||
|
backendsM.Lock()
|
||||||
|
defer backendsM.Unlock()
|
||||||
|
if i.backend == nil {
|
||||||
|
// Not allocated yet. Only non-volatile images can do lazy allocation so far.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return i.backend.restorable.IsVolatile()
|
||||||
|
}
|
||||||
|
|
||||||
func (i *Image) IsInvalidated() (bool, error) {
|
func (i *Image) IsInvalidated() (bool, error) {
|
||||||
backendsM.Lock()
|
backendsM.Lock()
|
||||||
defer backendsM.Unlock()
|
defer backendsM.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user