mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/ui: refactoring
This commit is contained in:
parent
0e57fc4c5f
commit
8479fee606
@ -93,7 +93,7 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
|||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("ui: unexpected image type: %d", imageType))
|
panic(fmt.Sprintf("ui: unexpected image type: %d", imageType))
|
||||||
}
|
}
|
||||||
i.bigOffscreenBuffer = newBigOffscreenImage(i, i.width, i.height, imageType)
|
i.bigOffscreenBuffer = newBigOffscreenImage(i, imageType)
|
||||||
}
|
}
|
||||||
|
|
||||||
i.bigOffscreenBuffer.drawTriangles(srcs, vertices, indices, blend, dstRegion, srcRegion, subimageOffsets, shader, uniforms, evenOdd, canSkipMipmap, false)
|
i.bigOffscreenBuffer.drawTriangles(srcs, vertices, indices, blend, dstRegion, srcRegion, subimageOffsets, shader, uniforms, evenOdd, canSkipMipmap, false)
|
||||||
@ -305,9 +305,12 @@ func (i *Image) Fill(r, g, b, a float32, x, y, width, height int) {
|
|||||||
|
|
||||||
type bigOffscreenImage struct {
|
type bigOffscreenImage struct {
|
||||||
orig *Image
|
orig *Image
|
||||||
|
imageType atlas.ImageType
|
||||||
|
|
||||||
image *Image
|
image *Image
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
|
|
||||||
blend graphicsdriver.Blend
|
blend graphicsdriver.Blend
|
||||||
dirty bool
|
dirty bool
|
||||||
|
|
||||||
@ -315,22 +318,29 @@ type bigOffscreenImage struct {
|
|||||||
tmpVerticesForCopying []float32
|
tmpVerticesForCopying []float32
|
||||||
}
|
}
|
||||||
|
|
||||||
func newBigOffscreenImage(orig *Image, width, height int, imageType atlas.ImageType) *bigOffscreenImage {
|
func newBigOffscreenImage(orig *Image, imageType atlas.ImageType) *bigOffscreenImage {
|
||||||
return &bigOffscreenImage{
|
return &bigOffscreenImage{
|
||||||
orig: orig,
|
orig: orig,
|
||||||
image: NewImage(width*bigOffscreenScale, height*bigOffscreenScale, imageType),
|
imageType: imageType,
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *bigOffscreenImage) markDisposed() {
|
func (i *bigOffscreenImage) markDisposed() {
|
||||||
|
if i.image != nil {
|
||||||
i.image.MarkDisposed()
|
i.image.MarkDisposed()
|
||||||
i.image = nil
|
i.image = nil
|
||||||
|
}
|
||||||
i.dirty = false
|
i.dirty = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *bigOffscreenImage) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion, srcRegion graphicsdriver.Region, subimageOffsets [graphics.ShaderImageCount - 1][2]float32, shader *Shader, uniforms []uint32, evenOdd bool, canSkipMipmap bool, antialias bool) {
|
func (i *bigOffscreenImage) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion, srcRegion graphicsdriver.Region, subimageOffsets [graphics.ShaderImageCount - 1][2]float32, shader *Shader, uniforms []uint32, evenOdd bool, canSkipMipmap bool, antialias bool) {
|
||||||
|
if i.image == nil {
|
||||||
|
// TODO: Start with a samller size (#2399)
|
||||||
|
i.image = NewImage(i.orig.width*bigOffscreenScale, i.orig.height*bigOffscreenScale, i.imageType)
|
||||||
|
i.width = i.orig.width
|
||||||
|
i.height = i.orig.height
|
||||||
|
}
|
||||||
|
|
||||||
if i.blend != blend {
|
if i.blend != blend {
|
||||||
i.flush()
|
i.flush()
|
||||||
}
|
}
|
||||||
@ -373,6 +383,10 @@ func (i *bigOffscreenImage) drawTriangles(srcs [graphics.ShaderImageCount]*Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *bigOffscreenImage) flush() {
|
func (i *bigOffscreenImage) flush() {
|
||||||
|
if i.image == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !i.dirty {
|
if !i.dirty {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user