mirror of https://github.com/axmolengine/axmol.git
Add a config option to enable or disable the premultiplied alpha code.
This commit is contained in:
parent
c25550e1a4
commit
6fb3946c51
|
@ -397,4 +397,12 @@ THE SOFTWARE.
|
||||||
#define CC_FILEUTILS_APPLE_ENABLE_OBJC 1
|
#define CC_FILEUTILS_APPLE_ENABLE_OBJC 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** @def CC_ENABLE_PREMULTIPLIED_ALPHA
|
||||||
|
* If enabled, all textures will be preprocessed to multiply its rgb components
|
||||||
|
* by its alpha component.
|
||||||
|
*/
|
||||||
|
#ifndef CC_ENABLE_PREMULTIPLIED_ALPHA
|
||||||
|
# define CC_ENABLE_PREMULTIPLIED_ALPHA 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __CCCONFIG_H__
|
#endif // __CCCONFIG_H__
|
||||||
|
|
|
@ -2451,6 +2451,10 @@ bool Image::saveImageToJPG(const std::string& filePath)
|
||||||
|
|
||||||
void Image::premultipliedAlpha()
|
void Image::premultipliedAlpha()
|
||||||
{
|
{
|
||||||
|
#if CC_ENABLE_PREMULTIPLIED_ALPHA == 0
|
||||||
|
_hasPremultipliedAlpha = false;
|
||||||
|
return;
|
||||||
|
#else
|
||||||
CCASSERT(_renderFormat == Texture2D::PixelFormat::RGBA8888, "The pixel format should be RGBA8888!");
|
CCASSERT(_renderFormat == Texture2D::PixelFormat::RGBA8888, "The pixel format should be RGBA8888!");
|
||||||
|
|
||||||
unsigned int* fourBytes = (unsigned int*)_data;
|
unsigned int* fourBytes = (unsigned int*)_data;
|
||||||
|
@ -2461,6 +2465,7 @@ void Image::premultipliedAlpha()
|
||||||
}
|
}
|
||||||
|
|
||||||
_hasPremultipliedAlpha = true;
|
_hasPremultipliedAlpha = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue