mirror of https://github.com/axmolengine/axmol.git
Merge pull request #15831 from j-jorge/premultiplied-alpha-config
Add a config option to enable or disable the premultiplied alpha code.
This commit is contained in:
commit
08898db883
|
@ -397,4 +397,12 @@ THE SOFTWARE.
|
|||
#define CC_FILEUTILS_APPLE_ENABLE_OBJC 1
|
||||
#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__
|
||||
|
|
|
@ -2451,6 +2451,10 @@ bool Image::saveImageToJPG(const std::string& filePath)
|
|||
|
||||
void Image::premultipliedAlpha()
|
||||
{
|
||||
#if CC_ENABLE_PREMULTIPLIED_ALPHA == 0
|
||||
_hasPremultipliedAlpha = false;
|
||||
return;
|
||||
#else
|
||||
CCASSERT(_renderFormat == Texture2D::PixelFormat::RGBA8888, "The pixel format should be RGBA8888!");
|
||||
|
||||
unsigned int* fourBytes = (unsigned int*)_data;
|
||||
|
@ -2461,6 +2465,7 @@ void Image::premultipliedAlpha()
|
|||
}
|
||||
|
||||
_hasPremultipliedAlpha = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue