Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into ScriptHandler

This commit is contained in:
samuele3hu 2013-07-17 14:45:02 +08:00
commit 847b87b297
31 changed files with 234 additions and 297 deletions

View File

@ -443,6 +443,7 @@ Developers:
Explicitly initialising CCAcceleration structure. Explicitly initialising CCAcceleration structure.
Add support to save/retrieve CCData into/from CCUserDefault. Add support to save/retrieve CCData into/from CCUserDefault.
Text Shadows fix Text Shadows fix
Solving 'black screen' on android.
MarcelBloemendaal MarcelBloemendaal
Adding secureTextEntry property to CCTextFieldTTF. Adding secureTextEntry property to CCTextFieldTTF.

View File

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

View File

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

View File

@ -65,12 +65,13 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); 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 // Need to listen the event only when not use batchnode, because it will use VBO
NotificationCenter::getInstance()->addObserver(this, NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(ParticleSystemQuad::listenBackToForeground), callfuncO_selector(ParticleSystemQuad::listenBackToForeground),
EVNET_COME_TO_FOREGROUND, EVNET_COME_TO_FOREGROUND,
NULL); NULL);
#endif
return true; return true;
} }
@ -100,7 +101,9 @@ ParticleSystemQuad::~ParticleSystemQuad()
#endif #endif
} }
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
} }
// implementation ParticleSystemQuad // 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) void FileUtils::setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder)
{ {
bool bExistDefault = false; bool bExistDefault = false;
_fullPathCache.clear();
_searchResolutionsOrderArray.clear(); _searchResolutionsOrderArray.clear();
for (std::vector<std::string>::const_iterator iter = searchResolutionsOrder.begin(); iter != searchResolutionsOrder.end(); ++iter) 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; bool bExistDefaultRootPath = false;
_fullPathCache.clear();
_searchPathArray.clear(); _searchPathArray.clear();
for (std::vector<std::string>::const_iterator iter = searchPaths.begin(); iter != searchPaths.end(); ++iter) 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) void FileUtils::setFilenameLookupDictionary(Dictionary* pFilenameLookupDict)
{ {
_fullPathCache.clear();
CC_SAFE_RELEASE(_filenameLookupDict); CC_SAFE_RELEASE(_filenameLookupDict);
_filenameLookupDict = pFilenameLookupDict; _filenameLookupDict = pFilenameLookupDict;
CC_SAFE_RETAIN(_filenameLookupDict); 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 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 #define CC_ENABLE_CACHE_TEXTURE_DATA 1
#else #else
#define CC_ENABLE_CACHE_TEXTURE_DATA 0 #define CC_ENABLE_CACHE_TEXTURE_DATA 0

View File

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

View File

@ -219,7 +219,7 @@ void ShaderCache::reloadDefaultShaders()
// //
p = programForKey(kShader_PositionLengthTexureColor); p = programForKey(kShader_PositionLengthTexureColor);
p->reset(); p->reset();
loadDefaultShader(p, kShaderType_Position_uColor); loadDefaultShader(p, kShaderType_PositionLengthTexureColor);
} }
void ShaderCache::loadDefaultShader(GLProgram *p, int type) void ShaderCache::loadDefaultShader(GLProgram *p, int type)
@ -297,7 +297,7 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type)
GLProgram* ShaderCache::programForKey(const char* key) 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) void ShaderCache::addProgram(GLProgram* program, const char* key)

View File

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

View File

@ -442,8 +442,6 @@ 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) 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._shadow._shadowEnabled = false;
@ -458,65 +456,13 @@ bool Texture2D::initWithString(const char *text, const char *fontName, float fon
tempDef._fontFillColor = Color3B::WHITE; tempDef._fontFillColor = Color3B::WHITE;
return initWithString(text, tempDef); 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
} }
bool Texture2D::initWithString(const char *text, const FontDefinition& textDefinition) 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 #if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data // cache the texture data
VolatileTexture::addStringTexture(this, text, textDefinition._dimensions, textDefinition._alignment, textDefinition._vertAlignment, textDefinition._fontName.c_str(), textDefinition._fontSize); VolatileTexture::addStringTexture(this, text, textDefinition);
#endif #endif
bool bRet = false; bool bRet = false;
@ -543,6 +489,8 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
return false; return false;
} }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
// handle shadow parameters // handle shadow parameters
bool shadowEnabled = false; bool shadowEnabled = false;
float shadowDX = 0.0f; float shadowDX = 0.0f;
@ -610,12 +558,23 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
return bRet; return bRet;
#else #else
bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled;
CCAssert(false, "Currently only supported on iOS and Android!"); CCAssert(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!");
return false;
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 #endif
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,7 +43,7 @@ skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .
ParticleBatchNode::[getBlendFunc setBlendFunc], ParticleBatchNode::[getBlendFunc setBlendFunc],
LayerColor::[getBlendFunc setBlendFunc], LayerColor::[getBlendFunc setBlendFunc],
ParticleSystem::[getBlendFunc setBlendFunc], ParticleSystem::[getBlendFunc setBlendFunc],
DrawNode::[getBlendFunc setBlendFunc drawPolygon], DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground],
Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo], Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo],
Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased], Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased],
Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],