mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Optimized TextureTintPipeline.drawBlitter so it skips bobs that have alpha of zero and only calls setTexture2D
if the bob sourceIndex has changed, previously it called it for every single bob.
This commit is contained in:
parent
7df0488100
commit
835bc37e32
2 changed files with 19 additions and 4 deletions
|
@ -9,6 +9,7 @@
|
|||
* WebGLRenderer.config has a new property `maxTextures` which is derived from `gl.MAX_TEXTURE_IMAGE_UNITS`, you can get it via the new method `getMaxTextures()`.
|
||||
* WebGLRenderer.config has a new property `maxTextureSize` which is derived from `gl.MAX_TEXTURE_SIZE`, you can get it via the new method `getMaxTextureSize()`
|
||||
* WebGLRenderer has a new property `compression` which holds the browser / devices compressed texture support gl extensions, which is populated during `init`.
|
||||
* Optimized TextureTintPipeline.drawBlitter so it skips bobs that have alpha of zero and only calls `setTexture2D` if the bob sourceIndex has changed, previously it called it for every single bob.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -664,6 +664,8 @@ var TextureTintPipeline = new Class({
|
|||
var blitterX = blitter.x - cameraScrollX;
|
||||
var blitterY = blitter.y - cameraScrollY;
|
||||
|
||||
var prevTextureSourceIndex;
|
||||
|
||||
for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex)
|
||||
{
|
||||
var batchSize = Math.min(length, this.maxQuads);
|
||||
|
@ -673,6 +675,13 @@ var TextureTintPipeline = new Class({
|
|||
var bob = list[batchOffset + index];
|
||||
var frame = bob.frame;
|
||||
var alpha = bob.alpha;
|
||||
|
||||
if (alpha === 0)
|
||||
{
|
||||
// Nothing to see here, moving on ...
|
||||
continue;
|
||||
}
|
||||
|
||||
var tint = getTint(0xffffff, alpha);
|
||||
var uvs = frame.uvs;
|
||||
var flipX = bob.flipX;
|
||||
|
@ -688,10 +697,13 @@ var TextureTintPipeline = new Class({
|
|||
var tx1 = xw * a + yh * c + e;
|
||||
var ty1 = xw * b + yh * d + f;
|
||||
|
||||
// Bind Texture if texture wasn't bound.
|
||||
// This needs to be here because of multiple
|
||||
// texture atlas.
|
||||
this.setTexture2D(frame.texture.source[frame.sourceIndex].glTexture, 0);
|
||||
// Bind texture only if the Texture Source is different from before
|
||||
if (frame.sourceIndex !== prevTextureSourceIndex)
|
||||
{
|
||||
this.setTexture2D(frame.texture.source[frame.sourceIndex].glTexture, 0);
|
||||
|
||||
prevTextureSourceIndex = frame.sourceIndex;
|
||||
}
|
||||
|
||||
var vertexOffset = this.vertexCount * this.vertexComponentCount;
|
||||
|
||||
|
@ -739,6 +751,8 @@ var TextureTintPipeline = new Class({
|
|||
if (this.vertexCount >= this.vertexCapacity)
|
||||
{
|
||||
this.flush();
|
||||
|
||||
prevTextureSourceIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue