Don't cache nil frames

This commit is contained in:
Sergey Stepanov 2023-02-10 17:47:58 +03:00
parent 8b4b238cf9
commit beaf862dec
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B

View file

@ -60,8 +60,12 @@ func (c *Canvas) Get(w, h int) *Frame {
return i
}
func (c *Canvas) Put(i *Frame) { c.pool.Put(i) }
func (c *Canvas) Clear() { c.wg = sync.WaitGroup{} }
func (c *Canvas) Put(i *Frame) {
if i != nil {
c.pool.Put(i)
}
}
func (c *Canvas) Clear() { c.wg = sync.WaitGroup{} }
func (c *Canvas) Draw(encoding uint32, rot *Rotate, w, h, packedW, bpp int, data []byte, th int) *Frame {
dst := c.Get(w, h)