mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 14:40:38 +00:00
Remove renderer from RenderNode parameters.
It's easy to access via the manager parameter.
This commit is contained in:
parent
7e16caeed7
commit
d1a38d55c0
9 changed files with 32 additions and 44 deletions
|
@ -27,15 +27,15 @@ var RenderNode = require('./RenderNode');
|
||||||
* @since 3.90.0
|
* @since 3.90.0
|
||||||
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||||
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The renderer that owns this RenderNode.
|
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.BatchHandlerConfig} [config] - The configuration object for this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.BatchHandlerConfig} [config] - The configuration object for this RenderNode.
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.BatchHandlerConfig} defaultConfig - The default configuration object for this RenderNode. This is used to ensure all required properties are present, so it must be complete.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.BatchHandlerConfig} defaultConfig - The default configuration object for this RenderNode. This is used to ensure all required properties are present, so it must be complete.
|
||||||
*/
|
*/
|
||||||
var BatchHandler = new Class({
|
var BatchHandler = new Class({
|
||||||
Extends: RenderNode,
|
Extends: RenderNode,
|
||||||
|
|
||||||
initialize: function BatchHandler (manager, renderer, config, defaultConfig)
|
initialize: function BatchHandler (manager, config, defaultConfig)
|
||||||
{
|
{
|
||||||
|
var renderer = manager.renderer;
|
||||||
var gl = renderer.gl;
|
var gl = renderer.gl;
|
||||||
|
|
||||||
config = this._copyAndCompleteConfig(config || {}, defaultConfig);
|
config = this._copyAndCompleteConfig(config || {}, defaultConfig);
|
||||||
|
@ -46,7 +46,7 @@ var BatchHandler = new Class({
|
||||||
throw new Error('BatchHandler must have a name');
|
throw new Error('BatchHandler must have a name');
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderNode.call(this, name, manager, renderer);
|
RenderNode.call(this, name, manager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of instances per batch, used to determine the size of the
|
* The number of instances per batch, used to determine the size of the
|
||||||
|
@ -79,7 +79,7 @@ var BatchHandler = new Class({
|
||||||
// Calculate the final number of instances per batch.
|
// Calculate the final number of instances per batch.
|
||||||
var indexLimit = 65536; // 2^16
|
var indexLimit = 65536; // 2^16
|
||||||
var maxInstances = Math.floor(indexLimit / this.verticesPerInstance);
|
var maxInstances = Math.floor(indexLimit / this.verticesPerInstance);
|
||||||
var targetInstances = config.instancesPerBatch || this.renderer.config.batchSize || maxInstances;
|
var targetInstances = config.instancesPerBatch || renderer.config.batchSize || maxInstances;
|
||||||
this.instancesPerBatch = Math.min(targetInstances, maxInstances);
|
this.instancesPerBatch = Math.min(targetInstances, maxInstances);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,7 +247,7 @@ var BatchHandler = new Class({
|
||||||
|
|
||||||
// Set the dimension-related uniforms and listen for resize events.
|
// Set the dimension-related uniforms and listen for resize events.
|
||||||
this.resize(renderer.width, renderer.height);
|
this.resize(renderer.width, renderer.height);
|
||||||
this.renderer.on(Phaser.Renderer.Events.RESIZE, this.resize, this);
|
renderer.on(Phaser.Renderer.Events.RESIZE, this.resize, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,14 +16,13 @@ var RenderNode = require('./RenderNode');
|
||||||
* @since 3.90.0
|
* @since 3.90.0
|
||||||
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||||
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The renderer that owns this RenderNode.
|
|
||||||
*/
|
*/
|
||||||
var Camera = new Class({
|
var Camera = new Class({
|
||||||
Extends: RenderNode,
|
Extends: RenderNode,
|
||||||
|
|
||||||
initialize: function Camera (manager, renderer)
|
initialize: function Camera (manager)
|
||||||
{
|
{
|
||||||
RenderNode.call(this, 'Camera', manager, renderer);
|
RenderNode.call(this, 'Camera', manager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The RenderNode that handles filling the camera with a
|
* The RenderNode that handles filling the camera with a
|
||||||
|
|
|
@ -17,14 +17,13 @@ var RenderNode = require('./RenderNode');
|
||||||
* @since 3.90.0
|
* @since 3.90.0
|
||||||
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||||
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The renderer that owns this RenderNode.
|
|
||||||
*/
|
*/
|
||||||
var FillCamera = new Class({
|
var FillCamera = new Class({
|
||||||
Extends: RenderNode,
|
Extends: RenderNode,
|
||||||
|
|
||||||
initialize: function FillCamera (manager, renderer)
|
initialize: function FillCamera (manager)
|
||||||
{
|
{
|
||||||
RenderNode.call(this, 'FillCamera', manager, renderer);
|
RenderNode.call(this, 'FillCamera', manager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The RenderNode that draws a filled rectangle.
|
* The RenderNode that draws a filled rectangle.
|
||||||
|
|
|
@ -22,14 +22,13 @@ var RenderNode = require('./RenderNode');
|
||||||
* @since 3.90.0
|
* @since 3.90.0
|
||||||
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||||
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The renderer that owns this RenderNode.
|
|
||||||
*/
|
*/
|
||||||
var FillRect = new Class({
|
var FillRect = new Class({
|
||||||
Extends: RenderNode,
|
Extends: RenderNode,
|
||||||
|
|
||||||
initialize: function FillRect (manager, renderer)
|
initialize: function FillRect (manager)
|
||||||
{
|
{
|
||||||
RenderNode.call(this, 'FillRect', manager, renderer);
|
RenderNode.call(this, 'FillRect', manager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The QuadBatchHandler that handles the rendering of quads.
|
* The QuadBatchHandler that handles the rendering of quads.
|
||||||
|
@ -95,7 +94,7 @@ var FillRect = new Class({
|
||||||
|
|
||||||
this.quadBatchHandlerNode.batch(
|
this.quadBatchHandlerNode.batch(
|
||||||
drawingContext,
|
drawingContext,
|
||||||
this.renderer.whiteTexture,
|
this.manager.renderer.whiteTexture,
|
||||||
|
|
||||||
// Quad vertices in TRIANGLE_STRIP order:
|
// Quad vertices in TRIANGLE_STRIP order:
|
||||||
quad[0], quad[1],
|
quad[0], quad[1],
|
||||||
|
|
|
@ -44,19 +44,18 @@ var getTint = Utils.getTintAppendFloatAlpha;
|
||||||
* @since 3.90.0
|
* @since 3.90.0
|
||||||
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||||
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The renderer that owns this RenderNode.
|
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.GameObjectBatcherConfig} [config] - The configuration object for this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.GameObjectBatcherConfig} [config] - The configuration object for this RenderNode.
|
||||||
*/
|
*/
|
||||||
var GameObjectBatcher = new Class({
|
var GameObjectBatcher = new Class({
|
||||||
Extends: RenderNode,
|
Extends: RenderNode,
|
||||||
|
|
||||||
initialize: function GameObjectBatcher (manager, renderer, config)
|
initialize: function GameObjectBatcher (manager, config)
|
||||||
{
|
{
|
||||||
if (config === undefined) { config = {}; }
|
if (config === undefined) { config = {}; }
|
||||||
|
|
||||||
var name = config.name || 'GameObjectBatcher';
|
var name = config.name || 'GameObjectBatcher';
|
||||||
|
|
||||||
RenderNode.call(this, name, manager, renderer);
|
RenderNode.call(this, name, manager);
|
||||||
|
|
||||||
var batchHandler = 'QuadBatchHandler';
|
var batchHandler = 'QuadBatchHandler';
|
||||||
if (config.batchHandler)
|
if (config.batchHandler)
|
||||||
|
|
|
@ -16,14 +16,13 @@ var RenderNode = require('./RenderNode');
|
||||||
* @since 3.90.0
|
* @since 3.90.0
|
||||||
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
* @extends Phaser.Renderer.WebGL.RenderNodes.RenderNode
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||||
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The renderer that owns this RenderNode.
|
|
||||||
*/
|
*/
|
||||||
var ListCompositor = new Class({
|
var ListCompositor = new Class({
|
||||||
Extends: RenderNode,
|
Extends: RenderNode,
|
||||||
|
|
||||||
initialize: function ListCompositor (manager, renderer)
|
initialize: function ListCompositor (manager)
|
||||||
{
|
{
|
||||||
RenderNode.call(this, 'ListCompositor', manager, renderer);
|
RenderNode.call(this, 'ListCompositor', manager);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +42,7 @@ var ListCompositor = new Class({
|
||||||
var currentContext = displayContext;
|
var currentContext = displayContext;
|
||||||
var baseBlendMode = displayContext.blendMode;
|
var baseBlendMode = displayContext.blendMode;
|
||||||
var currentBlendMode = baseBlendMode;
|
var currentBlendMode = baseBlendMode;
|
||||||
|
var renderer = this.manager.renderer;
|
||||||
|
|
||||||
// Render each child in the display list
|
// Render each child in the display list
|
||||||
for (var i = 0; i < children.length; i++)
|
for (var i = 0; i < children.length; i++)
|
||||||
|
@ -73,7 +73,7 @@ var ListCompositor = new Class({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
child.renderWebGL(this.renderer, child, currentContext, parentTransformMatrix);
|
child.renderWebGL(renderer, child, currentContext, parentTransformMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release any remaining context.
|
// Release any remaining context.
|
||||||
|
|
|
@ -20,19 +20,18 @@ var BatchHandler = require('./BatchHandler');
|
||||||
* @constructor
|
* @constructor
|
||||||
* @since 3.90.0
|
* @since 3.90.0
|
||||||
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||||
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The renderer that owns this RenderNode.
|
|
||||||
* @param {Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig} [config] - The configuration object for this handler.
|
* @param {Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig} [config] - The configuration object for this handler.
|
||||||
*/
|
*/
|
||||||
var QuadBatchHandler = new Class({
|
var QuadBatchHandler = new Class({
|
||||||
Extends: BatchHandler,
|
Extends: BatchHandler,
|
||||||
|
|
||||||
initialize: function QuadBatchHandler (manager, renderer, config)
|
initialize: function QuadBatchHandler (manager, config)
|
||||||
{
|
{
|
||||||
BatchHandler.call(this, manager, renderer, config, this.defaultConfig);
|
BatchHandler.call(this, manager, config, this.defaultConfig);
|
||||||
|
|
||||||
// Main sampler will never change after initialization,
|
// Main sampler will never change after initialization,
|
||||||
// because it addresses texture units, not textures.
|
// because it addresses texture units, not textures.
|
||||||
this.program.setUniform('uMainSampler[0]', this.renderer.textureUnitIndices);
|
this.program.setUniform('uMainSampler[0]', this.manager.renderer.textureUnitIndices);
|
||||||
},
|
},
|
||||||
|
|
||||||
defaultConfig: {
|
defaultConfig: {
|
||||||
|
@ -112,7 +111,7 @@ var QuadBatchHandler = new Class({
|
||||||
resize: function (width, height)
|
resize: function (width, height)
|
||||||
{
|
{
|
||||||
this.program.setUniform('uResolution', [ width, height ]);
|
this.program.setUniform('uResolution', [ width, height ]);
|
||||||
this.program.setUniform('uProjectionMatrix', this.renderer.projectionMatrix.val);
|
this.program.setUniform('uProjectionMatrix', this.manager.renderer.projectionMatrix.val);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,12 +135,14 @@ var QuadBatchHandler = new Class({
|
||||||
*/
|
*/
|
||||||
updateTextureCount: function (count)
|
updateTextureCount: function (count)
|
||||||
{
|
{
|
||||||
|
var renderer = this.manager.renderer;
|
||||||
|
|
||||||
if (count === undefined)
|
if (count === undefined)
|
||||||
{
|
{
|
||||||
count = this.renderer.maxTextures;
|
count = renderer.maxTextures;
|
||||||
}
|
}
|
||||||
|
|
||||||
var newCount = Math.max(1, Math.min(count, this.renderer.maxTextures));
|
var newCount = Math.max(1, Math.min(count, renderer.maxTextures));
|
||||||
if (newCount === this.texturesPerBatch)
|
if (newCount === this.texturesPerBatch)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -168,9 +169,9 @@ var QuadBatchHandler = new Class({
|
||||||
|
|
||||||
this.program.setUniform(
|
this.program.setUniform(
|
||||||
'uMainSampler[0]',
|
'uMainSampler[0]',
|
||||||
this.renderer.textureUnitIndices
|
renderer.textureUnitIndices
|
||||||
);
|
);
|
||||||
this.resize(this.renderer.width, this.renderer.height);
|
this.resize(renderer.width, renderer.height);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,7 +192,7 @@ var QuadBatchHandler = new Class({
|
||||||
var indicesPerInstance = this.indicesPerInstance;
|
var indicesPerInstance = this.indicesPerInstance;
|
||||||
var program = this.program;
|
var program = this.program;
|
||||||
var vao = this.vao;
|
var vao = this.vao;
|
||||||
var renderer = this.renderer;
|
var renderer = this.manager.renderer;
|
||||||
var vertexBuffer = this.vertexBufferLayout.buffer;
|
var vertexBuffer = this.vertexBufferLayout.buffer;
|
||||||
|
|
||||||
// Finalize the current batch entry.
|
// Finalize the current batch entry.
|
||||||
|
|
|
@ -16,13 +16,13 @@ var Class = require('../../../utils/Class');
|
||||||
* @constructor
|
* @constructor
|
||||||
* @since 3.90.0
|
* @since 3.90.0
|
||||||
* @param {string} name - The name of the RenderNode.
|
* @param {string} name - The name of the RenderNode.
|
||||||
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The renderer that owns this RenderNode.
|
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
|
||||||
*/
|
*/
|
||||||
var RenderNode = new Class({
|
var RenderNode = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function RenderNode (name, manager, renderer)
|
function RenderNode (name, manager)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name of the RenderNode.
|
* The name of the RenderNode.
|
||||||
|
@ -42,15 +42,6 @@ var RenderNode = new Class({
|
||||||
*/
|
*/
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
|
||||||
/**
|
|
||||||
* The renderer that owns this RenderNode.
|
|
||||||
*
|
|
||||||
* @name Phaser.Renderer.WebGL.RenderNodes.RenderNode#renderer
|
|
||||||
* @type {Phaser.Renderer.WebGL.WebGLRenderer}
|
|
||||||
* @since 3.90.0
|
|
||||||
*/
|
|
||||||
this.renderer = renderer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to the original `run` method of this node.
|
* Reference to the original `run` method of this node.
|
||||||
* Used when `setDebug` is enabled.
|
* Used when `setDebug` is enabled.
|
||||||
|
|
|
@ -238,7 +238,7 @@ var RenderNodeManager = new Class({
|
||||||
}
|
}
|
||||||
if (this._nodeConstructors[name])
|
if (this._nodeConstructors[name])
|
||||||
{
|
{
|
||||||
var node = new this._nodeConstructors[name](this, this.renderer);
|
var node = new this._nodeConstructors[name](this);
|
||||||
this.addNode(name, node);
|
this.addNode(name, node);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue