From d78304599d9e7c2875468d24530d69e6f6c43c66 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 28 Feb 2014 16:10:48 -0800 Subject: [PATCH] Cache working OK. Performance increased in 20% for static objects. --- cocos/2d/CCAtlasNode.cpp | 14 ++--- cocos/2d/CCAtlasNode.h | 2 +- cocos/2d/CCClippingNode.cpp | 5 +- cocos/2d/CCClippingNode.h | 2 +- cocos/2d/CCDirector.cpp | 2 +- cocos/2d/CCDrawNode.cpp | 4 +- cocos/2d/CCDrawNode.h | 2 +- cocos/2d/CCLabel.cpp | 9 +-- cocos/2d/CCLabel.h | 4 +- cocos/2d/CCLayer.cpp | 4 +- cocos/2d/CCLayer.h | 3 +- cocos/2d/CCMotionStreak.cpp | 8 +-- cocos/2d/CCMotionStreak.h | 12 +--- cocos/2d/CCNode.cpp | 60 +++++++++---------- cocos/2d/CCNode.h | 54 +++++++---------- cocos/2d/CCNodeGrid.cpp | 5 +- cocos/2d/CCNodeGrid.h | 2 +- cocos/2d/CCParallaxNode.cpp | 4 +- cocos/2d/CCParallaxNode.h | 2 +- cocos/2d/CCParticleBatchNode.cpp | 9 +-- cocos/2d/CCParticleBatchNode.h | 4 +- cocos/2d/CCParticleSystemQuad.cpp | 10 ++-- cocos/2d/CCParticleSystemQuad.h | 2 +- cocos/2d/CCProgressTimer.cpp | 4 +- cocos/2d/CCProgressTimer.h | 2 +- cocos/2d/CCRenderTexture.cpp | 9 +-- cocos/2d/CCRenderTexture.h | 4 +- cocos/2d/CCSprite.cpp | 14 +++-- cocos/2d/CCSprite.h | 4 +- cocos/2d/CCSpriteBatchNode.cpp | 11 ++-- cocos/2d/CCSpriteBatchNode.h | 4 +- cocos/2d/CCTextFieldTTF.cpp | 6 +- cocos/2d/CCTextFieldTTF.h | 2 +- cocos/2d/CCTransition.cpp | 44 +++++++------- cocos/2d/CCTransition.h | 10 ++-- cocos/2d/CCTransitionPageTurn.cpp | 20 +++---- cocos/2d/CCTransitionPageTurn.h | 2 +- .../editor-support/cocostudio/CCArmature.cpp | 16 ++--- cocos/editor-support/cocostudio/CCArmature.h | 4 +- .../editor-support/cocostudio/CCBatchNode.cpp | 13 ++-- cocos/editor-support/cocostudio/CCBatchNode.h | 4 +- cocos/editor-support/cocostudio/CCSkin.cpp | 4 +- cocos/editor-support/cocostudio/CCSkin.h | 2 +- cocos/editor-support/spine/CCSkeleton.cpp | 4 +- cocos/editor-support/spine/CCSkeleton.h | 2 +- cocos/gui/UILayout.cpp | 17 +++--- cocos/gui/UILayout.h | 6 +- cocos/gui/UIWidget.cpp | 4 +- cocos/gui/UIWidget.h | 2 +- .../GUI/CCControlExtension/CCScale9Sprite.cpp | 4 +- .../GUI/CCControlExtension/CCScale9Sprite.h | 2 +- extensions/GUI/CCEditBox/CCEditBox.cpp | 4 +- extensions/GUI/CCEditBox/CCEditBox.h | 2 +- extensions/GUI/CCScrollView/CCScrollView.cpp | 5 +- extensions/GUI/CCScrollView/CCScrollView.h | 2 +- .../physics-nodes/CCPhysicsDebugNode.cpp | 4 +- extensions/physics-nodes/CCPhysicsDebugNode.h | 2 +- tests/Classes/ActionsTest/ActionsTest.cpp | 28 ++++----- tests/Classes/ActionsTest/ActionsTest.h | 10 ++-- tests/Classes/Box2DTest/Box2dTest.cpp | 6 +- tests/Classes/Box2DTest/Box2dTest.h | 2 +- tests/Classes/Box2DTestBed/Box2dView.cpp | 6 +- tests/Classes/Box2DTestBed/Box2dView.h | 2 +- .../ClippingNodeTest/ClippingNodeTest.cpp | 9 +-- .../ClippingNodeTest/ClippingNodeTest.h | 2 +- .../DrawPrimitivesTest/DrawPrimitivesTest.cpp | 4 +- .../DrawPrimitivesTest/DrawPrimitivesTest.h | 2 +- .../CocoStudioArmatureTest/ArmatureScene.cpp | 12 ++-- .../CocoStudioArmatureTest/ArmatureScene.h | 6 +- .../CocoStudioSceneTest/SceneEditorTest.cpp | 4 +- .../CocoStudioSceneTest/SceneEditorTest.h | 2 +- .../TableViewTest/CustomTableViewCell.cpp | 4 +- .../TableViewTest/CustomTableViewCell.h | 2 +- tests/Classes/LabelTest/LabelTest.cpp | 14 ++--- tests/Classes/LabelTest/LabelTest.h | 6 +- tests/Classes/LabelTest/LabelTestNew.cpp | 14 ++--- tests/Classes/LabelTest/LabelTestNew.h | 6 +- tests/Classes/MutiTouchTest/MutiTouchTest.cpp | 2 +- tests/Classes/NodeTest/NodeTest.cpp | 6 +- .../RenderTextureTest/RenderTextureTest.cpp | 25 ++++---- .../RenderTextureTest/RenderTextureTest.h | 4 +- tests/Classes/ShaderTest/ShaderTest.cpp | 10 ++-- tests/Classes/ShaderTest/ShaderTest.h | 2 +- tests/Classes/ShaderTest/ShaderTest2.cpp | 8 +-- tests/Classes/Texture2dTest/Texture2dTest.cpp | 13 ++-- tests/Classes/Texture2dTest/Texture2dTest.h | 4 +- tests/Classes/TileMapTest/TileMapTest.cpp | 12 ++-- tests/Classes/TileMapTest/TileMapTest.h | 6 +- 88 files changed, 338 insertions(+), 357 deletions(-) diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index 33bb3392d6..10cd780816 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -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); } diff --git a/cocos/2d/CCAtlasNode.h b/cocos/2d/CCAtlasNode.h index 2af1d89134..b7ff634856 100644 --- a/cocos/2d/CCAtlasNode.h +++ b/cocos/2d/CCAtlasNode.h @@ -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; diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 6417e9e458..d243f38481 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -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, diff --git a/cocos/2d/CCClippingNode.h b/cocos/2d/CCClippingNode.h index 6f0606adc4..bda23ebbca 100644 --- a/cocos/2d/CCClippingNode.h +++ b/cocos/2d/CCClippingNode.h @@ -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(); diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index 3361ecacf3..de204a7ca4 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -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); } diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index e695f2ae1e..b2112d0d1a 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -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() diff --git a/cocos/2d/CCDrawNode.h b/cocos/2d/CCDrawNode.h index 1c7fd6eb82..c25b3bd47b 100644 --- a/cocos/2d/CCDrawNode.h +++ b/cocos/2d/CCDrawNode.h @@ -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(); diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index b0f488568f..a8b1cb0c74 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -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, diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 4be65b0137..098a4694c9 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -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;} diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 97c00d86d0..3e1c29a32d 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -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) { diff --git a/cocos/2d/CCLayer.h b/cocos/2d/CCLayer.h index 73f3192f55..1ed05c6c3c 100644 --- a/cocos/2d/CCLayer.h +++ b/cocos/2d/CCLayer.h @@ -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; diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index 5bd4a49aa2..d7ef7c3b33 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -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); } diff --git a/cocos/2d/CCMotionStreak.h b/cocos/2d/CCMotionStreak.h index 96d050a7d4..1993e8ab34 100644 --- a/cocos/2d/CCMotionStreak.h +++ b/cocos/2d/CCMotionStreak.h @@ -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 */ diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 7dbfa93d47..2413d1fefd 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -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,8 +256,8 @@ 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,8 +415,8 @@ 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; } diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index e9b04215d2..312615ef5c 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -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 @@ -1481,7 +1471,9 @@ 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(); @@ -1506,32 +1498,32 @@ protected: float _skewX; ///< skew angle on x-axis float _skewY; ///< skew angle on y-axis - Point _anchorPointInPoints; ///< anchor point in points - Point _anchorPoint; ///< anchor point normalized (NOT in points) + Point _anchorPointInPoints; ///< anchor point in points + Point _anchorPoint; ///< anchor point normalized (NOT in points) - Size _contentSize; ///< untransformed size of the node + Size _contentSize; ///< untransformed size of the node kmMat4 _modelViewTransform; ///< ModelView transform of the Node. // "cache" variables are allowed to be mutable + mutable kmMat4 _transform; ///< transform + mutable bool _transformDirty; ///< transform dirty flag + mutable kmMat4 _inverse; ///< inverse transform + mutable bool _inverseDirty; ///< inverse transform dirty flag 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 bool _inverseDirty; ///< inverse transform dirty flag + 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 - int _localZOrder; ///< Local order (relative to its siblings) used to sort the node - float _globalZOrder; ///< Global order used to sort the node - - Vector _children; ///< array of children nodes + Vector _children; ///< array of children nodes Node *_parent; ///< weak reference to parent node - int _tag; ///< a tag. Can be any number you assigned just to identify this node + int _tag; ///< a tag. Can be any number you assigned just to identify this node - void *_userData; ///< A user assingned void pointer, Can be point to any cpp object - Ref *_userObject; ///< A user assigned Object + void *_userData; ///< A user assingned void pointer, Can be point to any cpp object + Ref *_userObject; ///< A user assigned Object GLProgram *_shaderProgram; ///< OpenGL shader @@ -1543,9 +1535,9 @@ protected: EventDispatcher* _eventDispatcher; ///< event dispatcher used to dispatch all kinds of events - bool _running; ///< is running + bool _running; ///< is running - bool _visible; ///< is this node visible + bool _visible; ///< is this node visible bool _ignoreAnchorPointForPosition; ///< true if the Anchor Point will be (0,0) when you position the Node, false otherwise. ///< Used by Layer and Scene. diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index a94bfcecb0..66585a3c61 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -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, diff --git a/cocos/2d/CCNodeGrid.h b/cocos/2d/CCNodeGrid.h index 45c165b1e0..626b2d43e8 100644 --- a/cocos/2d/CCNodeGrid.h +++ b/cocos/2d/CCNodeGrid.h @@ -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(); diff --git a/cocos/2d/CCParallaxNode.cpp b/cocos/2d/CCParallaxNode.cpp index 85968330d6..19b3b6b96d 100644 --- a/cocos/2d/CCParallaxNode.cpp +++ b/cocos/2d/CCParallaxNode.cpp @@ -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 diff --git a/cocos/2d/CCParallaxNode.h b/cocos/2d/CCParallaxNode.h index 26956c5a67..7f74bba10c 100644 --- a/cocos/2d/CCParallaxNode.h +++ b/cocos/2d/CCParallaxNode.h @@ -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 diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index 7f68da628b..4fa0e67f0a 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -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"); } diff --git a/cocos/2d/CCParticleBatchNode.h b/cocos/2d/CCParticleBatchNode.h index 9623c74dee..17c889f818 100644 --- a/cocos/2d/CCParticleBatchNode.h +++ b/cocos/2d/CCParticleBatchNode.h @@ -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; /** diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index afa62e20e9..1f11b4c4d6 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -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); } } diff --git a/cocos/2d/CCParticleSystemQuad.h b/cocos/2d/CCParticleSystemQuad.h index db858ca1e4..3e48129ac0 100644 --- a/cocos/2d/CCParticleSystemQuad.h +++ b/cocos/2d/CCParticleSystemQuad.h @@ -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 diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index 4b8097f3b5..9e47e78dbb 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -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); } diff --git a/cocos/2d/CCProgressTimer.h b/cocos/2d/CCProgressTimer.h index f19c08367f..2013453e84 100644 --- a/cocos/2d/CCProgressTimer.h +++ b/cocos/2d/CCProgressTimer.h @@ -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; diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index 91eaedae55..f039bd5973 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -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 diff --git a/cocos/2d/CCRenderTexture.h b/cocos/2d/CCRenderTexture.h index 5ccd0ae25f..2e5df94754 100644 --- a/cocos/2d/CCRenderTexture.h +++ b/cocos/2d/CCRenderTexture.h @@ -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. diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index c39b202a7b..e61912d4ae 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -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 } } diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index f79abdb9db..9e8c8c4bdc 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -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); }; diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index f5d38a732b..aae535904a 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -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) diff --git a/cocos/2d/CCSpriteBatchNode.h b/cocos/2d/CCSpriteBatchNode.h index 24f4f90c60..d95fcfcaf4 100644 --- a/cocos/2d/CCSpriteBatchNode.h +++ b/cocos/2d/CCSpriteBatchNode.h @@ -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. diff --git a/cocos/2d/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 8b7c06cecb..4911187604 100644 --- a/cocos/2d/CCTextFieldTTF.cpp +++ b/cocos/2d/CCTextFieldTTF.cpp @@ -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); } diff --git a/cocos/2d/CCTextFieldTTF.h b/cocos/2d/CCTextFieldTTF.h index 6aa6ffd2a3..9019cf95ee 100644 --- a/cocos/2d/CCTextFieldTTF.h +++ b/cocos/2d/CCTextFieldTTF.h @@ -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 diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 0dac8352c8..7344a28306 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -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); } } diff --git a/cocos/2d/CCTransition.h b/cocos/2d/CCTransition.h index 29989f819b..b98eb7c360 100644 --- a/cocos/2d/CCTransition.h +++ b/cocos/2d/CCTransition.h @@ -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(); diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index d7780ae8ce..9736dcda21 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -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); } } diff --git a/cocos/2d/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h index f65a66f2cd..ebbffa4d06 100644 --- a/cocos/2d/CCTransitionPageTurn.h +++ b/cocos/2d/CCTransitionPageTurn.h @@ -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. diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 3599e9d867..5c417ee316 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -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(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, diff --git a/cocos/editor-support/cocostudio/CCArmature.h b/cocos/editor-support/cocostudio/CCArmature.h index ae5d9e1031..b951aa7b1f 100644 --- a/cocos/editor-support/cocostudio/CCArmature.h +++ b/cocos/editor-support/cocostudio/CCArmature.h @@ -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; diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 58841cb695..c8aa941a3b 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -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); } } } diff --git a/cocos/editor-support/cocostudio/CCBatchNode.h b/cocos/editor-support/cocostudio/CCBatchNode.h index d08f134283..56acaf0f15 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.h +++ b/cocos/editor-support/cocostudio/CCBatchNode.h @@ -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(); diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index f6656cee62..4d153f5baf 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -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) diff --git a/cocos/editor-support/cocostudio/CCSkin.h b/cocos/editor-support/cocostudio/CCSkin.h index 29583892b6..33b1a24915 100644 --- a/cocos/editor-support/cocostudio/CCSkin.h +++ b/cocos/editor-support/cocostudio/CCSkin.h @@ -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 diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index 5089f374f4..1b23ac971c 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -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 () diff --git a/cocos/editor-support/spine/CCSkeleton.h b/cocos/editor-support/spine/CCSkeleton.h index 18bdd50328..fa81d1bfa6 100644 --- a/cocos/editor-support/spine/CCSkeleton.h +++ b/cocos/editor-support/spine/CCSkeleton.h @@ -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; diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index e33742808c..3a13abc41e 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -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); diff --git a/cocos/gui/UILayout.h b/cocos/gui/UILayout.h index 48eeff5870..67b9006c8f 100644 --- a/cocos/gui/UILayout.h +++ b/cocos/gui/UILayout.h @@ -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(); diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 211ccb48c5..7ecfe2f93a 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -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); } } diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index 9d1f925afa..3cdd3b3f13 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -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 diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index b25ea9bfac..01f9e1a05b 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -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) diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/extensions/GUI/CCControlExtension/CCScale9Sprite.h index c66949f515..6c2ee432bd 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -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; diff --git a/extensions/GUI/CCEditBox/CCEditBox.cpp b/extensions/GUI/CCEditBox/CCEditBox.cpp index 01df63ace1..479f28b905 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.cpp +++ b/extensions/GUI/CCEditBox/CCEditBox.cpp @@ -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(); diff --git a/extensions/GUI/CCEditBox/CCEditBox.h b/extensions/GUI/CCEditBox/CCEditBox.h index eb05e7a1a7..90b962d516 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.h +++ b/extensions/GUI/CCEditBox/CCEditBox.h @@ -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 diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index f681ba2339..e858b36cdf 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -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, diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index 0ec96b5049..4dc5871bc9 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -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; diff --git a/extensions/physics-nodes/CCPhysicsDebugNode.cpp b/extensions/physics-nodes/CCPhysicsDebugNode.cpp index f1f5cdb0b6..3e5e9b434a 100644 --- a/extensions/physics-nodes/CCPhysicsDebugNode.cpp +++ b/extensions/physics-nodes/CCPhysicsDebugNode.cpp @@ -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 } diff --git a/extensions/physics-nodes/CCPhysicsDebugNode.h b/extensions/physics-nodes/CCPhysicsDebugNode.h index d39cf3376b..385a4938b2 100644 --- a/extensions/physics-nodes/CCPhysicsDebugNode.h +++ b/extensions/physics-nodes/CCPhysicsDebugNode.h @@ -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; diff --git a/tests/Classes/ActionsTest/ActionsTest.cpp b/tests/Classes/ActionsTest/ActionsTest.cpp index 0e9167f2a0..7795b08a0c 100644 --- a/tests/Classes/ActionsTest/ActionsTest.cpp +++ b/tests/Classes/ActionsTest/ActionsTest.cpp @@ -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() diff --git a/tests/Classes/ActionsTest/ActionsTest.h b/tests/Classes/ActionsTest/ActionsTest.h index 6467961a8a..3545add4e7 100644 --- a/tests/Classes/ActionsTest/ActionsTest.h +++ b/tests/Classes/ActionsTest/ActionsTest.h @@ -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: diff --git a/tests/Classes/Box2DTest/Box2dTest.cpp b/tests/Classes/Box2DTest/Box2dTest.cpp index 57f23413d9..799799aae8 100644 --- a/tests/Classes/Box2DTest/Box2dTest.cpp +++ b/tests/Classes/Box2DTest/Box2dTest.cpp @@ -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 diff --git a/tests/Classes/Box2DTest/Box2dTest.h b/tests/Classes/Box2DTest/Box2dTest.h index ce7ce93503..b9873d219a 100644 --- a/tests/Classes/Box2DTest/Box2dTest.h +++ b/tests/Classes/Box2DTest/Box2dTest.h @@ -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); diff --git a/tests/Classes/Box2DTestBed/Box2dView.cpp b/tests/Classes/Box2DTestBed/Box2dView.cpp index 277955b9d5..eee2ea87de 100644 --- a/tests/Classes/Box2DTestBed/Box2dView.cpp +++ b/tests/Classes/Box2DTestBed/Box2dView.cpp @@ -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() diff --git a/tests/Classes/Box2DTestBed/Box2dView.h b/tests/Classes/Box2DTestBed/Box2dView.h index 3e95cda7bd..aded546074 100644 --- a/tests/Classes/Box2DTestBed/Box2dView.h +++ b/tests/Classes/Box2DTestBed/Box2dView.h @@ -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); diff --git a/tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 0949d0163a..da1423de7f 100644 --- a/tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -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()); @@ -614,9 +614,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const kmMat4 &transform, boo iter->func = CC_CALLBACK_0(RawStencilBufferTest::onEnableStencil, this); 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() diff --git a/tests/Classes/ClippingNodeTest/ClippingNodeTest.h b/tests/Classes/ClippingNodeTest/ClippingNodeTest.h index ed82143233..faeb155ad7 100644 --- a/tests/Classes/ClippingNodeTest/ClippingNodeTest.h +++ b/tests/Classes/ClippingNodeTest/ClippingNodeTest.h @@ -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); diff --git a/tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 7439490fbf..7159ba6a7e 100644 --- a/tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -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() diff --git a/tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h b/tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h index 8534d23894..de6a5a47f2 100644 --- a/tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h +++ b/tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h @@ -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: diff --git a/tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index adc4a84ac9..17475ff07d 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -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,12 +1106,12 @@ 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); + } void TestBoundingBox::onDraw() diff --git a/tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index 1add61178f..f7b1fa74e7 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -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; diff --git a/tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index cc2523b01d..eb0362dead 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -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); } diff --git a/tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h b/tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h index 523b8f9840..623b30a828 100644 --- a/tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h +++ b/tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h @@ -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; diff --git a/tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp b/tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp index f90354d4bd..abed653fd4 100644 --- a/tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp +++ b/tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp @@ -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); diff --git a/tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h b/tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h index a82d74375a..d7277f65da 100644 --- a/tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h +++ b/tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h @@ -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__ */ diff --git a/tests/Classes/LabelTest/LabelTest.cpp b/tests/Classes/LabelTest/LabelTest.cpp index 7bc56727a5..8e5bc43148 100644 --- a/tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/Classes/LabelTest/LabelTest.cpp @@ -206,14 +206,14 @@ 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() diff --git a/tests/Classes/LabelTest/LabelTest.h b/tests/Classes/LabelTest/LabelTest.h index fcc18d37c1..f549e0d542 100644 --- a/tests/Classes/LabelTest/LabelTest.h +++ b/tests/Classes/LabelTest/LabelTest.h @@ -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: diff --git a/tests/Classes/LabelTest/LabelTestNew.cpp b/tests/Classes/LabelTest/LabelTestNew.cpp index e1c320bae9..276407e139 100644 --- a/tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/Classes/LabelTest/LabelTestNew.cpp @@ -309,12 +309,12 @@ 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); + } void LabelFNTSpriteActions::onDraw() @@ -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 diff --git a/tests/Classes/LabelTest/LabelTestNew.h b/tests/Classes/LabelTest/LabelTestNew.h index b567056a9d..179ea50d98 100644 --- a/tests/Classes/LabelTest/LabelTestNew.h +++ b/tests/Classes/LabelTest/LabelTestNew.h @@ -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; diff --git a/tests/Classes/MutiTouchTest/MutiTouchTest.cpp b/tests/Classes/MutiTouchTest/MutiTouchTest.cpp index 23933b76b4..a17e5a072f 100644 --- a/tests/Classes/MutiTouchTest/MutiTouchTest.cpp +++ b/tests/Classes/MutiTouchTest/MutiTouchTest.cpp @@ -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); diff --git a/tests/Classes/NodeTest/NodeTest.cpp b/tests/Classes/NodeTest/NodeTest.cpp index a3e10a4753..900de637a2 100644 --- a/tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/Classes/NodeTest/NodeTest.cpp @@ -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() diff --git a/tests/Classes/RenderTextureTest/RenderTextureTest.cpp b/tests/Classes/RenderTextureTest/RenderTextureTest.cpp index 4107b99ff1..31e670ce72 100644 --- a/tests/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -462,32 +462,31 @@ 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(); _rend->end(); _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); - - Sprite::draw(renderer, transform, transformDirty); + renderer->addCommand(&_customCommand); + + Sprite::draw(renderer, transform, transformUpdated); } diff --git a/tests/Classes/RenderTextureTest/RenderTextureTest.h b/tests/Classes/RenderTextureTest/RenderTextureTest.h index 88aead2bfc..18b71928b3 100644 --- a/tests/Classes/RenderTextureTest/RenderTextureTest.h +++ b/tests/Classes/RenderTextureTest/RenderTextureTest.h @@ -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(); diff --git a/tests/Classes/ShaderTest/ShaderTest.cpp b/tests/Classes/ShaderTest/ShaderTest.cpp index 6818dc9869..5fccff59f5 100644 --- a/tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/Classes/ShaderTest/ShaderTest.cpp @@ -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() diff --git a/tests/Classes/ShaderTest/ShaderTest.h b/tests/Classes/ShaderTest/ShaderTest.h index 677efd4a59..7f40f7e313 100644 --- a/tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/Classes/ShaderTest/ShaderTest.h @@ -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); diff --git a/tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/Classes/ShaderTest/ShaderTest2.cpp index e605ef78e9..e506e64b4d 100644 --- a/tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/Classes/ShaderTest/ShaderTest2.cpp @@ -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,12 +176,12 @@ 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); + } void ShaderSprite::onDraw() diff --git a/tests/Classes/Texture2dTest/Texture2dTest.cpp b/tests/Classes/Texture2dTest/Texture2dTest.cpp index a5cd917408..7c6fed175a 100644 --- a/tests/Classes/Texture2dTest/Texture2dTest.cpp +++ b/tests/Classes/Texture2dTest/Texture2dTest.cpp @@ -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() diff --git a/tests/Classes/Texture2dTest/Texture2dTest.h b/tests/Classes/Texture2dTest/Texture2dTest.h index 672da26333..90fb0adb06 100644 --- a/tests/Classes/Texture2dTest/Texture2dTest.h +++ b/tests/Classes/Texture2dTest/Texture2dTest.h @@ -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(); diff --git a/tests/Classes/TileMapTest/TileMapTest.cpp b/tests/Classes/TileMapTest/TileMapTest.cpp index b44fefa4fa..198874d30a 100644 --- a/tests/Classes/TileMapTest/TileMapTest.cpp +++ b/tests/Classes/TileMapTest/TileMapTest.cpp @@ -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() diff --git a/tests/Classes/TileMapTest/TileMapTest.h b/tests/Classes/TileMapTest/TileMapTest.h index 85ad393a56..7c34b3dfc1 100644 --- a/tests/Classes/TileMapTest/TileMapTest.h +++ b/tests/Classes/TileMapTest/TileMapTest.h @@ -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;