graphics: Refactoring

This commit is contained in:
Hajime Hoshi 2018-04-16 01:50:53 +09:00
parent b691e73342
commit 63c33b24df
2 changed files with 3 additions and 5 deletions

View File

@ -377,12 +377,9 @@ func NewImage(width, height int, filter Filter) (*Image, error) {
// Note that volatile images are internal only and will never be source of drawing.
//
// If width or height is less than 1 or more than device-dependent maximum size, newVolatileImage panics.
//
// Error returned by newVolatileImage is always nil as of 1.5.0-alpha.
func newVolatileImage(width, height int) *Image {
i := &Image{
shareableImage: shareable.NewVolatileImage(width, height),
filter: FilterDefault,
}
i.addr = i
runtime.SetFinalizer(i, (*Image).Dispose)

View File

@ -622,8 +622,8 @@ func BenchmarkDrawImage(b *testing.B) {
}
func TestImageLinear(t *testing.T) {
src, _ := NewImage(32, 32, FilterLinear)
dst, _ := NewImage(64, 64, FilterNearest)
src, _ := NewImage(32, 32, FilterDefault)
dst, _ := NewImage(64, 64, FilterDefault)
src.Fill(color.RGBA{0, 0xff, 0, 0xff})
ebitenutil.DrawRect(src, 8, 8, 16, 16, color.RGBA{0xff, 0, 0, 0xff})
@ -632,6 +632,7 @@ func TestImageLinear(t *testing.T) {
op.GeoM.Scale(2, 2)
r := image.Rect(8, 8, 24, 24)
op.SourceRect = &r
op.Filter = FilterLinear
dst.DrawImage(src, op)
for j := 0; j < 64; j++ {