cocos2d-x 10.1版本 修复真机上白屏问题
########################################################
10.1 版本修改底层记录 (游戏开发群:主席)
群号:44727718
#######################################################
1. 修改:CCTextureCache.h
1.)添加:VolatileTexture::addDataTexture(CCTexture2D *tt,const void* data,CCTexture2DPixelFormat pixelFormat,unsigned int pixelsWide,unsigned int pixelsHigh,const CCSize& c ontentSize)
让其增加数据备份功能:
void VolatileTexture::addDataTexture(CCTexture2D *tt,const void* data,CCTexture2DPixelFormat pixelFormat,unsigned int pixelsWide,unsigned int pixelsHigh,const CCSize& contentSize)
{
if (isReloading)
return;
VolatileTexture *vt = 0;
std::list<VolatileTexture *>::iterator i = textures.begin();
while( i != textures.end() )
{
VolatileTexture *v = *i++;
if (v->texture == tt) {
vt = v;
break;
}
}
if (!vt)
vt = new VolatileTexture(tt);
vt->m_eCashedImageType = kImageData;
vt->m_PixelFormat = pixelFormat;
vt->m_TextureSize = contentSize;
if(vt->m_pTextureData)
{
delete[] vt->m_pTextureData;
vt->m_pTextureData = 0;
}
switch(pixelFormat)
{
case kCCTexture2DPixelFormat_RGBA8888:
case kCCTexture2DPixelFormat_RGBA4444:
case kCCTexture2DPixelFormat_RGB5A1:
case kCCTexture2DPixelFormat_RGB565:
case kCCTexture2DPixelFormat_A8:
vt->m_pTextureData = new char[pixelsWide * pixelsHigh * 4];
memcpy(vt->m_pTextureData,data,pixelsWide * pixelsHigh * 4);
break;
case kCCTexture2DPixelFormat_RGB888:
vt->m_pTextureData = new char[pixelsWide * pixelsHigh * 3];
memccpy(vt->m_pTextureData,data,pixelsWide * pixelsHigh * 3);
break;
}
}
2.)CCTextureCache.cpp
VolatileTexture::~VolatileTexture()
{
//Ambition 添加
if(this->m_pTextureData)
{
delete [] this->m_pTextureData;
}
textures.remove(this);
}
2.修改:CCTexture2D.h
1.)cpp文件里 initWithData(const void *data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const CCSize& contentSize)
//Ambition 添加
#if CC_ENABLE_CACHE_TEXTTURE_DATA
VolatileTexture::addDataTexture(this,data,pixelFormat,pixelsWide,pixelsHigh,contentSize);
#endif