@@ -13,15 +13,32 @@ var pool = [];
1313// Automatically apply smoothing(false) to created Canvas elements
1414var _disableContextSmoothing = false ;
1515
16- // This singleton is instantiated as soon as Phaser loads,
17- // before a Phaser.Game instance has even been created.
18- // Which means all instances of Phaser Games on the same page
19- // can share the one single pool
20-
21- // The CanvasPool is a global static object, that allows Phaser to recycle and pool Canvas DOM elements.
16+ /**
17+ * The CanvasPool is a global static object, that allows Phaser to recycle and pool Canvas DOM elements.
18+ *
19+ * This singleton is instantiated as soon as Phaser loads,
20+ * before a Phaser.Game instance has even been created.
21+ * Which means all instances of Phaser Games on the same page
22+ * can share the one single pool
23+ *
24+ * @namespace Phaser.Display.Canvas.CanvasPool
25+ * @since 3.0.0
26+ */
2227var CanvasPool = function ( )
2328{
24- // Creates a new Canvas DOM element, or pulls one from the pool if free.
29+ /**
30+ * Creates a new Canvas DOM element, or pulls one from the pool if free.
31+ *
32+ * @function Phaser.Display.Canvas.CanvasPool.create
33+ * @since 3.0.0
34+ *
35+ * @param {any } parent - [description]
36+ * @param {integer } [width=1] - [description]
37+ * @param {integer } [height=1] - [description]
38+ * @param {integer } [type] - [description]
39+ *
40+ * @return {HTMLCanvasElement } [description]
41+ */
2542 var create = function ( parent , width , height , type )
2643 {
2744 if ( width === undefined ) { width = 1 ; }
@@ -61,17 +78,50 @@ var CanvasPool = function ()
6178 return canvas ;
6279 } ;
6380
81+ /**
82+ * Creates a new Canvas DOM element, or pulls one from the pool if free.
83+ *
84+ * @function Phaser.Display.Canvas.CanvasPool.create2D
85+ * @since 3.0.0
86+ *
87+ * @param {any } parent - [description]
88+ * @param {integer } [width=1] - [description]
89+ * @param {integer } [height=1] - [description]
90+ *
91+ * @return {HTMLCanvasElement } [description]
92+ */
6493 var create2D = function ( parent , width , height )
6594 {
6695 return create ( parent , width , height , CONST . CANVAS ) ;
6796 } ;
6897
98+ /**
99+ * Creates a new Canvas DOM element, or pulls one from the pool if free.
100+ *
101+ * @function Phaser.Display.Canvas.CanvasPool.createWebGL
102+ * @since 3.0.0
103+ *
104+ * @param {any } parent - [description]
105+ * @param {integer } [width=1] - [description]
106+ * @param {integer } [height=1] - [description]
107+ *
108+ * @return {HTMLCanvasElement } [description]
109+ */
69110 var createWebGL = function ( parent , width , height )
70111 {
71112 return create ( parent , width , height , CONST . WEBGL ) ;
72113 } ;
73114
74- // Gets the first free canvas index from the pool.
115+ /**
116+ * Gets the first free canvas index from the pool.
117+ *
118+ * @function Phaser.Display.Canvas.CanvasPool.first
119+ * @since 3.0.0
120+ *
121+ * @param {integer } [type] - [description]
122+ *
123+ * @return {HTMLCanvasElement } [description]
124+ */
75125 var first = function ( type )
76126 {
77127 if ( type === undefined ) { type = CONST . CANVAS ; }
@@ -87,8 +137,15 @@ var CanvasPool = function ()
87137 return null ;
88138 } ;
89139
90- // Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use.
91- // The canvas has its width and height set to 1, and its parent attribute nulled.
140+ /**
141+ * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use.
142+ * The canvas has its width and height set to 1, and its parent attribute nulled.
143+ *
144+ * @function Phaser.Display.Canvas.CanvasPool.remove
145+ * @since 3.0.0
146+ *
147+ * @param {any } parent - [description]
148+ */
92149 var remove = function ( parent )
93150 {
94151 // Check to see if the parent is a canvas object
@@ -106,7 +163,14 @@ var CanvasPool = function ()
106163 } ) ;
107164 } ;
108165
109- // Gets the total number of used canvas elements in the pool.
166+ /**
167+ * Gets the total number of used canvas elements in the pool.
168+ *
169+ * @function Phaser.Display.Canvas.CanvasPool.total
170+ * @since 3.0.0
171+ *
172+ * @return {integer } [description]
173+ */
110174 var total = function ( )
111175 {
112176 var c = 0 ;
@@ -122,19 +186,36 @@ var CanvasPool = function ()
122186 return c ;
123187 } ;
124188
125- // Gets the total number of free canvas elements in the pool.
189+ /**
190+ * Gets the total number of free canvas elements in the pool.
191+ *
192+ * @function Phaser.Display.Canvas.CanvasPool.free
193+ * @since 3.0.0
194+ *
195+ * @return {integer } [description]
196+ */
126197 var free = function ( )
127198 {
128199 return pool . length - total ( ) ;
129200 } ;
130201
131- // Disable context smoothing on any new Canvas element created
202+ /**
203+ * Disable context smoothing on any new Canvas element created.
204+ *
205+ * @function Phaser.Display.Canvas.CanvasPool.disableSmoothing
206+ * @since 3.0.0
207+ */
132208 var disableSmoothing = function ( )
133209 {
134210 _disableContextSmoothing = true ;
135211 } ;
136212
137- // Enable context smoothing on any new Canvas element created
213+ /**
214+ * Enable context smoothing on any new Canvas element created.
215+ *
216+ * @function Phaser.Display.Canvas.CanvasPool.enableSmoothing
217+ * @since 3.0.0
218+ */
138219 var enableSmoothing = function ( )
139220 {
140221 _disableContextSmoothing = false ;
0 commit comments