buffered: Remove unnecessary line and add comments

This commit is contained in:
Hajime Hoshi 2020-04-17 21:49:30 +09:00
parent b9e0b5f04b
commit 514c3faebd

View File

@ -127,11 +127,12 @@ func (i *Image) At(x, y int) (r, g, b, a byte, err error) {
if needsToDelayCommands { if needsToDelayCommands {
panic("buffered: the command queue is not available yet at At") panic("buffered: the command queue is not available yet at At")
} }
// If there are pixels that needs to be resolved, use this rather than resolving. Resolving pixels needs
// to access GPU and is expensive (#1137).
if i.pixels != nil { if i.pixels != nil {
idx := i.width*y + x idx := i.width*y + x
return i.pixels[4*idx], i.pixels[4*idx+1], i.pixels[4*idx+2], i.pixels[4*idx+3], nil return i.pixels[4*idx], i.pixels[4*idx+1], i.pixels[4*idx+2], i.pixels[4*idx+3], nil
} }
i.resolvePendingPixels(true)
return i.img.At(x, y) return i.img.At(x, y)
} }