Skip to content

Commit 36b7e7d

Browse files
author
Huabing.Xu
committed
Merge pull request #2 from boyu0/develop_removeCommandPool
Develop remove command pool
2 parents 7f6acc2 + abaaf84 commit 36b7e7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+202
-165
lines changed

cocos/2d/CCAtlasNode.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ THE SOFTWARE.
3434
#include "CCDirector.h"
3535
#include "TransformUtils.h"
3636
#include "CCRenderer.h"
37-
#include "CCQuadCommand.h"
37+
#include "renderer/CCQuadCommand.h"
3838

3939
// external
4040
#include "kazmath/GL/matrix.h"
@@ -151,8 +151,7 @@ void AtlasNode::draw(void)
151151

152152
auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
153153

154-
QuadCommand* cmd = new QuadCommand();
155-
cmd->init(0,
154+
_quadCommand.init(0,
156155
_vertexZ,
157156
_textureAtlas->getTexture()->getName(),
158157
shader,
@@ -161,7 +160,7 @@ void AtlasNode::draw(void)
161160
_textureAtlas->getTotalQuads(),
162161
_modelViewTransform);
163162

164-
Director::getInstance()->getRenderer()->addCommand(cmd);
163+
Director::getInstance()->getRenderer()->addCommand(&_quadCommand);
165164

166165
}
167166

cocos/2d/CCAtlasNode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ THE SOFTWARE.
3030
#include "CCNode.h"
3131
#include "CCProtocols.h"
3232
#include "ccTypes.h"
33+
#include "renderer/CCQuadCommand.h"
3334

3435
NS_CC_BEGIN
3536

@@ -130,6 +131,8 @@ class CC_DLL AtlasNode : public Node, public TextureProtocol
130131
GLint _uniformColor;
131132
// This varible is only used for LabelAtlas FPS display. So plz don't modify its value.
132133
bool _ignoreContentScaleFactor;
134+
// quad command
135+
QuadCommand _quadCommand;
133136

134137
private:
135138
CC_DISALLOW_COPY_AND_ASSIGN(AtlasNode);

cocos/2d/CCClippingNode.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,20 @@ void ClippingNode::visit()
209209

210210
Renderer* renderer = Director::getInstance()->getRenderer();
211211

212-
GroupCommand* groupCommand = new GroupCommand();
213-
groupCommand->init(0,_vertexZ);
214-
renderer->addCommand(groupCommand);
212+
_groupCommand.init(0,_vertexZ);
213+
renderer->addCommand(&_groupCommand);
215214

216-
renderer->pushGroup(groupCommand->getRenderQueueID());
215+
renderer->pushGroup(_groupCommand.getRenderQueueID());
217216

218-
CustomCommand* beforeVisitCmd = new CustomCommand();
219-
beforeVisitCmd->init(0,_vertexZ);
220-
beforeVisitCmd->func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
221-
renderer->addCommand(beforeVisitCmd);
217+
_beforeVisitCmd.init(0,_vertexZ);
218+
_beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
219+
renderer->addCommand(&_beforeVisitCmd);
222220

223221
_stencil->visit();
224222

225-
CustomCommand* afterDrawStencilCmd = new CustomCommand();
226-
afterDrawStencilCmd->init(0,_vertexZ);
227-
afterDrawStencilCmd->func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
228-
renderer->addCommand(afterDrawStencilCmd);
223+
_afterDrawStencilCmd.init(0,_vertexZ);
224+
_afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
225+
renderer->addCommand(&_afterDrawStencilCmd);
229226

230227
int i = 0;
231228

@@ -253,10 +250,9 @@ void ClippingNode::visit()
253250
this->draw();
254251
}
255252

256-
CustomCommand* afterVisitCmd = new CustomCommand();
257-
afterVisitCmd->init(0,_vertexZ);
258-
afterVisitCmd->func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
259-
renderer->addCommand(afterVisitCmd);
253+
_afterVisitCmd.init(0,_vertexZ);
254+
_afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
255+
renderer->addCommand(&_afterVisitCmd);
260256

261257
renderer->popGroup();
262258

cocos/2d/CCClippingNode.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
#include "CCNode.h"
3232
#include "CCGL.h"
33+
#include "renderer/CCGroupCommand.h"
34+
#include "renderer/CCCustomCommand.h"
3335

3436
NS_CC_BEGIN
3537

@@ -141,6 +143,11 @@ class CC_DLL ClippingNode : public Node
141143
GLclampf _currentAlphaTestRef;
142144

143145
GLint _mask_layer_le;
146+
147+
GroupCommand _groupCommand;
148+
CustomCommand _beforeVisitCmd;
149+
CustomCommand _afterDrawStencilCmd;
150+
CustomCommand _afterVisitCmd;
144151

145152
private:
146153
CC_DISALLOW_COPY_AND_ASSIGN(ClippingNode);

cocos/2d/CCDrawNode.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,9 @@ void DrawNode::render()
241241

242242
void DrawNode::draw()
243243
{
244-
CustomCommand* cmd = new CustomCommand();
245-
cmd->init(0, _vertexZ);
246-
cmd->func = CC_CALLBACK_0(DrawNode::onDraw, this);
247-
Director::getInstance()->getRenderer()->addCommand(cmd);
244+
_customCommand.init(0, _vertexZ);
245+
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this);
246+
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
248247
}
249248

250249
void DrawNode::onDraw()

cocos/2d/CCDrawNode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "CCNode.h"
3434
#include "ccTypes.h"
35+
#include "renderer/CCCustomCommand.h"
3536

3637
NS_CC_BEGIN
3738

@@ -105,6 +106,7 @@ class CC_DLL DrawNode : public Node
105106
V2F_C4B_T2F *_buffer;
106107

107108
BlendFunc _blendFunc;
109+
CustomCommand _customCommand;
108110

109111
bool _dirty;
110112

cocos/2d/CCLayer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,9 @@ void LayerColor::updateColor()
564564

565565
void LayerColor::draw()
566566
{
567-
CustomCommand* cmd = new CustomCommand();
568-
cmd->init(0, _vertexZ);
569-
cmd->func = CC_CALLBACK_0(LayerColor::onDraw, this);
570-
Director::getInstance()->getRenderer()->addCommand(cmd);
567+
_customCommand.init(0, _vertexZ);
568+
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this);
569+
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
571570
}
572571

573572
void LayerColor::onDraw()

cocos/2d/CCLayer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ THE SOFTWARE.
3535
#endif // EMSCRIPTEN
3636

3737
#include "CCEventKeyboard.h"
38+
#include "renderer/CCCustomCommand.h"
3839

3940
NS_CC_BEGIN
4041

@@ -296,6 +297,7 @@ class CC_DLL LayerColor : public Layer, public BlendProtocol
296297
BlendFunc _blendFunc;
297298
Vertex2F _squareVertices[4];
298299
Color4F _squareColors[4];
300+
CustomCommand _customCommand;
299301

300302
private:
301303
CC_DISALLOW_COPY_AND_ASSIGN(LayerColor);

cocos/2d/CCMotionStreak.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,9 @@ void MotionStreak::draw()
358358
if(_nuPoints <= 1)
359359
return;
360360
kmGLGetMatrix(KM_GL_MODELVIEW,&_cachedMV);
361-
CustomCommand* cmd = new CustomCommand();
362-
cmd->init(0,_vertexZ);
363-
cmd->func = CC_CALLBACK_0(MotionStreak::onDraw, this);
364-
Director::getInstance()->getRenderer()->addCommand(cmd);
361+
_customCommand.init(0,_vertexZ);
362+
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this);
363+
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
365364

366365
}
367366

cocos/2d/CCMotionStreak.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ THE SOFTWARE.
2929
#include "CCTexture2D.h"
3030
#include "ccTypes.h"
3131
#include "CCNode.h"
32+
#include "renderer/CCCustomCommand.h"
3233
#ifdef EMSCRIPTEN
3334
#include "CCGLBufferedNode.h"
3435
#endif // EMSCRIPTEN
@@ -144,6 +145,8 @@ class CC_DLL MotionStreak : public Node, public TextureProtocol
144145
Vertex2F* _vertices;
145146
GLubyte* _colorPointer;
146147
Tex2F* _texCoords;
148+
149+
CustomCommand _customCommand;
147150

148151
private:
149152
CC_DISALLOW_COPY_AND_ASSIGN(MotionStreak);

0 commit comments

Comments
 (0)