Skip to content

Commit c4d7870

Browse files
committed
* PIXI.Texture.fromImage, PIXI.BaseTexture.fromImage and PIXI.Sprite.fromImage have all been removed. They should never have actually been used, as they bypass the Phaser Loader, and don't factor in CORs or any other advanced loader settings.
* The PIXI.BaseTexture.imageUrl property has been removed, as it was never actually populated. * The PIXI.BaseTexture._UID property has been removed, as it was never actually used internally. * All references to PIXI.BaseTextureCache have been removed (primarily from BaseTexture.destroy and Texture.destroy), as the BaseTextureCache was never used internally by Phaser, or by our custom version of Pixi. * PIXI.TextureCache has been removed. It was only ever used by the __default and __missing images that Phaser generates on start-up. It wasn't used internally by Phaser anywhere else, and the only references Pixi has to it have all been removed. If you need it in your own game, please refactor it to avoid it, or re-create the object on the PIXI global object. * Canvases created by `BaseTexture.fromCanvas` no longer have the `_pixiId` property attached to them, as this was never used internally by Phaser or Pixi. * PIXI.BaseTexture.updateSourceImage is now deprecated. Please use `Sprite.loadTexture` instead. * The property PIXI.BaseTextureCacheIdGenerator has been removed, as it is no longer used internally by Phaser or Pixi. * PIXI.Texture.addTextureToCache has been removed. The PIXI Texture Cache was never actually used by Phaser, and was leading to complications internally. * PIXI.Texture.removeTextureFromCache has been removed. The PIXI Texture Cache was never actually used by Phaser, and was leading to complications internally. * PIXI.Texture.fromFrame and PIXI.Sprite.fromFrame have been removed. They relied on the PIXI Texture Cache, which was never actually used by Phaser, and was never used internally by Pixi either. * The property PIXI.TextureCacheIdGenerator has been removed, as it was not used internally. * The property PIXI.FrameCache has been removed, as it was not used internally.
1 parent 440e2af commit c4d7870

11 files changed

Lines changed: 33 additions & 209 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
338338
* The canvas created by Phaser.Debug for use when displaying debug data is no longer stored in the CanvasPool, and is instead a stand-alone canvas, free from ever being re-used by another game object.
339339
* BitmapData has a new, optional, fifth argument: `skipPool`. By default BitmapData objects will ask for the first free canvas found in the CanvasPool, but this behavior can now be customized on a per object basis.
340340
* Phaser.ArrayUtils.rotate is now deprecated. Please use Phaser.ArrayUtils.rotateLeft instead.
341+
* Phaser.Text.fontPropertiesCanvas used to be taken from the CanvasPool, but as it's constantly needed it is now generated directly from the document.
342+
* The default image texture, for when none is supplied, is now available under `Phaser.Cache.DEFAULT`.
343+
* The missing image texture, for when an image has failed to load, is now available under `Phaser.Cache.MISSING`.
344+
* Phaser.Cache.addImage will now check the key given, and if `__default` or `__missing` it will update the new consts `Phaser.Cache.DEFAULT` and `Phaser.Cache.MISSING` accordingly, allowing you to replace the default or missing image textures used by Phaser.
345+
* Phaser.Cache.getPixiTexture has now been removed, as the Pixi Cache isn't used internally anywhere any longer.
346+
* Phaser.Cache.getPixiBaseTexture has now been removed, as the Pixi Cache isn't used internally anywhere any longer.
341347

342348
### Bug Fixes
343349

@@ -353,6 +359,22 @@ Please note that Phaser uses a custom build of Pixi and always has done. The fol
353359

354360
* Removed `_renderWebGL`, `_renderCanvas`, `getLocalBounds` and `getBounds` from PIXI.DisplayObject, as they were only there to pass ancient jshint rules.
355361
* All Pixi.Graphics methods that change the Graphics, i.e. `drawShape`, `lineTo`, `arc`, etc will now all automatically call `Graphics.updateLocalBounds`. This is so that the bounds of the Graphics object are kept updated, allowing you to scale and rotate the Graphics object and still obtain correct dimensions from it (thanks @kelu-smiley #2573)
362+
* PIXI.CanvasPool no longer _just_ checks for `null` parent comparisons. It will check for all falsey parents, helping free-up canvases when the parent objects have been removed elsewhere.
363+
* PIXI.CanvasPool.remove and `removeByCanvas` both now set the removed canvas width and height to 1.
364+
* PIXI.Texture.fromImage, PIXI.BaseTexture.fromImage and PIXI.Sprite.fromImage have all been removed. They should never have actually been used, as they bypass the Phaser Loader, and don't factor in CORs or any other advanced loader settings.
365+
* The PIXI.BaseTexture.imageUrl property has been removed, as it was never actually populated.
366+
* The PIXI.BaseTexture._UID property has been removed, as it was never actually used internally.
367+
* All references to PIXI.BaseTextureCache have been removed (primarily from BaseTexture.destroy and Texture.destroy), as the BaseTextureCache was never used internally by Phaser, or by our custom version of Pixi.
368+
* PIXI.TextureCache has been removed. It was only ever used by the __default and __missing images that Phaser generates on start-up. It wasn't used internally by Phaser anywhere else, and the only references Pixi has to it have all been removed. If you need it in your own game, please refactor it to avoid it, or re-create the object on the PIXI global object.
369+
* Canvases created by `BaseTexture.fromCanvas` no longer have the `_pixiId` property attached to them, as this was never used internally by Phaser or Pixi.
370+
* PIXI.BaseTexture.updateSourceImage is now deprecated. Please use `Sprite.loadTexture` instead.
371+
* The property PIXI.BaseTextureCacheIdGenerator has been removed, as it is no longer used internally by Phaser or Pixi.
372+
* PIXI.Texture.addTextureToCache has been removed. The PIXI Texture Cache was never actually used by Phaser, and was leading to complications internally.
373+
* PIXI.Texture.removeTextureFromCache has been removed. The PIXI Texture Cache was never actually used by Phaser, and was leading to complications internally.
374+
* PIXI.Texture.fromFrame and PIXI.Sprite.fromFrame have been removed. They relied on the PIXI Texture Cache, which was never actually used by Phaser, and was never used internally by Pixi either.
375+
* The property PIXI.TextureCacheIdGenerator has been removed, as it was not used internally.
376+
* The property PIXI.FrameCache has been removed, as it was not used internally.
377+
356378

357379
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
358380

src/animation/AnimationManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ Phaser.AnimationManager.prototype = {
400400
refreshFrame: function () {
401401

402402
// TODO
403-
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
403+
// this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
404404

405405
},
406406

src/gameobjects/Creature.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Phaser.Creature = function (game, x, y, key, mesh, animation) {
8181

8282
if (typeof key === 'string')
8383
{
84-
var texture = game.cache.getPixiTexture(key);
84+
var texture = new PIXI.Texture(game.cache.getBaseTexture(key));
8585
}
8686
else
8787
{

src/gameobjects/Image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Phaser.Image = function (game, x, y, key, frame) {
4545
*/
4646
this.type = Phaser.IMAGE;
4747

48-
PIXI.Sprite.call(this, PIXI.TextureCache['__default']);
48+
PIXI.Sprite.call(this, Phaser.Cache.DEFAULT);
4949

5050
Phaser.Component.Core.init.call(this, game, x, y, key, frame);
5151

src/gameobjects/Rope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Phaser.Rope = function (game, x, y, key, frame, points) {
5656
*/
5757
this.type = Phaser.ROPE;
5858

59-
PIXI.Rope.call(this, PIXI.TextureCache['__default'], this.points);
59+
PIXI.Rope.call(this, Phaser.Cache.DEFAULT, this.points);
6060

6161
Phaser.Component.Core.init.call(this, game, x, y, key, frame);
6262

src/gameobjects/Sprite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
6060
*/
6161
this.physicsType = Phaser.SPRITE;
6262

63-
PIXI.Sprite.call(this, PIXI.TextureCache['__default']);
63+
PIXI.Sprite.call(this, Phaser.Cache.DEFAULT);
6464

6565
Phaser.Component.Core.init.call(this, game, x, y, key, frame);
6666

src/gameobjects/Video.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Phaser.Video = function (game, key, url) {
252252
}
253253
else
254254
{
255-
this.baseTexture = new PIXI.BaseTexture(PIXI.TextureCache['__default'].baseTexture.source);
255+
this.baseTexture = new PIXI.BaseTexture(Phaser.Cache.DEFAULT.baseTexture.source);
256256
this.baseTexture.forceLoaded(this.width, this.height);
257257
}
258258

src/pixi/display/Sprite.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -491,41 +491,3 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
491491
}
492492

493493
};
494-
495-
// some helper functions..
496-
497-
/**
498-
*
499-
* Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId
500-
* The frame ids are created when a Texture packer file has been loaded
501-
*
502-
* @method fromFrame
503-
* @static
504-
* @param frameId {String} The frame Id of the texture in the cache
505-
* @return {Sprite} A new Sprite using a texture from the texture cache matching the frameId
506-
*/
507-
PIXI.Sprite.fromFrame = function(frameId)
508-
{
509-
var texture = PIXI.TextureCache[frameId];
510-
511-
if (!texture) throw new Error('The frameId "' + frameId + '" does not exist in the texture cache' + this);
512-
513-
return new PIXI.Sprite(texture);
514-
};
515-
516-
/**
517-
*
518-
* Helper function that creates a sprite that will contain a texture based on an image url
519-
* If the image is not in the texture cache it will be loaded
520-
*
521-
* @method fromImage
522-
* @static
523-
* @param imageId {String} The image url of the texture
524-
* @return {Sprite} A new Sprite using a texture from the texture cache matching the image id
525-
*/
526-
PIXI.Sprite.fromImage = function(imageId, crossorigin, scaleMode)
527-
{
528-
var texture = PIXI.Texture.fromImage(imageId, crossorigin, scaleMode);
529-
530-
return new PIXI.Sprite(texture);
531-
};

src/pixi/primitives/Graphics.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,6 @@ PIXI.Graphics.prototype.generateTexture = function(resolution, scaleMode, paddin
671671

672672
canvasBuffer.context.translate(-bounds.x, -bounds.y);
673673

674-
// Call here
675-
676674
PIXI.CanvasGraphics.renderGraphics(this, canvasBuffer.context);
677675

678676
return texture;

src/pixi/textures/BaseTexture.js

Lines changed: 5 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
* @author Mat Groves http://matgroves.com/ @Doormat23
33
*/
44

5-
PIXI.BaseTextureCache = {};
6-
7-
PIXI.BaseTextureCacheIdGenerator = 0;
8-
95
/**
106
* A texture stores the information that represents an image. All textures have a base texture.
117
*
128
* @class BaseTexture
139
* @uses EventTarget
1410
* @constructor
15-
* @param source {String} the source object (image or canvas)
11+
* @param source {String|Canvas} the source object (image or canvas)
1612
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
1713
*/
1814
PIXI.BaseTexture = function(source, scaleMode)
@@ -69,8 +65,6 @@ PIXI.BaseTexture = function(source, scaleMode)
6965
*/
7066
this.source = source;
7167

72-
this._UID = PIXI._UID++;
73-
7468
/**
7569
* Controls if RGB channels should be pre-multiplied by Alpha (WebGL only)
7670
*
@@ -129,12 +123,6 @@ PIXI.BaseTexture = function(source, scaleMode)
129123
*/
130124
this.skipRender = false;
131125

132-
/**
133-
* @property imageUrl
134-
* @type String
135-
*/
136-
this.imageUrl = null;
137-
138126
/**
139127
* @property _powerOf2
140128
* @type Boolean
@@ -161,7 +149,6 @@ PIXI.BaseTexture.prototype.forceLoaded = function(width, height)
161149
this.width = width;
162150
this.height = height;
163151
this.dirty();
164-
165152
};
166153

167154
/**
@@ -171,23 +158,9 @@ PIXI.BaseTexture.prototype.forceLoaded = function(width, height)
171158
*/
172159
PIXI.BaseTexture.prototype.destroy = function()
173160
{
174-
if (this.imageUrl)
175-
{
176-
delete PIXI.BaseTextureCache[this.imageUrl];
177-
delete PIXI.TextureCache[this.imageUrl];
178-
179-
this.imageUrl = null;
180-
181-
if (!navigator.isCocoonJS) this.source.src = '';
182-
}
183-
else if (this.source)
161+
if (this.source)
184162
{
185163
PIXI.CanvasPool.removeByCanvas(this.source);
186-
187-
if (this.source._pixiId)
188-
{
189-
delete PIXI.BaseTextureCache[this.source._pixiId];
190-
}
191164
}
192165

193166
this.source = null;
@@ -200,12 +173,11 @@ PIXI.BaseTexture.prototype.destroy = function()
200173
*
201174
* @method updateSourceImage
202175
* @param newSrc {String} the path of the image
176+
* @deprecated This method is deprecated. Please use Phaser.Sprite.loadTexture instead.
203177
*/
204178
PIXI.BaseTexture.prototype.updateSourceImage = function(newSrc)
205179
{
206-
this.hasLoaded = false;
207-
this.source.src = null;
208-
this.source.src = newSrc;
180+
console.warn("PIXI.BaseTexture.updateSourceImage is deprecated. Use Phaser.Sprite.loadTexture instead.");
209181
};
210182

211183
/**
@@ -249,49 +221,6 @@ PIXI.BaseTexture.prototype.unloadFromGPU = function()
249221
this.dirty();
250222
};
251223

252-
/**
253-
* Helper function that creates a base texture from the given image url.
254-
* If the image is not in the base texture cache it will be created and loaded.
255-
*
256-
* @static
257-
* @method fromImage
258-
* @param imageUrl {String} The image url of the texture
259-
* @param crossorigin {Boolean}
260-
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
261-
* @return {BaseTexture}
262-
*/
263-
PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
264-
{
265-
var baseTexture = PIXI.BaseTextureCache[imageUrl];
266-
267-
if(crossorigin === undefined && imageUrl.indexOf('data:') === -1) crossorigin = true;
268-
269-
if(!baseTexture)
270-
{
271-
// new Image() breaks tex loading in some versions of Chrome.
272-
// See https://code.google.com/p/chromium/issues/detail?id=238071
273-
var image = new Image();
274-
275-
if (crossorigin)
276-
{
277-
image.crossOrigin = '';
278-
}
279-
280-
image.src = imageUrl;
281-
baseTexture = new PIXI.BaseTexture(image, scaleMode);
282-
baseTexture.imageUrl = imageUrl;
283-
PIXI.BaseTextureCache[imageUrl] = baseTexture;
284-
285-
// if there is an @2x at the end of the url we are going to assume its a highres image
286-
if( imageUrl.indexOf(PIXI.RETINA_PREFIX + '.') !== -1)
287-
{
288-
baseTexture.resolution = 2;
289-
}
290-
}
291-
292-
return baseTexture;
293-
};
294-
295224
/**
296225
* Helper function that creates a base texture from the given canvas element.
297226
*
@@ -303,11 +232,6 @@ PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
303232
*/
304233
PIXI.BaseTexture.fromCanvas = function(canvas, scaleMode)
305234
{
306-
if (!canvas._pixiId)
307-
{
308-
canvas._pixiId = 'canvas_' + PIXI.TextureCacheIdGenerator++;
309-
}
310-
311235
if (canvas.width === 0)
312236
{
313237
canvas.width = 1;
@@ -318,13 +242,5 @@ PIXI.BaseTexture.fromCanvas = function(canvas, scaleMode)
318242
canvas.height = 1;
319243
}
320244

321-
var baseTexture = PIXI.BaseTextureCache[canvas._pixiId];
322-
323-
if (!baseTexture)
324-
{
325-
baseTexture = new PIXI.BaseTexture(canvas, scaleMode);
326-
PIXI.BaseTextureCache[canvas._pixiId] = baseTexture;
327-
}
328-
329-
return baseTexture;
245+
return new PIXI.BaseTexture(canvas, scaleMode);
330246
};

0 commit comments

Comments
 (0)