From 2f1908b05c767cb2489e7c921bf7689d0ee33746 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 28 Feb 2018 02:10:19 +0900 Subject: [PATCH] restorable: Use nil instead of empty affine.ColorM --- internal/restorable/image.go | 2 +- internal/restorable/images_test.go | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 440cadbc3..a9a1f6b95 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -127,7 +127,7 @@ func (i *Image) makeStale() { var ( dummyImage = graphics.NewImage(16, 16) - clearColorM = &affine.ColorM{} + clearColorM *affine.ColorM ) func init() { diff --git a/internal/restorable/images_test.go b/internal/restorable/images_test.go index 4a037d97c..c5c0794c6 100644 --- a/internal/restorable/images_test.go +++ b/internal/restorable/images_test.go @@ -132,7 +132,7 @@ func TestRestoreChain(t *testing.T) { clr := color.RGBA{0x00, 0x00, 0x00, 0xff} fill(imgs[0], clr.R, clr.G, clr.B, clr.A) for i := 0; i < num-1; i++ { - imgs[i+1].DrawImage(imgs[i], 0, 0, 1, 1, nil, &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) + imgs[i+1].DrawImage(imgs[i], 0, 0, 1, 1, nil, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) } if err := ResolveStaleImages(); err != nil { t.Fatal(err) @@ -167,10 +167,10 @@ func TestRestoreOverrideSource(t *testing.T) { clr0 := color.RGBA{0x00, 0x00, 0x00, 0xff} clr1 := color.RGBA{0x00, 0x00, 0x01, 0xff} fill(img1, clr0.R, clr0.G, clr0.B, clr0.A) - img2.DrawImage(img1, 0, 0, 1, 1, nil, &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img3.DrawImage(img2, 0, 0, 1, 1, nil, &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img2.DrawImage(img1, 0, 0, 1, 1, nil, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img3.DrawImage(img2, 0, 0, 1, 1, nil, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) fill(img0, clr1.R, clr1.G, clr1.B, clr1.A) - img1.DrawImage(img0, 0, 0, 1, 1, nil, &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img1.DrawImage(img0, 0, 0, 1, 1, nil, nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) if err := ResolveStaleImages(); err != nil { t.Fatal(err) } @@ -248,15 +248,15 @@ func TestRestoreComplexGraph(t *testing.T) { img1.Dispose() img0.Dispose() }() - img3.DrawImage(img0, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(0, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img3.DrawImage(img1, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img4.DrawImage(img1, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img4.DrawImage(img2, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(2, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img5.DrawImage(img3, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(0, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img6.DrawImage(img3, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(0, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img6.DrawImage(img4, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img7.DrawImage(img2, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(0, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img7.DrawImage(img3, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(2, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img3.DrawImage(img0, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(0, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img3.DrawImage(img1, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img4.DrawImage(img1, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img4.DrawImage(img2, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(2, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img5.DrawImage(img3, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(0, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img6.DrawImage(img3, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(0, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img6.DrawImage(img4, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img7.DrawImage(img2, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(0, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img7.DrawImage(img3, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(2, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) if err := ResolveStaleImages(); err != nil { t.Fatal(err) } @@ -343,8 +343,8 @@ func TestRestoreRecursive(t *testing.T) { img1.Dispose() img0.Dispose() }() - img1.DrawImage(img0, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) - img0.DrawImage(img1, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), &affine.ColorM{}, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img1.DrawImage(img0, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) + img0.DrawImage(img1, 0, 0, 4, 1, (*affine.GeoM)(nil).Translate(1, 0), nil, opengl.CompositeModeSourceOver, graphics.FilterNearest) if err := ResolveStaleImages(); err != nil { t.Fatal(err) }