Cache working OK.

Performance increased in 20% for static objects.
This commit is contained in:
Ricardo Quesada 2014-02-28 16:10:48 -08:00
parent 13b60c8759
commit d78304599d
88 changed files with 338 additions and 357 deletions

View File

@ -35,7 +35,6 @@ THE SOFTWARE.
#include "CCDirector.h"
#include "TransformUtils.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCQuadCommand.h"
// external
#include "kazmath/GL/matrix.h"
@ -110,8 +109,7 @@ bool AtlasNode::initWithTexture(Texture2D* texture, int tileWidth, int tileHeigh
_quadsToDraw = itemsToRender;
// shader stuff
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR));
_uniformColor = glGetUniformLocation( getShaderProgram()->getProgram(), "u_color");
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
return true;
}
@ -138,20 +136,18 @@ void AtlasNode::updateAtlasValues()
}
// AtlasNode - draw
void AtlasNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void AtlasNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
_quadCommand.init(
_globalZOrder,
_textureAtlas->getTexture()->getName(),
shader,
_shaderProgram,
_blendFunc,
_textureAtlas->getQuads(),
_quadsToDraw,
_modelViewTransform);
transform);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
renderer->addCommand(&_quadCommand);
}

View File

@ -69,7 +69,7 @@ public:
// Overrides
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual Texture2D* getTexture() const override;
virtual void setTexture(Texture2D *texture) override;
virtual bool isOpacityModifyRGB() const override;

View File

@ -199,14 +199,15 @@ void ClippingNode::drawFullScreenQuadClearStencil()
kmGLPopMatrix();
}
void ClippingNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void ClippingNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
if(!_visible)
return;
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,

View File

@ -95,7 +95,7 @@ public:
* @lua NA
*/
virtual void onExit() override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
protected:
ClippingNode();

View File

@ -282,7 +282,7 @@ void Director::drawScene()
// draw the scene
if (_runningScene)
{
_runningScene->visit(_renderer, identity, true);
_runningScene->visit(_renderer, identity, false);
_eventDispatcher->dispatchEvent(_eventAfterVisit);
}

View File

@ -239,11 +239,11 @@ void DrawNode::render()
CHECK_GL_ERROR_DEBUG();
}
void DrawNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void DrawNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void DrawNode::onDraw()

View File

@ -92,7 +92,7 @@ public:
void onDraw();
// Overrides
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
DrawNode();

View File

@ -679,23 +679,24 @@ void Label::onDraw()
CC_PROFILER_STOP("Label - draw");
}
void Label::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void Label::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
if (! _visible)
{
return;
}
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,

View File

@ -128,8 +128,8 @@ public:
void addChild(Node * child, int zOrder=0, int tag=0) override;
virtual std::string getDescription() const override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual void onDraw();
virtual FontAtlas* getFontAtlas() const {return _fontAtlas;}

View File

@ -581,11 +581,11 @@ void LayerColor::updateColor()
}
}
void LayerColor::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void LayerColor::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
for(int i = 0; i < 4; ++i)
{

View File

@ -37,7 +37,6 @@ THE SOFTWARE.
#include "CCEventKeyboard.h"
#include "renderer/CCCustomCommand.h"
#include "renderer/CCQuadCommand.h"
NS_CC_BEGIN
@ -266,7 +265,7 @@ public:
//
// Overrides
//
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual void onDraw();
virtual void setContentSize(const Size & var) override;

View File

@ -328,7 +328,7 @@ void MotionStreak::reset()
void MotionStreak::onDraw()
{
getShaderProgram()->use();
getShaderProgram()->setUniformsForBuiltins(_cachedMV);
getShaderProgram()->setUniformsForBuiltins(_modelViewTransform);
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
GL::blendFunc( _blendFunc.src, _blendFunc.dst );
@ -352,16 +352,16 @@ void MotionStreak::onDraw()
#endif // EMSCRIPTEN
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nuPoints*2);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2);
}
void MotionStreak::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void MotionStreak::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
if(_nuPoints <= 1)
return;
kmGLGetMatrix(KM_GL_MODELVIEW,&_cachedMV);
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}

View File

@ -78,7 +78,7 @@ public:
* @js NA
* @lua NA
*/
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
/**
* @js NA
* @lua NA
@ -102,19 +102,9 @@ public:
virtual bool isOpacityModifyRGB() const override;
protected:
kmMat4 _cachedMV;
//renderer callback
void onDraw();
protected:
/**
* @js ctor
*/
MotionStreak();
/**
* @js NA
* @lua NA
*/
virtual ~MotionStreak();
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */

View File

@ -92,6 +92,7 @@ Node::Node(void)
, _useAdditionalTransform(false)
, _transformDirty(true)
, _inverseDirty(true)
, _transformUpdated(true)
// children (lazy allocs)
// lazy alloc
, _localZOrder(0)
@ -193,7 +194,7 @@ void Node::setSkewX(float skewX)
return;
_skewX = skewX;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
float Node::getSkewY() const
@ -207,7 +208,7 @@ void Node::setSkewY(float skewY)
return;
_skewY = skewY;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
@ -255,7 +256,7 @@ void Node::setRotation(float rotation)
return;
_rotationZ_X = _rotationZ_Y = rotation;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
#if CC_USE_PHYSICS
if (_physicsBody)
@ -277,7 +278,7 @@ void Node::setRotation3D(const Vertex3F& rotation)
_rotationZ_X == rotation.z)
return;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
_rotationX = rotation.x;
_rotationY = rotation.y;
@ -307,7 +308,7 @@ void Node::setRotationSkewX(float rotationX)
return;
_rotationZ_X = rotationX;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
float Node::getRotationSkewY() const
@ -321,7 +322,7 @@ void Node::setRotationSkewY(float rotationY)
return;
_rotationZ_Y = rotationY;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
/// scale getter
@ -338,7 +339,7 @@ void Node::setScale(float scale)
return;
_scaleX = _scaleY = _scaleZ = scale;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
/// scaleX getter
@ -355,7 +356,7 @@ void Node::setScale(float scaleX,float scaleY)
_scaleX = scaleX;
_scaleY = scaleY;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
/// scaleX setter
@ -365,7 +366,7 @@ void Node::setScaleX(float scaleX)
return;
_scaleX = scaleX;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
/// scaleY getter
@ -381,7 +382,7 @@ void Node::setScaleZ(float scaleZ)
return;
_scaleZ = scaleZ;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
/// scaleY getter
@ -397,7 +398,7 @@ void Node::setScaleY(float scaleY)
return;
_scaleY = scaleY;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
@ -414,7 +415,7 @@ void Node::setPosition(const Point& position)
return;
_position = position;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
#if CC_USE_PHYSICS
if (_physicsBody)
@ -480,7 +481,7 @@ void Node::setPositionZ(float positionZ)
if (_positionZ == positionZ)
return;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
_positionZ = positionZ;
@ -538,7 +539,7 @@ void Node::setAnchorPoint(const Point& point)
{
_anchorPoint = point;
_anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
}
@ -555,7 +556,7 @@ void Node::setContentSize(const Size & size)
_contentSize = size;
_anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
}
@ -582,7 +583,7 @@ void Node::ignoreAnchorPointForPosition(bool newValue)
if (newValue != _ignoreAnchorPointForPosition)
{
_ignoreAnchorPointForPosition = newValue;
_transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
}
@ -906,7 +907,7 @@ void Node::draw()
draw(renderer, _modelViewTransform, true);
}
void Node::draw(Renderer* renderer, const kmMat4 &transform, bool transformDirty)
void Node::draw(Renderer* renderer, const kmMat4 &transform, bool transformUpdated)
{
}
@ -918,7 +919,7 @@ void Node::visit()
visit(renderer, parentTransform, true);
}
void Node::visit(Renderer* renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void Node::visit(Renderer* renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
// quick return if not visible. children won't be drawn.
if (!_visible)
@ -926,9 +927,10 @@ void Node::visit(Renderer* renderer, const kmMat4 &parentTransform, bool parentT
return;
}
bool dirty = _transformDirty || parentTransformDirty;
bool dirty = _transformUpdated || parentTransformUpdated;
if(dirty)
_modelViewTransform = this->transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
@ -969,17 +971,10 @@ void Node::visit(Renderer* renderer, const kmMat4 &parentTransform, bool parentT
kmGLPopMatrix();
}
void Node::transformAncestors()
{
// remove me
CCASSERT(false, "no longer supported");
}
kmMat4 Node::transform(const kmMat4& parentTransform)
{
kmMat4 ret;
kmMat4 transfrom4x4 = this->getNodeToParentTransform();
kmMat4Multiply(&ret, &parentTransform, &transfrom4x4);
kmMat4 ret = this->getNodeToParentTransform();
kmMat4Multiply(&ret, &parentTransform, &ret);
return ret;
}
@ -1362,19 +1357,20 @@ void Node::setNodeToParentTransform(const kmMat4& transform)
{
_transform = transform;
_transformDirty = false;
_transformUpdated = true;
}
void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
{
CGAffineToGL(additionalTransform, _additionalTransform.mat);
_transformDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
_useAdditionalTransform = true;
}
void Node::setAdditionalTransform(const kmMat4& additionalTransform)
{
_additionalTransform = additionalTransform;
_transformDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
_useAdditionalTransform = true;
}

View File

@ -991,13 +991,13 @@ public:
* AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE
* But if you enable any other GL state, you should disable it after drawing your node.
*/
virtual void draw(Renderer *renderer, const kmMat4& transform, bool transformDirty);
virtual void draw(Renderer *renderer, const kmMat4& transform, bool transformUpdated);
virtual void draw() final;
/**
* Visits this node's children and draw them recursively.
*/
virtual void visit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformDirty);
virtual void visit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformUpdated);
virtual void visit() final;
@ -1253,16 +1253,6 @@ public:
/// @{
/// @name Transformations
/**
* Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes.
*/
kmMat4 transform(const kmMat4 &parentTransform);
/**
* Performs OpenGL view-matrix transformation of it's ancestors.
* Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO)
* It's necessary to transform the ancestors again.
*/
void transformAncestors();
/**
* Calls children's updateTransform() method recursively.
*
@ -1313,7 +1303,7 @@ public:
virtual AffineTransform getWorldToNodeAffineTransform() const;
/** @deprecated Use worldToNodeTransform() instead */
/** @deprecated Use getWorldToNodeTransform() instead */
CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform worldToNodeTransform() const { return getWorldToNodeAffineTransform(); }
/// @} end of Transformations
@ -1404,8 +1394,8 @@ public:
spriteB->setAdditionalTransform(t);
@endcode
*/
void setAdditionalTransform(const AffineTransform& additionalTransform);
void setAdditionalTransform(const kmMat4& additionalTransform);
void setAdditionalTransform(const AffineTransform& additionalTransform);
/// @} end of Coordinate Converters
@ -1482,6 +1472,8 @@ protected:
/// Convert cocos2d coordinates to UI windows coordinate.
Point convertToWindowSpace(const Point& nodePoint) const;
kmMat4 transform(const kmMat4 &parentTransform);
virtual void updateCascadeOpacity();
virtual void disableCascadeOpacity();
virtual void updateCascadeColor();
@ -1514,13 +1506,13 @@ protected:
kmMat4 _modelViewTransform; ///< ModelView transform of the Node.
// "cache" variables are allowed to be mutable
mutable kmMat4 _additionalTransform; ///< transform
mutable kmMat4 _transform; ///< transform
mutable kmMat4 _inverse; ///< inverse transform
bool _useAdditionalTransform; ///< The flag to check whether the additional transform is dirty
mutable bool _transformDirty; ///< transform dirty flag
mutable kmMat4 _inverse; ///< inverse transform
mutable bool _inverseDirty; ///< inverse transform dirty flag
mutable kmMat4 _additionalTransform; ///< transform
bool _useAdditionalTransform; ///< The flag to check whether the additional transform is dirty
bool _transformUpdated; ///< Whether or not the Transform object was updated since the last frame
int _localZOrder; ///< Local order (relative to its siblings) used to sort the node
float _globalZOrder; ///< Global order used to sort the node

View File

@ -82,7 +82,7 @@ void NodeGrid::onGridEndDraw()
}
}
void NodeGrid::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void NodeGrid::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
// quick return if not visible. children won't be drawn.
if (!_visible)
@ -94,9 +94,10 @@ void NodeGrid::visit(Renderer *renderer, const kmMat4 &parentTransform, bool par
renderer->addCommand(&_groupCommand);
renderer->pushGroup(_groupCommand.getRenderQueueID());
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = this->transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,

View File

@ -55,7 +55,7 @@ public:
void setTarget(Node *target);
// overrides
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
protected:
NodeGrid();

View File

@ -145,7 +145,7 @@ The positions are updated at visit because:
- using a timer is not guaranteed that it will called after all the positions were updated
- overriding "draw" will only precise if the children have a z > 0
*/
void ParallaxNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void ParallaxNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
// Point pos = position_;
// Point pos = [self convertToWorldSpace:Point::ZERO];
@ -161,7 +161,7 @@ void ParallaxNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool
}
_lastPosition = pos;
}
Node::visit(renderer, parentTransform, parentTransformDirty);
Node::visit(renderer, parentTransform, parentTransformUpdated);
}
NS_CC_END

View File

@ -67,7 +67,7 @@ public:
virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void removeChild(Node* child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
protected:
/** Adds a child to the container with a z-order, a parallax ratio and a position offset

View File

@ -120,7 +120,7 @@ bool ParticleBatchNode::initWithFile(const std::string& fileImage, int capacity)
// override visit.
// Don't call visit on it's children
void ParticleBatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void ParticleBatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
// CAREFUL:
// This visit is almost identical to Node#visit
@ -134,9 +134,10 @@ void ParticleBatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform,
return;
}
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,
@ -379,7 +380,7 @@ void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup)
_textureAtlas->removeAllQuads();
}
void ParticleBatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ParticleBatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
CC_PROFILER_START("CCParticleBatchNode - draw");
@ -394,7 +395,7 @@ void ParticleBatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool t
_blendFunc,
_textureAtlas,
_modelViewTransform);
Director::getInstance()->getRenderer()->addCommand(&_batchCommand);
renderer->addCommand(&_batchCommand);
CC_PROFILER_STOP("CCParticleBatchNode - draw");
}

View File

@ -97,13 +97,13 @@ public:
inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; };
// Overrides
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
using Node::addChild;
virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void removeChild(Node* child, bool cleanup) override;
virtual void reorderChild(Node * child, int zOrder) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual Texture2D* getTexture(void) const override;
virtual void setTexture(Texture2D *texture) override;
/**

View File

@ -72,7 +72,7 @@ bool ParticleSystemQuad::initWithTotalParticles(int numberOfParticles)
setupVBO();
}
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO
@ -358,16 +358,14 @@ void ParticleSystemQuad::postStep()
}
// overriding draw method
void ParticleSystemQuad::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ParticleSystemQuad::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad");
//quad command
if(_particleIdx > 0)
{
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
_quadCommand.init(_globalZOrder, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, _quads, _particleIdx, _modelViewTransform);
renderer->addCommand(&_quadCommand);
}
}

View File

@ -104,7 +104,7 @@ public:
* @js NA
* @lua NA
*/
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
/**
* @js NA

View File

@ -550,14 +550,14 @@ void ProgressTimer::onDraw()
}
}
void ProgressTimer::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ProgressTimer::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
if( ! _vertexData || ! _sprite)
return;
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}

View File

@ -111,7 +111,7 @@ public:
inline Point getBarChangeRate() const { return _barChangeRate; }
// Overrides
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual void setAnchorPoint(const Point& anchorPoint) override;
virtual void setColor(const Color3B &color) override;
virtual const Color3B& getColor() const override;

View File

@ -361,7 +361,7 @@ void RenderTexture::clearStencil(int stencilValue)
glClearStencil(stencilClearValue);
}
void RenderTexture::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void RenderTexture::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
// override visit.
// Don't call visit on its children
@ -370,9 +370,10 @@ void RenderTexture::visit(Renderer *renderer, const kmMat4 &parentTransform, boo
return;
}
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,
@ -617,7 +618,7 @@ void RenderTexture::onClearDepth()
glClearDepth(depthClearValue);
}
void RenderTexture::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void RenderTexture::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
if (_autoDraw)
{
@ -635,7 +636,7 @@ void RenderTexture::draw(Renderer *renderer, const kmMat4 &transform, bool trans
for(const auto &child: _children)
{
if (child != _sprite)
child->visit(renderer, transform, transformDirty);
child->visit(renderer, transform, transformUpdated);
}
//End will pop the current render group

View File

@ -154,8 +154,8 @@ public:
};
// Overrides
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
public:
// XXX should be procted.

View File

@ -277,6 +277,7 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
Sprite::Sprite(void)
: _shouldBeHidden(false)
, _texture(nullptr)
, _insideBounds(true)
{
}
@ -586,16 +587,19 @@ void Sprite::updateTransform(void)
// draw
void Sprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void Sprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
if(isInsideBounds())
// Don't do calculate the culling if the transform was not updated
_insideBounds = transformUpdated ? isInsideBounds() : _insideBounds;
if(_insideBounds)
{
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, transform);
renderer->addCommand(&_quadCommand);
#if CC_SPRITE_DEBUG_DRAW
_customDebugDrawCommand.init(_globalZOrder);
_customDebugDrawCommand.func = CC_CALLBACK_0(Sprite::drawDebugData, this);
Director::getInstance()->getRenderer()->addCommand(&_customDebugDrawCommand);
renderer->addCommand(&_customDebugDrawCommand);
#endif //CC_SPRITE_DEBUG_DRAW
}
}

View File

@ -424,7 +424,7 @@ public:
virtual void setAnchorPoint(const Point& anchor) override;
virtual void ignoreAnchorPointForPosition(bool value) override;
virtual void setVisible(bool bVisible) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual void setOpacityModifyRGB(bool modify) override;
virtual bool isOpacityModifyRGB(void) const override;
/// @}
@ -573,6 +573,8 @@ protected:
bool _flippedX; /// Whether the sprite is flipped horizontally or not
bool _flippedY; /// Whether the sprite is flipped vertically or not
bool _insideBounds; /// whether or not the sprite was inside bounds the previous frame
private:
CC_DISALLOW_COPY_AND_ASSIGN(Sprite);
};

View File

@ -131,7 +131,7 @@ SpriteBatchNode::~SpriteBatchNode()
// override visit
// don't call visit on it's children
void SpriteBatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void SpriteBatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
@ -149,9 +149,10 @@ void SpriteBatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, b
sortAllChildren();
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,
@ -352,7 +353,7 @@ void SpriteBatchNode::reorderBatch(bool reorder)
_reorderChildDirty=reorder;
}
void SpriteBatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void SpriteBatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
// Optimization: Fast Dispatch
if( _textureAtlas->getTotalQuads() == 0 )
@ -368,8 +369,8 @@ void SpriteBatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool tra
_shaderProgram,
_blendFunc,
_textureAtlas,
_modelViewTransform);
Director::getInstance()->getRenderer()->addCommand(&_batchCommand);
transform);
renderer->addCommand(&_batchCommand);
}
void SpriteBatchNode::increaseAtlasCapacity(void)

View File

@ -155,7 +155,7 @@ public:
*/
virtual const BlendFunc& getBlendFunc() const override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
using Node::addChild;
virtual void addChild(Node * child, int zOrder, int tag) override;
@ -164,7 +164,7 @@ public:
virtual void removeChild(Node *child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void sortAllChildren() override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string getDescription() const override;
/** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.

View File

@ -242,7 +242,7 @@ const std::string& TextFieldTTF::getContentText()
return _inputText;
}
void TextFieldTTF::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TextFieldTTF::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
if (_delegate && _delegate->onDraw(this))
{
@ -250,14 +250,14 @@ void TextFieldTTF::draw(Renderer *renderer, const kmMat4 &transform, bool transf
}
if (_inputText.length())
{
LabelTTF::draw(renderer, transform, transformDirty);
LabelTTF::draw(renderer, transform, transformUpdated);
return;
}
// draw placeholder
Color3B color = getColor();
setColor(_colorSpaceHolder);
LabelTTF::draw(renderer, transform, transformDirty);
LabelTTF::draw(renderer, transform, transformUpdated);
setColor(color);
}

View File

@ -173,7 +173,7 @@ protected:
bool _secureTextEntry;
protected:
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
//////////////////////////////////////////////////////////////////////////
// IMEDelegate interface

View File

@ -97,16 +97,16 @@ void TransitionScene::sceneOrder()
_isInSceneOnTop = true;
}
void TransitionScene::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TransitionScene::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
Scene::draw(renderer, transform, transformDirty);
Scene::draw(renderer, transform, transformUpdated);
if( _isInSceneOnTop ) {
_outScene->visit(renderer, transform, transformDirty);
_inScene->visit(renderer, transform, transformDirty);
_outScene->visit(renderer, transform, transformUpdated);
_inScene->visit(renderer, transform, transformUpdated);
} else {
_inScene->visit(renderer, transform, transformDirty);
_outScene->visit(renderer, transform, transformDirty);
_inScene->visit(renderer, transform, transformUpdated);
_outScene->visit(renderer, transform, transformUpdated);
}
}
@ -1258,7 +1258,7 @@ TransitionCrossFade* TransitionCrossFade::create(float t, Scene* scene)
return nullptr;
}
void TransitionCrossFade::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TransitionCrossFade::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
// override draw since both scenes (textures) are rendered in 1 scene
}
@ -1407,19 +1407,19 @@ void TransitionTurnOffTiles::onExit()
TransitionScene::onExit();
}
void TransitionTurnOffTiles::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TransitionTurnOffTiles::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
Scene::draw(renderer, transform, transformDirty);
Scene::draw(renderer, transform, transformUpdated);
if( _isInSceneOnTop )
{
_outSceneProxy->visit(renderer, transform, transformDirty);
_inScene->visit(renderer, transform, transformDirty);
_outSceneProxy->visit(renderer, transform, transformUpdated);
_inScene->visit(renderer, transform, transformUpdated);
}
else
{
_inScene->visit(renderer, transform, transformDirty);
_outSceneProxy->visit(renderer, transform, transformDirty);
_inScene->visit(renderer, transform, transformUpdated);
_outSceneProxy->visit(renderer, transform, transformUpdated);
}
}
@ -1487,10 +1487,10 @@ void TransitionSplitCols::switchTargetToInscene()
_gridProxy->setTarget(_inScene);
}
void TransitionSplitCols::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TransitionSplitCols::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
Scene::draw(renderer, transform, transformDirty);
_gridProxy->visit(renderer, transform, transformDirty);
Scene::draw(renderer, transform, transformUpdated);
_gridProxy->visit(renderer, transform, transformUpdated);
}
void TransitionSplitCols::onExit()
@ -1603,19 +1603,19 @@ void TransitionFadeTR::onExit()
TransitionScene::onExit();
}
void TransitionFadeTR::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TransitionFadeTR::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
Scene::draw(renderer, transform, transformDirty);
Scene::draw(renderer, transform, transformUpdated);
if( _isInSceneOnTop )
{
_outSceneProxy->visit(renderer, transform, transformDirty);
_inScene->visit(renderer, transform, transformDirty);
_outSceneProxy->visit(renderer, transform, transformUpdated);
_inScene->visit(renderer, transform, transformUpdated);
}
else
{
_inScene->visit(renderer, transform, transformDirty);
_outSceneProxy->visit(renderer, transform, transformDirty);
_inScene->visit(renderer, transform, transformUpdated);
_outSceneProxy->visit(renderer, transform, transformUpdated);
}
}

View File

@ -91,7 +91,7 @@ public:
//
// Overrides
//
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual void onEnter() override;
virtual void onExit() override;
virtual void cleanup() override;
@ -609,7 +609,7 @@ public :
* @js NA
* @lua NA
*/
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
/**
* @js NA
* @lua NA
@ -647,7 +647,7 @@ public :
virtual void onEnter() override;
virtual void onExit() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
TransitionTurnOffTiles();
@ -680,7 +680,7 @@ public:
virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
virtual void onExit() override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
TransitionSplitCols();
virtual ~TransitionSplitCols();
@ -731,7 +731,7 @@ public:
virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
virtual void onExit() override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
TransitionFadeTR();
virtual ~TransitionFadeTR();

View File

@ -92,31 +92,31 @@ void TransitionPageTurn::onDisablePolygonOffset()
glPolygonOffset(0, 0);
}
void TransitionPageTurn::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TransitionPageTurn::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
Scene::draw(renderer, transform, transformDirty);
Scene::draw(renderer, transform, transformUpdated);
if( _isInSceneOnTop ) {
_outSceneProxy->visit(renderer, transform, transformDirty);
_outSceneProxy->visit(renderer, transform, transformUpdated);
_enableOffsetCmd.init(_globalZOrder);
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd);
_inSceneProxy->visit(renderer, transform, transformDirty);
renderer->addCommand(&_enableOffsetCmd);
_inSceneProxy->visit(renderer, transform, transformUpdated);
_disableOffsetCmd.init(_globalZOrder);
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd);
renderer->addCommand(&_disableOffsetCmd);
} else {
_inSceneProxy->visit(renderer, transform, transformDirty);
_inSceneProxy->visit(renderer, transform, transformUpdated);
_enableOffsetCmd.init(_globalZOrder);
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd);
renderer->addCommand(&_enableOffsetCmd);
_outSceneProxy->visit(renderer, transform, transformDirty);
_outSceneProxy->visit(renderer, transform, transformUpdated);
_disableOffsetCmd.init(_globalZOrder);
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd);
renderer->addCommand(&_disableOffsetCmd);
}
}

View File

@ -72,7 +72,7 @@ public:
//
// Overrides
//
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
/**
* Creates a base transition with duration and incoming scene.

View File

@ -29,7 +29,6 @@ THE SOFTWARE.
#include "cocostudio/CCDatas.h"
#include "cocostudio/CCSkin.h"
#include "renderer/CCQuadCommand.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCGroupCommand.h"
#include "CCShaderCache.h"
@ -378,7 +377,7 @@ void Armature::update(float dt)
_armatureTransformDirty = false;
}
void Armature::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void Armature::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
if (_parentBone == nullptr && _batchNode == nullptr)
{
@ -408,17 +407,17 @@ void Armature::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool t
{
skin->setBlendFunc(bone->getBlendFunc());
}
skin->draw(renderer, transform, transformDirty);
skin->draw(renderer, transform, transformUpdated);
}
break;
case CS_DISPLAY_ARMATURE:
{
node->draw(renderer, transform, transformDirty);
node->draw(renderer, transform, transformUpdated);
}
break;
default:
{
node->visit(renderer, transform, transformDirty);
node->visit(renderer, transform, transformUpdated);
CC_NODE_DRAW_SETUP();
}
break;
@ -426,7 +425,7 @@ void Armature::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool t
}
else if(Node *node = dynamic_cast<Node *>(object))
{
node->visit(renderer, transform, transformDirty);
node->visit(renderer, transform, transformUpdated);
CC_NODE_DRAW_SETUP();
}
}
@ -445,7 +444,7 @@ void Armature::onExit()
}
void Armature::visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void Armature::visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
// quick return if not visible. children won't be drawn.
if (!_visible)
@ -453,9 +452,10 @@ void Armature::visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform,
return;
}
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,

View File

@ -156,8 +156,8 @@ public:
* @js NA
* @lua NA
*/
virtual void visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual void update(float dt) override;
virtual void onEnter() override;

View File

@ -101,7 +101,7 @@ void BatchNode::removeChild(Node* child, bool cleanup)
Node::removeChild(child, cleanup);
}
void BatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void BatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
// quick return if not visible. children won't be drawn.
if (!_visible)
@ -109,9 +109,10 @@ void BatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool pa
return;
}
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,
@ -128,7 +129,7 @@ void BatchNode::visit(Renderer *renderer, const kmMat4 &parentTransform, bool pa
kmGLPopMatrix();
}
void BatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void BatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
if (_children.empty())
{
@ -149,14 +150,14 @@ void BatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool transform
pushed = true;
}
armature->visit(renderer, transform, transformDirty);
armature->visit(renderer, transform, transformUpdated);
}
else
{
Director::getInstance()->getRenderer()->popGroup();
renderer->popGroup();
pushed = false;
((Node *)object)->visit(renderer, transform, transformDirty);
((Node *)object)->visit(renderer, transform, transformUpdated);
}
}
}

View File

@ -56,8 +56,8 @@ public:
virtual void addChild(cocos2d::Node *pChild, int zOrder) override;
virtual void addChild(cocos2d::Node *pChild, int zOrder, int tag) override;
virtual void removeChild(cocos2d::Node* child, bool cleanup) override;
virtual void visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
void generateGroupCommand();

View File

@ -219,14 +219,14 @@ kmMat4 Skin::getNodeToWorldTransformAR() const
return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(),displayTransform);
}
void Skin::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void Skin::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
kmMat4 mv;
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
//TODO implement z order
_quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
renderer->addCommand(&_quadCommand);
}
void Skin::setBone(Bone *bone)

View File

@ -54,7 +54,7 @@ public:
kmMat4 getNodeToWorldTransform() const override;
kmMat4 getNodeToWorldTransformAR() const;
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
/**
* @js NA

View File

@ -125,12 +125,12 @@ void Skeleton::update (float deltaTime) {
spSkeleton_update(skeleton, deltaTime * timeScale);
}
void Skeleton::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void Skeleton::draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void Skeleton::onDraw ()

View File

@ -67,7 +67,7 @@ public:
virtual ~Skeleton ();
virtual void update (float deltaTime) override;
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
void onDraw();
void onEnter() override;
void onExit() override;

View File

@ -167,7 +167,7 @@ bool Layout::hitTest(const Point &pt)
return false;
}
void Layout::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void Layout::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
if (!_enabled)
{
@ -178,10 +178,10 @@ void Layout::visit(Renderer *renderer, const kmMat4 &parentTransform, bool paren
switch (_clippingType)
{
case LAYOUT_CLIPPING_STENCIL:
stencilClippingVisit(renderer, parentTransform, parentTransformDirty);
stencilClippingVisit(renderer, parentTransform, parentTransformUpdated);
break;
case LAYOUT_CLIPPING_SCISSOR:
scissorClippingVisit(renderer, parentTransform, parentTransformDirty);
scissorClippingVisit(renderer, parentTransform, parentTransformUpdated);
break;
default:
break;
@ -189,7 +189,7 @@ void Layout::visit(Renderer *renderer, const kmMat4 &parentTransform, bool paren
}
else
{
Node::visit(renderer, parentTransform, parentTransformDirty);
Node::visit(renderer, parentTransform, parentTransformUpdated);
}
}
@ -199,14 +199,15 @@ void Layout::sortAllChildren()
doLayout();
}
void Layout::stencilClippingVisit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void Layout::stencilClippingVisit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
if(!_visible)
return;
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,
@ -339,13 +340,13 @@ void Layout::onAfterVisitScissor()
glDisable(GL_SCISSOR_TEST);
}
void Layout::scissorClippingVisit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformDirty)
void Layout::scissorClippingVisit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformUpdated)
{
_beforeVisitCmdScissor.init(_globalZOrder);
_beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this);
renderer->addCommand(&_beforeVisitCmdScissor);
Node::visit(renderer, parentTransform, parentTransformDirty);
Node::visit(renderer, parentTransform, parentTransformUpdated);
_afterVisitCmdScissor.init(_globalZOrder);
_afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this);

View File

@ -209,7 +209,7 @@ public:
*/
virtual void addChild(Node* child, int zOrder, int tag) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
virtual void sortAllChildren() override;
@ -234,8 +234,8 @@ protected:
virtual void copySpecialProperties(Widget* model) override;
virtual void copyClonedWidgetChildren(Widget* model) override;
void stencilClippingVisit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformDirty);
void scissorClippingVisit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformDirty);
void stencilClippingVisit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformUpdated);
void scissorClippingVisit(Renderer *renderer, const kmMat4& parentTransform, bool parentTransformUpdated);
void setStencilClippingSize(const Size& size);
const Rect& getClippingRect();

View File

@ -108,11 +108,11 @@ void Widget::onExit()
Node::onExit();
}
void Widget::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void Widget::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
if (_enabled)
{
Node::visit(renderer, parentTransform, parentTransformDirty);
Node::visit(renderer, parentTransform, parentTransformUpdated);
}
}

View File

@ -331,7 +331,7 @@ public:
virtual void removeAllNodes();
virtual void visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
/**
* Sets the touch event target/selector of the menu item

View File

@ -769,14 +769,14 @@ void Scale9Sprite::setInsetBottom(float insetBottom)
this->updateCapInset();
}
void Scale9Sprite::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void Scale9Sprite::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
if(this->_positionsAreDirty)
{
this->updatePositions();
this->_positionsAreDirty = false;
}
Node::visit(renderer, parentTransform, parentTransformDirty);
Node::visit(renderer, parentTransform, parentTransformUpdated);
}
void Scale9Sprite::setColor(const Color3B& color)

View File

@ -261,7 +261,7 @@ public:
* @js NA
* @lua NA
*/
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
virtual void setOpacityModifyRGB(bool bValue) override;
virtual bool isOpacityModifyRGB(void) const override;
virtual void setOpacity(GLubyte opacity) override;

View File

@ -316,9 +316,9 @@ void EditBox::setAnchorPoint(const Point& anchorPoint)
}
}
void EditBox::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void EditBox::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
ControlButton::visit(renderer, parentTransform, parentTransformDirty);
ControlButton::visit(renderer, parentTransform, parentTransformUpdated);
if (_editBoxImpl != NULL)
{
_editBoxImpl->visit();

View File

@ -379,7 +379,7 @@ public:
* @js NA
* @lua NA
*/
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
/**
* @js NA
* @lua NA

View File

@ -552,7 +552,7 @@ void ScrollView::onAfterDraw()
}
}
void ScrollView::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty)
void ScrollView::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
// quick return if not visible
if (!isVisible())
@ -560,9 +560,10 @@ void ScrollView::visit(Renderer *renderer, const kmMat4 &parentTransform, bool p
return;
}
bool dirty = parentTransformDirty || _transformDirty;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = this->transform(parentTransform);
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the kmGL stack,

View File

@ -225,7 +225,7 @@ public:
* @js NA
* @lua NA
*/
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformDirty) override;
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
using Node::addChild;
virtual void addChild(Node * child, int zOrder, int tag) override;

View File

@ -182,7 +182,7 @@ static void DrawConstraint(cpConstraint *constraint, DrawNode *renderer)
// implementation of PhysicsDebugNode
void PhysicsDebugNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void PhysicsDebugNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
if (! _spacePtr)
{
@ -192,7 +192,7 @@ void PhysicsDebugNode::draw(Renderer *renderer, const kmMat4 &transform, bool tr
cpSpaceEachShape(_spacePtr, (cpSpaceShapeIteratorFunc)DrawShape, this);
cpSpaceEachConstraint(_spacePtr, (cpSpaceConstraintIteratorFunc)DrawConstraint, this);
DrawNode::draw(renderer, transform, transformDirty);
DrawNode::draw(renderer, transform, transformUpdated);
DrawNode::clear();
#endif
}

View File

@ -61,7 +61,7 @@ public:
void setSpace(cpSpace *space);
// Overrides
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
cpSpace *_spacePtr;

View File

@ -1342,12 +1342,12 @@ void ActionFollow::onEnter()
this->runAction(Follow::create(_grossini, Rect(0, 0, s.width * 2 - 100, s.height)));
}
void ActionFollow::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ActionFollow::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void ActionFollow::onDraw()
@ -1649,9 +1649,9 @@ ActionCatmullRomStacked::~ActionCatmullRomStacked()
CC_SAFE_RELEASE(_array2);
}
void ActionCatmullRomStacked::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ActionCatmullRomStacked::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
ActionsDemo::draw(renderer, transform, transformDirty);
ActionsDemo::draw(renderer, transform, transformUpdated);
// move to 50,50 since the "by" path will start at 50,50
kmGLPushMatrix();
@ -1662,7 +1662,7 @@ void ActionCatmullRomStacked::draw(Renderer *renderer, const kmMat4 &transform,
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void ActionCatmullRomStacked::onDraw()
@ -1758,9 +1758,9 @@ ActionCardinalSplineStacked::~ActionCardinalSplineStacked()
CC_SAFE_RELEASE(_array);
}
void ActionCardinalSplineStacked::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ActionCardinalSplineStacked::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
ActionsDemo::draw(renderer, transform, transformDirty);
ActionsDemo::draw(renderer, transform, transformUpdated);
// move to 50,50 since the "by" path will start at 50,50
kmGLPushMatrix();
@ -1777,7 +1777,7 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const kmMat4 &transfo
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void ActionCardinalSplineStacked::onDraw()
@ -2125,9 +2125,9 @@ ActionCatmullRom::~ActionCatmullRom()
_array2->release();
}
void ActionCatmullRom::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ActionCatmullRom::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
ActionsDemo::draw(renderer, transform, transformDirty);
ActionsDemo::draw(renderer, transform, transformUpdated);
// move to 50,50 since the "by" path will start at 50,50
kmGLPushMatrix();
@ -2139,7 +2139,7 @@ void ActionCatmullRom::draw(Renderer *renderer, const kmMat4 &transform, bool tr
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
@ -2220,9 +2220,9 @@ ActionCardinalSpline::~ActionCardinalSpline()
_array->release();
}
void ActionCardinalSpline::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ActionCardinalSpline::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
ActionsDemo::draw(renderer, transform, transformDirty);
ActionsDemo::draw(renderer, transform, transformUpdated);
// move to 50,50 since the "by" path will start at 50,50
kmGLPushMatrix();
@ -2239,7 +2239,7 @@ void ActionCardinalSpline::draw(Renderer *renderer, const kmMat4 &transform, boo
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void ActionCardinalSpline::onDraw()

View File

@ -375,7 +375,7 @@ public:
CREATE_FUNC(ActionFollow);
virtual void onEnter() override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string subtitle() const override;
protected:
@ -451,7 +451,7 @@ public:
CREATE_FUNC(ActionCatmullRomStacked);
virtual ~ActionCatmullRomStacked();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
@ -472,7 +472,7 @@ public:
CREATE_FUNC(ActionCardinalSplineStacked);
virtual ~ActionCardinalSplineStacked();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty);
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
@ -567,7 +567,7 @@ public:
~ActionCatmullRom();
virtual void onEnter() override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string subtitle() const override;
virtual std::string title() const override;
private:
@ -588,7 +588,7 @@ public:
~ActionCardinalSpline();
virtual void onEnter() override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string subtitle() const override;
virtual std::string title() const override;
private:

View File

@ -137,14 +137,14 @@ void Box2DTestLayer::createResetButton()
}
void Box2DTestLayer::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void Box2DTestLayer::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
//
// IMPORTANT:
// This is only for debug purposes
// It is recommend to disable it
//
Layer::draw(renderer, transform, transformDirty);
Layer::draw(renderer, transform, transformUpdated);
#if CC_ENABLE_BOX2D_INTEGRATION
GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION );
@ -154,7 +154,7 @@ void Box2DTestLayer::draw(Renderer *renderer, const kmMat4 &transform, bool tran
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Box2DTestLayer::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
kmGLPopMatrix();
#endif

View File

@ -17,7 +17,7 @@ public:
void initPhysics();
void createResetButton();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
void addNewSpriteAtPosition(Point p);
void update(float dt);

View File

@ -207,13 +207,13 @@ void Box2DView::tick(float dt)
m_test->Step(&settings);
}
void Box2DView::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void Box2DView::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
Layer::draw(renderer, transform, transformDirty);
Layer::draw(renderer, transform, transformUpdated);
_customCmd.init(_globalZOrder);
_customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCmd);
renderer->addCommand(&_customCmd);
}
void Box2DView::onDraw()

View File

@ -42,7 +42,7 @@ public:
bool initWithEntryID(int entryId);
std::string title() const;
void tick(float dt);
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
// virtual void registerWithTouchDispatcher();
bool onTouchBegan(Touch* touch, Event* event);

View File

@ -596,7 +596,7 @@ void RawStencilBufferTest::setup()
Director::getInstance()->setAlphaBlending(true);
}
void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
auto winPoint = Point(Director::getInstance()->getWinSize());
@ -615,8 +615,6 @@ void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, boo
renderer->addCommand(&(*iter));
++iter;
for (int i = 0; i < _planeCount; i++) {
auto stencilPoint = planeSize * (_planeCount - i);
@ -634,7 +632,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, boo
kmGLPushMatrix();
_modelViewTransform = this->transform(transform);
_sprites.at(i)->visit(renderer, _modelViewTransform, transformDirty);
_sprites.at(i)->visit(renderer, _modelViewTransform, transformUpdated);
kmGLPopMatrix();
iter->init(_globalZOrder);
@ -644,14 +642,13 @@ void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, boo
kmGLPushMatrix();
_modelViewTransform = this->transform(transform);
_sprites.at(i)->visit(renderer, _modelViewTransform, transformDirty);
_sprites.at(i)->visit(renderer, _modelViewTransform, transformUpdated);
kmGLPopMatrix();
}
iter->init(_globalZOrder);
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onDisableStencil, this);
renderer->addCommand(&(*iter));
}
void RawStencilBufferTest::onEnableStencil()

View File

@ -153,7 +153,7 @@ public:
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void setup();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual void setupStencilForClippingOnPlane(GLint plane);
virtual void setupStencilForDrawingOnPlane(GLint plane);

View File

@ -114,11 +114,11 @@ DrawPrimitivesTest::DrawPrimitivesTest()
{
}
void DrawPrimitivesTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void DrawPrimitivesTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void DrawPrimitivesTest::onDraw()

View File

@ -27,7 +27,7 @@ public:
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
void onDraw();
protected:

View File

@ -845,7 +845,7 @@ void TestColliderDetector::onExit()
ArmatureTestLayer::onExit();
}
void TestColliderDetector::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TestColliderDetector::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
kmGLPushMatrix();
@ -1065,11 +1065,11 @@ void TestColliderDetector::update(float delta)
}
}
}
void TestColliderDetector::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TestColliderDetector::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void TestColliderDetector::onDraw()
@ -1106,11 +1106,11 @@ std::string TestBoundingBox::title() const
{
return "Test BoundingBox";
}
void TestBoundingBox::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TestBoundingBox::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}

View File

@ -211,7 +211,7 @@ public:
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual void update(float delta);
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
@ -270,7 +270,7 @@ public:
virtual void onEnter() override;
virtual std::string title() const override;
virtual void update(float delta);
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
void onDraw();
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
@ -293,7 +293,7 @@ class TestBoundingBox : public ArmatureTestLayer
public:
virtual void onEnter() override;
virtual std::string title() const override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
cocostudio::Armature *armature;
Rect rect;

View File

@ -194,9 +194,9 @@ void SceneEditorTestLayer::backCallback(Ref *pSender)
s->release();
}
void SceneEditorTestLayer::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void SceneEditorTestLayer::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
Layer::draw(renderer, transform, transformDirty);
Layer::draw(renderer, transform, transformUpdated);
}

View File

@ -43,7 +43,7 @@ public:
virtual void nextCallback(cocos2d::Ref* pSender);
virtual void backCallback(cocos2d::Ref* pSender);
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
MenuItemImage *restartItem;

View File

@ -2,9 +2,9 @@
USING_NS_CC;
void CustomTableViewCell::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void CustomTableViewCell::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
TableViewCell::draw(renderer, transform, transformDirty);
TableViewCell::draw(renderer, transform, transformUpdated);
// draw bounding box
// auto pos = getPosition();
// auto size = Size(178, 200);

View File

@ -7,7 +7,7 @@
class CustomTableViewCell : public cocos2d::extension::TableViewCell
{
public:
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(cocos2d::Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
};
#endif /* __CUSTOMTABELVIEWCELL_H__ */

View File

@ -206,13 +206,13 @@ Atlas1::~Atlas1()
_textureAtlas->release();
}
void Atlas1::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void Atlas1::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
// GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// GL_TEXTURE_2D
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
// [textureAtlas drawNumberOfQuads:3];
@ -529,11 +529,11 @@ Atlas4::Atlas4()
schedule( schedule_selector(Atlas4::step), 0.1f);
}
void Atlas4::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void Atlas4::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void Atlas4::onDraw()
@ -1615,11 +1615,11 @@ std::string LabelBMFontBounds::subtitle() const
return "You should see string enclosed by a box";
}
void LabelBMFontBounds::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void LabelBMFontBounds::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void LabelBMFontBounds::onDraw()

View File

@ -35,7 +35,7 @@ public:
~Atlas1();
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
void onDraw();
protected:
@ -102,7 +102,7 @@ public:
Atlas4();
virtual void step(float dt);
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
@ -377,7 +377,7 @@ public:
LabelBMFontBounds();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:

View File

@ -309,11 +309,11 @@ LabelFNTSpriteActions::LabelFNTSpriteActions()
schedule( schedule_selector(LabelFNTSpriteActions::step), 0.1f);
}
void LabelFNTSpriteActions::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void LabelFNTSpriteActions::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
renderer->addCommand(&_renderCmd);
}
@ -926,11 +926,11 @@ std::string LabelFNTBounds::subtitle() const
return "You should see string enclosed by a box";
}
void LabelFNTBounds::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void LabelFNTBounds::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
renderer->addCommand(&_renderCmd);
}
void LabelFNTBounds::onDraw()
@ -1515,11 +1515,11 @@ void LabelTTFOldNew::onDraw()
kmGLLoadMatrix(&oldMat);
}
void LabelTTFOldNew::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void LabelTTFOldNew::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(LabelTTFOldNew::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
renderer->addCommand(&_renderCmd);
}
std::string LabelTTFOldNew::title() const

View File

@ -57,7 +57,7 @@ public:
LabelFNTSpriteActions();
virtual void step(float dt);
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
@ -222,7 +222,7 @@ public:
LabelFNTBounds();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
@ -411,7 +411,7 @@ public:
LabelTTFOldNew();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;

View File

@ -17,7 +17,7 @@ public:
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
}
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
DrawPrimitives::setDrawColor4B(_touchColor.r, _touchColor.g, _touchColor.b, 255);
glLineWidth(10);

View File

@ -974,7 +974,7 @@ public:
sprite->setShaderProgram(shader);
return sprite;
}
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
void onDraw();
protected:
@ -982,11 +982,11 @@ protected:
};
void MySprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void MySprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void MySprite::onDraw()

View File

@ -462,23 +462,23 @@ RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil()
CC_SAFE_RELEASE(_spriteDS);
}
void RenderTextureTestDepthStencil::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void RenderTextureTestDepthStencil::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_renderCmds[0].init(_globalZOrder);
_renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[0]);
renderer->addCommand(&_renderCmds[0]);
_rend->beginWithClear(0, 0, 0, 0, 0, 0);
_renderCmds[1].init(_globalZOrder);
_renderCmds[1].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeStencil, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[1]);
renderer->addCommand(&_renderCmds[1]);
_spriteDS->visit();
_renderCmds[2].init(_globalZOrder);
_renderCmds[2].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[2]);
renderer->addCommand(&_renderCmds[2]);
_spriteDraw->visit();
@ -486,8 +486,7 @@ void RenderTextureTestDepthStencil::draw(Renderer *renderer, const kmMat4 &trans
_renderCmds[3].init(_globalZOrder);
_renderCmds[3].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onAfterDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmds[3]);
renderer->addCommand(&_renderCmds[3]);
}
void RenderTextureTestDepthStencil::onBeforeClear()
@ -630,13 +629,13 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea
return sprite;
}
void SpriteRenderTextureBug::SimpleSprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void SpriteRenderTextureBug::SimpleSprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(SpriteRenderTextureBug::SimpleSprite::onBeforeDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
Sprite::draw(renderer, transform, transformDirty);
Sprite::draw(renderer, transform, transformUpdated);
}

View File

@ -86,7 +86,7 @@ public:
virtual ~RenderTextureTestDepthStencil();
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
private:
CustomCommand _renderCmds[4];
void onBeforeClear();
@ -125,7 +125,7 @@ public:
public:
static SimpleSprite* create(const char* filename, const Rect &rect);
SimpleSprite();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty);
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated);
protected:
void onBeforeDraw();

View File

@ -191,11 +191,11 @@ void ShaderNode::setPosition(const Point &newPosition)
_center = Vertex2F(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR());
}
void ShaderNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ShaderNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void ShaderNode::onDraw()
@ -433,7 +433,7 @@ public:
~SpriteBlur();
void setBlurSize(float f);
bool initWithTexture(Texture2D* texture, const Rect& rect);
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
void initProgram();
static SpriteBlur* create(const char *pszFileName);
@ -525,11 +525,11 @@ void SpriteBlur::initProgram()
CHECK_GL_ERROR_DEBUG();
}
void SpriteBlur::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void SpriteBlur::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(SpriteBlur::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
renderer->addCommand(&_customCommand);
}
void SpriteBlur::onDraw()

View File

@ -121,7 +121,7 @@ public:
virtual void update(float dt);
virtual void setPosition(const Point &newPosition);
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
static ShaderNode* shaderNodeWithVertex(const char *vert, const char *frag);

View File

@ -112,7 +112,7 @@ public:
virtual void initShader();
void setBackgroundNotification();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
void listenBackToForeground(Ref *obj);
protected:
@ -176,11 +176,11 @@ void ShaderSprite::initShader()
CHECK_GL_ERROR_DEBUG();
}
void ShaderSprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void ShaderSprite::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_renderCommand.init(_globalZOrder);
_renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCommand);
renderer->addCommand(&_renderCommand);
}

View File

@ -1791,13 +1791,13 @@ std::string TextureDrawAtPoint::subtitle() const
return "draws 2 textures using drawAtPoint";
}
void TextureDrawAtPoint::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TextureDrawAtPoint::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
TextureDemo::draw(renderer, transform, transformDirty);
TextureDemo::draw(renderer, transform, transformUpdated);
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
renderer->addCommand(&_renderCmd);
}
@ -1832,14 +1832,13 @@ TextureDrawInRect::~TextureDrawInRect()
_Tex2F->release();
}
void TextureDrawInRect::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TextureDrawInRect::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
TextureDemo::draw(renderer, transform, transformDirty);
TextureDemo::draw(renderer, transform, transformUpdated);
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
renderer->addCommand(&_renderCmd);
}
void TextureDrawInRect::onDraw()

View File

@ -466,7 +466,7 @@ public:
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void onEnter() override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
CustomCommand _renderCmd;
void onDraw();
@ -482,7 +482,7 @@ public:
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void onEnter() override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
CustomCommand _renderCmd;
void onDraw();

View File

@ -755,11 +755,11 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest()
CCLOG("%s", objectsVal.getDescription().c_str());
}
void TMXOrthoObjectsTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TMXOrthoObjectsTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
renderer->addCommand(&_renderCmd);
}
void TMXOrthoObjectsTest::onDraw()
@ -829,11 +829,11 @@ TMXIsoObjectsTest::TMXIsoObjectsTest()
CCLOG("%s", objectsVal.getDescription().c_str());
}
void TMXIsoObjectsTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TMXIsoObjectsTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
renderer->addCommand(&_renderCmd);
}
void TMXIsoObjectsTest::onDraw()
@ -1513,11 +1513,11 @@ TMXGIDObjectsTest::TMXGIDObjectsTest()
}
void TMXGIDObjectsTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty)
void TMXGIDObjectsTest::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
renderer->addCommand(&_renderCmd);
}
void TMXGIDObjectsTest::onDraw()

View File

@ -134,7 +134,7 @@ public:
TMXOrthoObjectsTest(void);
virtual std::string title() const override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string subtitle() const override;
protected:
CustomCommand _renderCmd;
@ -147,7 +147,7 @@ public:
TMXIsoObjectsTest(void);
virtual std::string title() const override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
virtual std::string subtitle() const override;
protected:
CustomCommand _renderCmd;
@ -292,7 +292,7 @@ public:
TMXGIDObjectsTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformDirty) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
protected:
CustomCommand _renderCmd;