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
Resolve memory issues of webp
[platform/core/uifw/dali-adaptor.git]
/
dali
/
internal
/
imaging
/
common
/
webp-loading.cpp
diff --git
a/dali/internal/imaging/common/webp-loading.cpp
b/dali/internal/imaging/common/webp-loading.cpp
index
dc758fa
..
707821b
100644
(file)
--- a/
dali/internal/imaging/common/webp-loading.cpp
+++ b/
dali/internal/imaging/common/webp-loading.cpp
@@
-116,7
+116,7
@@
public:
{
Internal::Platform::FileReader fileReader(mUrl);
fp = fileReader.GetFile();
{
Internal::Platform::FileReader fileReader(mUrl);
fp = fileReader.GetFile();
- if(fp ==
NULL
)
+ if(fp ==
nullptr
)
{
return false;
}
{
return false;
}
@@
-165,28
+165,37
@@
public:
return false;
}
return false;
}
- // Moveable but not copyable
-
- Impl(const Impl&) = delete;
- Impl& operator=(const Impl&) = delete;
- Impl(Impl&&) = default;
- Impl& operator=(Impl&&) = default;
-
- ~Impl()
+ void ReleaseResource()
{
#ifdef DALI_ANIMATED_WEBP_ENABLED
{
#ifdef DALI_ANIMATED_WEBP_ENABLED
- if(&mWebPData !=
NULL
)
+ if(&mWebPData !=
nullptr
)
{
mWebPData.bytes = nullptr;
WebPDataInit(&mWebPData);
}
{
mWebPData.bytes = nullptr;
WebPDataInit(&mWebPData);
}
- if(mWebPAnimDecoder)
+ if(mWebPAnimDecoder
!= nullptr
)
{
WebPAnimDecoderDelete(mWebPAnimDecoder);
{
WebPAnimDecoderDelete(mWebPAnimDecoder);
+ mWebPAnimDecoder = nullptr;
}
#endif
}
#endif
- free((void*)mBuffer);
- mBuffer = nullptr;
+ if(mBuffer != nullptr)
+ {
+ free((void*)mBuffer);
+ mBuffer = nullptr;
+ }
+ }
+
+ // Moveable but not copyable
+
+ Impl(const Impl&) = delete;
+ Impl& operator=(const Impl&) = delete;
+ Impl(Impl&&) = default;
+ Impl& operator=(Impl&&) = default;
+
+ ~Impl()
+ {
+ ReleaseResource();
}
std::string mUrl;
}
std::string mUrl;
@@
-279,8
+288,9
@@
Dali::Devel::PixelBuffer WebPLoading::LoadFrame(uint32_t frameIndex)
const int32_t imageBufferSize = width * height * sizeof(uint8_t) * channelNumber;
memcpy(pixelBuffer.GetBuffer(), frameBuffer, imageBufferSize);
free((void*)frameBuffer);
const int32_t imageBufferSize = width * height * sizeof(uint8_t) * channelNumber;
memcpy(pixelBuffer.GetBuffer(), frameBuffer, imageBufferSize);
free((void*)frameBuffer);
- return pixelBuffer;
}
}
+ mImpl->ReleaseResource();
+ return pixelBuffer;
}
#endif
}
#endif