Skip to content

Commit f650b2a

Browse files
committed
vector: bug fix: atlas size was not enough for antialias renderings
Closes #3377
1 parent f66fd7e commit f650b2a

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

vector/atlas.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,13 @@ func (a *atlas) setPaths(dstBounds image.Rectangle, paths []*Path, bounds []imag
9090
a.pathIndexToAtlasRegionIndex[r.pathIndex] = i
9191
}
9292

93+
w, h := dstBounds.Dx(), dstBounds.Dy()
94+
// For antialiasing, doubled regions in the X direction are used.
95+
if antialias {
96+
w *= 2
97+
}
9398
// Use 2^n - 1, as a region in internal/atlas has 1px padding.
94-
maxImageSize := max(4093, dstBounds.Dx(), dstBounds.Dy())
99+
maxImageSize := max(4093, w, h)
95100

96101
// Pack the regions into an atlas with a very simple algorithm:
97102
// Order the regions by height and then place them in a row.

vector/util_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,23 @@ func TestFillRects(t *testing.T) {
126126
t.Errorf("got: %v, want: %v", got, want)
127127
}
128128
}
129+
130+
// Issue #3377
131+
func TestFillRectOnBigImage(t *testing.T) {
132+
dst := ebiten.NewImage(3000, 3000)
133+
defer dst.Deallocate()
134+
135+
vector.FillRect(dst, 0, 0, 3000, 3000, color.White, true)
136+
if got, want := dst.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
137+
t.Errorf("got: %v, want: %v", got, want)
138+
}
139+
if got, want := dst.At(2980, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
140+
t.Errorf("got: %v, want: %v", got, want)
141+
}
142+
if got, want := dst.At(0, 2980), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
143+
t.Errorf("got: %v, want: %v", got, want)
144+
}
145+
if got, want := dst.At(2980, 2980), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
146+
t.Errorf("got: %v, want: %v", got, want)
147+
}
148+
}

0 commit comments

Comments
 (0)