mirror of https://github.com/axmolengine/axmol.git
Remove unnecessary parameter
This commit is contained in:
parent
e8f0bf9787
commit
64e678c84a
|
@ -154,8 +154,7 @@ void FontAtlas::initTextureWithZeros(Texture2D* texture)
|
|||
}
|
||||
zeros = new char[zeroBytes]();
|
||||
// std::fill(zeros, zeros + cnt, 0);
|
||||
texture->initWithData(zeros, zeroBytes, pixelFormat, CacheTextureWidth, CacheTextureHeight,
|
||||
Vec2(CacheTextureWidth, CacheTextureHeight));
|
||||
texture->initWithData(zeros, zeroBytes, pixelFormat, CacheTextureWidth, CacheTextureHeight);
|
||||
delete[] zeros;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,6 @@ bool Texture2D::initWithData(const void* data,
|
|||
backend::PixelFormat renderFormat,
|
||||
int pixelsWide,
|
||||
int pixelsHigh,
|
||||
const Vec2& /*contentSize*/,
|
||||
bool preMultipliedAlpha)
|
||||
{
|
||||
CCASSERT(dataLen > 0 && pixelsWide > 0 && pixelsHigh > 0, "Invalid size");
|
||||
|
@ -215,7 +214,7 @@ bool Texture2D::updateWithImage(Image* image, backend::PixelFormat format, int i
|
|||
}
|
||||
|
||||
unsigned char* tempData = image->getData();
|
||||
Vec2 imageSize = Vec2((float)imageWidth, (float)imageHeight);
|
||||
// Vec2 imageSize = Vec2((float)imageWidth, (float)imageHeight);
|
||||
backend::PixelFormat renderFormat = (PixelFormat::NONE == format) ? image->getPixelFormat() : format;
|
||||
backend::PixelFormat imagePixelFormat = image->getPixelFormat();
|
||||
size_t tempDataLen = image->getDataLen();
|
||||
|
@ -250,30 +249,21 @@ bool Texture2D::updateWithImage(Image* image, backend::PixelFormat format, int i
|
|||
|
||||
// pixel format of data is not converted, renderFormat can be different from pixelFormat
|
||||
// it will be done later
|
||||
updateWithMipmaps(image->getMipmaps(), image->getNumberOfMipmaps(), image->getPixelFormat(), renderFormat,
|
||||
imageWidth, imageHeight, image->hasPremultipliedAlpha(), index);
|
||||
updateWithMipmaps(image->getMipmaps(), image->getNumberOfMipmaps(), image->getPixelFormat(), renderFormat, imageHeight, image->hasPremultipliedAlpha(), index);
|
||||
}
|
||||
else if (image->isCompressed())
|
||||
{ // !Only hardware support texture will be compression PixelFormat, otherwise, will convert to RGBA8 duraing image
|
||||
// load
|
||||
renderFormat = imagePixelFormat;
|
||||
updateWithData(tempData, tempDataLen, image->getPixelFormat(), image->getPixelFormat(), imageWidth, imageHeight,
|
||||
imageSize, image->hasPremultipliedAlpha(), index);
|
||||
updateWithData(tempData, tempDataLen, image->getPixelFormat(), image->getPixelFormat(), imageWidth, imageHeight, image->hasPremultipliedAlpha(), index);
|
||||
}
|
||||
else
|
||||
{
|
||||
// after conversion, renderFormat == pixelFormat of data
|
||||
updateWithData(tempData, tempDataLen, imagePixelFormat, renderFormat, imageWidth, imageHeight, imageSize,
|
||||
updateWithData(tempData, tempDataLen, imagePixelFormat, renderFormat, imageWidth, imageHeight,
|
||||
image->hasPremultipliedAlpha(), index);
|
||||
}
|
||||
|
||||
// pitfall: we do merge RGB+A at at dual sampler shader, so must mark as _hasPremultipliedAlpha = true to makesure
|
||||
// alpha blend works well.
|
||||
if (index > 0)
|
||||
{
|
||||
setPremultipliedAlpha(Image::isCompressedImageHavePMA(Image::CompressedImagePMAFlag::DUAL_SAMPLER));
|
||||
_samplerFlags |= TextureSamplerFlag::DUAL_SAMPLER;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -283,7 +273,6 @@ bool Texture2D::updateWithData(const void* data,
|
|||
backend::PixelFormat renderFormat,
|
||||
int pixelsWide,
|
||||
int pixelsHigh,
|
||||
const Vec2& /*contentSize*/,
|
||||
bool preMultipliedAlpha,
|
||||
int index)
|
||||
{
|
||||
|
@ -425,6 +414,14 @@ bool Texture2D::updateWithMipmaps(MipmapInfo* mipmaps,
|
|||
setPremultipliedAlpha(preMultipliedAlpha);
|
||||
}
|
||||
|
||||
// pitfall: we do merge RGB+A at at dual sampler shader, so must mark as _hasPremultipliedAlpha = true to makesure
|
||||
// alpha blend works well.
|
||||
if (index > 0)
|
||||
{
|
||||
setPremultipliedAlpha(Image::isCompressedImageHavePMA(Image::CompressedImagePMAFlag::DUAL_SAMPLER));
|
||||
_samplerFlags |= TextureSamplerFlag::DUAL_SAMPLER;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -552,7 +549,7 @@ bool Texture2D::initWithString(const char* text, const FontDefinition& textDefin
|
|||
backend::PixelFormatUtils::convertDataToFormat(outData.getBytes(), imageWidth * imageHeight * 4,
|
||||
PixelFormat::RGBA8, pixelFormat, &outTempData, &outTempDataLen);
|
||||
|
||||
ret = initWithData(outTempData, outTempDataLen, pixelFormat, imageWidth, imageHeight, imageSize);
|
||||
ret = initWithData(outTempData, outTempDataLen, pixelFormat, imageWidth, imageHeight);
|
||||
|
||||
if (outTempData != nullptr && outTempData != outData.getBytes())
|
||||
{
|
||||
|
|
|
@ -147,10 +147,9 @@ public:
|
|||
backend::PixelFormat pixelFormat,
|
||||
int pixelsWide,
|
||||
int pixelsHigh,
|
||||
const Vec2& contentSize,
|
||||
bool preMultipliedAlpha = false)
|
||||
{
|
||||
return initWithData(data, dataLen, pixelFormat, pixelFormat, pixelsWide, pixelsHigh, contentSize,
|
||||
return initWithData(data, dataLen, pixelFormat, pixelFormat, pixelsWide, pixelsHigh,
|
||||
preMultipliedAlpha);
|
||||
}
|
||||
|
||||
|
@ -173,7 +172,6 @@ public:
|
|||
backend::PixelFormat renderFormat,
|
||||
int pixelsWide,
|
||||
int pixelsHigh,
|
||||
const Vec2& contentSize,
|
||||
bool preMultipliedAlpha = false);
|
||||
|
||||
/** Initializes with mipmaps.
|
||||
|
@ -208,7 +206,6 @@ public:
|
|||
backend::PixelFormat renderFormat,
|
||||
int pixelsWide,
|
||||
int pixelsHigh,
|
||||
const Vec2& /*contentSize*/,
|
||||
bool preMultipliedAlpha,
|
||||
int index = 0);
|
||||
bool updateWithMipmaps(MipmapInfo* mipmaps,
|
||||
|
|
|
@ -105,8 +105,7 @@ static Sprite* engine_inj_create_lump(const Color4B& color, int height, int widt
|
|||
// create cursor by pixels
|
||||
Texture2D* texture = new Texture2D();
|
||||
|
||||
texture->initWithData(pixels, height * width * sizeof(unsigned int), backend::PixelFormat::RGBA8, width, height,
|
||||
Vec2(width, height));
|
||||
texture->initWithData(pixels, height * width * sizeof(unsigned int), backend::PixelFormat::RGBA8, width, height);
|
||||
|
||||
auto cursor = Sprite::createWithTexture(texture);
|
||||
|
||||
|
|
|
@ -559,8 +559,7 @@ bool ImGui_ImplAdxe_CreateFontsTexture()
|
|||
bd->FontTexture = new Texture2D();
|
||||
|
||||
bd->FontTexture->setAntiAliasTexParameters();
|
||||
bd->FontTexture->initWithData(pixels, width * height, backend::PixelFormat::A8, width, height,
|
||||
Size{static_cast<float>(width), static_cast<float>(height)});
|
||||
bd->FontTexture->initWithData(pixels, width * height, backend::PixelFormat::A8, width, height);
|
||||
io.Fonts->TexID = (ImTextureID)bd->FontTexture;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue