Skip to content

Commit 41396d5

Browse files
committed
Merged all of the relevant Pixi 2.2.7 fixes in (phaserjs#1621)
1 parent 03a2db1 commit 41396d5

6 files changed

Lines changed: 40 additions & 36 deletions

File tree

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ We've also removed functions and properties from Pixi classes that Phaser doesn'
192192
* Animation.update skips ahead frames when the system is lagging, however it failed to set the animation to the final frame in the sequence if the animation skipped ahead too far (thanks @richpixel #1628)
193193
* Loader.preloadSprite had an extra guard added to ensure it didn't try to updateCrop a non-existent sprite (thanks @noidexe #1636)
194194

195+
### Pixi 2.2.7 Bug Fixes
196+
197+
* SpriteBatch added fix to handle batch context loss on change.
198+
* RenderTexture resolution fix.
199+
* WebGL Filter Resolution fix.
200+
* TilingSprite fixes when masked in canvas mode.
201+
195202
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
196203

197204
![div](http://www.phaser.io/images/github/div.png)
@@ -361,12 +368,10 @@ We don't officially support any version of TypeScript before 1.4, however you ca
361368

362369
Here are some of the features planned for future releases. Not all are promised to be delivered and no timescale is given. But they serve as a good indication of the direction Phaser is heading in.
363370

364-
### Version 2.3 ("Tarabon")
371+
### Version 2.4
365372

366-
* New parallel asset loader (already started in dev branch)
367373
* Enhance the State Management, so you can perform non-destructive State swaps and persistence.
368374
* Updated Text handling
369-
* Look carefully at the internal structure of Phaser to avoid method repetition (such as Sprite.crop and Image.crop), investigate using mixins to help reduce overall codebase size.
370375
* Restore Math.interpolateAngles and Math.nearestAngleBetween
371376
* Scene Manager - json scene parser.
372377
* Touch Gestures.
@@ -376,12 +381,8 @@ Here are some of the features planned for future releases. Not all are promised
376381
* Allow Groups to be InputEnabled? Dragging a Group would be really useful.
377382
* Cache to localStorage using If-Modified-Since. [See github request](https://github.com/photonstorm/phaser/issues/495)
378383
* Allow for complex assets like Bitmap Fonts to be stored within a texture atlas.
379-
380-
### Version 2.4
381-
384+
* Add more support for [Legacy Audio Events](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events)
382385
* Ability to control DOM elements from the core game and layer them into the game.
383-
* Game parameters stored in Google Docs.
384-
* Optimised global Animation manager to cut down on object creation.
385386
* Flash CC HTML5 export integration.
386387
* Massively enhance the audio side of Phaser. Take more advantage of Web Audio: echo effects, positional sound, etc.
387388
* DragonBones support.

src/pixi/Pixi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PIXI.CANVAS_RENDERER = 1;
3737
* @property {String} VERSION
3838
* @static
3939
*/
40-
PIXI.VERSION = "v2.2.5c";
40+
PIXI.VERSION = "v2.2.7c";
4141

4242
// used to create uids for various pixi objects..
4343
PIXI._UID = 0;

src/pixi/display/SpriteBatch.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
* @constructor
2323
* @param texture {Texture}
2424
*/
25-
26-
//TODO RENAME to PARTICLE CONTAINER?
2725
PIXI.SpriteBatch = function(texture)
2826
{
2927
PIXI.DisplayObjectContainer.call( this);
@@ -72,10 +70,18 @@ PIXI.SpriteBatch.prototype.updateTransform = function()
7270
*/
7371
PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession)
7472
{
75-
if(!this.visible || this.alpha <= 0 || !this.children.length)return;
73+
if (!this.visible || this.alpha <= 0 || !this.children.length) return;
7674

77-
if(!this.ready)this.initWebGL( renderSession.gl );
75+
if (!this.ready)
76+
{
77+
this.initWebGL(renderSession.gl);
78+
}
7879

80+
if (this.fastSpriteBatch.gl !== renderSession.gl)
81+
{
82+
this.fastSpriteBatch.setContext(renderSession.gl);
83+
}
84+
7985
renderSession.spriteBatch.stop();
8086

8187
renderSession.shaderManager.setShader(renderSession.shaderManager.fastShader);
@@ -96,32 +102,32 @@ PIXI.SpriteBatch.prototype._renderWebGL = function(renderSession)
96102
*/
97103
PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
98104
{
99-
if(!this.visible || this.alpha <= 0 || !this.children.length)return;
105+
if (!this.visible || this.alpha <= 0 || !this.children.length) return;
100106

101107
var context = renderSession.context;
108+
102109
context.globalAlpha = this.worldAlpha;
103110

104111
this.displayObjectUpdateTransform();
105112

106113
var transform = this.worldTransform;
107-
// alow for trimming
108114

109115
var isRotated = true;
110116

111-
for (var i = 0; i < this.children.length; i++) {
112-
117+
for (var i = 0; i < this.children.length; i++)
118+
{
113119
var child = this.children[i];
114120

115-
if(!child.visible)continue;
121+
if (!child.visible) continue;
116122

117123
var texture = child.texture;
118124
var frame = texture.frame;
119125

120126
context.globalAlpha = this.worldAlpha * child.alpha;
121127

122-
if(child.rotation % (Math.PI * 2) === 0)
128+
if (child.rotation % (Math.PI * 2) === 0)
123129
{
124-
if(isRotated)
130+
if (isRotated)
125131
{
126132
context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty);
127133
isRotated = false;
@@ -140,7 +146,7 @@ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
140146
}
141147
else
142148
{
143-
if(!isRotated)isRotated = true;
149+
if (!isRotated) isRotated = true;
144150

145151
child.displayObjectUpdateTransform();
146152

@@ -166,12 +172,7 @@ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
166172
((child.anchor.y) * (-frame.height) + 0.5) | 0,
167173
frame.width,
168174
frame.height);
169-
170-
171175
}
172-
173-
// context.restore();
174176
}
175177

176-
// context.restore();
177178
};

src/pixi/extras/TilingSprite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
204204

205205
if (this._mask)
206206
{
207-
renderSession.maskManager.pushMask(this._mask, context);
207+
renderSession.maskManager.pushMask(this._mask, renderSession);
208208
}
209209

210210
context.globalAlpha = this.worldAlpha;
@@ -265,7 +265,7 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
265265

266266
if (this._mask)
267267
{
268-
renderSession.maskManager.popMask(renderSession.context);
268+
renderSession.maskManager.popMask(renderSession);
269269
}
270270

271271
for (i=0,j=this.children.length; i<j; i++)

src/pixi/renderers/webgl/utils/WebGLFilterManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ PIXI.WebGLFilterManager.prototype.popFilter = function()
286286

287287
gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uvArray);
288288

289-
gl.viewport(0, 0, sizeX, sizeY);
289+
gl.viewport(0, 0, sizeX * this.renderSession.resolution, sizeY * this.renderSession.resolution);
290290

291291
// bind the buffer
292292
gl.bindFramebuffer(gl.FRAMEBUFFER, buffer );

src/pixi/textures/RenderTexture.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ PIXI.RenderTexture = function(width, height, renderer, scaleMode, resolution)
9393

9494
PIXI.Texture.call(this,
9595
this.baseTexture,
96-
new PIXI.Rectangle(0, 0, this.width, this.height)
96+
new PIXI.Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution)
9797
);
9898

9999
/**
@@ -109,7 +109,7 @@ PIXI.RenderTexture = function(width, height, renderer, scaleMode, resolution)
109109
var gl = this.renderer.gl;
110110
this.baseTexture._dirty[gl.id] = false;
111111

112-
this.textureBuffer = new PIXI.FilterTexture(gl, this.width * this.resolution, this.height * this.resolution, this.baseTexture.scaleMode);
112+
this.textureBuffer = new PIXI.FilterTexture(gl, this.width, this.height, this.baseTexture.scaleMode);
113113
this.baseTexture._glTextures[gl.id] = this.textureBuffer.texture;
114114

115115
this.render = this.renderWebGL;
@@ -148,13 +148,15 @@ PIXI.RenderTexture.prototype.resize = function(width, height, updateBase)
148148

149149
this.valid = (width > 0 && height > 0);
150150

151-
this.width = this.frame.width = this.crop.width = width;
152-
this.height = this.frame.height = this.crop.height = height;
151+
this.width = width;
152+
this.height = height;
153+
this.frame.width = this.crop.width = width * this.resolution;
154+
this.frame.height = this.crop.height = height * this.resolution;
153155

154156
if (updateBase)
155157
{
156-
this.baseTexture.width = this.width;
157-
this.baseTexture.height = this.height;
158+
this.baseTexture.width = this.width * this.resolution;
159+
this.baseTexture.height = this.height * this.resolution;
158160
}
159161

160162
if (this.renderer.type === PIXI.WEBGL_RENDERER)
@@ -165,7 +167,7 @@ PIXI.RenderTexture.prototype.resize = function(width, height, updateBase)
165167

166168
if(!this.valid)return;
167169

168-
this.textureBuffer.resize(this.width * this.resolution, this.height * this.resolution);
170+
this.textureBuffer.resize(this.width, this.height);
169171
};
170172

171173
/**

0 commit comments

Comments
 (0)