Merge pull request #4728 from dabingnn/develop_removeCommandPool

Develop remove command pool
This commit is contained in:
minggo 2013-12-29 21:53:12 -08:00
commit 0e9b43248c
61 changed files with 274 additions and 268 deletions

View File

@ -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 = QuadCommand::getCommandPool().generateCommand();
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);
}

View File

@ -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);

View File

@ -209,23 +209,20 @@ void ClippingNode::visit()
Renderer* renderer = Director::getInstance()->getRenderer();
GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand();
groupCommand->init(0,_vertexZ);
renderer->addCommand(groupCommand);
_groupCommand.init(0,_vertexZ);
renderer->addCommand(&_groupCommand);
renderer->pushGroup(groupCommand->getRenderQueueID());
renderer->pushGroup(_groupCommand.getRenderQueueID());
CustomCommand* beforeVisitCmd = CustomCommand::getCommandPool().generateCommand();
beforeVisitCmd->init(0,_vertexZ);
beforeVisitCmd->func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
renderer->addCommand(beforeVisitCmd);
_beforeVisitCmd.init(0,_vertexZ);
_beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
renderer->addCommand(&_beforeVisitCmd);
_stencil->visit();
CustomCommand* afterDrawStencilCmd = CustomCommand::getCommandPool().generateCommand();
afterDrawStencilCmd->init(0,_vertexZ);
afterDrawStencilCmd->func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
renderer->addCommand(afterDrawStencilCmd);
_afterDrawStencilCmd.init(0,_vertexZ);
_afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
renderer->addCommand(&_afterDrawStencilCmd);
int i = 0;
@ -253,10 +250,9 @@ void ClippingNode::visit()
this->draw();
}
CustomCommand* afterVisitCmd = CustomCommand::getCommandPool().generateCommand();
afterVisitCmd->init(0,_vertexZ);
afterVisitCmd->func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
renderer->addCommand(afterVisitCmd);
_afterVisitCmd.init(0,_vertexZ);
_afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
renderer->addCommand(&_afterVisitCmd);
renderer->popGroup();

View File

@ -30,6 +30,8 @@
#include "CCNode.h"
#include "CCGL.h"
#include "renderer/CCGroupCommand.h"
#include "renderer/CCCustomCommand.h"
NS_CC_BEGIN
@ -141,6 +143,11 @@ protected:
GLclampf _currentAlphaTestRef;
GLint _mask_layer_le;
GroupCommand _groupCommand;
CustomCommand _beforeVisitCmd;
CustomCommand _afterDrawStencilCmd;
CustomCommand _afterVisitCmd;
private:
CC_DISALLOW_COPY_AND_ASSIGN(ClippingNode);

View File

@ -241,10 +241,9 @@ void DrawNode::render()
void DrawNode::draw()
{
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(DrawNode::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void DrawNode::onDraw()

View File

@ -32,6 +32,7 @@
#include "CCNode.h"
#include "ccTypes.h"
#include "renderer/CCCustomCommand.h"
NS_CC_BEGIN
@ -105,6 +106,7 @@ protected:
V2F_C4B_T2F *_buffer;
BlendFunc _blendFunc;
CustomCommand _customCommand;
bool _dirty;

View File

@ -564,10 +564,9 @@ void LayerColor::updateColor()
void LayerColor::draw()
{
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(LayerColor::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void LayerColor::onDraw()

View File

@ -35,6 +35,7 @@ THE SOFTWARE.
#endif // EMSCRIPTEN
#include "CCEventKeyboard.h"
#include "renderer/CCCustomCommand.h"
NS_CC_BEGIN
@ -296,6 +297,7 @@ protected:
BlendFunc _blendFunc;
Vertex2F _squareVertices[4];
Color4F _squareColors[4];
CustomCommand _customCommand;
private:
CC_DISALLOW_COPY_AND_ASSIGN(LayerColor);

View File

@ -358,10 +358,9 @@ void MotionStreak::draw()
if(_nuPoints <= 1)
return;
kmGLGetMatrix(KM_GL_MODELVIEW,&_cachedMV);
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0,_vertexZ);
cmd->func = CC_CALLBACK_0(MotionStreak::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0,_vertexZ);
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -29,6 +29,7 @@ THE SOFTWARE.
#include "CCTexture2D.h"
#include "ccTypes.h"
#include "CCNode.h"
#include "renderer/CCCustomCommand.h"
#ifdef EMSCRIPTEN
#include "CCGLBufferedNode.h"
#endif // EMSCRIPTEN
@ -144,6 +145,8 @@ protected:
Vertex2F* _vertices;
GLubyte* _colorPointer;
Tex2F* _texCoords;
CustomCommand _customCommand;
private:
CC_DISALLOW_COPY_AND_ASSIGN(MotionStreak);

View File

@ -92,10 +92,9 @@ void NodeGrid::visit()
Renderer* renderer = Director::getInstance()->getRenderer();
GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand();
groupCommand->init(0,_vertexZ);
renderer->addCommand(groupCommand);
renderer->pushGroup(groupCommand->getRenderQueueID());
_groupCommand.init(0,_vertexZ);
renderer->addCommand(&_groupCommand);
renderer->pushGroup(_groupCommand.getRenderQueueID());
kmGLPushMatrix();
Director::Projection beforeProjectionType;
@ -105,10 +104,9 @@ void NodeGrid::visit()
_nodeGrid->set2DProjection();
}
CustomCommand* gridBeginCmd = CustomCommand::getCommandPool().generateCommand();
gridBeginCmd->init(0,_vertexZ);
gridBeginCmd->func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this);
renderer->addCommand(gridBeginCmd);
_gridBeginCommand.init(0,_vertexZ);
_gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this);
renderer->addCommand(&_gridBeginCommand);
this->transform();
@ -154,10 +152,9 @@ void NodeGrid::visit()
director->setProjection(beforeProjectionType);
}
CustomCommand* gridEndCmd = CustomCommand::getCommandPool().generateCommand();
gridEndCmd->init(0,_vertexZ);
gridEndCmd->func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this);
renderer->addCommand(gridEndCmd);
_gridEndCommand.init(0,_vertexZ);
_gridEndCommand.func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this);
renderer->addCommand(&_gridEndCommand);
renderer->popGroup();

View File

@ -27,6 +27,8 @@
#include "CCNode.h"
#include "kazmath/GL/matrix.h"
#include "renderer/CCGroupCommand.h"
#include "renderer/CCCustomCommand.h"
NS_CC_BEGIN
@ -64,6 +66,9 @@ protected:
Node* _gridTarget;
GridBase* _nodeGrid;
GroupCommand _groupCommand;
CustomCommand _gridBeginCommand;
CustomCommand _gridEndCommand;
private:
CC_DISALLOW_COPY_AND_ASSIGN(NodeGrid);

View File

@ -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 = QuadCommand::getCommandPool().generateCommand();
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");
}

View File

@ -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

View File

@ -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 = QuadCommand::getCommandPool().generateCommand();
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);
}
}

View File

@ -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);
};

View File

@ -532,10 +532,9 @@ void ProgressTimer::draw()
if( ! _vertexData || ! _sprite)
return;
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(ProgressTimer::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -26,6 +26,7 @@ THE SOFTWARE.
#define __MISC_NODE_CCPROGRESS_TIMER_H__
#include "CCSprite.h"
#include "renderer/CCCustomCommand.h"
#ifdef EMSCRIPTEN
#include "CCGLBufferedNode.h"
#endif // EMSCRIPTEN
@ -143,6 +144,8 @@ protected:
Sprite *_sprite;
int _vertexDataCount;
V2F_C4B_T2F *_vertexData;
CustomCommand _customCommand;
bool _reverseDirection;

View File

@ -329,10 +329,9 @@ void RenderTexture::beginWithClear(float r, float g, float b, float a, float dep
this->begin();
//clear screen
CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand();
clearCmd->init(0, _vertexZ);
clearCmd->func = CC_CALLBACK_0(RenderTexture::onClear, this);
Director::getInstance()->getRenderer()->addCommand(clearCmd);
_beginWithClearCommand.init(0, _vertexZ);
_beginWithClearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this);
Director::getInstance()->getRenderer()->addCommand(&_beginWithClearCommand);
}
//TODO find a better way to clear the screen, there is no need to rebind render buffer there.
@ -348,11 +347,10 @@ void RenderTexture::clearDepth(float depthValue)
this->begin();
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(RenderTexture::onClearDepth, this);
_clearDepthCommand.init(0, _vertexZ);
_clearDepthCommand.func = CC_CALLBACK_0(RenderTexture::onClearDepth, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
Director::getInstance()->getRenderer()->addCommand(&_clearDepthCommand);
this->end();
}
@ -614,10 +612,9 @@ void RenderTexture::draw()
begin();
//clear screen
CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand();
clearCmd->init(0, _vertexZ);
clearCmd->func = CC_CALLBACK_0(RenderTexture::onClear, this);
Director::getInstance()->getRenderer()->addCommand(clearCmd);
_clearCommand.init(0, _vertexZ);
_clearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this);
Director::getInstance()->getRenderer()->addCommand(&_clearCommand);
//! make sure all children are drawn
sortAllChildren();
@ -643,28 +640,25 @@ void RenderTexture::begin()
kmGLPushMatrix();
kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix);
GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand();
groupCommand->init(0, _vertexZ);
_groupCommand.init(0, _vertexZ);
Renderer *renderer = Director::getInstance()->getRenderer();
renderer->addCommand(groupCommand);
renderer->pushGroup(groupCommand->getRenderQueueID());
renderer->addCommand(&_groupCommand);
renderer->pushGroup(_groupCommand.getRenderQueueID());
CustomCommand* beginCmd = CustomCommand::getCommandPool().generateCommand();
beginCmd->init(0, _vertexZ);
beginCmd->func = CC_CALLBACK_0(RenderTexture::onBegin, this);
_beginCommand.init(0, _vertexZ);
_beginCommand.func = CC_CALLBACK_0(RenderTexture::onBegin, this);
Director::getInstance()->getRenderer()->addCommand(beginCmd);
Director::getInstance()->getRenderer()->addCommand(&_beginCommand);
}
void RenderTexture::end()
{
CustomCommand* endCmd = CustomCommand::getCommandPool().generateCommand();
endCmd->init(0, _vertexZ);
endCmd->func = CC_CALLBACK_0(RenderTexture::onEnd, this);
_endCommand.init(0, _vertexZ);
_endCommand.func = CC_CALLBACK_0(RenderTexture::onEnd, this);
Renderer *renderer = Director::getInstance()->getRenderer();
renderer->addCommand(endCmd);
renderer->addCommand(&_endCommand);
renderer->popGroup();
}

View File

@ -29,6 +29,8 @@ THE SOFTWARE.
#include "CCSprite.h"
#include "kazmath/mat4.h"
#include "platform/CCImage.h"
#include "renderer/CCGroupCommand.h"
#include "renderer/CCCustomCommand.h"
NS_CC_BEGIN
@ -187,6 +189,13 @@ protected:
- [[renderTexture sprite] setBlendFunc:(BlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
*/
Sprite* _sprite;
GroupCommand _groupCommand;
CustomCommand _beginWithClearCommand;
CustomCommand _clearDepthCommand;
CustomCommand _clearCommand;
CustomCommand _beginCommand;
CustomCommand _endCommand;
protected:
//renderer caches and callbacks
void onBegin();

View File

@ -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,16 +671,11 @@ void Sprite::updateTransform(void)
void Sprite::draw(void)
{
//TODO implement z order
QuadCommand* renderCommand = QuadCommand::getCommandPool().generateCommand();
renderCommand->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
_quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform);
// if(!culling())
// {
// renderCommand->releaseToCommandPool();
// }
// else
// if(culling())
{
Director::getInstance()->getRenderer()->addCommand(renderCommand);
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
}
}

View File

@ -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

View File

@ -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 = QuadCommand::getCommandPool().generateCommand();
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)

View File

@ -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

View File

@ -25,7 +25,6 @@
#include "CCCustomCommand.h"
NS_CC_BEGIN
RenderCommandPool<CustomCommand> CustomCommand::_commandPool;
CustomCommand::CustomCommand()
:RenderCommand()
@ -66,9 +65,4 @@ void CustomCommand::execute()
}
}
void CustomCommand::releaseToCommandPool()
{
getCommandPool().pushBackCommand(this);
}
NS_CC_END

View File

@ -34,7 +34,10 @@ NS_CC_BEGIN
class CustomCommand : public RenderCommand
{
public:
static RenderCommandPool<CustomCommand>& getCommandPool() { return _commandPool; }
CustomCommand();
~CustomCommand();
public:
void init(int viewport, int32_t depth);
@ -48,18 +51,11 @@ public:
void execute();
inline bool isTranslucent() { return true; }
virtual void releaseToCommandPool() override;
std::function<void()> func;
protected:
CustomCommand();
~CustomCommand();
int _viewport;
int32_t _depth;
static RenderCommandPool<CustomCommand> _commandPool;
friend class RenderCommandPool<CustomCommand>;
};
NS_CC_END

View File

@ -28,7 +28,6 @@
#include "CCDirector.h"
NS_CC_BEGIN
RenderCommandPool<GroupCommand> GroupCommand::_commandPool;
static GroupCommandManager* s_instance;
GroupCommandManager *GroupCommandManager::getInstance()
@ -119,10 +118,4 @@ int64_t GroupCommand::generateID()
return _id;
}
void GroupCommand::releaseToCommandPool()
{
getCommandPool().pushBackCommand(this);
}
NS_CC_END

View File

@ -53,7 +53,10 @@ protected:
class GroupCommand : public RenderCommand
{
public:
static RenderCommandPool<GroupCommand>& getCommandPool() { return _commandPool; }
GroupCommand();
~GroupCommand();
public:
void init(int viewport, int32_t depth);
@ -66,18 +69,11 @@ public:
inline bool isTranslucent() {return true;}
inline int getRenderQueueID() {return _renderQueueID;}
virtual void releaseToCommandPool() override;
protected:
GroupCommand();
~GroupCommand();
int _viewport;
int32_t _depth;
int _renderQueueID;
static RenderCommandPool<GroupCommand> _commandPool;
friend class RenderCommandPool<GroupCommand>;
};
NS_CC_END

View File

@ -23,11 +23,10 @@
****************************************************************************/
#include "CCQuadCommand.h"
#include "renderer/CCQuadCommand.h"
#include "ccGLStateCache.h"
NS_CC_BEGIN
RenderCommandPool<QuadCommand> QuadCommand::_commandPool;
QuadCommand::QuadCommand()
:RenderCommand()
@ -172,9 +171,4 @@ void QuadCommand::useMaterial()
GL::blendFunc(_blendType.src, _blendType.dst);
}
void QuadCommand::releaseToCommandPool()
{
getCommandPool().pushBackCommand(this);
}
NS_CC_END

View File

@ -37,7 +37,6 @@ NS_CC_BEGIN
class QuadCommand : public RenderCommand
{
public:
static RenderCommandPool<QuadCommand>& getCommandPool() { return _commandPool; }
QuadCommand();
~QuadCommand();
@ -69,8 +68,6 @@ public:
inline BlendFunc getBlendType() const { return _blendType; }
virtual void releaseToCommandPool() override;
protected:
int32_t _materialID;
@ -91,12 +88,7 @@ protected:
V3F_C4B_T2F_Quad* _quad;
ssize_t _quadCount;
ssize_t _capacity;
friend class RenderCommandPool<QuadCommand>;
static RenderCommandPool<QuadCommand> _commandPool;
};
NS_CC_END
#endif //_CC_QUADCOMMAND_H_

View File

@ -52,7 +52,6 @@ public:
virtual inline int64_t getID() { return _id; }
virtual inline Type getType() { return _type; }
virtual void releaseToCommandPool() =0;
protected:
RenderCommand();

View File

@ -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"
@ -296,13 +296,13 @@ void Renderer::render()
}
}
//TODO give command back to command pool
for (size_t j = 0 ; j < _renderGroups.size(); j++)
{
for (const auto &cmd : _renderGroups[j])
{
cmd->releaseToCommandPool();
}
//commands are owned by nodes
// for (const auto &cmd : _renderGroups[j])
// {
// cmd->releaseToCommandPool();
// }
_renderGroups[j].clear();
}

View File

@ -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"

View File

@ -46,11 +46,13 @@ BatchNode *BatchNode::create()
}
BatchNode::BatchNode()
: _groupCommand(nullptr)
{
}
BatchNode::~BatchNode()
{
CC_SAFE_DELETE(_groupCommand);
}
bool BatchNode::init()
@ -78,6 +80,10 @@ void BatchNode::addChild(Node *child, int zOrder, int tag)
if (armature != nullptr)
{
armature->setBatchNode(this);
if (_groupCommand == nullptr)
{
_groupCommand = new GroupCommand();
}
}
}
@ -119,17 +125,17 @@ void BatchNode::draw()
}
CC_NODE_DRAW_SETUP();
generateGroupCommand();
bool pushed = false;
for(auto object : _children)
{
Armature *armature = dynamic_cast<Armature *>(object);
if (armature)
{
if (_popGroupCommand)
if (!pushed)
{
generateGroupCommand();
pushed = true;
}
armature->visit();
@ -137,7 +143,7 @@ void BatchNode::draw()
else
{
Director::getInstance()->getRenderer()->popGroup();
_popGroupCommand = true;
pushed = false;
((Node *)object)->visit();
}
@ -147,13 +153,10 @@ void BatchNode::draw()
void BatchNode::generateGroupCommand()
{
Renderer* renderer = Director::getInstance()->getRenderer();
GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand();
groupCommand->init(0,_vertexZ);
renderer->addCommand(groupCommand);
_groupCommand->init(0,_vertexZ);
renderer->addCommand(_groupCommand);
renderer->pushGroup(groupCommand->getRenderQueueID());
_popGroupCommand = false;
renderer->pushGroup(_groupCommand->getRenderQueueID());
}
}

View File

@ -27,6 +27,10 @@ THE SOFTWARE.
#include "cocostudio/CCArmatureDefine.h"
namespace cocos2d {
class GroupCommand;
}
namespace cocostudio {
class BatchNode : public cocos2d::Node
@ -61,11 +65,10 @@ public:
*/
void draw() override;
void setPopGroupCommand(bool pop) { _popGroupCommand = pop; }
protected:
void generateGroupCommand();
bool _popGroupCommand;
cocos2d::GroupCommand* _groupCommand;
};
}

View File

@ -219,9 +219,8 @@ void Skin::draw()
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
//TODO implement z order
QuadCommand* renderCommand = QuadCommand::getCommandPool().generateCommand();
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)

View File

@ -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
};
}

View File

@ -1289,11 +1289,10 @@ void ActionFollow::onEnter()
void ActionFollow::draw()
{
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(ActionFollow::onDraw, this);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void ActionFollow::onDraw()
@ -1606,10 +1605,9 @@ void ActionCatmullRomStacked::draw()
kmGLPopMatrix();
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void ActionCatmullRomStacked::onDraw()
@ -1722,10 +1720,9 @@ void ActionCardinalSplineStacked::draw()
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
kmGLPopMatrix();
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void ActionCardinalSplineStacked::onDraw()
@ -2085,10 +2082,9 @@ void ActionCatmullRom::draw()
kmGLPopMatrix();
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
@ -2186,10 +2182,9 @@ void ActionCardinalSpline::draw()
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2);
kmGLPopMatrix();
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void ActionCardinalSpline::onDraw()

View File

@ -346,6 +346,9 @@ public:
protected:
void onDraw();
private:
CustomCommand _customCommand;
};
class ActionTargeted : public ActionsDemo
@ -426,6 +429,7 @@ protected:
private:
PointArray* _array1;
PointArray* _array2;
CustomCommand _customCommand;
};
class ActionCardinalSplineStacked : public ActionsDemo
@ -444,6 +448,7 @@ protected:
void onDraw();
kmMat4 _modelViewMV1;
kmMat4 _modelViewMV2;
CustomCommand _customCommand;
};
class Issue1305 : public ActionsDemo
@ -538,6 +543,7 @@ protected:
void onDraw();
kmMat4 _modelViewMV1;
kmMat4 _modelViewMV2;
CustomCommand _customCommand;
};
class ActionCardinalSpline : public ActionsDemo
@ -557,6 +563,7 @@ protected:
void onDraw();
kmMat4 _modelViewMV1;
kmMat4 _modelViewMV2;
CustomCommand _customCommand;
};
class PauseResumeActions : public ActionsDemo

View File

@ -149,10 +149,9 @@ void Box2DTestLayer::draw()
kmGLPushMatrix();
kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV);
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(Box2DTestLayer::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(Box2DTestLayer::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
kmGLPopMatrix();
#endif

View File

@ -28,6 +28,7 @@ public:
protected:
kmMat4 _modelViewMV;
void onDraw();
CustomCommand _customCommand;
#endif
} ;

View File

@ -2,7 +2,6 @@
#include "GLES-Render.h"
#include "Test.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCCustomCommand.h"
#define kAccelerometerFrequency 30
#define FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK 10
@ -212,10 +211,9 @@ void Box2DView::draw()
{
Layer::draw();
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(Box2DView::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCmd.init(0, _vertexZ);
_customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCmd);
}
void Box2DView::onDraw()

View File

@ -3,6 +3,7 @@
//#include "cocos2d.h"
#include "../testBasic.h"
#include "renderer/CCCustomCommand.h"
class MenuLayer : public Layer
{
@ -51,6 +52,7 @@ public:
static Box2DView* viewWithEntryID(int entryId);
protected:
CustomCommand _customCmd;
void onDraw();
};

View File

@ -8,7 +8,6 @@
#include "ClippingNodeTest.h"
#include "../testResource.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCCustomCommand.h"
enum {
kTagTitleLabel = 1,
@ -599,11 +598,18 @@ void RawStencilBufferTest::draw()
auto planeSize = winPoint * (1.0 / _planeCount);
Renderer *renderer = Director::getInstance()->getRenderer();
size_t neededCmdSize = _planeCount * 2 + 2;
if(_renderCmds.size() != neededCmdSize)
{
_renderCmds.resize(neededCmdSize);
}
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(RawStencilBufferTest::onEnableStencil, this);
renderer->addCommand(cmd);
auto iter = _renderCmds.begin();
iter->init(0, _vertexZ);
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onEnableStencil, this);
renderer->addCommand(&(*iter));
++iter;
@ -617,20 +623,20 @@ void RawStencilBufferTest::draw()
spritePoint.y = 0;
_sprite->setPosition( spritePoint );
cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint);
renderer->addCommand(cmd);
iter->init(0, _vertexZ);
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint);
renderer->addCommand(&(*iter));
++iter;
kmGLPushMatrix();
this->transform();
_sprite->visit();
kmGLPopMatrix();
cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawSprite, this, i, winPoint);
renderer->addCommand(cmd);
iter->init(0, _vertexZ);
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawSprite, this, i, winPoint);
renderer->addCommand(&(*iter));
++iter;
kmGLPushMatrix();
this->transform();
@ -638,10 +644,9 @@ void RawStencilBufferTest::draw()
kmGLPopMatrix();
}
cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(RawStencilBufferTest::onDisableStencil, this);
renderer->addCommand(cmd);
iter->init(0, _vertexZ);
iter->func = CC_CALLBACK_0(RawStencilBufferTest::onDisableStencil, this);
renderer->addCommand(&(*iter));
}

View File

@ -3,6 +3,8 @@
#include "../testBasic.h"
#include "../BaseTest.h"
#include "renderer/CCCustomCommand.h"
#include <list>
class BaseClippingNodeTest : public BaseTest
{
@ -157,6 +159,7 @@ public:
virtual void setupStencilForDrawingOnPlane(GLint plane);
protected:
std::list<CustomCommand> _renderCmds;
void onEnableStencil();
void onDisableStencil();
void onBeforeDrawClip(int planeIndex, const Point& pt);

View File

@ -116,10 +116,9 @@ DrawPrimitivesTest::DrawPrimitivesTest()
void DrawPrimitivesTest::draw()
{
CustomCommand * cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void DrawPrimitivesTest::onDraw()

View File

@ -30,6 +30,8 @@ public:
virtual void draw();
protected:
void onDraw();
protected:
CustomCommand _customCommand;
};
class DrawNodeTest : public BaseLayer

View File

@ -1094,10 +1094,9 @@ std::string TestBoundingBox::title() const
}
void TestBoundingBox::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(TestBoundingBox::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}

View File

@ -297,6 +297,8 @@ public:
Rect rect;
protected:
void onDraw();
protected:
CustomCommand _customCommand;
};
class TestAnchorPoint : public ArmatureTestLayer

View File

@ -210,10 +210,9 @@ void Atlas1::draw()
// GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// GL_TEXTURE_2D
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(Atlas1::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
// [textureAtlas drawNumberOfQuads:3];
@ -527,10 +526,9 @@ Atlas4::Atlas4()
void Atlas4::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(Atlas4::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void Atlas4::onDraw()
@ -1614,10 +1612,9 @@ std::string LabelBMFontBounds::subtitle() const
void LabelBMFontBounds::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void LabelBMFontBounds::onDraw()

View File

@ -38,6 +38,8 @@ public:
virtual void draw();
protected:
void onDraw();
protected:
CustomCommand _customCommand;
};
class LabelAtlasTest : public AtlasDemo
@ -106,6 +108,8 @@ public:
virtual std::string subtitle() const override;
protected:
void onDraw();
protected:
CustomCommand _customCommand;
};
class Atlas5 : public AtlasDemo
@ -380,6 +384,7 @@ protected:
void onDraw();
private:
LabelBMFont *label1;
CustomCommand _customCommand;
};
class NewLabelTTFUnicode : public AtlasDemo

View File

@ -1,7 +1,6 @@
#include "LabelTestNew.h"
#include "../testResource.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCCustomCommand.h"
enum {
kTagTileMap = 1,
@ -302,10 +301,9 @@ LabelFNTSpriteActions::LabelFNTSpriteActions()
void LabelFNTSpriteActions::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_renderCmd.init(0, _vertexZ);
_renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}
@ -914,10 +912,9 @@ std::string LabelFNTBounds::subtitle() const
void LabelFNTBounds::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_renderCmd.init(0, _vertexZ);
_renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}
void LabelFNTBounds::onDraw()

View File

@ -3,6 +3,7 @@
#include "../testBasic.h"
#include "../BaseTest.h"
#include "renderer/CCCustomCommand.h"
class AtlasDemoNew : public BaseTest
@ -61,6 +62,7 @@ public:
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
CustomCommand _renderCmd;
void onDraw();
};
@ -226,6 +228,7 @@ public:
private:
Label *label1;
protected:
CustomCommand _renderCmd;
void onDraw();
};

View File

@ -589,10 +589,9 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea
void SpriteRenderTextureBug::SimpleSprite::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(SpriteRenderTextureBug::SimpleSprite::onBeforeDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(SpriteRenderTextureBug::SimpleSprite::onBeforeDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
Sprite::draw();

View File

@ -117,6 +117,8 @@ public:
void onBeforeDraw();
public:
RenderTexture *_rt;
protected:
CustomCommand _customCommand;
};
public:

View File

@ -196,10 +196,9 @@ void ShaderNode::setPosition(const Point &newPosition)
void ShaderNode::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(ShaderNode::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void ShaderNode::onDraw()
@ -449,6 +448,8 @@ public:
GLuint subLocation;
protected:
void onDraw();
private:
CustomCommand _customCommand;
};
SpriteBlur::~SpriteBlur()
@ -532,10 +533,9 @@ void SpriteBlur::initProgram()
void SpriteBlur::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(SpriteBlur::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_customCommand.init(0, _vertexZ);
_customCommand.func = CC_CALLBACK_0(SpriteBlur::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
void SpriteBlur::onDraw()

View File

@ -137,6 +137,7 @@ private:
GLuint _uniformCenter, _uniformResolution, _uniformTime;
std::string _vertFileName;
std::string _fragFileName;
CustomCommand _customCommand;
};
class ShaderFail : public ShaderTestDemo

View File

@ -2,7 +2,6 @@
#include "Texture2dTest.h"
#include "../testResource.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCCustomCommand.h"
enum {
kTagLabel = 1,
@ -1768,10 +1767,9 @@ void TextureDrawAtPoint::draw()
{
TextureDemo::draw();
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_renderCmd.init(0, _vertexZ);
_renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}
@ -1810,10 +1808,9 @@ void TextureDrawInRect::draw()
{
TextureDemo::draw();
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_renderCmd.init(0, _vertexZ);
_renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}

View File

@ -3,6 +3,7 @@
#include "../testBasic.h"
#include "../BaseTest.h"
#include "renderer/CCCustomCommand.h"
class TextureDemo : public BaseTest
@ -442,6 +443,7 @@ public:
virtual void onEnter();
virtual void draw();
protected:
CustomCommand _renderCmd;
void onDraw();
private:
Texture2D* _tex1, *_Tex2F;
@ -457,6 +459,7 @@ public:
virtual void onEnter();
virtual void draw();
protected:
CustomCommand _renderCmd;
void onDraw();
private:
Texture2D* _tex1, *_Tex2F;

View File

@ -599,10 +599,9 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest()
void TMXOrthoObjectsTest::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_renderCmd.init(0, _vertexZ);
_renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}
void TMXOrthoObjectsTest::onDraw()
@ -673,10 +672,9 @@ TMXIsoObjectsTest::TMXIsoObjectsTest()
void TMXIsoObjectsTest::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_renderCmd.init(0, _vertexZ);
_renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}
void TMXIsoObjectsTest::onDraw()
@ -1475,10 +1473,9 @@ TMXGIDObjectsTest::TMXGIDObjectsTest()
void TMXGIDObjectsTest::draw()
{
CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand();
cmd->init(0, _vertexZ);
cmd->func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(cmd);
_renderCmd.init(0, _vertexZ);
_renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_renderCmd);
}
void TMXGIDObjectsTest::onDraw()

View File

@ -3,6 +3,7 @@
#include "../testBasic.h"
#include "../BaseTest.h"
#include "renderer/CCCustomCommand.h"
class TileDemo : public BaseTest
{
@ -136,6 +137,7 @@ public:
virtual void draw();
virtual std::string subtitle() const override;
protected:
CustomCommand _renderCmd;
void onDraw();
};
@ -148,6 +150,7 @@ public:
virtual void draw();
virtual std::string subtitle() const override;
protected:
CustomCommand _renderCmd;
void onDraw();
};
@ -285,6 +288,7 @@ public:
virtual void draw();
protected:
CustomCommand _renderCmd;
void onDraw();
};