mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/restorable: refactoring
This commit is contained in:
parent
8f2097d55e
commit
46173ffec6
@ -697,37 +697,18 @@ func (i *Image) InternalSize() (int, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) appendRegionsForDrawTriangles(regions []image.Rectangle) []image.Rectangle {
|
func (i *Image) appendRegionsForDrawTriangles(regions []image.Rectangle) []image.Rectangle {
|
||||||
origIndex := len(regions)
|
n := len(regions)
|
||||||
for _, d := range i.drawTrianglesHistory {
|
for _, d := range i.drawTrianglesHistory {
|
||||||
r := regionToRectangle(d.dstRegion)
|
r := regionToRectangle(d.dstRegion)
|
||||||
if r.Empty() {
|
if r.Empty() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace duplicated regions with empty regions.
|
|
||||||
for i, rr := range regions[origIndex:] {
|
|
||||||
if rr.Empty() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if rr.In(r) {
|
|
||||||
regions[origIndex+i] = image.Rectangle{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
regions = append(regions, r)
|
regions = append(regions, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove empty regions.
|
origRegions := regions[:n]
|
||||||
n := origIndex
|
newRegions := removeDuplicatedRegions(regions[n:])
|
||||||
for _, r := range regions[origIndex:] {
|
return append(origRegions, newRegions...)
|
||||||
if r.Empty() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
regions[n] = r
|
|
||||||
n++
|
|
||||||
}
|
|
||||||
|
|
||||||
return regions[:n]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func regionToRectangle(region graphicsdriver.Region) image.Rectangle {
|
func regionToRectangle(region graphicsdriver.Region) image.Rectangle {
|
||||||
|
Loading…
Reference in New Issue
Block a user