Make WebP Support Optional 58/238158/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 29 Jun 2020 15:30:03 +0000 (16:30 +0100)
committerSeungho, Baek <sbsh.baek@samsung.com>
Thu, 9 Jul 2020 04:15:19 +0000 (13:15 +0900)
Change-Id: I770351aa726d240b8bff59bb0f8efeb7a98f511d

build/tizen/CMakeLists.txt
build/tizen/deps-check.cmake
build/tizen/profiles/windows-profile.cmake
dali/internal/imaging/common/webp-loading.cpp
packaging/dali-adaptor.spec

index 6f3856a..5d0ec0a 100644 (file)
@@ -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}")
index c43bfeb..ea7e10d 100644 (file)
@@ -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
index fc992a4..a8b11d1 100644 (file)
@@ -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
index 78e2e11..d3031fa 100644 (file)
 #include <dali/internal/imaging/common/webp-loading.h>
 
 // EXTERNAL INCLUDES
+#ifdef DALI_WEBP_AVAILABLE
 #include <webp/decode.h>
 #include <webp/demux.h>
+
+#if WEBP_DEMUX_ABI_VERSION > 0x0101
+#define DALI_WEBP_ENABLED 1
+#endif
+
+#endif
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/images/pixel-data.h>
 
@@ -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<uint32_t> 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<Dali::PixelData> &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
index ed41061..fc08e75 100644 (file)
@@ -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)