internal/restorable: remove empty regions at appendRegionsForDrawTriangles

This commit is contained in:
Hajime Hoshi 2023-03-08 16:32:41 +09:00
parent f298b9541b
commit da55397420

View File

@ -690,6 +690,7 @@ func (i *Image) appendRegionsForDrawTriangles(regions []image.Rectangle) []image
continue continue
} }
// Replace duplicated regions with empty regions.
for i, rr := range regions[origIndex:] { for i, rr := range regions[origIndex:] {
if rr.Empty() { if rr.Empty() {
continue continue
@ -702,7 +703,17 @@ func (i *Image) appendRegionsForDrawTriangles(regions []image.Rectangle) []image
regions = append(regions, r) regions = append(regions, r)
} }
return regions // Remove empty regions.
n := origIndex
for _, r := range regions[origIndex:] {
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 {