123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #include "renderer/CCGroupCommand.h"
- #include "renderer/CCRenderer.h"
- #include "base/CCDirector.h"
- NS_CC_BEGIN
- GroupCommandManager::GroupCommandManager()
- {
- }
- GroupCommandManager::~GroupCommandManager()
- {
-
- }
- bool GroupCommandManager::init()
- {
-
- _groupMapping[0] = true;
- return true;
- }
- int GroupCommandManager::getGroupID()
- {
-
- if (!_unusedIDs.empty())
- {
- int groupID = *_unusedIDs.rbegin();
- _unusedIDs.pop_back();
- _groupMapping[groupID] = true;
- return groupID;
- }
-
- int newID = Director::getInstance()->getRenderer()->createRenderQueue();
- _groupMapping[newID] = true;
- return newID;
- }
- void GroupCommandManager::releaseGroupID(int groupID)
- {
- _groupMapping[groupID] = false;
- _unusedIDs.push_back(groupID);
- }
- GroupCommand::GroupCommand()
- {
- _type = RenderCommand::Type::GROUP_COMMAND;
- _renderQueueID = Director::getInstance()->getRenderer()->getGroupCommandManager()->getGroupID();
- }
- void GroupCommand::init(float globalOrder)
- {
- _globalOrder = globalOrder;
- auto manager = Director::getInstance()->getRenderer()->getGroupCommandManager();
- manager->releaseGroupID(_renderQueueID);
- _renderQueueID = manager->getGroupID();
- }
- GroupCommand::~GroupCommand()
- {
- Director::getInstance()->getRenderer()->getGroupCommandManager()->releaseGroupID(_renderQueueID);
- }
- NS_CC_END
|