Revert "buffered: Defer ReplacePixels when possible"

This reverts commit 1395ab5e84.

Reason: This increases the number of ReplacePixels aggressively.
This commit is contained in:
Hajime Hoshi 2020-06-28 02:43:38 +09:00
parent 36515eb1f5
commit aea4630b5f

View File

@ -197,12 +197,9 @@ func (i *Image) ReplacePixels(pix []byte, x, y, width, height int) error {
if x == 0 && y == 0 && width == i.width && height == i.height { if x == 0 && y == 0 && width == i.width && height == i.height {
i.invalidatePendingPixels() i.invalidatePendingPixels()
// Don't call (*mipmap.Mipmap).ReplacePixels here. Let's defer it to reduce GPU operations as much as // Call ReplacePixels immediately. If a lot of new images are created but they are used at different
// posssible. // timings, pixels are sent to GPU at different timings, which is very inefficient.
copied := make([]byte, len(pix)) i.img.ReplacePixels(pix)
copy(copied, pix)
i.pixels = copied
i.needsToResolvePixels = true
return nil return nil
} }