Support YUV decoding for JPEG
[platform/core/uifw/dali-adaptor.git] / dali / internal / imaging / common / image-loader.cpp
old mode 100755 (executable)
new mode 100644 (file)
index b83878e..9f9db11
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -19,6 +19,9 @@
 #include <dali/devel-api/common/ref-counted-dali-vector.h>
 #include <dali/internal/imaging/common/pixel-buffer-impl.h>
 
+#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
+#include <dali/internal/imaging/common/image-operations.h>
 #include <dali/internal/imaging/common/loader-astc.h>
 #include <dali/internal/imaging/common/loader-bmp.h>
 #include <dali/internal/imaging/common/loader-gif.h>
@@ -27,9 +30,7 @@
 #include <dali/internal/imaging/common/loader-ktx.h>
 #include <dali/internal/imaging/common/loader-png.h>
 #include <dali/internal/imaging/common/loader-wbmp.h>
-#include <dali/internal/imaging/common/image-operations.h>
-#include <dali/devel-api/adaptor-framework/image-loader-input.h>
-#include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
+#include <dali/internal/imaging/common/loader-webp.h>
 #include <dali/internal/system/common/file-reader.h>
 
 using namespace Dali::Integration;
@@ -38,15 +39,16 @@ namespace Dali
 {
 namespace TizenPlatform
 {
-
 namespace
 {
 #if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_IMAGE_LOADING" );
+Integration::Log::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_IMAGE_LOADING");
 #endif
 
 static unsigned int gMaxTextureSize = 4096;
 
+static bool gMaxTextureSizeUpdated = false;
+
 /**
  * Enum for file formats, has to be in sync with BITMAP_LOADER_LOOKUP_TABLE
  */
@@ -60,6 +62,7 @@ enum FileFormats
   FORMAT_JPEG,
   FORMAT_BMP,
   FORMAT_GIF,
+  FORMAT_WEBP,
   FORMAT_KTX,
   FORMAT_ASTC,
   FORMAT_ICO,
@@ -74,17 +77,20 @@ enum FileFormats
  * A lookup table containing all the bitmap loaders with the appropriate information.
  * Has to be in sync with enum FileFormats
  */
+// clang-format off
 const Dali::ImageLoader::BitmapLoader BITMAP_LOADER_LOOKUP_TABLE[FORMAT_TOTAL_COUNT] =
-{
-  { Png::MAGIC_BYTE_1,  Png::MAGIC_BYTE_2,  LoadBitmapFromPng,  LoadPngHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS },
-  { Jpeg::MAGIC_BYTE_1, Jpeg::MAGIC_BYTE_2, LoadBitmapFromJpeg, LoadJpegHeader, Bitmap::BITMAP_2D_PACKED_PIXELS },
-  { Bmp::MAGIC_BYTE_1,  Bmp::MAGIC_BYTE_2,  LoadBitmapFromBmp,  LoadBmpHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS },
-  { Gif::MAGIC_BYTE_1,  Gif::MAGIC_BYTE_2,  LoadBitmapFromGif,  LoadGifHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS },
-  { Ktx::MAGIC_BYTE_1,  Ktx::MAGIC_BYTE_2,  LoadBitmapFromKtx,  LoadKtxHeader,  Bitmap::BITMAP_COMPRESSED       },
-  { Astc::MAGIC_BYTE_1, Astc::MAGIC_BYTE_2, LoadBitmapFromAstc, LoadAstcHeader, Bitmap::BITMAP_COMPRESSED       },
-  { Ico::MAGIC_BYTE_1,  Ico::MAGIC_BYTE_2,  LoadBitmapFromIco,  LoadIcoHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS },
-  { 0x0,                0x0,                LoadBitmapFromWbmp, LoadWbmpHeader, Bitmap::BITMAP_2D_PACKED_PIXELS },
-};
+  {
+    {Png::MAGIC_BYTE_1,  Png::MAGIC_BYTE_2,  LoadBitmapFromPng,  nullptr, LoadPngHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS},
+    {Jpeg::MAGIC_BYTE_1, Jpeg::MAGIC_BYTE_2, LoadBitmapFromJpeg, LoadPlanesFromJpeg, LoadJpegHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
+    {Bmp::MAGIC_BYTE_1,  Bmp::MAGIC_BYTE_2,  LoadBitmapFromBmp,  nullptr, LoadBmpHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS},
+    {Gif::MAGIC_BYTE_1,  Gif::MAGIC_BYTE_2,  LoadBitmapFromGif,  nullptr, LoadGifHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS},
+    {Webp::MAGIC_BYTE_1, Webp::MAGIC_BYTE_2, LoadBitmapFromWebp, nullptr, LoadWebpHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
+    {Ktx::MAGIC_BYTE_1,  Ktx::MAGIC_BYTE_2,  LoadBitmapFromKtx,  nullptr, LoadKtxHeader,  Bitmap::BITMAP_COMPRESSED      },
+    {Astc::MAGIC_BYTE_1, Astc::MAGIC_BYTE_2, LoadBitmapFromAstc, nullptr, LoadAstcHeader, Bitmap::BITMAP_COMPRESSED      },
+    {Ico::MAGIC_BYTE_1,  Ico::MAGIC_BYTE_2,  LoadBitmapFromIco,  nullptr, LoadIcoHeader,  Bitmap::BITMAP_2D_PACKED_PIXELS},
+    {0x0,                0x0,                LoadBitmapFromWbmp, nullptr, LoadWbmpHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
+  };
+// clang-format on
 
 const unsigned int MAGIC_LENGTH = 2;
 
@@ -94,32 +100,35 @@ const unsigned int MAGIC_LENGTH = 2;
 struct FormatExtension
 {
   const std::string extension;
-  FileFormats format;
+  FileFormats       format;
 };
 
+// clang-format off
 const FormatExtension FORMAT_EXTENSIONS[] =
-{
- { ".png",  FORMAT_PNG  },
- { ".jpg",  FORMAT_JPEG },
- { ".bmp",  FORMAT_BMP  },
- { ".gif",  FORMAT_GIF  },
- { ".ktx",  FORMAT_KTX  },
- { ".astc", FORMAT_ASTC },
- { ".ico",  FORMAT_ICO  },
- { ".wbmp", FORMAT_WBMP }
-};
+  {
+    {".png",  FORMAT_PNG },
+    {".jpg",  FORMAT_JPEG},
+    {".bmp",  FORMAT_BMP },
+    {".gif",  FORMAT_GIF },
+    {".webp", FORMAT_WEBP },
+    {".ktx",  FORMAT_KTX },
+    {".astc", FORMAT_ASTC},
+    {".ico",  FORMAT_ICO },
+    {".wbmp", FORMAT_WBMP}
+  };
+// clang-format on
 
 const unsigned int FORMAT_EXTENSIONS_COUNT = sizeof(FORMAT_EXTENSIONS) / sizeof(FormatExtension);
 
-FileFormats GetFormatHint( const std::string& filename )
+FileFormats GetFormatHint(const std::string& filename)
 {
   FileFormats format = FORMAT_UNKNOWN;
 
-  for ( unsigned int i = 0; i < FORMAT_EXTENSIONS_COUNT; ++i )
+  for(unsigned int i = 0; i < FORMAT_EXTENSIONS_COUNT; ++i)
   {
     unsigned int length = FORMAT_EXTENSIONS[i].extension.size();
-    if ( ( filename.size() > length ) &&
-         ( 0 == filename.compare( filename.size() - length, length, FORMAT_EXTENSIONS[i].extension ) ) )
+    if((filename.size() > length) &&
+       (0 == filename.compare(filename.size() - length, length, FORMAT_EXTENSIONS[i].extension)))
     {
       format = FORMAT_EXTENSIONS[i].format;
       break;
@@ -139,69 +148,70 @@ FileFormats GetFormatHint( const std::string& filename )
  * @param[out]  profile The kind of bitmap to hold the bits loaded for the bitmap.
  * @return true, if we can decode the image, false otherwise
  */
-bool GetBitmapLoaderFunctions( FILE *fp,
-                               FileFormats format,
-                               Dali::ImageLoader::LoadBitmapFunction& loader,
-                               Dali::ImageLoader::LoadBitmapHeaderFunction& header,
-                               Bitmap::Profile& profile,
-                               const std::string& filename )
+bool GetBitmapLoaderFunctions(FILE*                                        fp,
+                              FileFormats                                  format,
+                              Dali::ImageLoader::LoadBitmapFunction&       loader,
+                              Dali::ImageLoader::LoadPlanesFunction&       planeLoader,
+                              Dali::ImageLoader::LoadBitmapHeaderFunction& header,
+                              Bitmap::Profile&                             profile,
+                              const std::string&                           filename)
 {
   unsigned char magic[MAGIC_LENGTH];
-  size_t read = fread(magic, sizeof(unsigned char), MAGIC_LENGTH, fp);
+  size_t        read = fread(magic, sizeof(unsigned char), MAGIC_LENGTH, fp);
 
   // Reset to the start of the file.
-  if( fseek(fp, 0, SEEK_SET) )
+  if(fseek(fp, 0, SEEK_SET))
   {
     DALI_LOG_ERROR("Error seeking to start of file\n");
   }
 
-  if (read != MAGIC_LENGTH)
+  if(read != MAGIC_LENGTH)
   {
     return false;
   }
 
-  bool loaderFound = false;
-  const Dali::ImageLoader::BitmapLoader *lookupPtr = BITMAP_LOADER_LOOKUP_TABLE;
-  Dali::ImageLoader::Input defaultInput( fp );
+  bool                                   loaderFound = false;
+  const Dali::ImageLoader::BitmapLoader* lookupPtr   = BITMAP_LOADER_LOOKUP_TABLE;
+  Dali::ImageLoader::Input               defaultInput(fp);
 
   // try plugin image loader
-  const Dali::ImageLoader::BitmapLoader* data = Internal::Adaptor::ImageLoaderPluginProxy::BitmapLoaderLookup( filename );
-  if( data != NULL )
+  const Dali::ImageLoader::BitmapLoader* data = Internal::Adaptor::ImageLoaderPluginProxy::BitmapLoaderLookup(filename);
+  if(data != NULL)
   {
-    lookupPtr = data;
-    unsigned int width = 0;
+    lookupPtr           = data;
+    unsigned int width  = 0;
     unsigned int height = 0;
-    loaderFound = lookupPtr->header( fp, width, height );
+    loaderFound         = lookupPtr->header(fp, width, height);
   }
 
   // try hinted format
-  if ( false == loaderFound && format != FORMAT_UNKNOWN )
+  if(false == loaderFound && format != FORMAT_UNKNOWN)
   {
     lookupPtr = BITMAP_LOADER_LOOKUP_TABLE + format;
-    if ( format >= FORMAT_MAGIC_BYTE_COUNT ||
-         ( lookupPtr->magicByte1 == magic[0] && lookupPtr->magicByte2 == magic[1] ) )
+    if(format >= FORMAT_MAGIC_BYTE_COUNT ||
+       (lookupPtr->magicByte1 == magic[0] && lookupPtr->magicByte2 == magic[1]))
     {
-      unsigned int width = 0;
+      unsigned int width  = 0;
       unsigned int height = 0;
-      loaderFound = lookupPtr->header( fp, width, height );
+      loaderFound         = lookupPtr->header(fp, width, height);
     }
   }
 
   // then try to get a match with formats that have magic bytes
-  if ( false == loaderFound )
+  if(false == loaderFound)
   {
-    for ( lookupPtr = BITMAP_LOADER_LOOKUP_TABLE;
-          lookupPtr < BITMAP_LOADER_LOOKUP_TABLE + FORMAT_MAGIC_BYTE_COUNT;
-          ++lookupPtr )
+    for(lookupPtr = BITMAP_LOADER_LOOKUP_TABLE;
+        lookupPtr < BITMAP_LOADER_LOOKUP_TABLE + FORMAT_MAGIC_BYTE_COUNT;
+        ++lookupPtr)
     {
-      if ( lookupPtr->magicByte1 == magic[0] && lookupPtr->magicByte2 == magic[1] )
+      if(lookupPtr->magicByte1 == magic[0] && lookupPtr->magicByte2 == magic[1])
       {
         // to seperate ico file format and wbmp file format
-        unsigned int width = 0;
+        unsigned int width  = 0;
         unsigned int height = 0;
-        loaderFound = lookupPtr->header(fp, width, height);
+        loaderFound         = lookupPtr->header(fp, width, height);
       }
-      if (loaderFound)
+      if(loaderFound)
       {
         break;
       }
@@ -209,17 +219,17 @@ bool GetBitmapLoaderFunctions( FILE *fp,
   }
 
   // finally try formats that do not use magic bytes
-  if ( false == loaderFound )
+  if(false == loaderFound)
   {
-    for ( lookupPtr = BITMAP_LOADER_LOOKUP_TABLE + FORMAT_MAGIC_BYTE_COUNT;
-          lookupPtr < BITMAP_LOADER_LOOKUP_TABLE + FORMAT_TOTAL_COUNT;
-          ++lookupPtr )
+    for(lookupPtr = BITMAP_LOADER_LOOKUP_TABLE + FORMAT_MAGIC_BYTE_COUNT;
+        lookupPtr < BITMAP_LOADER_LOOKUP_TABLE + FORMAT_TOTAL_COUNT;
+        ++lookupPtr)
     {
       // to seperate ico file format and wbmp file format
-      unsigned int width = 0;
+      unsigned int width  = 0;
       unsigned int height = 0;
-      loaderFound = lookupPtr->header(fp, width, height);
-      if (loaderFound)
+      loaderFound         = lookupPtr->header(fp, width, height);
+      if(loaderFound)
       {
         break;
       }
@@ -227,15 +237,16 @@ bool GetBitmapLoaderFunctions( FILE *fp,
   }
 
   // if a loader was found set the outputs
-  if ( loaderFound )
+  if(loaderFound)
   {
-    loader  = lookupPtr->loader;
-    header  = lookupPtr->header;
-    profile = lookupPtr->profile;
+    loader      = lookupPtr->loader;
+    planeLoader = lookupPtr->planeLoader;
+    header      = lookupPtr->header;
+    profile     = lookupPtr->profile;
   }
 
   // Reset to the start of the file.
-  if( fseek(fp, 0, SEEK_SET) )
+  if(fseek(fp, 0, SEEK_SET))
   {
     DALI_LOG_ERROR("Error seeking to start of file\n");
   }
@@ -245,83 +256,149 @@ bool GetBitmapLoaderFunctions( FILE *fp,
 
 } // anonymous namespace
 
-
 namespace ImageLoader
 {
-
-bool ConvertStreamToBitmap( const BitmapResourceType& resource, std::string path, FILE * const fp, Dali::Devel::PixelBuffer& pixelBuffer )
+bool ConvertStreamToBitmap(const BitmapResourceType& resource, const std::string& path, FILE* const fp, Dali::Devel::PixelBuffer& pixelBuffer)
 {
-  DALI_LOG_TRACE_METHOD( gLogFilter );
+  DALI_LOG_TRACE_METHOD(gLogFilter);
 
   bool result = false;
 
-  if (fp != NULL)
+  if(fp != NULL)
   {
-    Dali::ImageLoader::LoadBitmapFunction function;
+    Dali::ImageLoader::LoadBitmapFunction       function;
+    Dali::ImageLoader::LoadPlanesFunction       planeLoader;
     Dali::ImageLoader::LoadBitmapHeaderFunction header;
 
     Bitmap::Profile profile;
 
-    if ( GetBitmapLoaderFunctions( fp,
-                                   GetFormatHint( path ),
-                                   function,
-                                   header,
-                                   profile,
-                                   path ) )
+    if(GetBitmapLoaderFunctions(fp,
+                                GetFormatHint(path),
+                                function,
+                                planeLoader,
+                                header,
+                                profile,
+                                path))
     {
-      const Dali::ImageLoader::ScalingParameters scalingParameters( resource.size, resource.scalingMode, resource.samplingMode );
-      const Dali::ImageLoader::Input input( fp, scalingParameters, resource.orientationCorrection );
+      const Dali::ImageLoader::ScalingParameters scalingParameters(resource.size, resource.scalingMode, resource.samplingMode);
+      const Dali::ImageLoader::Input             input(fp, scalingParameters, resource.orientationCorrection);
 
       // Run the image type decoder:
-      result = function( input, pixelBuffer );
+      result = function(input, pixelBuffer);
 
-      if (!result)
+      if(!result)
       {
-        DALI_LOG_WARNING( "Unable to convert %s\n", path.c_str() );
+        DALI_LOG_ERROR("Unable to convert %s\n", path.c_str());
         pixelBuffer.Reset();
       }
 
-      pixelBuffer = Internal::Platform::ApplyAttributesToBitmap( pixelBuffer, resource.size, resource.scalingMode, resource.samplingMode );
+      pixelBuffer = Internal::Platform::ApplyAttributesToBitmap(pixelBuffer, resource.size, resource.scalingMode, resource.samplingMode);
+    }
+    else
+    {
+      DALI_LOG_ERROR("Image Decoder for %s unavailable\n", path.c_str());
+    }
+  }
+
+  return result;
+}
+
+bool ConvertStreamToPlanes(const Integration::BitmapResourceType& resource, const std::string& path, FILE* const fp, std::vector<Dali::Devel::PixelBuffer>& pixelBuffers)
+{
+  DALI_LOG_TRACE_METHOD(gLogFilter);
+
+  bool result = false;
+
+  if(fp != NULL)
+  {
+    Dali::ImageLoader::LoadBitmapFunction       loader;
+    Dali::ImageLoader::LoadPlanesFunction       planeLoader;
+    Dali::ImageLoader::LoadBitmapHeaderFunction header;
+
+    Bitmap::Profile profile;
+
+    if(GetBitmapLoaderFunctions(fp,
+                                GetFormatHint(path),
+                                loader,
+                                planeLoader,
+                                header,
+                                profile,
+                                path))
+    {
+      const Dali::ImageLoader::ScalingParameters scalingParameters(resource.size, resource.scalingMode, resource.samplingMode);
+      const Dali::ImageLoader::Input             input(fp, scalingParameters, resource.orientationCorrection);
+
+      pixelBuffers.clear();
+
+      // Run the image type decoder:
+      if(planeLoader)
+      {
+        result = planeLoader(input, pixelBuffers);
+        if(!result)
+        {
+          DALI_LOG_ERROR("Unable to convert %s\n", path.c_str());
+        }
+      }
+      else
+      {
+        Dali::Devel::PixelBuffer pixelBuffer;
+        result = loader(input, pixelBuffer);
+        if(!result)
+        {
+          DALI_LOG_ERROR("Unable to convert %s\n", path.c_str());
+          return false;
+        }
+
+        pixelBuffer = Internal::Platform::ApplyAttributesToBitmap(pixelBuffer, resource.size, resource.scalingMode, resource.samplingMode);
+        if(pixelBuffer)
+        {
+          pixelBuffers.push_back(pixelBuffer);
+        }
+        else
+        {
+          DALI_LOG_ERROR("ApplyAttributesToBitmap is failed [%s]\n", path.c_str());
+          return false;
+        }
+      }
     }
     else
     {
-      DALI_LOG_WARNING( "Image Decoder for %s unavailable\n", path.c_str() );
+      DALI_LOG_ERROR("Image Decoder for %s unavailable\n", path.c_str());
     }
   }
 
   return result;
 }
 
-ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resource, const std::string& path )
+ResourcePointer LoadImageSynchronously(const Integration::BitmapResourceType& resource, const std::string& path)
 {
-  ResourcePointer result;
+  ResourcePointer          result;
   Dali::Devel::PixelBuffer bitmap;
 
-  Internal::Platform::FileReader fileReader( path );
-  FILE * const fp = fileReader.GetFile();
-  if( fp != NULL )
+  Internal::Platform::FileReader fileReader(path);
+  FILE* const                    fp = fileReader.GetFile();
+  if(fp != NULL)
   {
     bool success = ConvertStreamToBitmap(resource, path, fp, bitmap);
-    if (success && bitmap)
+    if(success && bitmap)
     {
       Bitmap::Profile profile{Bitmap::Profile::BITMAP_2D_PACKED_PIXELS};
 
       // For backward compatibility the Bitmap must be created
       auto retval = Bitmap::New(profile, Dali::ResourcePolicy::OWNED_DISCARD);
 
-      DALI_LOG_SET_OBJECT_STRING( retval, path );
+      DALI_LOG_SET_OBJECT_STRING(retval, path);
 
       retval->GetPackedPixelsProfile()->ReserveBuffer(
-              bitmap.GetPixelFormat(),
-              bitmap.GetWidth(),
-              bitmap.GetHeight(),
-              bitmap.GetWidth(),
-              bitmap.GetHeight()
-            );
+        bitmap.GetPixelFormat(),
+        bitmap.GetWidth(),
+        bitmap.GetHeight(),
+        bitmap.GetWidth(),
+        bitmap.GetHeight());
 
       auto& impl = Dali::GetImplementation(bitmap);
 
-      std::copy( impl.GetBuffer(), impl.GetBuffer()+impl.GetBufferSize(), retval->GetBuffer());
+      std::copy(impl.GetBuffer(), impl.GetBuffer() + impl.GetBufferSize(), retval->GetBuffer());
       result.Reset(retval);
     }
   }
@@ -329,95 +406,100 @@ ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& r
 }
 
 ///@ToDo: Rename GetClosestImageSize() functions. Make them use the orientation correction and scaling information. Requires jpeg loader to tell us about reorientation. [Is there still a requirement for this functionality at all?]
-ImageDimensions  GetClosestImageSize( const std::string& filename,
-                                      ImageDimensions size,
-                                      FittingMode::Type fittingMode,
-                                      SamplingMode::Type samplingMode,
-                                      bool orientationCorrection )
+ImageDimensions GetClosestImageSize(const std::string& filename,
+                                    ImageDimensions    size,
+                                    FittingMode::Type  fittingMode,
+                                    SamplingMode::Type samplingMode,
+                                    bool               orientationCorrection)
 {
-  unsigned int width = 0;
+  unsigned int width  = 0;
   unsigned int height = 0;
 
-  Internal::Platform::FileReader fileReader( filename );
-  FILE *fp = fileReader.GetFile();
-  if (fp != NULL)
+  Internal::Platform::FileReader fileReader(filename);
+  FILE*                          fp = fileReader.GetFile();
+  if(fp != NULL)
   {
-    Dali::ImageLoader::LoadBitmapFunction loaderFunction;
+    Dali::ImageLoader::LoadBitmapFunction       loaderFunction;
+    Dali::ImageLoader::LoadPlanesFunction       planeLoader;
     Dali::ImageLoader::LoadBitmapHeaderFunction headerFunction;
-    Bitmap::Profile profile;
-
-    if ( GetBitmapLoaderFunctions( fp,
-                                   GetFormatHint(filename),
-                                   loaderFunction,
-                                   headerFunction,
-                                   profile,
-                                   filename ) )
+    Bitmap::Profile                             profile;
+
+    if(GetBitmapLoaderFunctions(fp,
+                                GetFormatHint(filename),
+                                loaderFunction,
+                                planeLoader,
+                                headerFunction,
+                                profile,
+                                filename))
     {
-      const Dali::ImageLoader::Input input( fp, Dali::ImageLoader::ScalingParameters( size, fittingMode, samplingMode ), orientationCorrection );
+      const Dali::ImageLoader::Input input(fp, Dali::ImageLoader::ScalingParameters(size, fittingMode, samplingMode), orientationCorrection);
 
-      const bool read_res = headerFunction( input, width, height );
+      const bool read_res = headerFunction(input, width, height);
       if(!read_res)
       {
-        DALI_LOG_WARNING("Image Decoder failed to read header for %s\n", filename.c_str());
+        DALI_LOG_ERROR("Image Decoder failed to read header for %s\n", filename.c_str());
       }
     }
     else
     {
-      DALI_LOG_WARNING("Image Decoder for %s unavailable\n", filename.c_str());
+      DALI_LOG_ERROR("Image Decoder for %s unavailable\n", filename.c_str());
     }
   }
-  return ImageDimensions( width, height );
+  return ImageDimensions(width, height);
 }
 
-ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
-                                     ImageDimensions size,
-                                     FittingMode::Type fittingMode,
-                                     SamplingMode::Type samplingMode,
-                                     bool orientationCorrection )
+ImageDimensions GetClosestImageSize(Integration::ResourcePointer resourceBuffer,
+                                    ImageDimensions              size,
+                                    FittingMode::Type            fittingMode,
+                                    SamplingMode::Type           samplingMode,
+                                    bool                         orientationCorrection)
 {
-  unsigned int width = 0;
+  unsigned int width  = 0;
   unsigned int height = 0;
 
   // Get the blob of binary data that we need to decode:
-  DALI_ASSERT_DEBUG( resourceBuffer );
-  Dali::RefCountedVector<uint8_t>* const encodedBlob = reinterpret_cast<Dali::RefCountedVector<uint8_t>*>( resourceBuffer.Get() );
+  DALI_ASSERT_DEBUG(resourceBuffer);
+  Dali::RefCountedVector<uint8_t>* const encodedBlob = reinterpret_cast<Dali::RefCountedVector<uint8_t>*>(resourceBuffer.Get());
 
-  if( encodedBlob != 0 )
+  if(encodedBlob != 0)
   {
-    if( encodedBlob->GetVector().Size() )
+    if(encodedBlob->GetVector().Size())
     {
       // Open a file handle on the memory buffer:
-      Internal::Platform::FileReader fileReader( encodedBlob->GetVector() );
-      FILE *fp = fileReader.GetFile();
-      if ( fp != NULL )
+      Internal::Platform::FileReader fileReader(encodedBlob->GetVector());
+      FILE*                          fp = fileReader.GetFile();
+      if(fp != NULL)
       {
-        Dali::ImageLoader::LoadBitmapFunction loaderFunction;
+        Dali::ImageLoader::LoadBitmapFunction       loaderFunction;
+        Dali::ImageLoader::LoadPlanesFunction       planeLoader;
         Dali::ImageLoader::LoadBitmapHeaderFunction headerFunction;
-        Bitmap::Profile profile;
-
-        if ( GetBitmapLoaderFunctions( fp,
-                                       FORMAT_UNKNOWN,
-                                       loaderFunction,
-                                       headerFunction,
-                                       profile,
-                                       "" ) )
+        Bitmap::Profile                             profile;
+
+        if(GetBitmapLoaderFunctions(fp,
+                                    FORMAT_UNKNOWN,
+                                    loaderFunction,
+                                    planeLoader,
+                                    headerFunction,
+                                    profile,
+                                    ""))
         {
-          const Dali::ImageLoader::Input input( fp, Dali::ImageLoader::ScalingParameters( size, fittingMode, samplingMode ), orientationCorrection );
-          const bool read_res = headerFunction( input, width, height );
-          if( !read_res )
+          const Dali::ImageLoader::Input input(fp, Dali::ImageLoader::ScalingParameters(size, fittingMode, samplingMode), orientationCorrection);
+          const bool                     read_res = headerFunction(input, width, height);
+          if(!read_res)
           {
-            DALI_LOG_WARNING( "Image Decoder failed to read header for resourceBuffer\n" );
+            DALI_LOG_ERROR("Image Decoder failed to read header for resourceBuffer\n");
           }
         }
       }
     }
   }
-  return ImageDimensions( width, height );
+  return ImageDimensions(width, height);
 }
 
-void SetMaxTextureSize( unsigned int size )
+void SetMaxTextureSize(unsigned int size)
 {
-  gMaxTextureSize = size;
+  gMaxTextureSize        = size;
+  gMaxTextureSizeUpdated = true;
 }
 
 unsigned int GetMaxTextureSize()
@@ -425,6 +507,11 @@ unsigned int GetMaxTextureSize()
   return gMaxTextureSize;
 }
 
-} // ImageLoader
-} // TizenPlatform
-} // Dali
+bool MaxTextureSizeUpdated()
+{
+  return gMaxTextureSizeUpdated;
+}
+
+} // namespace ImageLoader
+} // namespace TizenPlatform
+} // namespace Dali