From a27101a9b426fe777d7c9dd889f97e7f8f6ad2a8 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Tue, 30 Mar 2021 13:19:33 +0900 Subject: [PATCH 1/1] Revert "[Tizen] Use broken image when animated image loading is failed." This reverts commit 138e5360d72399b6b07f822f15caaca98828cad8. --- .../adaptor-framework/animated-image-loading.cpp | 7 +--- .../adaptor-framework/animated-image-loading.h | 9 +---- .../imaging/common/animated-image-loading-impl.h | 5 --- dali/internal/imaging/common/gif-loading.cpp | 46 +++++++--------------- dali/internal/imaging/common/gif-loading.h | 7 ---- dali/internal/imaging/common/image-operations.cpp | 6 +-- dali/internal/imaging/common/webp-loading.cpp | 20 ++-------- dali/internal/imaging/common/webp-loading.h | 12 ------ 8 files changed, 24 insertions(+), 88 deletions(-) diff --git a/dali/devel-api/adaptor-framework/animated-image-loading.cpp b/dali/devel-api/adaptor-framework/animated-image-loading.cpp index 8f6a118..265f911 100644 --- a/dali/devel-api/adaptor-framework/animated-image-loading.cpp +++ b/dali/devel-api/adaptor-framework/animated-image-loading.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -91,11 +91,6 @@ std::string AnimatedImageLoading::GetUrl() const return GetImplementation(*this).GetUrl(); } -bool AnimatedImageLoading::HasLoadingSucceeded() const -{ - return GetImplementation(*this).HasLoadingSucceeded(); -} - AnimatedImageLoading::AnimatedImageLoading(Internal::Adaptor::AnimatedImageLoading* internal) : BaseHandle(internal) { diff --git a/dali/devel-api/adaptor-framework/animated-image-loading.h b/dali/devel-api/adaptor-framework/animated-image-loading.h index 92d825c..d3549b9 100644 --- a/dali/devel-api/adaptor-framework/animated-image-loading.h +++ b/dali/devel-api/adaptor-framework/animated-image-loading.h @@ -2,7 +2,7 @@ #define DALI_ANIMATED_IMAGE_LOADING_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -149,13 +149,6 @@ public: */ std::string GetUrl() const; - /** - * @brief Return whether the animated image loading is succeeded or not. - * - * @return True when the animated image loading is succeeded. - */ - bool HasLoadingSucceeded() const; - public: // Not intended for application developers /// @cond internal /** diff --git a/dali/internal/imaging/common/animated-image-loading-impl.h b/dali/internal/imaging/common/animated-image-loading-impl.h index d2a624c..13be270 100644 --- a/dali/internal/imaging/common/animated-image-loading-impl.h +++ b/dali/internal/imaging/common/animated-image-loading-impl.h @@ -94,11 +94,6 @@ public: * @copydoc Dali::AnimatedImageLoading::GetUrl() */ virtual std::string GetUrl() const = 0; - - /** - * @copydoc Dali::AnimatedImageLoading::HasLoadingSucceeded() - */ - virtual bool HasLoadingSucceeded() const = 0; }; } // namespace Adaptor diff --git a/dali/internal/imaging/common/gif-loading.cpp b/dali/internal/imaging/common/gif-loading.cpp index 6b0d709..69d5b7a 100644 --- a/dali/internal/imaging/common/gif-loading.cpp +++ b/dali/internal/imaging/common/gif-loading.cpp @@ -218,7 +218,7 @@ struct GifAccessor if(!gif) { - DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT\n"); + DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT"); } } @@ -635,7 +635,6 @@ bool DecodeImage(GifFileType* gif, uint32_t* data, int rowpix, int xin, int yin, if((gifW < w) || (gifH < h)) { - DALI_LOG_ERROR("gifW : %d, w : %d, gifH : %d, h : %d\n", gifW, w, gifH, h); DALI_ASSERT_DEBUG(false && "Dimensions are bigger than the Gif image size"); goto on_error; } @@ -785,7 +784,7 @@ bool ReadHeader(LoaderInfo& loaderInfo, if(!success || !fileData.globalMap) { success = false; - DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE\n"); + DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE"); } else { @@ -831,7 +830,7 @@ bool ReadHeader(LoaderInfo& loaderInfo, else { success = false; - DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT\n"); + DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT"); } break; } @@ -846,14 +845,14 @@ bool ReadHeader(LoaderInfo& loaderInfo, if(DGifGetImageDesc(gifAccessor.gif) == GIF_ERROR) { success = false; - DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT\n"); + DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT"); break; } // skip decoding and just walk image to next if(DGifGetCode(gifAccessor.gif, &img_code, &img) == GIF_ERROR) { success = false; - DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT\n"); + DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT"); break; } // skip till next... @@ -1000,7 +999,7 @@ bool ReadNextFrame(LoaderInfo& loaderInfo, ImageProperties& prop, // use for w frame = FindFrame(animated, index); if(!frame) { - DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE\n"); + DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE"); return false; } else if(!(frame->loaded) || !(frame->data)) @@ -1025,13 +1024,13 @@ bool ReadNextFrame(LoaderInfo& loaderInfo, ImageProperties& prop, // use for w loaderInfo.fileInfo.position = 0; if(!loaderInfo.fileInfo.map) { - DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE\n"); + DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE"); return false; } std::unique_ptr gifAccessor = std::make_unique(loaderInfo.fileInfo); if(!gifAccessor->gif) { - DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT\n"); + DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT"); return false; } loaderInfo.gifAccessor = std::move(gifAccessor); @@ -1046,7 +1045,7 @@ bool ReadNextFrame(LoaderInfo& loaderInfo, ImageProperties& prop, // use for w { if(DGifGetRecordType(loaderInfo.gifAccessor->gif, &rec) == GIF_ERROR) { - DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT\n"); + DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT"); return false; } @@ -1074,7 +1073,7 @@ bool ReadNextFrame(LoaderInfo& loaderInfo, ImageProperties& prop, // use for w // get image desc if(DGifGetImageDesc(loaderInfo.gifAccessor->gif) == GIF_ERROR) { - DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT\n"); + DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT"); return false; } @@ -1148,7 +1147,7 @@ bool ReadNextFrame(LoaderInfo& loaderInfo, ImageProperties& prop, // use for w ClipCoordinates(prop.w, prop.h, &xin, &yin, frameInfo->x, frameInfo->y, frameInfo->w, frameInfo->h, &x, &y, &w, &h); if(!DecodeImage(loaderInfo.gifAccessor->gif, thisFrame->data, prop.w, xin, yin, frameInfo->transparent, x, y, w, h, first)) { - DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE\n"); + DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE"); return false; } @@ -1174,7 +1173,7 @@ bool ReadNextFrame(LoaderInfo& loaderInfo, ImageProperties& prop, // use for w // and decode the gif with overwriting if(!DecodeImage(loaderInfo.gifAccessor->gif, reinterpret_cast(pixels), prop.w, xin, yin, frameInfo->transparent, x, y, w, h, true)) { - DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE\n"); + DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE"); return false; } @@ -1188,7 +1187,7 @@ bool ReadNextFrame(LoaderInfo& loaderInfo, ImageProperties& prop, // use for w // skip decoding and just walk image to next if(DGifGetCode(loaderInfo.gifAccessor->gif, &img_code, &img) == GIF_ERROR) { - DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT\n"); + DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT"); return false; } @@ -1237,15 +1236,14 @@ struct GifLoading::Impl { public: Impl(const std::string& url, bool isLocalResource) - : mUrl(url), - mLoadSucceeded(true) + : mUrl(url) { loaderInfo.gifAccessor = nullptr; int error; loaderInfo.fileData.fileName = mUrl.c_str(); loaderInfo.fileData.isLocalResource = isLocalResource; - mLoadSucceeded = ReadHeader(loaderInfo, imageProperties, &error); + ReadHeader(loaderInfo, imageProperties, &error); } // Moveable but not copyable @@ -1257,7 +1255,6 @@ public: std::string mUrl; LoaderInfo loaderInfo; ImageProperties imageProperties; - bool mLoadSucceeded; }; AnimatedImageLoadingPtr GifLoading::New(const std::string& url, bool isLocalResource) @@ -1279,10 +1276,6 @@ bool GifLoading::LoadNextNFrames(uint32_t frameStartIndex, int count, std::vecto { int error; bool ret = false; - if(!mImpl->mLoadSucceeded) - { - return false; - } const int bufferSize = mImpl->imageProperties.w * mImpl->imageProperties.h * sizeof(uint32_t); @@ -1311,10 +1304,6 @@ Dali::Devel::PixelBuffer GifLoading::LoadFrame(uint32_t frameIndex) { int error; Dali::Devel::PixelBuffer pixelBuffer; - if(!mImpl->mLoadSucceeded) - { - return pixelBuffer; - } DALI_LOG_INFO(gGifLoadingLogFilter, Debug::Concise, "LoadFrame( frameIndex:%d )\n", frameIndex); @@ -1350,11 +1339,6 @@ std::string GifLoading::GetUrl() const return mImpl->mUrl; } -bool GifLoading::HasLoadingSucceeded() const -{ - return mImpl->mLoadSucceeded; -} - } // namespace Adaptor } // namespace Internal diff --git a/dali/internal/imaging/common/gif-loading.h b/dali/internal/imaging/common/gif-loading.h index 6797938..b817084 100644 --- a/dali/internal/imaging/common/gif-loading.h +++ b/dali/internal/imaging/common/gif-loading.h @@ -117,13 +117,6 @@ public: */ std::string GetUrl() const override; - /** - * @brief Return whether the animated image loading is succeeded or not. - * - * @return True when the animated image loading is succeeded. - */ - bool HasLoadingSucceeded() const override; - private: struct Impl; Impl* mImpl; diff --git a/dali/internal/imaging/common/image-operations.cpp b/dali/internal/imaging/common/image-operations.cpp index 0881753..96828b8 100644 --- a/dali/internal/imaging/common/image-operations.cpp +++ b/dali/internal/imaging/common/image-operations.cpp @@ -510,7 +510,7 @@ ImageDimensions CalculateDesiredDimensions(unsigned int bitmapWidth, unsigned in * @param[out] widthOut The width of the output buffer. * @param[out] heightOut The height of the output buffer. * - * @return Whether the rotation succeeded. + * @return Whether the rotation succeded. */ bool Rotate90(const uint8_t* const pixelsIn, unsigned int widthIn, @@ -569,7 +569,7 @@ bool Rotate90(const uint8_t* const pixelsIn, * @param[in] pixelSize The size of the pixel. * @param[out] pixelsOut The rotated output buffer. * - * @return Whether the rotation succeeded. + * @return Whether the rotation succeded. */ bool Rotate180(const uint8_t* const pixelsIn, unsigned int widthIn, @@ -621,7 +621,7 @@ bool Rotate180(const uint8_t* const pixelsIn, * @param[out] widthOut The width of the output buffer. * @param[out] heightOut The height of the output buffer. * - * @return Whether the rotation succeeded. + * @return Whether the rotation succeded. */ bool Rotate270(const uint8_t* const pixelsIn, unsigned int widthIn, diff --git a/dali/internal/imaging/common/webp-loading.cpp b/dali/internal/imaging/common/webp-loading.cpp index 2068240..bd1014b 100644 --- a/dali/internal/imaging/common/webp-loading.cpp +++ b/dali/internal/imaging/common/webp-loading.cpp @@ -61,8 +61,7 @@ struct WebPLoading::Impl { public: Impl(const std::string& url, bool isLocalResource) - : mUrl(url), - mLoadSucceeded(true) + : mUrl(url) { #ifdef DALI_WEBP_ENABLED if(ReadWebPInformation(isLocalResource)) @@ -74,10 +73,6 @@ public: WebPAnimDecoderGetInfo(mWebPAnimDecoder, &mWebPAnimInfo); mTimeStamp.assign(mWebPAnimInfo.frame_count, 0); } - else - { - mLoadSucceeded = false; - } #endif } @@ -181,7 +176,6 @@ public: std::string mUrl; std::vector mTimeStamp; uint32_t mLoadingFrame{0}; - bool mLoadSucceeded; #ifdef DALI_WEBP_ENABLED WebPData mWebPData{0}; @@ -211,7 +205,7 @@ WebPLoading::~WebPLoading() bool WebPLoading::LoadNextNFrames(uint32_t frameStartIndex, int count, std::vector& pixelData) { #ifdef DALI_WEBP_ENABLED - if(frameStartIndex >= mImpl->mWebPAnimInfo.frame_count || !mImpl->mLoadSucceeded) + if(frameStartIndex >= mImpl->mWebPAnimInfo.frame_count) { return false; } @@ -265,14 +259,13 @@ bool WebPLoading::LoadNextNFrames(uint32_t frameStartIndex, int count, std::vect Dali::Devel::PixelBuffer WebPLoading::LoadFrame(uint32_t frameIndex) { Dali::Devel::PixelBuffer pixelBuffer; - #ifdef DALI_WEBP_ENABLED - if(frameIndex >= mImpl->mWebPAnimInfo.frame_count || !mImpl->mLoadSucceeded) + if(frameIndex >= mImpl->mWebPAnimInfo.frame_count) { return pixelBuffer; } - DALI_LOG_INFO(gWebPLoadingLogFilter, Debug::Concise, "LoadFrame( frameIndex:%d )\n", frameIndex); + DALI_LOG_INFO(gWebPLoadingLogFilter, Debug::Concise, "LoadNextNFrames( frameIndex:%d )\n", frameIndex); if(mImpl->mLoadingFrame > frameIndex) { @@ -347,11 +340,6 @@ std::string WebPLoading::GetUrl() const return mImpl->mUrl; } -bool WebPLoading::HasLoadingSucceeded() const -{ - return mImpl->mLoadSucceeded; -} - } // namespace Adaptor } // namespace Internal diff --git a/dali/internal/imaging/common/webp-loading.h b/dali/internal/imaging/common/webp-loading.h index ecf8bbb..5806353 100644 --- a/dali/internal/imaging/common/webp-loading.h +++ b/dali/internal/imaging/common/webp-loading.h @@ -113,20 +113,8 @@ public: */ uint32_t GetFrameInterval(uint32_t frameIndex) const override; - /** - * @brief Get the animated image file URL - * - * @return The URL string of the animated image file - */ std::string GetUrl() const override; - /** - * @brief Return whether the animated image loading is succeeded or not. - * - * @return True when the animated image loading is succeeded. - */ - bool HasLoadingSucceeded() const override; - private: struct Impl; Impl* mImpl; -- 2.7.4