graphics: Bug fix: Make an image stale when another stale image is drawn to this (#257)

This commit is contained in:
Hajime Hoshi 2016-08-23 00:04:15 +09:00
parent 58f59f3832
commit 749a751369
2 changed files with 9 additions and 2 deletions

View File

@ -106,7 +106,6 @@ func newScreenImageImpl(width, height int) (*imageImpl, error) {
}
func (i *imageImpl) Fill(clr color.Color) error {
// TODO: Need to clone clr value
i.m.Lock()
defer i.m.Unlock()
if i.disposed {
@ -163,7 +162,11 @@ func (i *imageImpl) DrawImage(image *Image, options *DrawImageOptions) error {
geom := options.GeoM
colorm := options.ColorM
mode := opengl.CompositeMode(options.CompositeMode)
i.pixels.AppendDrawImageHistory(image.impl.image, vertices, &geom, &colorm, mode)
if image.impl.pixels.IsStale() {
i.pixels.MakeStale()
} else {
i.pixels.AppendDrawImageHistory(image.impl.image, vertices, &geom, &colorm, mode)
}
if err := i.image.DrawImage(image.impl.image, vertices, &geom, &colorm, mode); err != nil {
return err
}

View File

@ -40,6 +40,10 @@ type Pixels struct {
stale bool
}
func (p *Pixels) IsStale() bool {
return p.stale
}
func (p *Pixels) MakeStale() {
p.basePixels = nil
p.baseColor = nil