Skip to content

Commit 0501ca6

Browse files
committed
Merged latest Pixi dev build.
1 parent 3997a7c commit 0501ca6

12 files changed

Lines changed: 163 additions & 56 deletions

File tree

build/config.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
<script src="$path/src/pixi/textures/BaseTexture.js"></script>
7777
<script src="$path/src/pixi/textures/Texture.js"></script>
7878
<script src="$path/src/pixi/textures/RenderTexture.js"></script>
79+
<script src="$path/src/pixi/filters/AbstractFilter.js"></script>
80+
<script src="$path/src/pixi/filters/AsciiFilter.js"></script>
81+
<script src="$path/src/pixi/filters/TwistFilter.js"></script>
7982
8083
<script src="$path/src/Phaser.js"></script>
8184
<script src="$path/src/utils/Utils.js"></script>

src/pixi/display/Sprite.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ PIXI.Sprite = function(texture)
6464
* @type Number
6565
* @default 0xFFFFFF
6666
*/
67-
this.tint = 0xFFFFFF;// * Math.random();
67+
this.tint = 0xFFFFFF;
6868

6969
/**
7070
* The blend mode to be applied to the sprite
@@ -75,6 +75,16 @@ PIXI.Sprite = function(texture)
7575
*/
7676
this.blendMode = PIXI.blendModes.NORMAL;
7777

78+
79+
/**
80+
* The shader that will be used to render the texture to the stage.
81+
*
82+
* @property shader
83+
* @type PIXI.AbstractFilter
84+
* @default null
85+
*/
86+
this.shader = null;
87+
7888
if(texture.baseTexture.hasLoaded)
7989
{
8090
this.onTextureUpdate();
@@ -86,6 +96,7 @@ PIXI.Sprite = function(texture)
8696
}
8797

8898
this.renderable = true;
99+
89100
};
90101

91102
// constructor
@@ -292,10 +303,8 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
292303
{
293304
this.children[i]._renderWebGL(renderSession);
294305
}
306+
295307
}
296-
297-
298-
//TODO check culling
299308
};
300309

301310
/**

src/pixi/extras/Strip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ PIXI.Strip.prototype._renderStrip = function(renderSession)
125125
gl.uniformMatrix3fv(shader.translationMatrix, false, this.worldTransform.toArray(true));
126126
gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
127127
gl.uniform2f(shader.offsetVector, -offset.x, -offset.y);
128-
gl.uniform1f(shader.alpha, 1);
128+
gl.uniform1f(shader.alpha, this.worldAlpha);
129129

130130
if(!this.dirty)
131131
{
@@ -143,7 +143,7 @@ PIXI.Strip.prototype._renderStrip = function(renderSession)
143143
// check if a texture is dirty..
144144
if(this.texture.baseTexture._dirty[gl.id])
145145
{
146-
this.renderSession.renderer.updateTexture(this.texture.baseTexture);
146+
renderSession.renderer.updateTexture(this.texture.baseTexture);
147147
}
148148
else
149149
{

src/pixi/extras/TilingSprite.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
381381
{
382382
if (!this.texture.baseTexture.hasLoaded) return;
383383

384-
var texture = this.texture;
384+
var texture = this.originalTexture || this.texture;
385385
var frame = texture.frame;
386386
var targetWidth, targetHeight;
387387

@@ -458,5 +458,9 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
458458
}
459459

460460
this.refreshTexture = false;
461+
462+
this.originalTexture = this.texture;
463+
this.texture = this.tilingTexture;
464+
461465
this.tilingTexture.baseTexture._powerOf2 = true;
462466
};

src/pixi/filters/AbstractFilter.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,17 @@ PIXI.AbstractFilter = function(fragmentSrc, uniforms)
4444
*/
4545
this.fragmentSrc = fragmentSrc || [];
4646
};
47+
48+
PIXI.AbstractFilter.prototype.syncUniforms = function()
49+
{
50+
for(var i=0,j=this.shaders.length; i<j; i++)
51+
{
52+
this.shaders[i].dirty = true;
53+
}
54+
};
55+
/*
56+
PIXI.AbstractFilter.prototype.apply = function(frameBuffer)
57+
{
58+
// TODO :)
59+
};
60+
*/

src/pixi/renderers/canvas/CanvasRenderer.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ PIXI.CanvasRenderer = function(width, height, options)
131131
roundPixels: false
132132
};
133133

134+
this.mapBlendModes();
135+
134136
this.resize(width, height);
135137

136138
if("imageSmoothingEnabled" in this.context)
@@ -166,17 +168,20 @@ PIXI.CanvasRenderer.prototype.render = function(stage)
166168
this.context.fillStyle = "black";
167169
this.context.clear();
168170
}
169-
170-
if (!this.transparent && this.clearBeforeRender)
171-
{
172-
this.context.fillStyle = stage.backgroundColorString;
173-
this.context.fillRect(0, 0, this.width , this.height);
174-
}
175-
else if (this.transparent && this.clearBeforeRender)
171+
172+
if (this.clearBeforeRender)
176173
{
177-
this.context.clearRect(0, 0, this.width, this.height);
174+
if (this.transparent)
175+
{
176+
this.context.clearRect(0, 0, this.width, this.height);
177+
}
178+
else
179+
{
180+
this.context.fillStyle = stage.backgroundColorString;
181+
this.context.fillRect(0, 0, this.width , this.height);
182+
}
178183
}
179-
184+
180185
this.renderDisplayObject(stage);
181186

182187
// run interaction!

src/pixi/renderers/webgl/WebGLRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ PIXI.WebGLRenderer.prototype.resize = function(width, height)
315315
*/
316316
PIXI.WebGLRenderer.prototype.updateTexture = function(texture)
317317
{
318-
if(!texture.hasLoaded)return;
318+
if(!texture.hasLoaded )return;
319319

320320
var gl = this.gl;
321321

src/pixi/renderers/webgl/shaders/PixiShader.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ PIXI.PixiShader = function(gl)
3939
* @property {number} textureCount - A local texture counter for multi-texture shaders.
4040
*/
4141
this.textureCount = 0;
42+
this.firstRun = true;
43+
this.dirty = true;
4244

4345
this.attributes = [];
4446

@@ -289,7 +291,18 @@ PIXI.PixiShader.prototype.syncUniforms = function()
289291
if (uniform._init)
290292
{
291293
gl.activeTexture(gl['TEXTURE' + this.textureCount]);
292-
gl.bindTexture(gl.TEXTURE_2D, uniform.value.baseTexture._glTextures[gl.id] || PIXI.createWebGLTexture( uniform.value.baseTexture, gl));
294+
295+
if(uniform.value.baseTexture._dirty[gl.id])
296+
{
297+
PIXI.defaultRenderer.updateTexture(uniform.value.baseTexture);
298+
}
299+
else
300+
{
301+
// bind the current texture
302+
gl.bindTexture(gl.TEXTURE_2D, uniform.value.baseTexture._glTextures[gl.id]);
303+
}
304+
305+
// gl.bindTexture(gl.TEXTURE_2D, uniform.value.baseTexture._glTextures[gl.id] || PIXI.createWebGLTexture( uniform.value.baseTexture, gl));
293306
gl.uniform1i(uniform.uniformLocation, this.textureCount);
294307
this.textureCount++;
295308
}
@@ -323,7 +336,7 @@ PIXI.PixiShader.prototype.destroy = function()
323336
PIXI.PixiShader.defaultVertexSrc = [
324337
'attribute vec2 aVertexPosition;',
325338
'attribute vec2 aTextureCoord;',
326-
'attribute vec2 aColor;',
339+
'attribute vec4 aColor;',
327340

328341
'uniform vec2 projectionVector;',
329342
'uniform vec2 offsetVector;',

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock)
114114

115115
// update projection
116116
// now restore the regular shader..
117-
this.renderSession.shaderManager.setShader(this.defaultShader);
118-
gl.uniform2f(this.defaultShader.projectionVector, filterArea.width/2, -filterArea.height/2);
119-
gl.uniform2f(this.defaultShader.offsetVector, -filterArea.x, -filterArea.y);
117+
// this.renderSession.shaderManager.setShader(this.defaultShader);
118+
//gl.uniform2f(this.defaultShader.projectionVector, filterArea.width/2, -filterArea.height/2);
119+
//gl.uniform2f(this.defaultShader.offsetVector, -filterArea.x, -filterArea.y);
120120

121121
gl.colorMask(true, true, true, true);
122122
gl.clearColor(0,0,0, 0);
@@ -299,10 +299,10 @@ PIXI.WebGLFilterManager.prototype.popFilter = function()
299299
// apply!
300300
this.applyFilterPass(filter, filterArea, sizeX, sizeY);
301301

302-
// now restore the regular shader..
303-
this.renderSession.shaderManager.setShader(this.defaultShader);
304-
gl.uniform2f(this.defaultShader.projectionVector, sizeX/2, -sizeY/2);
305-
gl.uniform2f(this.defaultShader.offsetVector, -offsetX, -offsetY);
302+
// now restore the regular shader.. should happen automatically now..
303+
// this.renderSession.shaderManager.setShader(this.defaultShader);
304+
// gl.uniform2f(this.defaultShader.projectionVector, sizeX/2, -sizeY/2);
305+
// gl.uniform2f(this.defaultShader.offsetVector, -offsetX, -offsetY);
306306

307307
// return the texture to the pool
308308
this.texturePool.push(texture);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ PIXI.WebGLShaderManager = function()
1919
this.attribState[i] = false;
2020
}
2121

22+
this.stack = [];
23+
2224
//this.setContext(gl);
2325
// the final one is used for the rendering strips
2426
};

0 commit comments

Comments
 (0)