projects
/
platform
/
core
/
uifw
/
dali-adaptor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Minor optimization on image loading
[platform/core/uifw/dali-adaptor.git]
/
dali
/
internal
/
imaging
/
common
/
loader-png.cpp
diff --git
a/dali/internal/imaging/common/loader-png.cpp
b/dali/internal/imaging/common/loader-png.cpp
index
e13a8ec
..
ae63822
100644
(file)
--- a/
dali/internal/imaging/common/loader-png.cpp
+++ b/
dali/internal/imaging/common/loader-png.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 202
1
Samsung Electronics Co., Ltd.
+ * Copyright (c) 202
2
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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-59,36
+59,38
@@
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);
// 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;
}
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;
}
png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
return false;
}
png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if(
!png
)
+ if(
DALI_UNLIKELY(!png)
)
{
{
- DALI_LOG_
WARNING
("Can't create PNG read structure\n");
+ DALI_LOG_
ERROR
("Can't create PNG read structure\n");
return false;
}
info = png_create_info_struct(png);
return false;
}
info = png_create_info_struct(png);
- if(
!info
)
+ if(
DALI_UNLIKELY(!info)
)
{
{
- DALI_LOG_
WARNING
("png_create_info_struct failed\n");
+ DALI_LOG_
ERROR
("png_create_info_struct failed\n");
return false;
}
png_set_expand(png);
return false;
}
png_set_expand(png);
- if(
setjmp(png_jmpbuf(png
)))
+ if(
DALI_UNLIKELY(setjmp(png_jmpbuf(png)
)))
{
{
- DALI_LOG_
WARNING
("error during png_init_io\n");
+ DALI_LOG_
ERROR
("error during png_init_io\n");
return false;
}
return false;
}
@@
-132,7
+134,7
@@
bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel
bool valid = false;
// Load info from the header
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;
}
{
return false;
}
@@
-257,9
+259,9
@@
bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel
}
}
}
}
- if(
!valid
)
+ if(
DALI_UNLIKELY(!valid)
)
{
{
- DALI_LOG_
WARNING
("Unsupported png format\n");
+ DALI_LOG_
ERROR
("Unsupported png format\n");
return false;
}
return false;
}
@@
-268,9
+270,9
@@
bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel
png_read_update_info(png, info);
png_read_update_info(png, info);
- if(
setjmp(png_jmpbuf(png
)))
+ if(
DALI_UNLIKELY(setjmp(png_jmpbuf(png)
)))
{
{
- DALI_LOG_
WARNING
("error during png_read_image\n");
+ DALI_LOG_
ERROR
("error during png_read_image\n");
return false;
}
return false;
}
@@
-298,18
+300,18
@@
bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel
break;
}
}
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<png_bytep*>(malloc(sizeof(png_bytep) * height));
rows = reinterpret_cast<png_bytep*>(malloc(sizeof(png_bytep) * height));
- if(
!rows
)
+ if(
DALI_UNLIKELY(!rows)
)
{
DALI_LOG_ERROR("malloc is failed\n");
return false;
}
{
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;
for(y = 0; y < height; y++)
{
rows[y] = pixels + y * stride;
@@
-388,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
extern "C" void FlushData(png_structp png_ptr)
{
#ifdef DEBUG_ENABLED
- Debug::LogMessage(Debug::DebugInfo, "PNG Flush");
+ Debug::LogMessage
WithFunctionLine
(Debug::DebugInfo, "PNG Flush");
#endif // DEBUG_ENABLED
}
} // namespace
#endif // DEBUG_ENABLED
}
} // namespace