diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index 1cc4d752b2..d63eee9aac 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -34,7 +34,7 @@ THE SOFTWARE. #include "CCDirector.h" #include "TransformUtils.h" #include "CCRenderer.h" -#include "CCQuadCommand.h" +#include "renderer/CCQuadCommand.h" // external #include "kazmath/GL/matrix.h" @@ -151,8 +151,7 @@ void AtlasNode::draw(void) auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); - QuadCommand* cmd = new QuadCommand(); - cmd->init(0, + _quadCommand.init(0, _vertexZ, _textureAtlas->getTexture()->getName(), shader, @@ -161,7 +160,7 @@ void AtlasNode::draw(void) _textureAtlas->getTotalQuads(), _modelViewTransform); - Director::getInstance()->getRenderer()->addCommand(cmd); + Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } diff --git a/cocos/2d/CCAtlasNode.h b/cocos/2d/CCAtlasNode.h index fc0636326b..7aabea937d 100644 --- a/cocos/2d/CCAtlasNode.h +++ b/cocos/2d/CCAtlasNode.h @@ -30,6 +30,7 @@ THE SOFTWARE. #include "CCNode.h" #include "CCProtocols.h" #include "ccTypes.h" +#include "renderer/CCQuadCommand.h" NS_CC_BEGIN @@ -130,6 +131,8 @@ protected: GLint _uniformColor; // This varible is only used for LabelAtlas FPS display. So plz don't modify its value. bool _ignoreContentScaleFactor; + // quad command + QuadCommand _quadCommand; private: CC_DISALLOW_COPY_AND_ASSIGN(AtlasNode); diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index 0156c33554..e58f919b92 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -42,7 +42,7 @@ #include "platform/CCFileUtils.h" #include "kazmath/GL/matrix.h" #include "CCProfiling.h" -#include "CCQuadCommand.h" +#include "renderer/CCQuadCommand.h" #include "CCRenderer.h" NS_CC_BEGIN @@ -392,8 +392,7 @@ void ParticleBatchNode::draw(void) kmMat4 mv; kmGLGetMatrix(KM_GL_MODELVIEW, &mv); - QuadCommand* cmd = new QuadCommand(); - cmd->init(0, + _quadCommand.init(0, _vertexZ, _textureAtlas->getTexture()->getName(), shader, @@ -401,7 +400,7 @@ void ParticleBatchNode::draw(void) _textureAtlas->getQuads(), _textureAtlas->getTotalQuads(), mv); - Director::getInstance()->getRenderer()->addCommand(cmd); + Director::getInstance()->getRenderer()->addCommand(&_quadCommand); CC_PROFILER_STOP("CCParticleBatchNode - draw"); } diff --git a/cocos/2d/CCParticleBatchNode.h b/cocos/2d/CCParticleBatchNode.h index 189bfc7da9..4162d3b9dd 100644 --- a/cocos/2d/CCParticleBatchNode.h +++ b/cocos/2d/CCParticleBatchNode.h @@ -31,6 +31,7 @@ #include "CCNode.h" #include "CCProtocols.h" +#include "renderer/CCQuadCommand.h" NS_CC_BEGIN @@ -140,6 +141,8 @@ private: private: /** the blend function used for drawing the quads */ BlendFunc _blendFunc; + // quad command + QuadCommand _quadCommand; }; // end of particle_nodes group diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 98c3f00c15..30a45644e0 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -39,7 +39,7 @@ THE SOFTWARE. #include "CCEventType.h" #include "CCConfiguration.h" #include "CCRenderer.h" -#include "CCQuadCommand.h" +#include "renderer/CCQuadCommand.h" #include "CCCustomCommand.h" // extern @@ -443,9 +443,8 @@ void ParticleSystemQuad::draw() auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); - QuadCommand* cmd = new QuadCommand(); - cmd->init(0, _vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform); - Director::getInstance()->getRenderer()->addCommand(cmd); + _quadCommand.init(0, _vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform); + Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } } diff --git a/cocos/2d/CCParticleSystemQuad.h b/cocos/2d/CCParticleSystemQuad.h index 07f8f6bffc..e5f54d0837 100644 --- a/cocos/2d/CCParticleSystemQuad.h +++ b/cocos/2d/CCParticleSystemQuad.h @@ -28,6 +28,7 @@ THE SOFTWARE. #define __CC_PARTICLE_SYSTEM_QUAD_H__ #include "CCParticleSystem.h" +#include "renderer/CCQuadCommand.h" NS_CC_BEGIN @@ -151,6 +152,8 @@ protected: GLuint _buffersVBO[2]; //0: vertex 1: indices kmMat4 _transformMatrix; + + QuadCommand _quadCommand; // quad command private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleSystemQuad); }; diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index af3dcd8891..f0e48184b0 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -45,7 +45,7 @@ THE SOFTWARE. #include "TransformUtils.h" #include "CCProfiling.h" #include "CCRenderer.h" -#include "CCQuadCommand.h" +#include "renderer/CCQuadCommand.h" #include "CCFrustum.h" // external @@ -671,8 +671,7 @@ void Sprite::updateTransform(void) void Sprite::draw(void) { //TODO implement z order - QuadCommand* renderCommand = new QuadCommand(); - renderCommand->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform); + _quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform); // if(!culling()) // { @@ -680,7 +679,7 @@ void Sprite::draw(void) // } // else { - Director::getInstance()->getRenderer()->addCommand(renderCommand); + Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } } diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 86df10a055..3b99769c07 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -37,6 +37,7 @@ THE SOFTWARE. #include "CCGLBufferedNode.h" #endif // EMSCRIPTEN #include "CCPhysicsBody.h" +#include "renderer/CCQuadCommand.h" #include "kazmath/kazmath.h" NS_CC_BEGIN @@ -545,6 +546,7 @@ protected: // BlendFunc _blendFunc; /// It's required for TextureProtocol inheritance Texture2D* _texture; /// Texture2D object that is used to render the sprite + QuadCommand _quadCommand; /// quad command // // Shared data diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index f553b3314c..41d57735cf 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -43,7 +43,7 @@ THE SOFTWARE. #include "CCLayer.h" #include "CCScene.h" #include "CCRenderer.h" -#include "CCQuadCommand.h" +#include "renderer/CCQuadCommand.h" // external #include "kazmath/GL/matrix.h" @@ -360,8 +360,7 @@ void SpriteBatchNode::draw() kmMat4 mv; kmGLGetMatrix(KM_GL_MODELVIEW, &mv); - QuadCommand* cmd = new QuadCommand(); - cmd->init(0, + _quadCommand.init(0, _vertexZ, _textureAtlas->getTexture()->getName(), shader, @@ -369,7 +368,7 @@ void SpriteBatchNode::draw() _textureAtlas->getQuads(), _textureAtlas->getTotalQuads(), mv); - Director::getInstance()->getRenderer()->addCommand(cmd); + Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } void SpriteBatchNode::increaseAtlasCapacity(void) diff --git a/cocos/2d/CCSpriteBatchNode.h b/cocos/2d/CCSpriteBatchNode.h index 82adde74af..28c7b382aa 100644 --- a/cocos/2d/CCSpriteBatchNode.h +++ b/cocos/2d/CCSpriteBatchNode.h @@ -34,6 +34,7 @@ THE SOFTWARE. #include "CCProtocols.h" #include "CCTextureAtlas.h" #include "ccMacros.h" +#include "renderer/CCQuadCommand.h" NS_CC_BEGIN @@ -187,6 +188,7 @@ protected: TextureAtlas *_textureAtlas; BlendFunc _blendFunc; + QuadCommand _quadCommand; // quad command // all descendants: children, grand children, etc... // There is not need to retain/release these objects, since they are already retained by _children diff --git a/cocos/2d/renderer/CCQuadCommand.cpp b/cocos/2d/renderer/CCQuadCommand.cpp index 89b5630db9..916519c6aa 100644 --- a/cocos/2d/renderer/CCQuadCommand.cpp +++ b/cocos/2d/renderer/CCQuadCommand.cpp @@ -23,7 +23,7 @@ ****************************************************************************/ -#include "CCQuadCommand.h" +#include "renderer/CCQuadCommand.h" #include "ccGLStateCache.h" NS_CC_BEGIN diff --git a/cocos/2d/renderer/CCQuadCommand.h b/cocos/2d/renderer/CCQuadCommand.h index 6516b9c1c6..afe306acbf 100644 --- a/cocos/2d/renderer/CCQuadCommand.h +++ b/cocos/2d/renderer/CCQuadCommand.h @@ -108,7 +108,6 @@ public: void pushBackCommand(QuadCommand* ptr) { - delete ptr; } }; diff --git a/cocos/2d/renderer/CCRenderer.cpp b/cocos/2d/renderer/CCRenderer.cpp index 0eeca3844f..8841aff768 100644 --- a/cocos/2d/renderer/CCRenderer.cpp +++ b/cocos/2d/renderer/CCRenderer.cpp @@ -26,7 +26,7 @@ #include "CCShaderCache.h" #include "ccGLStateCache.h" #include "CCCustomCommand.h" -#include "CCQuadCommand.h" +#include "renderer/CCQuadCommand.h" #include "CCGroupCommand.h" #include "CCConfiguration.h" #include "CCNotificationCenter.h" diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index f063fe60f4..dd57487d0e 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "cocostudio/CCDataReaderHelper.h" #include "cocostudio/CCDatas.h" #include "cocostudio/CCSkin.h" -#include "CCQuadCommand.h" +#include "renderer/CCQuadCommand.h" #include "CCRenderer.h" #include "CCGroupCommand.h" diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index 38450ff900..0f41b9f6f9 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -219,9 +219,8 @@ void Skin::draw() kmGLGetMatrix(KM_GL_MODELVIEW, &mv); //TODO implement z order - QuadCommand* renderCommand = new QuadCommand(); - renderCommand->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv); - Director::getInstance()->getRenderer()->addCommand(renderCommand); + _quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv); + Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } void Skin::setBone(Bone *bone) diff --git a/cocos/editor-support/cocostudio/CCSkin.h b/cocos/editor-support/cocostudio/CCSkin.h index d9e4c4e532..42ba994189 100644 --- a/cocos/editor-support/cocostudio/CCSkin.h +++ b/cocos/editor-support/cocostudio/CCSkin.h @@ -27,6 +27,7 @@ THE SOFTWARE. #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCBone.h" +#include "renderer/CCQuadCommand.h" namespace cocostudio { @@ -74,6 +75,7 @@ protected: Armature *_armature; kmMat4 _skinTransform; std::string _displayName; + cocos2d::QuadCommand _quadCommand; // quad command }; }