diff --git a/imageimpl.go b/imageimpl.go index fe9adef56..9b46e6ab3 100644 --- a/imageimpl.go +++ b/imageimpl.go @@ -34,7 +34,7 @@ type imageImpl struct { width int height int filter Filter - restorable restorable.Image + restorable *restorable.Image volatile bool screen bool m sync.Mutex @@ -46,11 +46,12 @@ func newImageImpl(width, height int, filter Filter, volatile bool) (*imageImpl, return nil, err } i := &imageImpl{ - image: img, - width: width, - height: height, - filter: filter, - volatile: volatile, + image: img, + width: width, + height: height, + filter: filter, + restorable: restorable.NewImage(), + volatile: volatile, } runtime.SetFinalizer(i, (*imageImpl).Dispose) return i, nil @@ -79,10 +80,11 @@ func newImageImplFromImage(source image.Image, filter Filter) (*imageImpl, error return nil, err } i := &imageImpl{ - image: img, - width: w, - height: h, - filter: filter, + image: img, + width: w, + height: h, + filter: filter, + restorable: restorable.NewImage(), } i.restorable.ReplacePixels(p) runtime.SetFinalizer(i, (*imageImpl).Dispose) @@ -95,11 +97,12 @@ func newScreenImageImpl(width, height int) (*imageImpl, error) { return nil, err } i := &imageImpl{ - image: img, - width: width, - height: height, - volatile: true, - screen: true, + image: img, + width: width, + height: height, + restorable: restorable.NewImage(), + volatile: true, + screen: true, } runtime.SetFinalizer(i, (*imageImpl).Dispose) return i, nil diff --git a/internal/restorable/image.go b/internal/restorable/image.go index abd0363eb..6f5a9878f 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -40,6 +40,10 @@ type Image struct { stale bool } +func NewImage() *Image { + return &Image{} +} + func (p *Image) IsStale() bool { return p.stale }