2016-10-04 21:36:07 +00:00
|
|
|
/**
|
|
|
|
* Note that 'this' in all functions here refer to the owning object.
|
|
|
|
* For example the Group, Stage, Sprite, etc. because the render function
|
|
|
|
* here is mapped to the prototype for the game object.
|
|
|
|
*/
|
|
|
|
Phaser.Renderer.WebGL.GameObjects.Graphics = {
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
TYPES: [
|
|
|
|
Phaser.Graphics.prototype
|
|
|
|
],
|
2016-10-04 21:36:07 +00:00
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
render: function (renderer, src)
|
|
|
|
{
|
|
|
|
if (src.visible === false || src.alpha === 0 || src.isMask === true)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._cacheAsBitmap)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src.dirty || src.cachedSpriteDirty)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
src._generateCachedSprite();
|
2016-10-04 21:36:07 +00:00
|
|
|
|
|
|
|
// we will also need to update the texture on the gpu too!
|
2016-10-05 00:25:06 +00:00
|
|
|
src.updateCachedSpriteTexture();
|
2016-10-04 21:36:07 +00:00
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
src.cachedSpriteDirty = false;
|
|
|
|
src.dirty = false;
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
src._cachedSprite.worldAlpha = src.worldAlpha;
|
2016-10-04 21:36:07 +00:00
|
|
|
|
|
|
|
// PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite, renderSession);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
renderer.spriteBatch.stop();
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.setBlendMode(src.blendMode);
|
2016-10-04 21:36:07 +00:00
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._mask)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.pushMask(src._mask);
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._filters)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.filterManager.pushFilter(src._filterBlock);
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check blend mode
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src.blendMode !== renderer.spriteBatch.currentBlendMode)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.spriteBatch.currentBlendMode = src.blendMode;
|
2016-10-04 21:36:07 +00:00
|
|
|
|
|
|
|
var blendModeWebGL = renderer.blendModes[renderer.spriteBatch.currentBlendMode];
|
|
|
|
|
|
|
|
renderer.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if the webgl graphic needs to be updated
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src.webGLDirty)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
src.dirty = true;
|
|
|
|
src.webGLDirty = false;
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Merge with this class
|
|
|
|
// PIXI.WebGLGraphics.renderGraphics(this, renderSession);
|
|
|
|
|
|
|
|
// only render if it has children!
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src.children.length)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
|
|
|
renderer.spriteBatch.start();
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
for (var i = 0; i < src.children.length; i++)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
var child = src.children[i];
|
|
|
|
child.render(renderer, child);
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderer.spriteBatch.stop();
|
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._filters)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
|
|
|
renderer.filterManager.popFilter();
|
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._mask)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.popMask(src.mask);
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderer.drawCount++;
|
|
|
|
|
|
|
|
renderer.spriteBatch.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|