vector: use destination bounds to allocate an image on atlas

Closes #3358
This commit is contained in:
Hajime Hoshi
2025-12-11 00:53:39 +09:00
parent 8197db788d
commit 7d0692124a
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ func roundUp16(x int) int {
return (x + 15) &^ 15
}
func (a *atlas) setPaths(dstBounds image.Rectangle, paths []*Path, antialias bool) {
func (a *atlas) setPaths(dstBounds image.Rectangle, paths []*Path, bounds []image.Rectangle, antialias bool) {
// Reset the members.
a.pathRenderingBounds = slices.Delete(a.pathRenderingBounds, 0, len(a.pathRenderingBounds))
a.atlasRegions = slices.Delete(a.atlasRegions, 0, len(a.atlasRegions))
@@ -60,7 +60,7 @@ func (a *atlas) setPaths(dstBounds image.Rectangle, paths []*Path, antialias boo
a.pathRenderingBounds = slices.Grow(a.pathRenderingBounds, len(paths))[:len(paths)]
for i, p := range paths {
b := p.Bounds().Intersect(dstBounds)
b := p.Bounds().Intersect(bounds[i]).Intersect(dstBounds)
// Round up the size to 16px in order to encourage reusing sub image cache.
a.pathRenderingBounds[i] = image.Rectangle{
Min: b.Min,
+1 -1
View File
@@ -185,7 +185,7 @@ func (f *fillPathsState) fillPaths(dst *ebiten.Image) {
f.indices = is
}()
theAtlas.setPaths(dst.Bounds(), f.paths, f.antialias)
theAtlas.setPaths(dst.Bounds(), f.paths, f.bounds, f.antialias)
offsetAndColors := offsetAndColorsNonAA
if f.antialias {