BaseMultipleBatchRenderQueue::~BaseMultipleBatchRenderQueue(void)
{
	BatchList& fontBatches = mBatches.MutableFront();
	BatchList& backBatches = mBatches.MutableBack();
	FOR_EACH_ITEM_CLEAR(fontBatches, BatchPool::Instance().Recycle);
	FOR_EACH_ITEM_CLEAR(backBatches, BatchPool::Instance().Recycle);

	mRenderGroup->Uninitialize();
	SAFE_DELETE(mRenderGroup);
}
Esempio n. 2
0
bool EffectRenderGroup::Uninitialize()
{
	FOR_EACH_TO(mGroups, Uninitialize());

	FOR_EACH_ITEM_CLEAR(mGroups, MaterialRenderGroupPool::Instance().Recycle);
	return true;
}
Esempio n. 3
0
bool MaterialRenderGroup::Uninitialize()
{
	FOR_EACH_ITEM_TO(mGroups, Uninitialize());

	FOR_EACH_ITEM_CLEAR(mGroups, StateRenderGroupPool::Instance().Recycle);
	SAFE_RELEASE(mMaterial);

	return true;
}
bool BaseMultipleBatchRenderQueue::OnUpdateBatchList()
{
	BatchList& fontBatches = mBatches.MutableFront();
	BatchList& backBatches = mBatches.MutableBack();

	BatchGroup currentBatchGroup = 0;
	IRenderBatch* currentBatch = nullptr;
	for(auto node: mNodes)
	{
		BatchGroup group = node->GetBatchGroup();
#ifdef MEDUSA_SAFE_CHECK
		if (group==0)
		{
			Log::AssertFailedFormat("Error batch group");
		}
#endif

		if (!group.IsMatch(currentBatchGroup))
		{
			BatchList::NodePtr prevBatch = fontBatches.FindFirstWithOtherKey<BatchGroup, IRenderBatchCompareToBatchGroup>(group);
			if (prevBatch != nullptr)
			{
				//found original batch
				if (currentBatch!=nullptr)
				{
					currentBatch->Freeze();
				}

				currentBatch = prevBatch->Value;
				currentBatch->Prepare();
				backBatches.Add(currentBatch);
				fontBatches.Delete(prevBatch);
			}
			else
			{
				//create a new one
				currentBatch = BatchPool::Instance().Create(node);
				currentBatch->Prepare();
				backBatches.Add(currentBatch);
			}
			currentBatchGroup = group;
		}

		if (!currentBatch->IsAvailableFor(*node))
		{
			if (currentBatch != nullptr)
			{
				currentBatch->Freeze();
			}

			currentBatch = BatchPool::Instance().Create(node);
			currentBatch->Prepare();
			backBatches.Add(currentBatch);
		}
		currentBatch->AddNode(node);

	}

	//clear front batches
	FOR_EACH_ITEM_CLEAR(fontBatches, BatchPool::Instance().Recycle);
	mBatches.Swap();


	return true;
}