From ac633d232624134a2d0cb8cb59195999f525a133 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Mon, 29 Jun 2020 16:30:03 +0100 Subject: [PATCH] Make WebP Support Optional Change-Id: I770351aa726d240b8bff59bb0f8efeb7a98f511d --- build/tizen/CMakeLists.txt | 1 + build/tizen/deps-check.cmake | 13 +++++++++++-- build/tizen/profiles/windows-profile.cmake | 2 ++ dali/internal/imaging/common/webp-loading.cpp | 27 +++++++++++++++++---------- packaging/dali-adaptor.spec | 14 +++++++++----- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 6f3856a..5d0ec0a 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -394,6 +394,7 @@ MESSAGE( STATUS "Profile: ${ENABLE_PROFILE}") MESSAGE( STATUS "Data Dir (Read/Write): ${dataReadWriteDir}") MESSAGE( STATUS "Data Dir (Read Only): ${dataReadOnlyDir}") MESSAGE( STATUS "EldBus: ${eldbus_available_ENABLED}") +MESSAGE( STATUS "WebP: ${webp_available_ENABLED}") MESSAGE( STATUS "Shader Binary Cache: ${ENABLE_SHADERBINCACHE}") MESSAGE( STATUS "Network logging enabled: ${ENABLE_NETWORKLOGGING}") MESSAGE( STATUS "Font config file: ${fontConfigurationFile}") diff --git a/build/tizen/deps-check.cmake b/build/tizen/deps-check.cmake index c43bfeb..ea7e10d 100644 --- a/build/tizen/deps-check.cmake +++ b/build/tizen/deps-check.cmake @@ -66,6 +66,8 @@ CHECK_MODULE_AND_SET( FREETYPE freetype2>=${FREETYPE_REQUIRED} freetype_availabl CHECK_MODULE_AND_SET( FREETYPE_BITMAP_SUPPORT freetype2>=${FREETYPE_BITMAP_SUPPORT_VERSION} freetype_bitmap_support) CHECK_MODULE_AND_SET( FONTCONFIG fontconfig fontconfig_available ) CHECK_MODULE_AND_SET( PNG libpng [] ) +CHECK_MODULE_AND_SET( WEBP libwebp webp_available ) +CHECK_MODULE_AND_SET( WEBP_DEMUX libwebpdemux [] ) CHECK_MODULE_AND_SET( LIBEXIF libexif [] ) CHECK_MODULE_AND_SET( LIBDRM libdrm [] ) CHECK_MODULE_AND_SET( LIBCURL libcurl [] ) @@ -137,6 +139,11 @@ IF( eldbus_available ) ADD_DEFINITIONS( -DDALI_ELDBUS_AVAILABLE ) ENDIF() +IF( webp_available ) + SET(DALI_WEBP_AVAILABLE 1) + ADD_DEFINITIONS( -DDALI_WEBP_AVAILABLE ) +ENDIF() + ADD_DEFINITIONS( -DPLATFORM_TIZEN ) IF( enable_debug ) @@ -239,6 +246,8 @@ SET( DALI_CFLAGS ${FONTCONFIG_CFLAGS} ${CAIRO_CFLAGS} ${PNG_CFLAGS} + ${WEBP_CFLAGS} + ${WEBP_DEMUX_CFLAGS} ${DLOG_CFLAGS} ${VCONF_CFLAGS} ${EXIF_CFLAGS} @@ -260,6 +269,8 @@ SET( DALI_LDFLAGS ${FONTCONFIG_LDFLAGS} ${CAIRO_LDFLAGS} ${PNG_LDFLAGS} + ${WEBP_LDFLAGS} + ${WEBP_DEMUX_LDFLAGS} ${DLOG_LDFLAGS} ${VCONF_LDFLAGS} ${EXIF_LDFLAGS} @@ -274,8 +285,6 @@ SET( DALI_LDFLAGS -lgif -lturbojpeg -ljpeg - -lwebp - -lwebpdemux ) # Android includes pthread with android lib diff --git a/build/tizen/profiles/windows-profile.cmake b/build/tizen/profiles/windows-profile.cmake index fc992a4..a8b11d1 100644 --- a/build/tizen/profiles/windows-profile.cmake +++ b/build/tizen/profiles/windows-profile.cmake @@ -64,6 +64,8 @@ FIND_PACKAGE( unofficial-angle REQUIRED ) FIND_PACKAGE( unofficial-cairo REQUIRED ) FIND_PACKAGE( WebP REQUIRED ) +SET(DALI_WEBP_AVAILABLE 1) +ADD_DEFINITIONS( -DDALI_WEBP_AVAILABLE ) # Set the linker flags SET( REQUIRED_LIBS diff --git a/dali/internal/imaging/common/webp-loading.cpp b/dali/internal/imaging/common/webp-loading.cpp index 78e2e11..d3031fa 100644 --- a/dali/internal/imaging/common/webp-loading.cpp +++ b/dali/internal/imaging/common/webp-loading.cpp @@ -19,8 +19,15 @@ #include // EXTERNAL INCLUDES +#ifdef DALI_WEBP_AVAILABLE #include #include + +#if WEBP_DEMUX_ABI_VERSION > 0x0101 +#define DALI_WEBP_ENABLED 1 +#endif + +#endif #include #include @@ -61,7 +68,7 @@ public: : mUrl( url ), mLoadingFrame( 0 ) { -#if WEBP_DEMUX_ABI_VERSION > 0x0101 +#ifdef DALI_WEBP_ENABLED if( ReadWebPInformation( isLocalResource ) ) { WebPAnimDecoderOptions webPAnimDecoderOptions; @@ -76,7 +83,7 @@ public: bool ReadWebPInformation( bool isLocalResource ) { -#if WEBP_DEMUX_ABI_VERSION > 0x0101 +#ifdef DALI_WEBP_ENABLED WebPDataInit( &mWebPData ); if( isLocalResource ) { @@ -157,7 +164,7 @@ public: ~Impl() { -#if WEBP_DEMUX_ABI_VERSION > 0x0101 +#ifdef DALI_WEBP_ENABLED if( &mWebPData != NULL ) { free( (void*)mWebPData.bytes ); @@ -175,7 +182,7 @@ public: std::vector mTimeStamp; uint32_t mLoadingFrame; -#if WEBP_DEMUX_ABI_VERSION > 0x0101 +#ifdef DALI_WEBP_ENABLED WebPData mWebPData; WebPAnimDecoder* mWebPAnimDecoder; WebPAnimInfo mWebPAnimInfo; @@ -184,8 +191,8 @@ public: AnimatedImageLoadingPtr WebPLoading::New( const std::string &url, bool isLocalResource ) { -#if WEBP_DEMUX_ABI_VERSION <= 0x0101 - DALI_LOG_ERROR( "The system do not support Animated WebP format.\n" ); +#ifndef DALI_WEBP_ENABLED + DALI_LOG_ERROR( "The system does not support Animated WebP format.\n" ); #endif return AnimatedImageLoadingPtr( new WebPLoading( url, isLocalResource ) ); } @@ -202,7 +209,7 @@ WebPLoading::~WebPLoading() bool WebPLoading::LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector &pixelData ) { -#if WEBP_DEMUX_ABI_VERSION > 0x0101 +#ifdef DALI_WEBP_ENABLED if( frameStartIndex >= mImpl->mWebPAnimInfo.frame_count ) { return false; @@ -258,7 +265,7 @@ bool WebPLoading::LoadNextNFrames( uint32_t frameStartIndex, int count, std::vec ImageDimensions WebPLoading::GetImageSize() const { -#if WEBP_DEMUX_ABI_VERSION > 0x0101 +#ifdef DALI_WEBP_ENABLED return ImageDimensions( mImpl->mWebPAnimInfo.canvas_width, mImpl->mWebPAnimInfo.canvas_height ); #else return ImageDimensions(); @@ -267,7 +274,7 @@ ImageDimensions WebPLoading::GetImageSize() const uint32_t WebPLoading::GetImageCount() const { -#if WEBP_DEMUX_ABI_VERSION > 0x0101 +#ifdef DALI_WEBP_ENABLED return mImpl->mWebPAnimInfo.frame_count; #else return 0u; @@ -294,4 +301,4 @@ uint32_t WebPLoading::GetFrameInterval( uint32_t frameIndex ) const } // namespace Internal -} // namespace Dali \ No newline at end of file +} // namespace Dali diff --git a/packaging/dali-adaptor.spec b/packaging/dali-adaptor.spec index ed41061..fc08e75 100644 --- a/packaging/dali-adaptor.spec +++ b/packaging/dali-adaptor.spec @@ -56,10 +56,6 @@ BuildRequires: pkgconfig BuildRequires: gawk BuildRequires: cmake BuildRequires: giflib-devel -BuildRequires: pkgconfig(libwebp) -BuildRequires: pkgconfig(libwebpdecoder) -BuildRequires: pkgconfig(libwebpdemux) -BuildRequires: pkgconfig(libwebpmux) BuildRequires: pkgconfig(fontconfig) BuildRequires: libjpeg-turbo-devel BuildRequires: pkgconfig(vconf) @@ -83,7 +79,15 @@ BuildRequires: pkgconfig(wayland-client) BuildRequires: wayland-devel BuildRequires: wayland-extension-client-devel -# dali-adaptor uses ecore mainloop +# WebP support only from Tizen 6 onwards +%if 0%{?tizen_version_major} >= 6 +BuildRequires: pkgconfig(libwebp) +BuildRequires: pkgconfig(libwebpdecoder) +BuildRequires: pkgconfig(libwebpdemux) +BuildRequires: pkgconfig(libwebpmux) +%endif + +# We use ecore mainloop %if 0%{?tizen_version_major} >= 5 BuildRequires: pkgconfig(ecore-wl2) BuildRequires: pkgconfig(wayland-egl-tizen) -- 2.7.4