Merge pull request #3166 from dumganhar/iss2410-blackscreen-android

Merge PR https://github.com/cocos2d/cocos2d-x/pull/3117
This commit is contained in:
James Chen 2013-07-16 23:25:01 -07:00
commit d3bf9935cd
29 changed files with 232 additions and 296 deletions

View File

@ -23,6 +23,8 @@
#include "CCDrawNode.h"
#include "shaders/CCShaderCache.h"
#include "CCGL.h"
#include "support/CCNotificationCenter.h"
#include "CCEventType.h"
NS_CC_BEGIN
@ -118,6 +120,10 @@ DrawNode::~DrawNode()
ccGLBindVAO(0);
_vao = 0;
#endif
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
}
DrawNode* DrawNode::create()
@ -181,6 +187,14 @@ bool DrawNode::init()
_dirty = true;
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO
NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(DrawNode::listenBackToForeground),
EVNET_COME_TO_FOREGROUND,
NULL);
#endif
return true;
}
@ -196,6 +210,7 @@ void DrawNode::render()
ccGLBindVAO(_vao);
#else
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
// vertex
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
@ -216,11 +231,9 @@ void DrawNode::render()
void DrawNode::draw()
{
CC_NODE_DRAW_SETUP();
ccGLBlendFunc(_blendFunc.src, _blendFunc.dst);
getShaderProgram()->use();
getShaderProgram()->setUniformsForBuiltins();
render();
}
@ -440,4 +453,11 @@ void DrawNode::setBlendFunc(const BlendFunc &blendFunc)
_blendFunc = blendFunc;
}
/** listen the event that coming to foreground on Android
*/
void DrawNode::listenBackToForeground(Object *obj)
{
init();
}
NS_CC_END

View File

@ -79,6 +79,10 @@ public:
DrawNode();
/** listen the event that coming to foreground on Android
*/
void listenBackToForeground(Object *obj);
private:
void ensureCapacity(unsigned int count);
void render();

View File

@ -65,13 +65,14 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO
NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(ParticleSystemQuad::listenBackToForeground),
EVNET_COME_TO_FOREGROUND,
NULL);
#endif
return true;
}
return false;
@ -100,7 +101,9 @@ ParticleSystemQuad::~ParticleSystemQuad()
#endif
}
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
}
// implementation ParticleSystemQuad

View File

@ -668,6 +668,7 @@ const char* FileUtils::fullPathFromRelativeFile(const char *pszFilename, const c
void FileUtils::setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder)
{
bool bExistDefault = false;
_fullPathCache.clear();
_searchResolutionsOrderArray.clear();
for (std::vector<std::string>::const_iterator iter = searchResolutionsOrder.begin(); iter != searchResolutionsOrder.end(); ++iter)
{
@ -709,6 +710,7 @@ void FileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefaultRootPath = false;
_fullPathCache.clear();
_searchPathArray.clear();
for (std::vector<std::string>::const_iterator iter = searchPaths.begin(); iter != searchPaths.end(); ++iter)
{
@ -755,6 +757,7 @@ void FileUtils::addSearchPath(const char* path_)
void FileUtils::setFilenameLookupDictionary(Dictionary* pFilenameLookupDict)
{
_fullPathCache.clear();
CC_SAFE_RELEASE(_filenameLookupDict);
_filenameLookupDict = pFilenameLookupDict;
CC_SAFE_RETAIN(_filenameLookupDict);

View File

@ -81,7 +81,7 @@ to be different from other platforms unless there's a good reason.
It's new in cocos2d-x since v0.99.5
*/
#if 0
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#define CC_ENABLE_CACHE_TEXTURE_DATA 1
#else
#define CC_ENABLE_CACHE_TEXTURE_DATA 0

View File

@ -241,7 +241,7 @@ bool GLProgram::link()
_vertShader = _fragShader = 0;
#if DEBUG
#if COCOS2D_DEBUG
glGetProgramiv(_program, GL_LINK_STATUS, &status);
if (status == GL_FALSE)

View File

@ -219,7 +219,7 @@ void ShaderCache::reloadDefaultShaders()
//
p = programForKey(kShader_PositionLengthTexureColor);
p->reset();
loadDefaultShader(p, kShaderType_Position_uColor);
loadDefaultShader(p, kShaderType_PositionLengthTexureColor);
}
void ShaderCache::loadDefaultShader(GLProgram *p, int type)
@ -297,7 +297,7 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type)
GLProgram* ShaderCache::programForKey(const char* key)
{
return (GLProgram*)_programs->objectForKey(key);
return static_cast<GLProgram*>(_programs->objectForKey(key));
}
void ShaderCache::addProgram(GLProgram* program, const char* key)

View File

@ -76,7 +76,11 @@ void ccGLInvalidateStateCache( void )
s_eBlendingSource = -1;
s_eBlendingDest = -1;
s_eGLServerState = 0;
#if CC_TEXTURE_ATLAS_USE_VAO
s_uVAO = 0;
#endif
#endif // CC_ENABLE_GL_STATE_CACHE
}
void ccGLDeleteProgram( GLuint program )

View File

@ -442,181 +442,140 @@ bool Texture2D::initWithString(const char *text, const char *fontName, float fon
bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions, TextAlignment hAlignment, VerticalTextAlignment vAlignment)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
FontDefinition tempDef;
FontDefinition tempDef;
tempDef._shadow._shadowEnabled = false;
tempDef._stroke._strokeEnabled = false;
tempDef._fontName = std::string(fontName);
tempDef._fontSize = fontSize;
tempDef._dimensions = dimensions;
tempDef._alignment = hAlignment;
tempDef._vertAlignment = vAlignment;
tempDef._fontFillColor = Color3B::WHITE;
return initWithString(text, tempDef);
#else
#if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data
VolatileTexture::addStringTexture(this, text, dimensions, hAlignment, vAlignment, fontName, fontSize);
#endif
bool bRet = false;
Image::ETextAlign eAlign;
if (kVerticalTextAlignmentTop == vAlignment)
{
eAlign = (kTextAlignmentCenter == hAlignment) ? Image::kAlignTop
: (kTextAlignmentLeft == hAlignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
}
else if (kVerticalTextAlignmentCenter == vAlignment)
{
eAlign = (kTextAlignmentCenter == hAlignment) ? Image::kAlignCenter
: (kTextAlignmentLeft == hAlignment) ? Image::kAlignLeft : Image::kAlignRight;
}
else if (kVerticalTextAlignmentBottom == vAlignment)
{
eAlign = (kTextAlignmentCenter == hAlignment) ? Image::kAlignBottom
: (kTextAlignmentLeft == hAlignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
}
else
{
CCAssert(false, "Not supported alignment format!");
return false;
}
do
{
Image* pImage = new Image();
CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize);
CC_BREAK_IF(!bRet);
bRet = initWithImage(pImage);
CC_SAFE_RELEASE(pImage);
} while (0);
return bRet;
#endif
tempDef._shadow._shadowEnabled = false;
tempDef._stroke._strokeEnabled = false;
tempDef._fontName = std::string(fontName);
tempDef._fontSize = fontSize;
tempDef._dimensions = dimensions;
tempDef._alignment = hAlignment;
tempDef._vertAlignment = vAlignment;
tempDef._fontFillColor = Color3B::WHITE;
return initWithString(text, tempDef);
}
bool Texture2D::initWithString(const char *text, const FontDefinition& textDefinition)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data
VolatileTexture::addStringTexture(this, text, textDefinition);
#endif
bool bRet = false;
Image::ETextAlign eAlign;
#if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data
VolatileTexture::addStringTexture(this, text, textDefinition._dimensions, textDefinition._alignment, textDefinition._vertAlignment, textDefinition._fontName.c_str(), textDefinition._fontSize);
#endif
bool bRet = false;
Image::ETextAlign eAlign;
if (kVerticalTextAlignmentTop == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
}
else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
}
else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
}
else
{
CCAssert(false, "Not supported alignment format!");
return false;
}
// handle shadow parameters
bool shadowEnabled = false;
float shadowDX = 0.0f;
float shadowDY = 0.0f;
float shadowBlur = 0.0f;
float shadowOpacity = 0.0f;
if ( textDefinition._shadow._shadowEnabled )
{
shadowEnabled = true;
shadowDX = textDefinition._shadow._shadowOffset.width;
shadowDY = textDefinition._shadow._shadowOffset.height;
shadowBlur = textDefinition._shadow._shadowBlur;
shadowOpacity = textDefinition._shadow._shadowOpacity;
}
// handle stroke parameters
bool strokeEnabled = false;
float strokeColorR = 0.0f;
float strokeColorG = 0.0f;
float strokeColorB = 0.0f;
float strokeSize = 0.0f;
if ( textDefinition._stroke._strokeEnabled )
{
strokeEnabled = true;
strokeColorR = textDefinition._stroke._strokeColor.r / 255.0f;
strokeColorG = textDefinition._stroke._strokeColor.g / 255.0f;
strokeColorB = textDefinition._stroke._strokeColor.b / 255.0f;
strokeSize = textDefinition._stroke._strokeSize;
}
Image* pImage = new Image();
do
{
CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithStringShadowStroke(text,
(int)textDefinition._dimensions.width,
(int)textDefinition._dimensions.height,
eAlign,
textDefinition._fontName.c_str(),
textDefinition._fontSize,
textDefinition._fontFillColor.r / 255.0f,
textDefinition._fontFillColor.g / 255.0f,
textDefinition._fontFillColor.b / 255.0f,
shadowEnabled,
shadowDX,
shadowDY,
shadowOpacity,
shadowBlur,
strokeEnabled,
strokeColorR,
strokeColorG,
strokeColorB,
strokeSize);
CC_BREAK_IF(!bRet);
bRet = initWithImage(pImage);
} while (0);
CC_SAFE_RELEASE(pImage);
return bRet;
#else
CCAssert(false, "Currently only supported on iOS and Android!");
if (kVerticalTextAlignmentTop == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
}
else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
}
else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
}
else
{
CCAssert(false, "Not supported alignment format!");
return false;
}
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
// handle shadow parameters
bool shadowEnabled = false;
float shadowDX = 0.0f;
float shadowDY = 0.0f;
float shadowBlur = 0.0f;
float shadowOpacity = 0.0f;
if ( textDefinition._shadow._shadowEnabled )
{
shadowEnabled = true;
shadowDX = textDefinition._shadow._shadowOffset.width;
shadowDY = textDefinition._shadow._shadowOffset.height;
shadowBlur = textDefinition._shadow._shadowBlur;
shadowOpacity = textDefinition._shadow._shadowOpacity;
}
// handle stroke parameters
bool strokeEnabled = false;
float strokeColorR = 0.0f;
float strokeColorG = 0.0f;
float strokeColorB = 0.0f;
float strokeSize = 0.0f;
if ( textDefinition._stroke._strokeEnabled )
{
strokeEnabled = true;
strokeColorR = textDefinition._stroke._strokeColor.r / 255.0f;
strokeColorG = textDefinition._stroke._strokeColor.g / 255.0f;
strokeColorB = textDefinition._stroke._strokeColor.b / 255.0f;
strokeSize = textDefinition._stroke._strokeSize;
}
Image* pImage = new Image();
do
{
CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithStringShadowStroke(text,
(int)textDefinition._dimensions.width,
(int)textDefinition._dimensions.height,
eAlign,
textDefinition._fontName.c_str(),
textDefinition._fontSize,
textDefinition._fontFillColor.r / 255.0f,
textDefinition._fontFillColor.g / 255.0f,
textDefinition._fontFillColor.b / 255.0f,
shadowEnabled,
shadowDX,
shadowDY,
shadowOpacity,
shadowBlur,
strokeEnabled,
strokeColorR,
strokeColorG,
strokeColorB,
strokeSize);
CC_BREAK_IF(!bRet);
bRet = initWithImage(pImage);
} while (0);
CC_SAFE_RELEASE(pImage);
return bRet;
#else
bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled;
CCAssert(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!");
Image* pImage = new Image();
do
{
CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithString(text, (int)textDefinition._dimensions.width, (int)textDefinition._dimensions.height, eAlign, textDefinition._fontName.c_str(), (int)textDefinition._fontSize);
CC_BREAK_IF(!bRet);
bRet = initWithImage(pImage);
} while (0);
CC_SAFE_RELEASE(pImage);
return bRet;
#endif
}
@ -624,7 +583,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
void Texture2D::drawAtPoint(const Point& point)
{
GLfloat coordinates[] = {
GLfloat coordinates[] = {
0.0f, _maxT,
_maxS,_maxT,
0.0f, 0.0f,

View File

@ -66,7 +66,9 @@ TextureAtlas::~TextureAtlas()
#endif
CC_SAFE_RELEASE(_texture);
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
}
unsigned int TextureAtlas::getTotalQuads() const
@ -176,12 +178,14 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, unsigned int capacity)
memset( _quads, 0, _capacity * sizeof(V3F_C4B_T2F_Quad) );
memset( _indices, 0, _capacity * 6 * sizeof(GLushort) );
#if CC_ENABLE_CACHE_TEXTURE_DATA
// listen the event when app go to background
NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(TextureAtlas::listenBackToForeground),
EVNET_COME_TO_FOREGROUND,
NULL);
#endif
this->setupIndices();
#if CC_TEXTURE_ATLAS_USE_VAO

View File

@ -138,7 +138,7 @@ void TextureCache::addImageAsync(const char *path, Object *target, SEL_CallFuncO
std::string pathKey = path;
pathKey = FileUtils::getInstance()->fullPathForFilename(pathKey.c_str());
texture = (Texture2D*)_textures->objectForKey(pathKey.c_str());
texture = static_cast<Texture2D*>(_textures->objectForKey(pathKey.c_str()));
std::string fullpath = pathKey;
if (texture != NULL)
@ -354,7 +354,7 @@ Texture2D * TextureCache::addImage(const char * path)
{
return NULL;
}
texture = (Texture2D*)_textures->objectForKey(pathKey.c_str());
texture = static_cast<Texture2D*>(_textures->objectForKey(pathKey.c_str()));
std::string fullpath = pathKey;
if (! texture)
@ -576,7 +576,7 @@ void TextureCache::removeUnusedTextures()
}
// remove elements
for (list<DictElement*>::iterator iter = elementToRemove.begin(); iter != elementToRemove.end(); ++iter)
for (auto iter = elementToRemove.begin(); iter != elementToRemove.end(); ++iter)
{
CCLOG("cocos2d: TextureCache: removing unused texture: %s", (*iter)->getStrKey());
_textures->removeObjectForElememt(*iter);
@ -647,40 +647,35 @@ void TextureCache::dumpCachedTextureInfo()
#if CC_ENABLE_CACHE_TEXTURE_DATA
std::list<VolatileTexture*> VolatileTexture::textures;
bool VolatileTexture::isReloading = false;
std::list<VolatileTexture*> VolatileTexture::_textures;
bool VolatileTexture::_isReloading = false;
VolatileTexture::VolatileTexture(Texture2D *t)
: texture(t)
: _texture(t)
, _cashedImageType(kInvalid)
, _textureData(NULL)
, _pixelFormat(kTexture2DPixelFormat_RGBA8888)
, _fileName("")
, _fmtImage(Image::kFmtPng)
, _alignment(kTextAlignmentCenter)
, _vAlignment(kVerticalTextAlignmentCenter)
, _fontName("")
, _text("")
, uiImage(NULL)
, _fontSize(0.0f)
, _uiImage(NULL)
{
_size = Size(0, 0);
_texParams.minFilter = GL_LINEAR;
_texParams.magFilter = GL_LINEAR;
_texParams.wrapS = GL_CLAMP_TO_EDGE;
_texParams.wrapT = GL_CLAMP_TO_EDGE;
textures.push_back(this);
_textures.push_back(this);
}
VolatileTexture::~VolatileTexture()
{
textures.remove(this);
CC_SAFE_RELEASE(uiImage);
_textures.remove(this);
CC_SAFE_RELEASE(_uiImage);
}
void VolatileTexture::addImageTexture(Texture2D *tt, const char* imageFileName, Image::EImageFormat format)
{
if (isReloading)
if (_isReloading)
{
return;
}
@ -697,18 +692,18 @@ void VolatileTexture::addImage(Texture2D *tt, Image *image)
{
VolatileTexture *vt = findVolotileTexture(tt);
image->retain();
vt->uiImage = image;
vt->_uiImage = image;
vt->_cashedImageType = kImage;
}
VolatileTexture* VolatileTexture::findVolotileTexture(Texture2D *tt)
{
VolatileTexture *vt = 0;
std::list<VolatileTexture *>::iterator i = textures.begin();
while (i != textures.end())
auto i = _textures.begin();
while (i != _textures.end())
{
VolatileTexture *v = *i++;
if (v->texture == tt)
if (v->_texture == tt)
{
vt = v;
break;
@ -725,7 +720,7 @@ VolatileTexture* VolatileTexture::findVolotileTexture(Texture2D *tt)
void VolatileTexture::addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize)
{
if (isReloading)
if (_isReloading)
{
return;
}
@ -738,10 +733,9 @@ void VolatileTexture::addDataTexture(Texture2D *tt, void* data, Texture2DPixelFo
vt->_textureSize = contentSize;
}
void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const Size& dimensions, TextAlignment alignment,
VerticalTextAlignment vAlignment, const char *fontName, float fontSize)
void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition)
{
if (isReloading)
if (_isReloading)
{
return;
}
@ -749,12 +743,8 @@ void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const Si
VolatileTexture *vt = findVolotileTexture(tt);
vt->_cashedImageType = kString;
vt->_size = dimensions;
vt->_fontName = fontName;
vt->_alignment = alignment;
vt->_vAlignment = vAlignment;
vt->_fontSize = fontSize;
vt->_text = text;
vt->_fontDefinition = fontDefinition;
}
void VolatileTexture::setTexParameters(Texture2D *t, const ccTexParams &texParams)
@ -773,12 +763,11 @@ void VolatileTexture::setTexParameters(Texture2D *t, const ccTexParams &texParam
void VolatileTexture::removeTexture(Texture2D *t)
{
std::list<VolatileTexture *>::iterator i = textures.begin();
while (i != textures.end())
auto i = _textures.begin();
while (i != _textures.end())
{
VolatileTexture *vt = *i++;
if (vt->texture == t)
if (vt->_texture == t)
{
delete vt;
break;
@ -788,12 +777,12 @@ void VolatileTexture::removeTexture(Texture2D *t)
void VolatileTexture::reloadAllTextures()
{
isReloading = true;
_isReloading = true;
CCLOG("reload all texture");
std::list<VolatileTexture *>::iterator iter = textures.begin();
auto iter = _textures.begin();
while (iter != textures.end())
while (iter != _textures.end())
{
VolatileTexture *vt = *iter++;
@ -812,7 +801,7 @@ void VolatileTexture::reloadAllTextures()
Texture2DPixelFormat oldPixelFormat = Texture2D::defaultAlphaPixelFormat();
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
vt->texture->initWithPVRFile(vt->_fileName.c_str());
vt->_texture->initWithPVRFile(vt->_fileName.c_str());
Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat);
}
else
@ -825,7 +814,7 @@ void VolatileTexture::reloadAllTextures()
{
Texture2DPixelFormat oldPixelFormat = Texture2D::defaultAlphaPixelFormat();
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
vt->texture->initWithImage(pImage);
vt->_texture->initWithImage(pImage);
Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat);
}
@ -836,7 +825,7 @@ void VolatileTexture::reloadAllTextures()
break;
case kImageData:
{
vt->texture->initWithData(vt->_textureData,
vt->_texture->initWithData(vt->_textureData,
vt->_pixelFormat,
vt->_textureSize.width,
vt->_textureSize.height,
@ -845,27 +834,21 @@ void VolatileTexture::reloadAllTextures()
break;
case kString:
{
vt->texture->initWithString(vt->_text.c_str(),
vt->_fontName.c_str(),
vt->_fontSize,
vt->_size,
vt->_alignment,
vt->_vAlignment
);
vt->_texture->initWithString(vt->_text.c_str(), vt->_fontDefinition);
}
break;
case kImage:
{
vt->texture->initWithImage(vt->uiImage);
vt->_texture->initWithImage(vt->_uiImage);
}
break;
default:
break;
}
vt->texture->setTexParameters(vt->_texParams);
vt->_texture->setTexParameters(vt->_texParams);
}
isReloading = false;
_isReloading = false;
}
#endif // CC_ENABLE_CACHE_TEXTURE_DATA

View File

@ -219,8 +219,7 @@ public:
~VolatileTexture();
static void addImageTexture(Texture2D *tt, const char* imageFileName, Image::EImageFormat format);
static void addStringTexture(Texture2D *tt, const char* text, const Size& dimensions, TextAlignment alignment,
VerticalTextAlignment vAlignment, const char *fontName, float fontSize);
static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition);
static void addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize);
static void addImage(Texture2D *tt, Image *image);
@ -229,8 +228,8 @@ public:
static void reloadAllTextures();
public:
static std::list<VolatileTexture*> textures;
static bool isReloading;
static std::list<VolatileTexture*> _textures;
static bool _isReloading;
private:
// find VolatileTexture by Texture2D*
@ -238,9 +237,9 @@ private:
static VolatileTexture* findVolotileTexture(Texture2D *tt);
protected:
Texture2D *texture;
Texture2D *_texture;
Image *uiImage;
Image *_uiImage;
ccCachedImageType _cashedImageType;
@ -251,13 +250,9 @@ protected:
std::string _fileName;
Image::EImageFormat _fmtImage;
ccTexParams _texParams;
Size _size;
TextAlignment _alignment;
VerticalTextAlignment _vAlignment;
std::string _fontName;
std::string _text;
float _fontSize;
ccTexParams _texParams;
std::string _text;
FontDefinition _fontDefinition;
};
#endif

View File

@ -34,10 +34,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -34,10 +34,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -31,18 +31,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -28,18 +28,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -31,10 +31,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();