mirror of https://github.com/axmolengine/axmol.git
Deprecate Texture2D::PVRImagesHavePremultipliedAlpha(), move Texture2D::PVRImagesHavePremultipliedAlpha() to Image.
This commit is contained in:
parent
e3b79f4150
commit
34a8d26124
|
@ -97,6 +97,8 @@ namespace
|
||||||
{
|
{
|
||||||
static const int PVR_TEXTURE_FLAG_TYPE_MASK = 0xff;
|
static const int PVR_TEXTURE_FLAG_TYPE_MASK = 0xff;
|
||||||
|
|
||||||
|
static bool _PVRHaveAlphaPremultiplied = false;
|
||||||
|
|
||||||
// Values taken from PVRTexture.h from http://www.imgtec.com
|
// Values taken from PVRTexture.h from http://www.imgtec.com
|
||||||
enum class PVR2TextureFlag
|
enum class PVR2TextureFlag
|
||||||
{
|
{
|
||||||
|
@ -1287,8 +1289,8 @@ bool Image::initWithPVRv2Data(const unsigned char * data, ssize_t dataLen)
|
||||||
|
|
||||||
Configuration *configuration = Configuration::getInstance();
|
Configuration *configuration = Configuration::getInstance();
|
||||||
|
|
||||||
//can not detect the premultiplied alpha from pvr file.
|
//can not detect the premultiplied alpha from pvr file, use _PVRHaveAlphaPremultiplied instead.
|
||||||
|
_hasPremultipliedAlpha = _PVRHaveAlphaPremultiplied;
|
||||||
|
|
||||||
unsigned int flags = CC_SWAP_INT32_LITTLE_TO_HOST(header->flags);
|
unsigned int flags = CC_SWAP_INT32_LITTLE_TO_HOST(header->flags);
|
||||||
PVR2TexturePixelFormat formatFlags = static_cast<PVR2TexturePixelFormat>(flags & PVR_TEXTURE_FLAG_TYPE_MASK);
|
PVR2TexturePixelFormat formatFlags = static_cast<PVR2TexturePixelFormat>(flags & PVR_TEXTURE_FLAG_TYPE_MASK);
|
||||||
|
@ -2355,5 +2357,11 @@ void Image::premultipliedAlpha()
|
||||||
_hasPremultipliedAlpha = true;
|
_hasPremultipliedAlpha = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Image::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
|
||||||
|
{
|
||||||
|
_PVRHaveAlphaPremultiplied = haveAlphaPremultiplied;
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,15 @@ public:
|
||||||
*/
|
*/
|
||||||
bool saveToFile(const std::string &filename, bool isToRGB = true);
|
bool saveToFile(const std::string &filename, bool isToRGB = true);
|
||||||
|
|
||||||
|
|
||||||
|
/** 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.
|
||||||
|
*/
|
||||||
|
static void PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool initWithJpgData(const unsigned char * data, ssize_t dataLen);
|
bool initWithJpgData(const unsigned char * data, ssize_t dataLen);
|
||||||
bool initWithPngData(const unsigned char * data, ssize_t dataLen);
|
bool initWithPngData(const unsigned char * data, ssize_t dataLen);
|
||||||
|
|
|
@ -121,8 +121,6 @@ const Texture2D::PixelFormatInfoMap Texture2D::_pixelFormatInfoTables(TexturePix
|
||||||
// Default is: RGBA8888 (32-bit textures)
|
// Default is: RGBA8888 (32-bit textures)
|
||||||
static Texture2D::PixelFormat g_defaultAlphaPixelFormat = Texture2D::PixelFormat::DEFAULT;
|
static Texture2D::PixelFormat g_defaultAlphaPixelFormat = Texture2D::PixelFormat::DEFAULT;
|
||||||
|
|
||||||
static bool _PVRHaveAlphaPremultiplied = false;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//conventer function
|
//conventer function
|
||||||
|
|
||||||
|
@ -779,20 +777,8 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format)
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the premultiplied tag
|
// set the premultiplied tag
|
||||||
if (!image->hasPremultipliedAlpha())
|
_hasPremultipliedAlpha = image->hasPremultipliedAlpha();
|
||||||
{
|
|
||||||
if (image->getFileType() == Image::Format::PVR)
|
|
||||||
{
|
|
||||||
_hasPremultipliedAlpha = _PVRHaveAlphaPremultiplied;
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
CCLOG("wanning: We cann't find the data is premultiplied or not, we will assume it's false.");
|
|
||||||
_hasPremultipliedAlpha = false;
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
_hasPremultipliedAlpha = image->isPremultipliedAlpha();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1218,7 +1204,7 @@ void Texture2D::drawInRect(const Rect& rect)
|
||||||
|
|
||||||
void Texture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
|
void Texture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
|
||||||
{
|
{
|
||||||
_PVRHaveAlphaPremultiplied = haveAlphaPremultiplied;
|
Image::PVRImagesHavePremultipliedAlpha(haveAlphaPremultiplied);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -183,9 +183,11 @@ public:
|
||||||
|
|
||||||
By default it is disabled.
|
By default it is disabled.
|
||||||
|
|
||||||
|
deprecated, please use Image::PVRImagesHavePremultipliedAlpha() instead.
|
||||||
|
|
||||||
@since v0.99.5
|
@since v0.99.5
|
||||||
*/
|
*/
|
||||||
static void PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
|
CC_DEPRECATED_ATTRIBUTE static void PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue