mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2026-04-22 15:57:15 +08:00
vector: use destination bounds to allocate an image on atlas
Closes #3358
This commit is contained in:
+2
-2
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user