mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Add onRunBegin
and onRunEnd
to RenderNodes.
Also make `manager` available in `BatchHandler._copyAndCompleteConfig`.
This commit is contained in:
parent
82738c78f2
commit
5c4d978556
9 changed files with 68 additions and 5 deletions
|
@ -38,7 +38,7 @@ var BatchHandler = new Class({
|
|||
var renderer = manager.renderer;
|
||||
var gl = renderer.gl;
|
||||
|
||||
config = this._copyAndCompleteConfig(config || {}, defaultConfig);
|
||||
config = this._copyAndCompleteConfig(manager, config || {}, defaultConfig);
|
||||
|
||||
var name = config.name;
|
||||
if (!name)
|
||||
|
@ -264,10 +264,11 @@ var BatchHandler = new Class({
|
|||
* @method Phaser.Renderer.WebGL.RenderNodes.BatchHandler#_copyAndCompleteConfig
|
||||
* @since 3.90.0
|
||||
* @private
|
||||
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||
* @param {Phaser.Renderer.WebGL.RenderNodes.BatchHandlerConfig} config - The configuration object.
|
||||
* @param {Phaser.Renderer.WebGL.RenderNodes.BatchHandlerConfig} defaultConfig - The default configuration object.
|
||||
*/
|
||||
_copyAndCompleteConfig: function (config, defaultConfig)
|
||||
_copyAndCompleteConfig: function (manager, config, defaultConfig)
|
||||
{
|
||||
var newConfig = {};
|
||||
|
||||
|
|
|
@ -57,6 +57,8 @@ var Camera = new Class({
|
|||
*/
|
||||
run: function (drawingContext, children, camera, parentTransformMatrix)
|
||||
{
|
||||
this.onRunBegin(drawingContext);
|
||||
|
||||
var currentContext = drawingContext;
|
||||
|
||||
var cx = camera.x;
|
||||
|
@ -111,6 +113,8 @@ var Camera = new Class({
|
|||
camera.dirty = false;
|
||||
|
||||
camera.emit(CameraEvents.POST_RENDER, camera);
|
||||
|
||||
this.onRunEnd(drawingContext);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ var FillCamera = new Class({
|
|||
*/
|
||||
run: function (drawingContext, color)
|
||||
{
|
||||
this.onRunBegin(drawingContext);
|
||||
|
||||
var camera = drawingContext.camera;
|
||||
var cx = camera.x;
|
||||
var cy = camera.y;
|
||||
|
@ -53,6 +55,8 @@ var FillCamera = new Class({
|
|||
var ch = camera.height;
|
||||
|
||||
this.fillRectNode.run(drawingContext, null, cx, cy, cw, ch, color, color, color, color, 2);
|
||||
|
||||
this.onRunEnd(drawingContext);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@ var FillRect = new Class({
|
|||
*/
|
||||
run: function (drawingContext, parentMatrix, x, y, width, height, tintTL, tintTR, tintBL, tintBR, tintFill, inWorldSpace)
|
||||
{
|
||||
this.onRunBegin(drawingContext);
|
||||
|
||||
var currentMatrix = this._identityMatrix;
|
||||
|
||||
if (inWorldSpace)
|
||||
|
@ -110,6 +112,8 @@ var FillRect = new Class({
|
|||
// Tint colors in TRIANGLE_STRIP order:
|
||||
tintTL, tintTR, tintBL, tintBR
|
||||
);
|
||||
|
||||
this.onRunEnd(drawingContext);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -119,6 +119,8 @@ var GameObjectBatcher = new Class({
|
|||
*/
|
||||
run: function (drawingContext, gameObject, parentMatrix)
|
||||
{
|
||||
this.onRunBegin(drawingContext);
|
||||
|
||||
var frame = gameObject.frame;
|
||||
var frameX = frame.x;
|
||||
var frameY = frame.y;
|
||||
|
@ -242,7 +244,7 @@ var GameObjectBatcher = new Class({
|
|||
tintTL, tintTR, tintBL, tintBR
|
||||
);
|
||||
|
||||
return;
|
||||
this.onRunEnd(drawingContext);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ var ListCompositor = new Class({
|
|||
*/
|
||||
run: function (displayContext, children, parentTransformMatrix)
|
||||
{
|
||||
this.onRunBegin(displayContext);
|
||||
|
||||
var currentContext = displayContext;
|
||||
var baseBlendMode = displayContext.blendMode;
|
||||
var currentBlendMode = baseBlendMode;
|
||||
|
@ -81,6 +83,8 @@ var ListCompositor = new Class({
|
|||
{
|
||||
currentContext.release();
|
||||
}
|
||||
|
||||
this.onRunEnd(displayContext);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -174,6 +174,21 @@ var QuadBatchHandler = new Class({
|
|||
this.resize(renderer.width, renderer.height);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called at the beginning of the `run` method.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.RenderNodes.BatchHandler#onRunBegin
|
||||
* @since 3.90.0
|
||||
* @param {Phaser.Types.Renderer.WebGL.DrawingContext} drawingContext - The current drawing context.
|
||||
*/
|
||||
onRunBegin: function (drawingContext)
|
||||
{
|
||||
this.program.setUniform(
|
||||
'uRoundPixels',
|
||||
drawingContext.camera.roundPixels
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Draw then empty the current batch.
|
||||
*
|
||||
|
@ -188,6 +203,8 @@ var QuadBatchHandler = new Class({
|
|||
{
|
||||
if (this.instanceCount === 0) { return; }
|
||||
|
||||
this.onRunBegin(drawingContext);
|
||||
|
||||
var bytesPerIndexPerInstance = this.bytesPerIndexPerInstance;
|
||||
var indicesPerInstance = this.indicesPerInstance;
|
||||
var program = this.program;
|
||||
|
@ -210,8 +227,6 @@ var QuadBatchHandler = new Class({
|
|||
vertexBuffer.update(this.vertexBufferLayout.data);
|
||||
}
|
||||
|
||||
this.program.setUniform('uRoundPixels', drawingContext.camera.roundPixels);
|
||||
|
||||
var subBatches = this.batchEntries.length;
|
||||
for (var i = 0; i < subBatches; i++)
|
||||
{
|
||||
|
@ -230,6 +245,8 @@ var QuadBatchHandler = new Class({
|
|||
this.instanceCount = 0;
|
||||
this.currentBatchEntry.start = 0;
|
||||
this.batchEntries.length = 0;
|
||||
|
||||
this.onRunEnd(drawingContext);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,6 +70,32 @@ var RenderNode = new Class({
|
|||
// Insert code here.
|
||||
},
|
||||
|
||||
/**
|
||||
* By default this is an empty method hook that you can override and use in your own custom render nodes.
|
||||
*
|
||||
* This method is called at the start of the `run` method.
|
||||
* Don't forget to call it in your custom method.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.RenderNodes.RenderNode#onRunBegin
|
||||
* @since 3.90.0
|
||||
* @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The context currently in use.
|
||||
*/
|
||||
onRunBegin: function (drawingContext)
|
||||
{},
|
||||
|
||||
/**
|
||||
* By default this is an empty method hook that you can override and use in your own custom render nodes.
|
||||
*
|
||||
* This method is called at the end of the `run` method.
|
||||
* Don't forget to call it in your custom method.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.RenderNodes.RenderNode#onRunEnd
|
||||
* @since 3.90.0
|
||||
* @param {Phaser.Renderer.WebGL.DrawingContext} drawingContext - The context currently in use.
|
||||
*/
|
||||
onRunEnd: function (drawingContext)
|
||||
{},
|
||||
|
||||
/**
|
||||
* Set whether the node should report debug information.
|
||||
* It wraps the `run` method with additional debug information.
|
||||
|
|
|
@ -14,6 +14,7 @@ var RenderNodes = {
|
|||
FillCamera: require('./FillCamera'),
|
||||
FillRect: require('./FillRect'),
|
||||
GameObjectBatcher: require('./GameObjectBatcher'),
|
||||
ListCompositor: require('./ListCompositor'),
|
||||
QuadBatchHandler: require('./QuadBatchHandler'),
|
||||
RenderNode: require('./RenderNode')
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue