缓存GLProgramState。reuse the old GLProgramState, which will accelerate the creation of game objects such as sprites, particles etc.
class CC_DLL GLProgramStateCache
{
public:
static GLProgramStateCache* getInstance();
static void destroyInstance();
GLProgramState* getGLProgramState(GLProgram* program); // 没有则将为这个program创建ProgramState
void removeAllGLProgramState();
void removeUnusedGLProgramState(); // referenceCount == 1
protected:
GLProgramStateCache();
~GLProgramStateCache();
// key: gl program object
// value: program对应的program state
// 注意是cocos2d::Map类型,因此只要缓存了programState,那么就不必担心program的生命周期。
Map<GLProgram*, GLProgramState*> _glProgramStates;
static GLProgramStateCache* s_instance;
};