mirror of https://github.com/axmolengine/axmol.git
edit for lua
This commit is contained in:
parent
304d636deb
commit
41cac18ae2
|
@ -189,20 +189,20 @@ public:
|
||||||
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _initWithJpgData(void *data, int dataLen);
|
bool initWithJpgData(void *data, int dataLen);
|
||||||
bool _initWithPngData(void *data, int dataLen);
|
bool initWithPngData(void *data, int dataLen);
|
||||||
bool _initWithTiffData(void *data, int dataLen);
|
bool initWithTiffData(void *data, int dataLen);
|
||||||
bool _initWithWebpData(void *data, int dataLen);
|
bool initWithWebpData(void *data, int dataLen);
|
||||||
bool _initWithPVRData(void *data, int dataLen);
|
bool initWithPVRData(void *data, int dataLen);
|
||||||
bool _initWithPVRv2Data(void *data, int dataLen);
|
bool initWithPVRv2Data(void *data, int dataLen);
|
||||||
bool _initWithPVRv3Data(void *data, int dataLen);
|
bool initWithPVRv3Data(void *data, int dataLen);
|
||||||
bool _initWithETCData(void *data, int dataLen);
|
bool initWithETCData(void *data, int dataLen);
|
||||||
|
|
||||||
bool saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true);
|
bool saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true);
|
||||||
bool saveImageToJPG(const char *pszFilePath);
|
bool saveImageToJPG(const char *pszFilePath);
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
bool _iosSaveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
bool iosSaveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned char *_data;
|
unsigned char *_data;
|
||||||
|
@ -238,7 +238,7 @@ private:
|
||||||
bool isPvr(void *data, int dataLen);
|
bool isPvr(void *data, int dataLen);
|
||||||
bool isEtc(void *data, int dataLen);
|
bool isEtc(void *data, int dataLen);
|
||||||
|
|
||||||
bool _testFormatForPvrTCSupport(int format);
|
bool testFormatForPvrTCSupport(int format);
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of platform group
|
// end of platform group
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
bool Image::_initWithWebpData(void *data, int dataLen)
|
bool Image::initWithWebpData(void *data, int dataLen)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
do
|
do
|
||||||
|
|
|
@ -325,17 +325,17 @@ bool Image::initWithImageData(void * data, int dataLen)
|
||||||
switch (_fileType)
|
switch (_fileType)
|
||||||
{
|
{
|
||||||
case Format::PNG:
|
case Format::PNG:
|
||||||
return _initWithPngData(data, dataLen);
|
return initWithPngData(data, dataLen);
|
||||||
case Format::JPG:
|
case Format::JPG:
|
||||||
return _initWithJpgData(data, dataLen);
|
return initWithJpgData(data, dataLen);
|
||||||
case Format::TIFF:
|
case Format::TIFF:
|
||||||
return _initWithTiffData(data, dataLen);
|
return initWithTiffData(data, dataLen);
|
||||||
case Format::WEBP:
|
case Format::WEBP:
|
||||||
return _initWithWebpData(data, dataLen);
|
return initWithWebpData(data, dataLen);
|
||||||
case Format::PVR:
|
case Format::PVR:
|
||||||
return _initWithPVRData(data, dataLen);
|
return initWithPVRData(data, dataLen);
|
||||||
case Format::ETC:
|
case Format::ETC:
|
||||||
return _initWithETCData(data, dataLen);
|
return initWithETCData(data, dataLen);
|
||||||
default:
|
default:
|
||||||
CCAssert(false, "unsupport image format!");
|
CCAssert(false, "unsupport image format!");
|
||||||
return false;
|
return false;
|
||||||
|
@ -508,7 +508,7 @@ my_error_exit (j_common_ptr cinfo)
|
||||||
longjmp(myerr->setjmp_buffer, 1);
|
longjmp(myerr->setjmp_buffer, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::_initWithJpgData(void * data, int dataLen)
|
bool Image::initWithJpgData(void * data, int dataLen)
|
||||||
{
|
{
|
||||||
/* these are standard libjpeg structures for reading(decompression) */
|
/* these are standard libjpeg structures for reading(decompression) */
|
||||||
struct jpeg_decompress_struct cinfo;
|
struct jpeg_decompress_struct cinfo;
|
||||||
|
@ -603,7 +603,7 @@ bool Image::_initWithJpgData(void * data, int dataLen)
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::_initWithPngData(void * data, int dataLen)
|
bool Image::initWithPngData(void * data, int dataLen)
|
||||||
{
|
{
|
||||||
// length of bytes to check if it is a valid png file
|
// length of bytes to check if it is a valid png file
|
||||||
#define PNGSIGSIZE 8
|
#define PNGSIGSIZE 8
|
||||||
|
@ -841,7 +841,7 @@ static void _tiffUnmapProc(thandle_t fd, void* base, toff_t size)
|
||||||
CC_UNUSED_PARAM(size);
|
CC_UNUSED_PARAM(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::_initWithTiffData(void* data, int dataLen)
|
bool Image::initWithTiffData(void* data, int dataLen)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
do
|
do
|
||||||
|
@ -902,7 +902,7 @@ bool Image::_initWithTiffData(void* data, int dataLen)
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::_testFormatForPvrTCSupport(int format)
|
bool Image::testFormatForPvrTCSupport(int format)
|
||||||
{
|
{
|
||||||
#ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
#ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||||
if (!Configuration::getInstance()->supportsPVRTC())
|
if (!Configuration::getInstance()->supportsPVRTC())
|
||||||
|
@ -921,7 +921,7 @@ bool Image::_testFormatForPvrTCSupport(int format)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::_initWithPVRv2Data(void *data, int dataLen)
|
bool Image::initWithPVRv2Data(void *data, int dataLen)
|
||||||
{
|
{
|
||||||
ccPVRv2TexHeader *header = NULL;
|
ccPVRv2TexHeader *header = NULL;
|
||||||
unsigned int flags, pvrTag;
|
unsigned int flags, pvrTag;
|
||||||
|
@ -961,7 +961,7 @@ bool Image::_initWithPVRv2Data(void *data, int dataLen)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_testFormatForPvrTCSupport(formatFlags))
|
if (!testFormatForPvrTCSupport(formatFlags))
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%2x. Re-encode it with a OpenGL pixel format variant", formatFlags);
|
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%2x. Re-encode it with a OpenGL pixel format variant", formatFlags);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1054,7 +1054,7 @@ bool Image::_initWithPVRv2Data(void *data, int dataLen)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::_initWithPVRv3Data(void *data, int dataLen)
|
bool Image::initWithPVRv3Data(void *data, int dataLen)
|
||||||
{
|
{
|
||||||
if (dataLen < sizeof(ccPVRv3TexHeader))
|
if (dataLen < sizeof(ccPVRv3TexHeader))
|
||||||
{
|
{
|
||||||
|
@ -1073,7 +1073,7 @@ bool Image::_initWithPVRv3Data(void *data, int dataLen)
|
||||||
// parse pixel format
|
// parse pixel format
|
||||||
uint64_t pixelFormat = header->pixelFormat;
|
uint64_t pixelFormat = header->pixelFormat;
|
||||||
|
|
||||||
if (!_testFormatForPvrTCSupport(pixelFormat))
|
if (!testFormatForPvrTCSupport(pixelFormat))
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%2x. Re-encode it with a OpenGL pixel format variant", pixelFormat);
|
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%2x. Re-encode it with a OpenGL pixel format variant", pixelFormat);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1177,7 +1177,7 @@ bool Image::_initWithPVRv3Data(void *data, int dataLen)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::_initWithETCData(void *data, int dataLen)
|
bool Image::initWithETCData(void *data, int dataLen)
|
||||||
{
|
{
|
||||||
etc1_byte* header = (etc1_byte*)data;
|
etc1_byte* header = (etc1_byte*)data;
|
||||||
|
|
||||||
|
@ -1228,9 +1228,9 @@ bool Image::_initWithETCData(void *data, int dataLen)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::_initWithPVRData(void *data, int dataLen)
|
bool Image::initWithPVRData(void *data, int dataLen)
|
||||||
{
|
{
|
||||||
return _initWithPVRv2Data(data, dataLen) || _initWithPVRv3Data(data, dataLen);
|
return initWithPVRv2Data(data, dataLen) || initWithPVRv3Data(data, dataLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::initWithRawData(void * data, int dataLen, int nWidth, int nHeight, int nBitsPerComponent, bool bPreMulti)
|
bool Image::initWithRawData(void * data, int dataLen, int nWidth, int nHeight, int nBitsPerComponent, bool bPreMulti)
|
||||||
|
@ -1271,7 +1271,7 @@ bool Image::saveToFile(const char *pszFilePath, bool bIsToRGB)
|
||||||
assert(false);
|
assert(false);
|
||||||
return false;
|
return false;
|
||||||
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
return _iosSaveToFile(pszFilePath, bIsToRGB);
|
return iosSaveToFile(pszFilePath, bIsToRGB);
|
||||||
#else
|
#else
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
|
|
||||||
|
|
|
@ -379,7 +379,7 @@ bool Image::initWithStringShadowStroke(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::_iosSaveToFile(const char *pszFilePath, bool bIsToRGB)
|
bool Image::iosSaveToFile(const char *pszFilePath, bool bIsToRGB)
|
||||||
{
|
{
|
||||||
bool saveToPNG = false;
|
bool saveToPNG = false;
|
||||||
bool needToCopyPixels = false;
|
bool needToCopyPixels = false;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
8d25db0b26a3ad69e760268aab15843e0112eedf
|
b594adf598be0fbf5ca9ad804255069bc13405d5
|
|
@ -54,7 +54,7 @@ class CCImage : public CCObject
|
||||||
bool hasAlpha();
|
bool hasAlpha();
|
||||||
bool isPremultipliedAlpha();
|
bool isPremultipliedAlpha();
|
||||||
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
||||||
unsigned short getWidth();
|
int getWidth();
|
||||||
unsigned short getHeight();
|
int getHeight();
|
||||||
int getBitDepth();
|
int getBitPerPixel();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
|
|
||||||
class CCTextureCache : public CCObject
|
class CCTextureCache : public CCObject
|
||||||
{
|
{
|
||||||
CCTexture2D* addImage(const char* fileimage);
|
CCTexture2D* addImage(const char* fileimage);
|
||||||
CCTexture2D* addUIImage(CCImage *image, const char *key);
|
CCTexture2D* addUIImage(CCImage *image, const char *key);
|
||||||
CCTexture2D* textureForKey(const char* key);
|
CCTexture2D* textureForKey(const char* key);
|
||||||
|
|
||||||
CCTexture2D* addPVRImage(const char* filename);
|
void removeAllTextures();
|
||||||
|
void removeUnusedTextures();
|
||||||
void removeAllTextures();
|
void removeTexture(CCTexture2D* texture);
|
||||||
void removeUnusedTextures();
|
void removeTextureForKey(const char *textureKeyName);
|
||||||
void removeTexture(CCTexture2D* texture);
|
void dumpCachedTextureInfo();
|
||||||
void removeTextureForKey(const char *textureKeyName);
|
|
||||||
void dumpCachedTextureInfo();
|
static void reloadAllTextures();
|
||||||
|
|
||||||
static void reloadAllTextures();
|
static CCTextureCache * getInstance();
|
||||||
|
static void destroyInstance();
|
||||||
static CCTextureCache * getInstance();
|
};
|
||||||
static void destroyInstance();
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in New Issue