Remove annoying logs when we use astc image file 37/285937/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 22 Dec 2022 11:55:41 +0000 (20:55 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Thu, 22 Dec 2022 11:55:41 +0000 (20:55 +0900)
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 <eunkiki.hong@samsung.com>
dali/internal/imaging/common/loader-astc.cpp

index 7cd227144504493089a6b3a8757a2a2b4c74d51c..ac797a7c4671006e9f6c44675e36503b3fea0445 100644 (file)
@@ -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<uint8_t*>(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;
   }