Merge pull request #15946 from ricardoquesada/issue15937_v312

fix: fix delay when creating quadcommands
This commit is contained in:
minggo 2016-06-24 09:32:22 +08:00 committed by GitHub
commit 7a259fe8d9
1 changed files with 11 additions and 0 deletions

View File

@ -72,9 +72,20 @@ void QuadCommand::init(float globalOrder, GLuint textureID, GLProgramState* glPr
void QuadCommand::reIndex(int indicesCount)
{
// first time init: create a decent buffer size for indices to prevent too much resizing
if (__indexCapacity == -1)
{
indicesCount = std::max(indicesCount, 2048);
}
if (indicesCount > __indexCapacity)
{
// if resizing is needed, get needed size plus 25%, but not bigger that max size
indicesCount *= 1.25;
indicesCount = std::min(indicesCount, 65536);
CCLOG("cocos2d: QuadCommand: resizing index size from [%d] to [%d]", __indexCapacity, indicesCount);
_ownedIndices.push_back(__indices);
__indices = new (std::nothrow) GLushort[indicesCount];
__indexCapacity = indicesCount;