From 4b622a9a334f0917515cf51fbf997743fd28b5e8 Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Wed, 17 Nov 2021 10:52:15 +0900 Subject: [PATCH] Revert "[Tizen] Resolve memory issues of webp" This reverts commit fa6484215ed771ef3d0c1a9c60639fdbae2d322e. --- dali/internal/imaging/common/loader-webp.cpp | 2 -- dali/internal/imaging/common/webp-loading.cpp | 34 ++++++++++----------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/dali/internal/imaging/common/loader-webp.cpp b/dali/internal/imaging/common/loader-webp.cpp index da82a89..e388712 100644 --- a/dali/internal/imaging/common/loader-webp.cpp +++ b/dali/internal/imaging/common/loader-webp.cpp @@ -130,7 +130,6 @@ bool LoadWebpHeader(const Dali::ImageLoader::Input& input, unsigned int& width, WebPAnimDecoderGetInfo(webPAnimDecoder, &webPAnimInfo); width = webPAnimInfo.canvas_width; height = webPAnimInfo.canvas_height; - ReleaseResource(webPData, webPAnimDecoder); return true; } } @@ -226,7 +225,6 @@ bool LoadBitmapFromWebp(const Dali::ImageLoader::Input& input, Dali::Devel::Pixe bitmap = Dali::Devel::PixelBuffer::New(webPAnimInfo.canvas_width, webPAnimInfo.canvas_height, Dali::Pixel::RGBA8888); const int32_t bufferSize = webPAnimInfo.canvas_width * webPAnimInfo.canvas_height * sizeof(uint32_t); memcpy(bitmap.GetBuffer(), frameBuffer, bufferSize); - ReleaseResource(webPData, webPAnimDecoder); return true; } } diff --git a/dali/internal/imaging/common/webp-loading.cpp b/dali/internal/imaging/common/webp-loading.cpp index 1ba9cc4..dc758fa 100644 --- a/dali/internal/imaging/common/webp-loading.cpp +++ b/dali/internal/imaging/common/webp-loading.cpp @@ -165,7 +165,14 @@ public: return false; } - void ReleaseResource() + // Moveable but not copyable + + Impl(const Impl&) = delete; + Impl& operator=(const Impl&) = delete; + Impl(Impl&&) = default; + Impl& operator=(Impl&&) = default; + + ~Impl() { #ifdef DALI_ANIMATED_WEBP_ENABLED if(&mWebPData != NULL) @@ -173,29 +180,13 @@ public: mWebPData.bytes = nullptr; WebPDataInit(&mWebPData); } - if(mWebPAnimDecoder != nullptr) + if(mWebPAnimDecoder) { WebPAnimDecoderDelete(mWebPAnimDecoder); - mWebPAnimDecoder = nullptr; } #endif - if(mBuffer != NULL) - { - 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(); + free((void*)mBuffer); + mBuffer = nullptr; } std::string mUrl; @@ -288,9 +279,8 @@ 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); + return pixelBuffer; } - mImpl->ReleaseResource(); - return pixelBuffer; } #endif -- 2.7.4