buffered: Skip filling operation if possible

This commit is contained in:
Hajime Hoshi 2020-06-14 04:17:57 +09:00
parent e180598ce0
commit cf3436da21

View File

@ -201,14 +201,14 @@ func (i *Image) ReplacePixels(pix []byte, x, y, width, height int) error {
return nil
}
i.resolvePendingFill()
if x == 0 && y == 0 && width == i.width && height == i.height {
i.invalidatePendingPixels()
i.img.ReplacePixels(pix)
return nil
}
i.resolvePendingFill()
// TODO: Can we use (*restorable.Image).ReplacePixels?
if i.pixels == nil {
pix, err := i.img.Pixels(0, 0, i.width, i.height)