graphics: Bug fix: Flush after filling (#419)

This commit is contained in:
Hajime Hoshi
2017-08-24 00:11:08 +09:00
parent bb6dfeefd4
commit 12c24215b1
2 changed files with 30 additions and 2 deletions

View File

@@ -490,7 +490,7 @@ func TestImageFill(t *testing.T) {
}
}
// Issue 317
// Issue #317
func TestImageEdge(t *testing.T) {
const (
img0Width = 16
@@ -561,6 +561,28 @@ func TestImageEdge(t *testing.T) {
}
}
// Issue #419
func TestImageTooManyFill(t *testing.T) {
const width = 256
src, _ := NewImage(1, 1, FilterNearest)
dst, _ := NewImage(width, 1, FilterNearest)
for i := 0; i < width; i++ {
src.Fill(color.RGBA{uint8(i), uint8(i), uint8(i), 0xff})
op := &DrawImageOptions{}
op.GeoM.Translate(float64(i), 0)
dst.DrawImage(src, op)
}
for i := 0; i < width; i++ {
got := color.RGBAModel.Convert(dst.At(i, 0))
want := color.RGBA{uint8(i), uint8(i), uint8(i), 0xff}
if got != want {
t.Errorf("src At(%d, %d): got %#v, want: %#v", i, 0, got, want)
}
}
}
func BenchmarkDrawImage(b *testing.B) {
img0, _ := NewImage(16, 16, FilterNearest)
img1, _ := NewImage(16, 16, FilterNearest)