From 04dcaefc4524505876570559767e4270a8ed8580 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Thu, 22 Dec 2022 20:55:41 +0900 Subject: [PATCH] Remove annoying logs when we use astc image file PixelBuffer::New() call GetBytesPerPixel internally, and failed. That case, DALI_LOG_ERROR logged which is not useful. Change-Id: I6483002d00ee8abd61008d408b678b81bedb2e62 Signed-off-by: Eunki, Hong --- dali/internal/imaging/common/loader-astc.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dali/internal/imaging/common/loader-astc.cpp b/dali/internal/imaging/common/loader-astc.cpp index 7cd2271..ac797a7 100644 --- a/dali/internal/imaging/common/loader-astc.cpp +++ b/dali/internal/imaging/common/loader-astc.cpp @@ -220,25 +220,25 @@ bool LoadBitmapFromAstc(const Dali::ImageLoader::Input& input, Dali::Devel::Pixe } // allocate pixel data - bitmap = Dali::Devel::PixelBuffer::New(width, height, pixelFormat); + auto* pixels = static_cast(malloc(imageByteCount)); - // Compressed format won't allocate the buffer - auto pixels = bitmap.GetBuffer(); - if(!pixels) + if(DALI_UNLIKELY(pixels == nullptr)) { - // allocate buffer manually - auto& impl = GetImplementation(bitmap); - impl.AllocateFixedSize(imageByteCount); - pixels = bitmap.GetBuffer(); + DALI_LOG_ERROR("Buffer allocation failed. (required memory : %zu byte)\n", imageByteCount); + return false; } + // Create bitmap who will use allocated buffer. + const auto& bitmapInternal = Internal::Adaptor::PixelBuffer::New(pixels, imageByteCount, width, height, 0, pixelFormat); + bitmap = Dali::Devel::PixelBuffer(bitmapInternal.Get()); + // Load the image data. const size_t bytesRead = fread(pixels, 1, imageByteCount, filePointer); // Check the size of loaded data is what we expected. if(DALI_UNLIKELY(bytesRead != imageByteCount)) { - DALI_LOG_ERROR("Read of image pixel data failed.\n"); + DALI_LOG_ERROR("Read of image pixel data failed. (required image bytes : %zu, actual read from file : %zu\n", imageByteCount, bytesRead); return false; } -- 2.7.4