fixed #922: rename CCTexture2D::setPVRImagesHavePremultipliedAlpha() and change it to a static method

This commit is contained in:
minggo 2011-12-20 14:59:15 +08:00
parent a8d5b6544a
commit 01cf5793ad
2 changed files with 20 additions and 10 deletions

View File

@ -201,12 +201,9 @@ public:
/** returns the bits-per-pixel of the in-memory OpenGL texture
@since v1.0
*/
unsigned int bitsPerPixelForFormat();
void setPVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
unsigned int bitsPerPixelForFormat();
/** sets the default pixel format for UIImages that contains alpha channel.
/** sets the default pixel format for UIImagescontains alpha channel.
If the UIImage contains alpha channel, then the options are:
- generate 32-bit textures: kCCTexture2DPixelFormat_RGBA8888 (default one)
- generate 24-bit textures: kCCTexture2DPixelFormat_RGB888
@ -228,6 +225,16 @@ public:
*/
static CCTexture2DPixelFormat defaultAlphaPixelFormat();
/** treats (or not) PVR files as if they have alpha premultiplied.
Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is
possible load them as if they have (or not) the alpha channel premultiplied.
By default it is disabled.
@since v0.99.5
*/
static void PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
private:
bool initPremultipliedATextureWithImage(CCImage * image, unsigned int pixelsWide, unsigned int pixelsHigh);

View File

@ -59,6 +59,9 @@ namespace cocos2d {
// Default is: RGBA8888 (32-bit textures)
static CCTexture2DPixelFormat g_defaultAlphaPixelFormat = kCCTexture2DPixelFormat_Default;
// By default PVR images are treated as if they don't have the alpha channel premultiplied
static bool PVRHaveAlphaPremultiplied_ = false;
CCTexture2D::CCTexture2D()
: m_uPixelsWide(0)
, m_uPixelsHigh(0)
@ -538,7 +541,7 @@ bool CCTexture2D::initWithPVRTCData(const void *data, int level, int bpp, bool h
m_uPixelsHigh = length;
m_fMaxS = 1.0f;
m_fMaxT = 1.0f;
m_bHasPremultipliedAlpha = m_bPVRHaveAlphaPremultiplied;
m_bHasPremultipliedAlpha = PVRHaveAlphaPremultiplied_;
m_ePixelFormat = pixelFormat;
return true;
@ -562,8 +565,8 @@ bool CCTexture2D::initWithPVRFile(const char* file)
m_fMaxT = 1.0f;
m_uPixelsWide = pvr->getWidth();
m_uPixelsHigh = pvr->getHeight();
m_tContentSize = CCSizeMake(m_uPixelsWide, m_uPixelsHigh);
m_bHasPremultipliedAlpha = m_bPVRHaveAlphaPremultiplied;
m_tContentSize = CCSizeMake((float)m_uPixelsWide, (float)m_uPixelsHigh);
m_bHasPremultipliedAlpha = PVRHaveAlphaPremultiplied_;
m_ePixelFormat = pvr->getFormat();
this->setAntiAliasTexParameters();
@ -577,9 +580,9 @@ bool CCTexture2D::initWithPVRFile(const char* file)
return bRet;
}
void CCTexture2D::setPVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
void CCTexture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
{
m_bPVRHaveAlphaPremultiplied = haveAlphaPremultiplied;
PVRHaveAlphaPremultiplied_ = haveAlphaPremultiplied;
}