issue #1405:remove unneeded functions of CCFileUtils

This commit is contained in:
minggo 2012-08-08 18:39:33 +08:00
parent 3395bba327
commit cc39dc55f4
15 changed files with 44 additions and 353 deletions

View File

@ -305,22 +305,6 @@ typedef struct _ccBlendFunc
GLenum dst; GLenum dst;
} ccBlendFunc; } ccBlendFunc;
//! ccResolutionType
typedef enum
{
//! Unknonw resolution type
kCCResolutionUnknown,
//! iPhone resolution type
kCCResolutioniPhone,
//! RetinaDisplay resolution type
kCCResolutioniPhoneRetinaDisplay,
//! iPad resolution type
kCCResolutioniPad,
//! iPad Retina Display resolution type
kCCResolutioniPadRetinaDisplay,
} ccResolutionType;
// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m // XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m
//! Vertical text alignment type //! Vertical text alignment type
typedef enum typedef enum

View File

@ -294,32 +294,6 @@ void CCLabelTTF::updateTexture()
m_fFontSize * CC_CONTENT_SCALE_FACTOR()); m_fFontSize * CC_CONTENT_SCALE_FACTOR());
} }
// iPad ?
//if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
if (CCApplication::sharedApplication().isIpad())
{
if (CC_CONTENT_SCALE_FACTOR() == 2)
{
tex->setResolutionType(kCCResolutioniPadRetinaDisplay);
}
else
{
tex->setResolutionType(kCCResolutioniPad);
}
}
// iPhone ?
else
{
if (CC_CONTENT_SCALE_FACTOR() == 2)
{
tex->setResolutionType(kCCResolutioniPhoneRetinaDisplay);
}
else
{
tex->setResolutionType(kCCResolutioniPhone);
}
}
this->setTexture(tex); this->setTexture(tex);
tex->release(); tex->release();

View File

@ -62,16 +62,6 @@ public:
*/ */
unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize); unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize);
/** removes the suffix from a path
* On RetinaDisplay it will remove the -hd suffix
* On iPad it will remove the -ipad suffix
* On iPhone it will remove the (empty) suffix
Only valid on iOS. Not valid for OS X.
@since v0.99.5
*/
std::string& removeSuffixFromFile(std::string& path);
/** /**
@brief Generate the absolute path of the file. @brief Generate the absolute path of the file.
@param pszRelativePath The relative path of the file. @param pszRelativePath The relative path of the file.
@ -82,68 +72,10 @@ public:
*/ */
const char* fullPathFromRelativePath(const char *pszRelativePath); const char* fullPathFromRelativePath(const char *pszRelativePath);
/** Returns the fullpath of an filename including the resolution of the image.
If in RetinaDisplay mode, and a RetinaDisplay file is found, it will return that path.
If in iPad mode, and an iPad file is found, it will return that path.
Examples:
* In iPad mode: "image.png" -> "/full/path/image-ipad.png" (in case the -ipad file exists)
* In RetinaDisplay mode: "image.png" -> "/full/path/image-hd.png" (in case the -hd file exists)
If an iPad file is found, it will set resolution type to kCCResolutioniPad
If a RetinaDisplay file is found, it will set resolution type to kCCResolutionRetinaDisplay
*/
const char* fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType);
/// @cond /// @cond
const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile);
/// @endcond /// @endcond
/** Sets the iPhone RetinaDisplay suffix to load resources.
By default it is "-hd".
Only valid on iOS. Not valid for OS X.
@since v1.1
*/
void setiPhoneRetinaDisplaySuffix(const char *suffix);
/** Sets the iPad suffix to load resources.
By default it is "".
Only valid on iOS. Not valid for OS X.
*/
void setiPadSuffix(const char *suffix);
/** Sets the iPad Retina Display suffix to load resources.
By default it is "-ipadhd".
Only valid on iOS. Not valid for OS X.
@since v1.1
*/
void setiPadRetinaDisplaySuffix(const char *suffix);
/** Returns whether or not a given filename exists with the iPad suffix.
Only available on iOS. Not supported on OS X.
@since v1.1
*/
bool iPadFileExistsAtPath(const char *filename);
/** Returns whether or not a given filename exists with the iPad RetinaDisplay suffix.
Only available on iOS. Not supported on OS X.
@since v2.0
*/
bool iPadRetinaDisplayFileExistsAtPath(const char *filename);
/** Returns whether or not a given path exists with the iPhone RetinaDisplay suffix.
Only available on iOS. Not supported on OS X.
@since v1.1
*/
bool iPhoneRetinaDisplayFileExistsAtPath(const char *filename);
/** /**
@brief Set the ResourcePath,we will find resource relative to this path @brief Set the ResourcePath,we will find resource relative to this path
@param pszResourcePath Relative path to root @param pszResourcePath Relative path to root

View File

@ -42,10 +42,6 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
static const char *__suffixiPhoneRetinaDisplay = "-hd";
static const char *__suffixiPad = "-ipad";
static const char *__suffixiPadRetinaDisplay = "-ipadhd";
typedef enum typedef enum
{ {
SAX_NONE = 0, SAX_NONE = 0,
@ -322,27 +318,6 @@ public:
} }
}; };
std::string& CCFileUtils::removeSuffixFromFile(std::string& path)
{
// XXX win32 now can only support iphone retina, because
// we don't know it is ipad retina or iphone retina.
// fixe me later
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
std::string::size_type pos = path.rfind("/") + 1; // the begin index of last part of path
std::string::size_type suffixPos = path.rfind(__suffixiPhoneRetinaDisplay);
if (std::string::npos != suffixPos && suffixPos > pos)
{
CCLog("cocos2d: FilePath(%s) contains suffix(%s), remove it.", path.c_str(),
__suffixiPhoneRetinaDisplay);
path.replace(suffixPos, strlen(__suffixiPhoneRetinaDisplay), "");
}
}
return path;
}
CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName) CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName)
{ {
CCDictMaker tMaker; CCDictMaker tMaker;
@ -397,47 +372,6 @@ unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const
return pBuffer; return pBuffer;
} }
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
ccResolutionType ignore;
return fullPathFromRelativePath(pszRelativePath, &ignore);
}
/// functions iOS specific
void CCFileUtils::setiPhoneRetinaDisplaySuffix(const char *suffix)
{
CCAssert(0, "not implement");
}
void CCFileUtils::setiPadSuffix(const char *suffix)
{
CCAssert(0, "not implement");
}
void CCFileUtils::setiPadRetinaDisplaySuffix(const char *suffix)
{
CCAssert(0, "not implement");
}
bool CCFileUtils::iPadFileExistsAtPath(const char *filename)
{
CCAssert(0, "not implement");
return false;
}
bool CCFileUtils::iPadRetinaDisplayFileExistsAtPath(const char *filename)
{
CCAssert(0, "not implement");
return false;
}
bool CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath(const char *filename)
{
CCAssert(0, "not implement");
return false;
}
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory) void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
{ {
m_obDirectory = pszResourceDirectory; m_obDirectory = pszResourceDirectory;

View File

@ -63,8 +63,7 @@ void CCFileUtils::purgeCachedEntries()
} }
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
ccResolutionType *pResolutionType)
{ {
return pszRelativePath; return pszRelativePath;
} }
@ -92,9 +91,18 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
if (pszFileName[0] != '/') if (pszFileName[0] != '/')
{ {
// read from apk // read from apk
string pathWithoutDirectory = fullPath;
fullPath.insert(0, m_obDirectory.c_str()); fullPath.insert(0, m_obDirectory.c_str());
fullPath.insert(0, "assets/"); fullPath.insert(0, "assets/");
pData = CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), fullPath.c_str(), pSize); pData = CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), fullPath.c_str(), pSize);
if (! pData && m_obDirectory.size() > 0)
{
// search from root
pathWithoutDirectory.insert(0, "assets/");
pData = CCFileUtils::getFileDataFromZip(s_strResourcePath.c_str(), pathWithoutDirectory.c_str(), pSize);
}
} }
else else
{ {

View File

@ -44,9 +44,7 @@ USING_NS_CC;
static void static_addValueToCCDict(id key, id value, CCDictionary* pDict); static void static_addValueToCCDict(id key, id value, CCDictionary* pDict);
static void static_addItemToCCArray(id item, CCArray* pArray); static void static_addItemToCCArray(id item, CCArray* pArray);
static NSString *__suffixiPhoneRetinaDisplay =@"-hd";
static NSString *__suffixiPad =@"-ipad";
static NSString *__suffixiPadRetinaDisplay =@"-ipadhd";
static NSFileManager *__localFileManager= [[NSFileManager alloc] init]; static NSFileManager *__localFileManager= [[NSFileManager alloc] init];
static NSString* removeSuffixFromPath(NSString *suffix, NSString *path) static NSString* removeSuffixFromPath(NSString *suffix, NSString *path)
@ -243,57 +241,6 @@ void CCFileUtils::setResourceDirectory(const char *pszDirectoryName)
m_obDirectory = pszDirectoryName; m_obDirectory = pszDirectoryName;
} }
std::string& CCFileUtils::removeSuffixFromFile(std::string& cpath )
{
NSString *ret = nil;
NSString *path = [NSString stringWithUTF8String:cpath.c_str()];
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
{
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
ret = removeSuffixFromPath(__suffixiPadRetinaDisplay, path);
}
else
{
ret = removeSuffixFromPath(__suffixiPad, path);
}
}
else
{
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
ret = removeSuffixFromPath(__suffixiPhoneRetinaDisplay, [NSString stringWithUTF8String:cpath.c_str()]);
}
else
{
ret = path;
}
}
cpath = [ret UTF8String];
return cpath;
}
void CCFileUtils::setiPhoneRetinaDisplaySuffix(const char *suffix)
{
[__suffixiPhoneRetinaDisplay release];
__suffixiPhoneRetinaDisplay = [[NSString stringWithUTF8String:suffix] retain];
}
void CCFileUtils::setiPadSuffix(const char *suffix)
{
[__suffixiPad release];
__suffixiPad = [[NSString stringWithUTF8String:suffix] retain];
}
void CCFileUtils::setiPadRetinaDisplaySuffix(const char *suffix)
{
[__suffixiPadRetinaDisplay release];
__suffixiPadRetinaDisplay = [[NSString stringWithUTF8String:suffix] retain];
}
bool fileExistsAtPath(const char *cpath, const char *csuffix) bool fileExistsAtPath(const char *cpath, const char *csuffix)
{ {
NSString *fullpath = nil; NSString *fullpath = nil;
@ -320,28 +267,7 @@ bool fileExistsAtPath(const char *cpath, const char *csuffix)
return ( path != nil ); return ( path != nil );
} }
bool CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath(const char *cpath)
{
return fileExistsAtPath(cpath, [__suffixiPhoneRetinaDisplay UTF8String]);
}
bool CCFileUtils::iPadFileExistsAtPath(const char *cpath)
{
return fileExistsAtPath(cpath, [__suffixiPad UTF8String]);
}
bool CCFileUtils::iPadRetinaDisplayFileExistsAtPath(const char *cpath)
{
return fileExistsAtPath(cpath, [__suffixiPadRetinaDisplay UTF8String]);
}
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath) const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
ccResolutionType ignore;
return fullPathFromRelativePath(pszRelativePath, &ignore);
}
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType)
{ {
CCAssert(pszRelativePath != NULL, "CCFileUtils: Invalid path"); CCAssert(pszRelativePath != NULL, "CCFileUtils: Invalid path");
@ -355,14 +281,20 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, c
NSString *file = [relPath lastPathComponent]; NSString *file = [relPath lastPathComponent];
NSMutableString *imageDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()]; NSMutableString *imageDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
[imageDirectory appendString:[relPath stringByDeletingLastPathComponent]]; NSMutableString *imageDirectoryWithDirectory = imageDirectory;
//NSString *imageDirectory = [relPath stringByDeletingLastPathComponent]; [imageDirectoryWithDirectory appendString:[relPath stringByDeletingLastPathComponent]];
// search path from directory set by setResourceDirectory
fullpath = [[NSBundle mainBundle] pathForResource:file
ofType:nil
inDirectory:imageDirectoryWithDirectory];
if (fullpath == nil)
{
// search from root directory
fullpath = [[NSBundle mainBundle] pathForResource:file fullpath = [[NSBundle mainBundle] pathForResource:file
ofType:nil ofType:nil
inDirectory:imageDirectory]; inDirectory:imageDirectory];
}
} }
if (fullpath == nil) if (fullpath == nil)
@ -370,42 +302,6 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, c
fullpath = relPath; fullpath = relPath;
} }
/*
NSString *ret = nil;
// iPad?
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// Retina Display ?
if( CC_CONTENT_SCALE_FACTOR() == 2 ) {
ret = getPathForSuffix(fullpath, __suffixiPadRetinaDisplay);
*pResolutionType = kCCResolutioniPadRetinaDisplay;
}
else
{
ret = getPathForSuffix(fullpath, __suffixiPad);
*pResolutionType = kCCResolutioniPad;
}
}
// iPhone ?
else
{
// Retina Display ?
if( CC_CONTENT_SCALE_FACTOR() == 2 ) {
ret = getPathForSuffix(fullpath, __suffixiPhoneRetinaDisplay);
*pResolutionType = kCCResolutioniPhoneRetinaDisplay;
}
}
// If it is iPhone Non RetinaDisplay, or if the previous "getPath" failed, then use iPhone images.
if( ret == nil )
{
*pResolutionType = kCCResolutioniPhone;
ret = fullpath;
}
*/
return [fullpath UTF8String]; return [fullpath UTF8String];
} }

View File

@ -397,7 +397,7 @@ void CCEGLView::resize(int width, int height)
rcClient.bottom - rcClient.top, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); rcClient.bottom - rcClient.top, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
} }
void CCEGLView::setFrameSize(float width, float height) void CCEGLView::setSize(float width, float height)
{ {
Create((LPCTSTR)m_szViewName, (int)width, (int)height); Create((LPCTSTR)m_szViewName, (int)width, (int)height);
CCEGLViewProtocol::setFrameSize(width, height); CCEGLViewProtocol::setFrameSize(width, height);
@ -435,16 +435,13 @@ void CCEGLView::centerWindow()
SetWindowPos(m_hWnd, 0, offsetX, offsetY, 0, 0, SWP_NOCOPYBITS | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER); SetWindowPos(m_hWnd, 0, offsetX, offsetY, 0, 0, SWP_NOCOPYBITS | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER);
} }
bool CCEGLView::canSetContentScaleFactor() bool CCEGLView::setContentScaleFactor(float contentScaleFactor)
{
return true;
}
void CCEGLView::setContentScaleFactor(float contentScaleFactor)
{ {
CCEGLViewProtocol::setContentScaleFactor(contentScaleFactor); CCEGLViewProtocol::setContentScaleFactor(contentScaleFactor);
resize((int)(m_sSizeInPixel.width * contentScaleFactor), (int)(m_sSizeInPixel.height * contentScaleFactor)); resize((int)(m_sSizeInPixel.width * contentScaleFactor), (int)(m_sSizeInPixel.height * contentScaleFactor));
centerWindow(); centerWindow();
return true
} }
CCEGLView& CCEGLView::sharedOpenGLView() CCEGLView& CCEGLView::sharedOpenGLView()

View File

@ -44,9 +44,8 @@ public:
virtual bool isOpenGLReady(); virtual bool isOpenGLReady();
virtual void end(); virtual void end();
virtual void swapBuffers(); virtual void swapBuffers();
virtual bool canSetContentScaleFactor(); virtual bool setContentScaleFactor(float contentScaleFactor);
virtual void setContentScaleFactor(float contentScaleFactor); virtual void setSize(float width, float height);
virtual void setFrameSize(float width, float height);
virtual void setIMEKeyboardState(bool bOpen); virtual void setIMEKeyboardState(bool bOpen);
private: private:

View File

@ -83,7 +83,7 @@ void CCFileUtils::setResourcePath(const char *pszResourcePath)
strcpy(s_pszResourcePath, pszResourcePath); strcpy(s_pszResourcePath, pszResourcePath);
} }
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType) const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{ {
_CheckPath(); _CheckPath();

View File

@ -235,7 +235,6 @@ bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFor
m_bHasPremultipliedAlpha = false; m_bHasPremultipliedAlpha = false;
m_bHasMipmaps = false; m_bHasMipmaps = false;
m_eResolutionType = kCCResolutionUnknown;
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture)); setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture));
return true; return true;
@ -250,11 +249,6 @@ const char* CCTexture2D::description(void)
// implementation CCTexture2D (Image) // implementation CCTexture2D (Image)
bool CCTexture2D::initWithImage(CCImage *uiImage) bool CCTexture2D::initWithImage(CCImage *uiImage)
{
return initWithImage(uiImage, kCCResolutionUnknown);
}
bool CCTexture2D::initWithImage(CCImage * uiImage, ccResolutionType resolution)
{ {
if (uiImage == NULL) if (uiImage == NULL)
{ {
@ -276,11 +270,10 @@ bool CCTexture2D::initWithImage(CCImage * uiImage, ccResolutionType resolution)
return NULL; return NULL;
} }
m_eResolutionType = resolution;
// always load premultiplied images // always load premultiplied images
return initPremultipliedATextureWithImage(uiImage, imageWidth, imageHeight); return initPremultipliedATextureWithImage(uiImage, imageWidth, imageHeight);
} }
bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned int width, unsigned int height) bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned int width, unsigned int height)
{ {
unsigned char* tempData = image->getData(); unsigned char* tempData = image->getData();

View File

@ -134,8 +134,6 @@ public:
bool initWithImage(CCImage * uiImage); bool initWithImage(CCImage * uiImage);
bool initWithImage(CCImage *uiImage, ccResolutionType resolution);
/** Initializes a texture from a string with dimensions, alignment, font name and font size */ /** Initializes a texture from a string with dimensions, alignment, font name and font size */
bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize);
/** Initializes a texture from a string with font name and font size */ /** Initializes a texture from a string with font name and font size */
@ -273,17 +271,6 @@ private:
/** shader program used by drawAtPoint and drawInRect */ /** shader program used by drawAtPoint and drawInRect */
CC_PROPERTY(CCGLProgram*, m_pShaderProgram, ShaderProgram); CC_PROPERTY(CCGLProgram*, m_pShaderProgram, ShaderProgram);
/** Returns the resolution type of the texture.
Is it a RetinaDisplay texture, an iPad texture or an standard texture ?
Only valid on iOS. Not valid on OS X.
Should be a readonly property. It is readwrite as a hack.
@since v1.1
*/
CC_SYNTHESIZE(ccResolutionType, m_eResolutionType, ResolutionType);
}; };
// end of textures group // end of textures group

View File

@ -257,7 +257,6 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF
// optimization // optimization
std::string pathKey = path; std::string pathKey = path;
CCFileUtils::sharedFileUtils()->removeSuffixFromFile(pathKey);
pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str()); pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str());
texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str()); texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str());
@ -400,8 +399,6 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
// remove possible -HD suffix to prevent caching the same image twice (issue #1040) // remove possible -HD suffix to prevent caching the same image twice (issue #1040)
std::string pathKey = path; std::string pathKey = path;
ccResolutionType resolution = kCCResolutionUnknown;
CCFileUtils::sharedFileUtils()->removeSuffixFromFile(pathKey);
pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str()); pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str());
texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str()); texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str());
@ -446,7 +443,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
texture = new CCTexture2D(); texture = new CCTexture2D();
if( texture && if( texture &&
texture->initWithImage(&image, resolution) ) texture->initWithImage(&image) )
{ {
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture file name // cache the texture file name
@ -477,7 +474,6 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl
CCTexture2D * texture; CCTexture2D * texture;
std::string temp(path); std::string temp(path);
CCFileUtils::sharedFileUtils()->removeSuffixFromFile(temp);
if ( (texture = (CCTexture2D*)m_pTextures->objectForKey(temp.c_str())) ) if ( (texture = (CCTexture2D*)m_pTextures->objectForKey(temp.c_str())) )
{ {
@ -514,8 +510,6 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path)
CCTexture2D* texture = NULL; CCTexture2D* texture = NULL;
std::string key(path); std::string key(path);
// remove possible -HD suffix to prevent caching the same image twice (issue #1040)
CCFileUtils::sharedFileUtils()->removeSuffixFromFile(key);
if( (texture = (CCTexture2D*)m_pTextures->objectForKey(key.c_str())) ) if( (texture = (CCTexture2D*)m_pTextures->objectForKey(key.c_str())) )
{ {
@ -568,7 +562,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key)
// prevents overloading the autorelease pool // prevents overloading the autorelease pool
texture = new CCTexture2D(); texture = new CCTexture2D();
texture->initWithImage(image, kCCResolutionUnknown); texture->initWithImage(image);
if(key && texture) if(key && texture)
{ {
@ -890,8 +884,7 @@ void VolatileTexture::reloadAllTextures()
break; break;
case kImage: case kImage:
{ {
vt->texture->initWithImage(vt->uiImage, vt->texture->initWithImage(vt->uiImage);
kCCResolutionUnknown);
} }
break; break;
default: default:

View File

@ -24,9 +24,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
if (!CCDirector::sharedDirector()->getOpenGLView()) if (!CCDirector::sharedDirector()->getOpenGLView())
{ {
CCEGLView *view = &CCEGLView::sharedOpenGLView(); CCEGLView *view = &CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h); view->setSize(w, h);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
view->setDesignResolutionSize(480, 320);
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication().run(); CCApplication::sharedApplication().run();

View File

@ -25,9 +25,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
if (!CCDirector::sharedDirector()->getOpenGLView()) if (!CCDirector::sharedDirector()->getOpenGLView())
{ {
CCEGLView *view = &CCEGLView::sharedOpenGLView(); CCEGLView *view = &CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h); view->setSize(w, h);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
view->setDesignResolutionSize(480, 320, kResolutionScaleFullScreen);
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication().run(); CCApplication::sharedApplication().run();

View File

@ -25,9 +25,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
if (!CCDirector::sharedDirector()->getOpenGLView()) if (!CCDirector::sharedDirector()->getOpenGLView())
{ {
CCEGLView *view = &CCEGLView::sharedOpenGLView(); CCEGLView *view = &CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h); view->setSize(w, h);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
// view->setDesignResolutionSize(480, 320);
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication().run(); CCApplication::sharedApplication().run();