X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fimaging%2Fcommon%2Floader-png.cpp;h=ae6382252f6da70b63e7909b560c7b9621eac8b6;hb=8ef85cecbcb64033d0e0076f1240c07ad8850e0b;hp=4d76f97d12c700761a2bfb02e70d4a96a5c7a034;hpb=2799cdcc2768a59f3001f3a0e89da960ccbb74a2;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/imaging/common/loader-png.cpp b/dali/internal/imaging/common/loader-png.cpp index 4d76f97..ae63822 100644 --- a/dali/internal/imaging/common/loader-png.cpp +++ b/dali/internal/imaging/common/loader-png.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,13 +59,13 @@ bool LoadPngHeader(FILE* fp, unsigned int& width, unsigned int& height, png_stru // Check header to see if it is a PNG file size_t size = fread(header, 1, 8, fp); - if(size != 8) + if(DALI_UNLIKELY(size != 8)) { DALI_LOG_ERROR("fread failed\n"); return false; } - if(png_sig_cmp(header, 0, 8)) + if(DALI_UNLIKELY(png_sig_cmp(header, 0, 8))) { DALI_LOG_ERROR("png_sig_cmp failed\n"); return false; @@ -73,14 +73,14 @@ bool LoadPngHeader(FILE* fp, unsigned int& width, unsigned int& height, png_stru png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if(!png) + if(DALI_UNLIKELY(!png)) { DALI_LOG_ERROR("Can't create PNG read structure\n"); return false; } info = png_create_info_struct(png); - if(!info) + if(DALI_UNLIKELY(!info)) { DALI_LOG_ERROR("png_create_info_struct failed\n"); return false; @@ -88,7 +88,7 @@ bool LoadPngHeader(FILE* fp, unsigned int& width, unsigned int& height, png_stru png_set_expand(png); - if(setjmp(png_jmpbuf(png))) + if(DALI_UNLIKELY(setjmp(png_jmpbuf(png)))) { DALI_LOG_ERROR("error during png_init_io\n"); return false; @@ -134,7 +134,7 @@ bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel bool valid = false; // Load info from the header - if(!LoadPngHeader(input.file, width, height, png, info)) + if(DALI_UNLIKELY(!LoadPngHeader(input.file, width, height, png, info))) { return false; } @@ -259,7 +259,7 @@ bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel } } - if(!valid) + if(DALI_UNLIKELY(!valid)) { DALI_LOG_ERROR("Unsupported png format\n"); return false; @@ -270,7 +270,7 @@ bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel png_read_update_info(png, info); - if(setjmp(png_jmpbuf(png))) + if(DALI_UNLIKELY(setjmp(png_jmpbuf(png)))) { DALI_LOG_ERROR("error during png_read_image\n"); return false; @@ -300,18 +300,18 @@ bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel break; } } - - // decode the whole image into bitmap buffer - auto pixels = (bitmap = Dali::Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat)).GetBuffer(); - - DALI_ASSERT_DEBUG(pixels); rows = reinterpret_cast(malloc(sizeof(png_bytep) * height)); - if(!rows) + if(DALI_UNLIKELY(!rows)) { DALI_LOG_ERROR("malloc is failed\n"); return false; } + // decode the whole image into bitmap buffer + auto pixels = (bitmap = Dali::Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat)).GetBuffer(); + + DALI_ASSERT_DEBUG(pixels); + for(y = 0; y < height; y++) { rows[y] = pixels + y * stride; @@ -390,7 +390,7 @@ extern "C" void WriteData(png_structp png_ptr, png_bytep data, png_size_t length extern "C" void FlushData(png_structp png_ptr) { #ifdef DEBUG_ENABLED - Debug::LogMessage(Debug::DebugInfo, "PNG Flush"); + Debug::LogMessageWithFunctionLine(Debug::DebugInfo, "PNG Flush"); #endif // DEBUG_ENABLED } } // namespace