mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 22:28:32 +09:00
[Fix] (MG_Impl/Texture): don't malloc if unnecessary
This commit is contained in:
@@ -395,13 +395,15 @@ namespace MobileGL {
|
|||||||
processedPixels = MG_Util::PixelStoreProcessor::ProcessTexturePixelsDataUnpack(
|
processedPixels = MG_Util::PixelStoreProcessor::ProcessTexturePixelsDataUnpack(
|
||||||
originalPixels, MG_State::pGLContext->GetPixelStoreParameters(true), bytesPerPixel,
|
originalPixels, MG_State::pGLContext->GetPixelStoreParameters(true), bytesPerPixel,
|
||||||
{width, height, 1}, false, imageSize);
|
{width, height, 1}, false, imageSize);
|
||||||
|
} else {
|
||||||
|
MGLOG_D("TexImage2D_State: No input pixel, do allocate only");
|
||||||
}
|
}
|
||||||
|
|
||||||
MG_State::GLState::MipmapLevelInput mipmap =
|
MG_State::GLState::MipmapLevelInput mipmap =
|
||||||
MG_State::GLState::MipmapLevelInput({width, height, 1}, level, false, 0,
|
MG_State::GLState::MipmapLevelInput({width, height, 1}, level, false, 0,
|
||||||
{isProxy ? nullptr : malloc(totalBytes), isProxy ? 0 : totalBytes});
|
{(isProxy || originalPixels == nullptr) ? nullptr : malloc(totalBytes), isProxy ? 0 : totalBytes});
|
||||||
|
|
||||||
if (!isProxy && !mipmap.inputData.data) {
|
if (!isProxy && originalPixels != nullptr && !mipmap.inputData.data) {
|
||||||
MGLOG_E("TexImage2D_State: Failed to allocate memory for mipmap level data, size: %zu", totalBytes);
|
MGLOG_E("TexImage2D_State: Failed to allocate memory for mipmap level data, size: %zu", totalBytes);
|
||||||
free(processedPixels);
|
free(processedPixels);
|
||||||
processedPixels = nullptr;
|
processedPixels = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user