@@ -22,7 +22,7 @@ var ScaleModes = require('../renderer/ScaleModes');
2222 * @since 3.0.0
2323 *
2424 * @param {Phaser.Textures.Texture } texture - The Texture this TextureSource belongs to.
25- * @param {(HTMLImageElement|HTMLCanvasElement) } source - The source image data.
25+ * @param {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture|WebGLTexture ) } source - The source image data.
2626 * @param {integer } [width] - Optional width of the source image. If not given it's derived from the source itself.
2727 * @param {integer } [height] - Optional height of the source image. If not given it's derived from the source itself.
2828 */
@@ -54,10 +54,10 @@ var TextureSource = new Class({
5454
5555 /**
5656 * The source of the image data.
57- * This is either an Image Element, a Canvas Element or a RenderTexture .
57+ * This is either an Image Element, a Canvas Element, a RenderTexture or a WebGLTexture .
5858 *
5959 * @name Phaser.Textures.TextureSource#source
60- * @type {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture) }
60+ * @type {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture|WebGLTexture ) }
6161 * @since 3.12.0
6262 */
6363 this . source = source ;
@@ -150,7 +150,8 @@ var TextureSource = new Class({
150150 this . isPowerOf2 = IsSizePowerOfTwo ( this . width , this . height ) ;
151151
152152 /**
153- * The WebGL Texture of the source image.
153+ * The WebGL Texture of the source image. If this TextureSource is driven from a WebGLTexture
154+ * already, then this is a reference to that WebGLTexture.
154155 *
155156 * @name Phaser.Textures.TextureSource#glTexture
156157 * @type {?WebGLTexture }
@@ -186,10 +187,14 @@ var TextureSource = new Class({
186187
187188 this . glTexture = this . renderer . createTextureFromSource ( null , this . width , this . height , this . scaleMode ) ;
188189 }
189- else
190+ else if ( ! ( this . source instanceof WebGLTexture ) )
190191 {
191192 this . glTexture = this . renderer . createTextureFromSource ( this . image , this . width , this . height , this . scaleMode ) ;
192193 }
194+ else
195+ {
196+ this . glTexture = this . source ;
197+ }
193198 }
194199 else if ( this . isRenderTexture )
195200 {
@@ -235,19 +240,6 @@ var TextureSource = new Class({
235240 if ( this . renderer . gl && this . isCanvas )
236241 {
237242 this . glTexture = this . renderer . canvasToTexture ( this . image , this . glTexture ) ;
238-
239- // Update all the Frames using this TextureSource
240-
241- /*
242- var index = this.texture.getTextureSourceIndex(this);
243-
244- var frames = this.texture.getFramesFromTextureSource(index, true);
245-
246- for (var i = 0; i < frames.length; i++)
247- {
248- frames[i].glTexture = this.glTexture;
249- }
250- */
251243 }
252244 } ,
253245
0 commit comments