mirror of https://github.com/axmolengine/axmol.git
CCImage.cpp: If dds header reports 0 mipmaps, force _numberOfMipmaps to 1 to enable software decoding. Set _renderFormat just once for both hardware and software decoding (moved out of "load mipmaps" loop).
This commit is contained in:
parent
14ee675c19
commit
d9cbc5625c
|
@ -1584,11 +1584,11 @@ bool Image::initWithS3TCData(const unsigned char * data, ssize_t dataLen)
|
||||||
|
|
||||||
_width = header->ddsd.width;
|
_width = header->ddsd.width;
|
||||||
_height = header->ddsd.height;
|
_height = header->ddsd.height;
|
||||||
_numberOfMipmaps = header->ddsd.DUMMYUNIONNAMEN2.mipMapCount;
|
_numberOfMipmaps = MAX(1, header->ddsd.DUMMYUNIONNAMEN2.mipMapCount); //if dds header reports 0 mipmaps, set to 1 to force correct software decoding (if needed).
|
||||||
_dataLen = 0;
|
_dataLen = 0;
|
||||||
int blockSize = (FOURCC_DXT1 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) ? 8 : 16;
|
int blockSize = (FOURCC_DXT1 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) ? 8 : 16;
|
||||||
|
|
||||||
/* caculate the dataLen */
|
/* calculate the dataLen */
|
||||||
|
|
||||||
int width = _width;
|
int width = _width;
|
||||||
int height = _height;
|
int height = _height;
|
||||||
|
@ -1630,6 +1630,8 @@ bool Image::initWithS3TCData(const unsigned char * data, ssize_t dataLen)
|
||||||
{
|
{
|
||||||
_renderFormat = Texture2D::PixelFormat::S3TC_DXT5;
|
_renderFormat = Texture2D::PixelFormat::S3TC_DXT5;
|
||||||
}
|
}
|
||||||
|
} else { //will software decode
|
||||||
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load the mipmaps */
|
/* load the mipmaps */
|
||||||
|
@ -1657,7 +1659,6 @@ bool Image::initWithS3TCData(const unsigned char * data, ssize_t dataLen)
|
||||||
|
|
||||||
int bytePerPixel = 4;
|
int bytePerPixel = 4;
|
||||||
unsigned int stride = width * bytePerPixel;
|
unsigned int stride = width * bytePerPixel;
|
||||||
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
|
||||||
|
|
||||||
std::vector<unsigned char> decodeImageData(stride * height);
|
std::vector<unsigned char> decodeImageData(stride * height);
|
||||||
if (FOURCC_DXT1 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC)
|
if (FOURCC_DXT1 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC)
|
||||||
|
|
Loading…
Reference in New Issue