add a note about memory leaks to Drawer and Sprite docs

This commit is contained in:
faiface 2017-04-26 14:28:25 +02:00
parent bdbce3a27b
commit e8aa765ed3
2 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,11 @@ package pixel
//
// Whenever you change the Triangles, call Dirty to notify Drawer that Triangles changed. You don't
// need to notify Drawer about a change of the Picture.
//
// Note, that Drawer caches the results of MakePicture from Targets it's drawn to for each Picture
// it's set to. What it means is that using a Drawer with an unbounded number of Pictures leads to a
// memory leak, since Drawer caches them and never forgets. In such a situation, create a new Drawer
// for each Picture.
type Drawer struct {
Triangles Triangles
Picture Picture

View File

@ -11,6 +11,11 @@ import "image/color"
//
// To achieve different anchoring, transformations and color masking, use SetMatrix and SetColorMask
// methods.
//
// Note, that Sprite caches the results of MakePicture from Targets it's drawn to for each Picture
// it's set to. What it means is that using a Sprite with an unbounded number of Pictures leads to a
// memory leak, since Sprite caches them and never forgets. In such a situation, create a new Sprite
// for each Picture.
type Sprite struct {
tri *TrianglesData
frame Rect