Removed traces of ImageAttributes and dead old JPEG loader 80/41880/1
authorAndrew Cox <andrew.cox@partner.samsung.com>
Thu, 18 Jun 2015 15:18:11 +0000 (16:18 +0100)
committerAndrew Cox <andrew.cox@partner.samsung.com>
Thu, 18 Jun 2015 15:18:11 +0000 (16:18 +0100)
Change-Id: I67e4cc0ec822d8930e18bdae04c6d9d7fb85de25
Signed-off-by: Andrew Cox <andrew.cox@partner.samsung.com>
15 files changed:
automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-all-loads.cpp
automated-tests/src/dali-platform-abstraction/utc-image-loading-cancel-some-loads.cpp
automated-tests/src/dali-platform-abstraction/utc-image-loading-common.cpp
automated-tests/src/dali-platform-abstraction/utc-image-loading-common.h
build/tizen/adaptor/Makefile.am
build/tizen/configure.ac
platform-abstractions/tizen/file.list
platform-abstractions/tizen/image-loaders/loader-bmp.h
platform-abstractions/tizen/image-loaders/loader-gif.h
platform-abstractions/tizen/image-loaders/loader-ico.h
platform-abstractions/tizen/image-loaders/loader-jpeg.cpp [deleted file]
platform-abstractions/tizen/image-loaders/loader-jpeg.h
platform-abstractions/tizen/image-loaders/loader-ktx.h
platform-abstractions/tizen/image-loaders/loader-png.h
platform-abstractions/tizen/image-loaders/loader-wbmp.h

index 0c6d007..aa4d8b5 100644 (file)
@@ -55,7 +55,7 @@ int UtcDaliCancelAllLoads(void)
     // Issue load requests for a batch of images:
     for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage )
     {
-      const ImageAttributes & loadParams = gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ];
+      const ImageParameters & loadParams = gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ];
       const BitmapResourceType bitmapResourceType( loadParams.first, loadParams.second.first, loadParams.second.second.first, loadParams.second.second.second );
       const ResourceId resourceId = loadGroup * NUM_VALID_IMAGES + validImage + 1;
       gAbstraction->LoadResource( ResourceRequest( resourceId, bitmapResourceType, VALID_IMAGES[validImage], priority ) );
index ed58204..9a6d98e 100644 (file)
@@ -54,7 +54,7 @@ int UtcDaliCancelSomeLoads(void)
     // Issue load requests for a batch of images:
     for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage )
     {
-      const ImageAttributes & loadParams = gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ];
+      const ImageParameters & loadParams = gCancelAttributes[ loadsLaunched % gCancelAttributes.size() ];
       const BitmapResourceType bitmapResourceType( loadParams.first, loadParams.second.first, loadParams.second.second.first, loadParams.second.second.second );
       const ResourceId resourceId = loadGroup * NUM_VALID_IMAGES + validImage + 1;
       gAbstraction->LoadResource( ResourceRequest( resourceId, bitmapResourceType, VALID_IMAGES[validImage], priority ) );
index d53c0fb..3d80c50 100644 (file)
 /** Live platform abstraction recreated for each test case. */
 Integration::PlatformAbstraction * gAbstraction = 0;
 
-/** A variety of ImageAttributes to reach different code paths that have embedded code paths. */
-std::vector<ImageAttributes> gCancelAttributes;
+/** A variety of parameters to reach different code paths in image loading code. */
+std::vector<ImageParameters> gCancelAttributes;
 
 void utc_dali_loading_startup(void)
 {
   test_return_value = TET_UNDEF;
   gAbstraction = CreatePlatformAbstraction();
 
-  // Setup some ImageAttributes to engage post-processing stages:
+  // Setup some loading parameters to engage post-processing stages:
 
-  ImageAttributes scaleToFillAttributes;
+  ImageParameters scaleToFillAttributes;
   scaleToFillAttributes.second.first = FittingMode::SCALE_TO_FILL;
   scaleToFillAttributes.first = ImageDimensions( 160, 120 );
   gCancelAttributes.push_back( scaleToFillAttributes );
 
   // Hit the derived dimensions code:
-  ImageAttributes scaleToFillAttributesDeriveWidth = scaleToFillAttributes;
+  ImageParameters scaleToFillAttributesDeriveWidth = scaleToFillAttributes;
   scaleToFillAttributesDeriveWidth.first = ImageDimensions( 0, 120 );
   gCancelAttributes.push_back( scaleToFillAttributesDeriveWidth );
 
-  ImageAttributes scaleToFillAttributesDeriveHeight = scaleToFillAttributes;
+  ImageParameters scaleToFillAttributesDeriveHeight = scaleToFillAttributes;
   scaleToFillAttributesDeriveHeight.first = ImageDimensions( 160, 0 );
   gCancelAttributes.push_back( scaleToFillAttributesDeriveHeight );
 
   // Try to push a tall crop:
-  ImageAttributes scaleToFillAttributesTall = scaleToFillAttributes;
+  ImageParameters scaleToFillAttributesTall = scaleToFillAttributes;
   scaleToFillAttributesTall.first = ImageDimensions( 160, 480 );
-  ImageAttributes scaleToFillAttributesTall2 = scaleToFillAttributes;
+  ImageParameters scaleToFillAttributesTall2 = scaleToFillAttributes;
   scaleToFillAttributesTall2.first = ImageDimensions( 160, 509 );
-  ImageAttributes scaleToFillAttributesTall3 = scaleToFillAttributes;
+  ImageParameters scaleToFillAttributesTall3 = scaleToFillAttributes;
   scaleToFillAttributesTall3.first = ImageDimensions( 37, 251 );
   gCancelAttributes.push_back( scaleToFillAttributesTall );
   gCancelAttributes.push_back( scaleToFillAttributesTall2 );
   gCancelAttributes.push_back( scaleToFillAttributesTall3 );
 
   // Try to push a wide crop:
-  ImageAttributes scaleToFillAttributesWide = scaleToFillAttributes;
+  ImageParameters scaleToFillAttributesWide = scaleToFillAttributes;
   scaleToFillAttributesWide.first = ImageDimensions( 320, 60 );
-  ImageAttributes scaleToFillAttributesWide2 = scaleToFillAttributes;
+  ImageParameters scaleToFillAttributesWide2 = scaleToFillAttributes;
   scaleToFillAttributesWide2.first = ImageDimensions( 317, 60 );
-  ImageAttributes scaleToFillAttributesWide3 = scaleToFillAttributes;
+  ImageParameters scaleToFillAttributesWide3 = scaleToFillAttributes;
   scaleToFillAttributesWide3.first = ImageDimensions( 317, 53 );
   gCancelAttributes.push_back( scaleToFillAttributesWide );
   gCancelAttributes.push_back( scaleToFillAttributesWide2 );
   gCancelAttributes.push_back( scaleToFillAttributesWide3 );
 
-  ImageAttributes shrinkToFitAttributes = scaleToFillAttributes;
+  ImageParameters shrinkToFitAttributes = scaleToFillAttributes;
   shrinkToFitAttributes.second.first = FittingMode::SHRINK_TO_FIT;
   gCancelAttributes.push_back( shrinkToFitAttributes );
 
-  ImageAttributes fitWidthAttributes = scaleToFillAttributes;
+  ImageParameters fitWidthAttributes = scaleToFillAttributes;
   fitWidthAttributes.second.first = FittingMode::FIT_WIDTH;
   gCancelAttributes.push_back( fitWidthAttributes );
 
-  ImageAttributes fitHeightAttributes = scaleToFillAttributes;
+  ImageParameters fitHeightAttributes = scaleToFillAttributes;
   fitHeightAttributes.second.first = FittingMode::FIT_HEIGHT;
   gCancelAttributes.push_back( fitHeightAttributes );
 
index 4bec44b..9afcf8d 100644 (file)
@@ -77,9 +77,9 @@ double GetTimeMilliseconds( Integration::PlatformAbstraction& abstraction )
 /** Live platform abstraction recreated for each test case. */
 extern Integration::PlatformAbstraction * gAbstraction;
 
-/** A variety of ImageAttributes to reach different code paths that have embedded code paths. */
-typedef std::pair<ImageDimensions, std::pair<FittingMode::Type, std::pair<SamplingMode::Type, bool> > > ImageAttributes;
-extern std::vector<ImageAttributes> gCancelAttributes;
+/** A variety of parameters to reach different code paths in the image loading. */
+typedef std::pair<ImageDimensions, std::pair<FittingMode::Type, std::pair<SamplingMode::Type, bool> > > ImageParameters;
+extern std::vector<ImageParameters> gCancelAttributes;
 
 
 void utc_dali_loading_startup(void);
index ed609c7..f0eb8ec 100644 (file)
@@ -181,12 +181,6 @@ dalifeedbackthemedir = ${dataReadOnlyDir}/themes/feedback-themes/
 dalifeedbacktheme_DATA = ${dali_plugin_theme_files}
 endif
 
-if TURBO_JPEG_IS_ON
-  tizen_platform_abstraction_src_files += $(tizen_turbo_jpeg_loader)
-else
-  tizen_platform_abstraction_src_files += $(tizen_jpeg_loader)
-endif
-
 lib_LTLIBRARIES = libdali-adaptor.la
 
 libdali_adaptor_la_SOURCES = \
@@ -300,7 +294,8 @@ libdali_adaptor_la_LIBADD = \
                       $(HARFBUZZ_LIBS) \
                       $(CAPI_SYSTEM_INFO_LIBS) \
                       -lgif \
-                      -lboost_thread
+                      -lboost_thread \
+                      -lturbojpeg
 
 if WAYLAND
 libdali_adaptor_la_CXXFLAGS += $(WAYLAND_CFLAGS)
@@ -339,16 +334,10 @@ libdali_adaptor_la_CXXFLAGS += $(HAPTIC_CFLAGS)
 libdali_adaptor_la_LIBADD +=
 endif
 
-if TURBO_JPEG_IS_ON
-libdali_adaptor_la_LIBADD += -lturbojpeg
-CFLAGS += -D_TURBO_JPEG_LOADER
 if UBUNTU_PROFILE
 libdali_adaptor_la_LIBADD += -ljpeg
 CFLAGS += -fPIC
 endif
-else
-libdali_adaptor_la_LIBADD += -ljpeg
-endif
 
 tizenadaptorpublicapidir = $(devincludepath)/dali/public-api
 tizenadaptorpublicapi_HEADERS = $(public_api_header_files)
index 4fe7ac7..5047020 100644 (file)
@@ -132,14 +132,6 @@ AC_ARG_ENABLE([gles],
 
 DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DDALI_GLES_VERSION=${enable_gles}"
 
-AC_ARG_WITH([jpeg-turbo],
-            [AC_HELP_STRING([--with-jpeg-turbo],
-                            [Use the JPEG Turbo library])],
-            [with_jpeg_turbo=$withval],
-            [with_jpeg_turbo=yes])
-
-AM_CONDITIONAL(TURBO_JPEG_IS_ON, test $with_jpeg_turbo = yes)
-
 AC_ARG_WITH([over-tizen_2_2],
             [AC_HELP_STRING([--with-over-tizen_2_2],
                             [Use tizen API over ver. 2.2])],
@@ -282,7 +274,6 @@ Configuration
   Debug Build:                      $enable_debug
   Compile flags                     $DALI_ADAPTOR_CFLAGS
   Using Assimp Library:             $enable_assimp
-  Using JPEG Turbo Library:         $with_jpeg_turbo
   Freetype bitmap support (Emoji):  $freetype_bitmap_support
   Profile:                          $enable_profile
   Data Dir (Read/Write):            $dataReadWriteDir
index 0056d8a..a8c36a4 100755 (executable)
@@ -20,19 +20,14 @@ tizen_platform_abstraction_src_files = \
   \
   $(tizen_platform_abstraction_src_dir)/image-loaders/loader-bmp.cpp \
   $(tizen_platform_abstraction_src_dir)/image-loaders/loader-gif.cpp \
-  $(tizen_platform_abstraction_src_dir)/image-loaders/loader-png.cpp \
-  $(tizen_platform_abstraction_src_dir)/image-loaders/loader-ico.cpp \
+    $(tizen_platform_abstraction_src_dir)/image-loaders/loader-ico.cpp \
+  $(tizen_platform_abstraction_src_dir)/image-loaders/loader-jpeg-turbo.cpp \
   $(tizen_platform_abstraction_src_dir)/image-loaders/loader-ktx.cpp \
+  $(tizen_platform_abstraction_src_dir)/image-loaders/loader-png.cpp \
   $(tizen_platform_abstraction_src_dir)/image-loaders/loader-wbmp.cpp \
   $(tizen_platform_abstraction_src_dir)/image-loaders/image-loader.cpp \
   $(portable_platform_abstraction_src_dir)/image-operations.cpp
 
-tizen_turbo_jpeg_loader = \
-  $(tizen_platform_abstraction_src_dir)/image-loaders/loader-jpeg-turbo.cpp
-
-tizen_jpeg_loader = \
-  $(tizen_platform_abstraction_src_dir)/image-loaders/loader-jpeg.cpp
-
 # Add public headers here:
 
 # platform_abstraction_header_files =
index c5f9957..41872aa 100644 (file)
@@ -29,8 +29,6 @@ namespace Integration
 class Bitmap;
 }
 
-struct ImageAttributes;
-
 namespace TizenPlatform
 {
 
index 9b9c330..d2afd3b 100644 (file)
@@ -29,8 +29,6 @@ namespace Integration
   class Bitmap;
 }
 
-struct ImageAttributes;
-
 namespace TizenPlatform
 {
 
index d844e77..7b56737 100644 (file)
@@ -28,7 +28,6 @@ namespace Integration
 {
   class Bitmap;
 }
-struct ImageAttributes;
 
 namespace TizenPlatform
 {
diff --git a/platform-abstractions/tizen/image-loaders/loader-jpeg.cpp b/platform-abstractions/tizen/image-loaders/loader-jpeg.cpp
deleted file mode 100644 (file)
index 357f213..0000000
+++ /dev/null
@@ -1,819 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "loader-jpeg.h"
-
-#include <stdio.h>
-#include <jpeglib.h>
-#include <stdlib.h>
-
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/public-api/math/math-utils.h>
-#include <dali/public-api/math/vector2.h>
-
-#include "platform-capabilities.h"
-#include <cstring>
-#include <libexif/exif-data.h>
-#include <libexif/exif-tag.h>
-
-namespace Dali
-{
-using Integration::Bitmap;
-
-namespace TizenPlatform
-{
-
-namespace
-{
-
-typedef enum {
-  JPGFORM_NONE = 1,  /* no transformation 0th-Row = top & 0th-Column = left */
-  JPGFORM_FLIP_H ,   /* horizontal flip       0th-Row = top & 0th-Column = right */
-  JPGFORM_FLIP_V,    /* vertical flip     0th-Row = bottom & 0th-Column = right*/
-  JPGFORM_TRANSPOSE, /* transpose across UL-to-LR axis   0th-Row = bottom & 0th-Column = left*/
-  JPGFORM_TRANSVERSE,/* transpose across UR-to-LL axis   0th-Row = left      & 0th-Column = top*/
-  JPGFORM_ROT_90 ,   /* 90-degree clockwise rotation  0th-Row = right  & 0th-Column = top*/
-  JPGFORM_ROT_180,   /* 180-degree rotation  0th-Row = right  & 0th-Column = bottom*/
-  JPGFORM_ROT_270    /* 270-degree clockwise (or 90 ccw)  0th-Row = left  & 0th-Column = bottom*/
-} JPGFORM_CODE;
-
-
-typedef struct {
-   char R;
-   char G;
-   char B;
-}RGB888Type;
-typedef struct {
-   char R;
-   char G;
-   char B;
-   char A;
-}RGBA8888Type;
-typedef struct
-{
-  char RG;
-  char GB;
-}RGB565Type;
-typedef struct
-{
-  char gray;
-}L8Type;
-
-// simple class to enforce clean-up of JPEG structures
-struct auto_jpg
-{
-  auto_jpg(struct jpeg_decompress_struct& _cinfo)
-  : cinfo(_cinfo),
-    compression_started(false)
-  {
-  }
-
-  ~auto_jpg()
-  {
-    // clean up JPG resources
-    if( compression_started )
-    {
-      // finish decompression if started
-      jpeg_finish_decompress(&cinfo);
-    }
-
-    jpeg_destroy_decompress (&cinfo);
-  }
-
-  bool start_decompress()
-  {
-    // store flag indicating compression has started
-    compression_started = jpeg_start_decompress(&cinfo);
-    return compression_started;
-  }
-
-  void abort_decompress()
-  {
-    if( compression_started )
-    {
-      // abort decompression if started
-      jpeg_abort_decompress(&cinfo);
-      // clear compression started flag
-      compression_started = false;
-    }
-  }
-
-  struct jpeg_decompress_struct& cinfo;
-  bool compression_started;
-}; // struct auto_jpg;
-
-static void JpegFatalErrorHandler (j_common_ptr cinfo)
-{
-  /* LibJpeg causes an assert if this happens but we do not want that */
-}
-
-static void JpegOutputMessageHandler (j_common_ptr cinfo)
-{
-  /* Stop libjpeg from printing to stderr - Do Nothing */
-}
-
-bool LoadJpegHeader(FILE *fp, unsigned int &width, unsigned int &height, jpeg_decompress_struct &cinfo, jpeg_error_mgr &jerr)
-{
-    cinfo.err = jpeg_std_error(&jerr);
-
-    jerr.output_message = JpegOutputMessageHandler;
-    jerr.error_exit = JpegFatalErrorHandler;
-
-    jpeg_create_decompress(&cinfo);
-
-    jpeg_stdio_src(&cinfo, fp);
-
-    // Check header to see if it is  JPEG file
-    if (jpeg_read_header(&cinfo, TRUE) != JPEG_HEADER_OK)
-    {
-      return false;
-    }
-
-    width = (float)cinfo.image_width;
-    height = (float)cinfo.image_height;
-
-    return true;
-}
-
-// Simple struct to ensure xif data is deleted
-struct ExifAutoPtr
-{
-  ExifAutoPtr( ExifData* data)
-  :mData( data )
-  {}
-
-  ~ExifAutoPtr()
-  {
-    exif_data_free( mData);
-  }
-  ExifData *mData;
-};
-
-
-} // unnamed namespace
-
-bool JpegRotate90(unsigned char *buffer, int width, int height, int bpp);
-bool JpegRotate180(unsigned char *buffer, int width, int height, int bpp);
-bool JpegRotate270(unsigned char *buffer, int width, int height, int bpp);
-bool LoadJpegHeader(FILE *fp, unsigned int &width, unsigned int &height)
-{
-  struct jpeg_decompress_struct cinfo;
-  struct jpeg_error_mgr jerr;
-  auto_jpg autoJpg(cinfo);
-
-  return LoadJpegHeader(fp, width, height, cinfo, jerr);
-}
-
-bool LoadBitmapFromJpeg(FILE *fp, Bitmap& bitmap, ImageAttributes& attributes)
-{
-  JPGFORM_CODE transform = JPGFORM_NONE;
-  struct jpeg_decompress_struct cinfo;
-  struct jpeg_error_mgr jerr;
-  auto_jpg autoJpg(cinfo);
-
-  if( fseek(fp,0,SEEK_END) )
-  {
-    DALI_LOG_ERROR("Error seeking to end of file\n");
-    return false;
-  }
-
-  long positionIndicator = ftell(fp);
-  unsigned int jpegbufsize( 0u );
-  if( positionIndicator > -1L )
-  {
-    jpegbufsize = static_cast<unsigned int>(positionIndicator);
-  }
-
-  if( 0u == jpegbufsize )
-  {
-    return false;
-  }
-
-  if( fseek(fp, 0, SEEK_SET) )
-  {
-    DALI_LOG_ERROR("Error seeking to end of file\n");
-    return false;
-  }
-
-  std::vector<unsigned char> jpegbuf(jpegbufsize);
-  unsigned char *jpegbufPtr = &jpegbuf[0];
-  if(fread(jpegbufPtr, 1, jpegbufsize, fp) != jpegbufsize)
-  {
-    return false;
-  }
-
-  if( fseek(fp, 0, SEEK_SET) )
-  {
-    DALI_LOG_ERROR("Error seeking to end of file\n");
-    return false;
-  }
-
-  ExifAutoPtr exifData( exif_data_new_from_data(jpegbufPtr, jpegbufsize) );
-  ExifEntry *entry;
-  ExifTag tag = EXIF_TAG_ORIENTATION;
-  entry = exif_data_get_entry(exifData.mData, tag);
-  int orientation = 0;
-  if(entry)
-  {
-    orientation = exif_get_short(entry->data, exif_data_get_byte_order(entry->parent->parent));
-    switch(orientation)
-    {
-    case 1:
-      transform = JPGFORM_NONE;
-      break;
-    case 2:
-      transform = JPGFORM_FLIP_H;
-      break;
-    case 3:
-      transform = JPGFORM_FLIP_V;
-      break;
-    case 4:
-      transform = JPGFORM_TRANSPOSE;
-      break;
-    case 5:
-      transform = JPGFORM_TRANSVERSE;
-      break;
-    case 6:
-      transform = JPGFORM_ROT_90;
-      break;
-    case 7:
-      transform = JPGFORM_ROT_180;
-      break;
-    case 8:
-      transform = JPGFORM_ROT_270;
-      break;
-    default:
-      break;
-    }
-  }
-
-  // Load the header info
-  unsigned int width, height;
-  if (!LoadJpegHeader(fp, width, height, cinfo, jerr))
-  {
-      return false;
-  }
-
-  // set scaling if image request is not zero (which means full image)
-  // and requested size is smaller than actual size
-  if( ( attributes.GetWidth() > 0 )&&( attributes.GetHeight() > 0 ) &&
-      ( attributes.GetWidth()  < cinfo.image_width )           &&
-      ( attributes.GetHeight() < cinfo.image_height ))
-  {
-    // jpeg only supports scaling by 1/2, 1/4, 1/8, 1/16
-    // calculate width and height scale between (fitted) request and original
-    Size req = attributes.GetSize();
-    Size orig((float)cinfo.image_width, (float)cinfo.image_height);
-    Size fitted = FitInside(req, orig);
-    int widthScale = cinfo.image_width / fitted.width;
-    int heightScale = cinfo.image_height / fitted.height;
-    // pick the smallest one of those as we want to scale as close as possible
-    int scale = std::min( widthScale, heightScale );
-    // if the scale is not power of two make it
-    if( !IsPowerOfTwo( scale ) )
-    {
-      scale = NextPowerOfTwo( scale );
-    }
-    // finally set the scale 1 / scale
-    cinfo.scale_num = 1;
-    cinfo.scale_denom = scale;
-  }
-
-  Pixel::Format pixelFormat = Pixel::RGBA8888;
-  if (!autoJpg.start_decompress())
-  {
-   // @todo renable this log LOG_WARNING("error during jpeg_start_decompress\n");
-    return false;
-  }
-
-  int bytes_per_pixel   = cinfo.out_color_components;
-
-  // JPEG doesn't support transparency
-  if (bytes_per_pixel == 3)
-  {
-    pixelFormat = Pixel::RGB888;
-  }
-  else if (bytes_per_pixel == 2)
-  {
-    pixelFormat = Pixel::RGB565;
-  }
-  else if (bytes_per_pixel == 1)
-  {
-    pixelFormat = Pixel::L8;
-  }
-  else
-  {
-    DALI_LOG_WARNING ("Unsupported jpeg format\n");
-    autoJpg.abort_decompress();
-    return false;
-  }
-
-  width                      = cinfo.output_width;
-  height                     = cinfo.output_height;
-  unsigned int  bufferWidth  = GetTextureDimension( width );
-  unsigned int  bufferHeight = GetTextureDimension( height );
-  unsigned int  stride       = bufferWidth * bytes_per_pixel;
-
-  unsigned char *pixels      = NULL;
-  unsigned char *lptr        = NULL;
-
-  /// @todo support more scaling types
-  bool fitInside = attributes.GetScalingMode() == Dali::ImageAttributes::ShrinkToFit &&
-                   attributes.GetWidth() != 0 &&
-                   attributes.GetHeight() != 0 &&
-                  (attributes.GetWidth() < cinfo.output_width || attributes.GetHeight() < cinfo.output_height);
-  bool crop = attributes.GetScalingMode() == Dali::ImageAttributes::ScaleToFill;
-
-  if (fitInside || crop)
-  {
-    // create temporary decompression buffer
-    pixels = new unsigned char[stride*bufferHeight];
-    lptr   = pixels;
-  }
-  else
-  {
-    // decode the whole image into bitmap buffer
-    switch(transform)
-    {
-    case JPGFORM_NONE:
-    case JPGFORM_FLIP_H:
-    case JPGFORM_FLIP_V:
-    case JPGFORM_TRANSPOSE:
-    case JPGFORM_TRANSVERSE:
-    case JPGFORM_ROT_180:
-      pixels = bitmap.ReserveBuffer(pixelFormat, width, height, bufferWidth, bufferHeight);
-      break;
-    case JPGFORM_ROT_270:
-    case JPGFORM_ROT_90:
-      pixels = bitmap.ReserveBuffer(pixelFormat, height,width, bufferHeight,bufferWidth);
-    default:
-      break;
-    }
-    lptr   = pixels;
-  }
-
-  // decode jpeg
-  while (cinfo.output_scanline < cinfo.output_height)
-  {
-    lptr = pixels + (stride * cinfo.output_scanline);
-    jpeg_read_scanlines(&cinfo, &lptr, 1);
-  }
-  DALI_ASSERT_DEBUG(pixels);
-
-  switch(transform)
-  {
-  case JPGFORM_NONE:
-  case JPGFORM_FLIP_H:
-  case JPGFORM_FLIP_V:
-  case JPGFORM_TRANSPOSE:
-  case JPGFORM_TRANSVERSE:
-    break;
-  case JPGFORM_ROT_180:
-    JpegRotate180(pixels, bufferWidth, bufferHeight, bytes_per_pixel);
-    break;
-  case JPGFORM_ROT_270:
-    JpegRotate270(pixels, bufferWidth, bufferHeight, bytes_per_pixel);
-    break;
-  case JPGFORM_ROT_90:
-    JpegRotate90(pixels, bufferWidth, bufferHeight, bytes_per_pixel);
-    break;
-  default:
-    break;
-  }
-  // fit image completely inside requested size (maintaining aspect ratio)?
-  if (fitInside)
-  {
-    Size req = attributes.GetSize();
-    Size orig((float)cinfo.output_width, (float)cinfo.output_height);
-    switch(transform)
-    {
-    case JPGFORM_NONE:
-    case JPGFORM_FLIP_H:
-    case JPGFORM_FLIP_V:
-    case JPGFORM_TRANSPOSE:
-    case JPGFORM_TRANSVERSE:
-    case JPGFORM_ROT_180:
-      break;
-    case JPGFORM_ROT_270:
-    case JPGFORM_ROT_90:
-      orig = Vector2 ((float)cinfo.output_height, (float)cinfo.output_width);
-      stride = bufferHeight * bytes_per_pixel;
-      break;
-    default:
-      break;
-    }
-    // calculate actual width, height
-    req = FitInside(req, orig);
-
-    attributes.SetSize((int) req.width, (int) req.height);
-    attributes.SetPixelFormat(pixelFormat);
-
-    bufferWidth  = GetTextureDimension( attributes.GetWidth() );
-    bufferHeight = GetTextureDimension( attributes.GetHeight() );
-
-    // scaled buffer's stride
-    int lstride = bufferWidth*bytes_per_pixel;
-
-    // allocate bitmap buffer using requested size
-    unsigned char *bitmapBuffer = bitmap.ReserveBuffer(pixelFormat, attributes.GetWidth(), attributes.GetHeight(), bufferWidth, bufferHeight);
-
-    // scale original image to fit requested size
-    float xRatio = (float)cinfo.output_width / (float)attributes.GetWidth();
-    float yRatio = (float)cinfo.output_height / (float)attributes.GetHeight();
-    switch(transform)
-    {
-    case JPGFORM_NONE:
-    case JPGFORM_FLIP_H:
-    case JPGFORM_FLIP_V:
-    case JPGFORM_TRANSPOSE:
-    case JPGFORM_TRANSVERSE:
-    case JPGFORM_ROT_180:
-      break;
-    case JPGFORM_ROT_270:
-    case JPGFORM_ROT_90:
-      xRatio = (float)cinfo.output_height / (float)attributes.GetWidth();
-      yRatio = (float)cinfo.output_width / (float)attributes.GetHeight();
-      break;
-    default:
-      break;
-    }
-    // @todo Add a quality setting to ImageAttributes and use suitable shrink algorithm
-    unsigned char *bufptr = bitmapBuffer;
-    for (unsigned int y = 0; y < attributes.GetHeight(); ++y)
-    {
-      unsigned char* dest = bufptr;
-      lptr = pixels + (stride * (unsigned int)(floorf(yRatio * y)));
-      for (unsigned int x = 0; x < attributes.GetWidth(); ++x)
-      {
-        unsigned char* src = lptr + (unsigned int)(floorf(xRatio * x)) * bytes_per_pixel;
-        *dest++ = *src++;
-        if (bytes_per_pixel >= 2)
-        {
-          *dest++ = *src++;
-          if (bytes_per_pixel >= 3)
-          {
-            *dest++ = *src++;
-          }
-        }
-      }
-      bufptr += lstride;
-    }
-
-    delete[] pixels;
-  }
-  // copy part of the buffer to bitmap?
-  else if (crop)
-  {
-    Size req = attributes.GetSize();
-    const Size orig ((float)cinfo.output_width, (float)cinfo.output_height);
-
-    // calculate actual width, height
-    req = FitScaleToFill(req, orig);
-
-    // modify attributes with result
-    attributes.SetSize((int) req.width, (int) req.height);
-    attributes.SetPixelFormat(pixelFormat);
-
-    bufferWidth  = GetTextureDimension( attributes.GetWidth() );
-    bufferHeight = GetTextureDimension( attributes.GetHeight() );
-
-    // cropped buffer's stride
-    int lstride = bufferWidth*bytes_per_pixel;
-
-    // calculate offsets
-    int x_offset = ((cinfo.output_width  - attributes.GetWidth())  / 2) * bytes_per_pixel;
-    int y_offset = ((cinfo.output_height - attributes.GetHeight()) / 2) * stride;
-
-    // allocate bitmap buffer using requested size
-    unsigned char *bitmapBuffer = bitmap.ReserveBuffer(pixelFormat, attributes.GetWidth(), attributes.GetHeight(), bufferWidth, bufferHeight);
-
-    // crop center of original image to fit requested size
-    unsigned char *bufptr = bitmapBuffer;
-    lptr = pixels+y_offset+x_offset;
-    for (unsigned int i = 0; i < attributes.GetHeight(); ++i)
-    {
-      memcpy (bufptr, lptr, attributes.GetWidth()*bytes_per_pixel);
-      bufptr += lstride;
-      lptr += stride;
-    }
-
-    delete[] pixels;
-  }
-  else
-  {
-    // set the attributes
-    switch(transform)
-    {
-    case JPGFORM_NONE:
-    case JPGFORM_FLIP_H:
-    case JPGFORM_FLIP_V:
-    case JPGFORM_TRANSPOSE:
-    case JPGFORM_TRANSVERSE:
-    case JPGFORM_ROT_180:
-      attributes.SetSize(width, height);
-      break;
-    case JPGFORM_ROT_270:
-    case JPGFORM_ROT_90:
-      attributes.SetSize(height, width);
-      break;
-    default:
-      break;
-    }
-
-    attributes.SetPixelFormat(pixelFormat);
-  }
-
-  return true;
-}
-
-bool JpegRotate180(unsigned char *buffer, int width, int height, int bpp)
-{
-  int  ix, iw, ih, hw = 0;
-  iw = width;
-  ih = height;
-  hw = iw * ih;
-  ix = hw;
-
-  switch(bpp)
-  {
-  case 4:
-  {
-    RGBA8888Type *from, *to;
-    RGBA8888Type tmp;
-    from = ((RGBA8888Type * )buffer) + hw - 1;
-    to = (RGBA8888Type *)buffer;
-    for(; --ix >= (hw / 2); )
-    {
-      tmp = *to;
-      *to = *from;
-      *from = tmp;
-      to ++;
-      from --;
-    }
-    break;
-  }
-  case 3:
-  {
-    RGB888Type *from, *to;
-    RGB888Type tmp;
-    from = ((RGB888Type * )buffer) + hw - 1;
-    to = (RGB888Type *)buffer;
-    for(; --ix >= (hw / 2); )
-    {
-      tmp = *to;
-      *to = *from;
-      *from = tmp;
-      to ++;
-      from --;
-    }
-    break;
-  }
-  case 2:
-  {
-    RGB565Type *from, *to;
-    RGB565Type tmp;
-    from = ((RGB565Type * )buffer) + hw - 1;
-    to = (RGB565Type *)buffer;
-    for(; --ix >= (hw / 2); )
-    {
-      tmp = *to;
-      *to = *from;
-      *from = tmp;
-      to ++;
-      from --;
-    }
-    break;
-  }
-  case 1:
-  {
-    L8Type *from, *to;
-    L8Type tmp;
-    from = ((L8Type * )buffer) + hw - 1;
-    to = (L8Type *)buffer;
-    for(; --ix >= (hw / 2); )
-    {
-      tmp = *to;
-      *to = *from;
-      *from = tmp;
-      to ++;
-      from --;
-    }
-    break;
-  }
-  default:
-    break;
-  }
-
-  return true;
-}
-
-bool JpegRotate270(unsigned char *buffer, int width, int height, int bpp)
-{
-  int  w, iw, ih, hw = 0;
-  int ix, iy = 0;
-
-  iw = width;
-  ih = height;
-  std::vector<unsigned char> data(width * height * bpp);
-  unsigned char *dataPtr = &data[0];
-  memcpy(dataPtr, buffer, width * height * bpp);
-  w = ih;
-  ih = iw;
-  iw = w;
-  hw = iw * ih;
-
-  switch(bpp)
-  {
-  case 4:
-  {
-    RGBA8888Type *from, *to;
-    to = ((RGBA8888Type * )buffer) + hw  - iw;
-    w = -w;
-    hw =  hw + 1;
-    from = (RGBA8888Type *)dataPtr;
-    for(ix = iw; -- ix >= 0;)
-    {
-      for(iy = ih; -- iy >= 0;)
-      {
-        *to = *from;
-        from += 1;
-        to += w;
-      }
-      to += hw;
-    }
-    break;
-  }
-  case 3:
-  {
-    RGB888Type *from, *to;
-    to = ((RGB888Type * )buffer) + hw  - iw;
-    w = -w;
-    hw =  hw + 1;
-    from = (RGB888Type *)dataPtr;
-    for(ix = iw; -- ix >= 0;)
-    {
-      for(iy = ih; -- iy >= 0;)
-      {
-        *to = *from;
-        from += 1;
-        to += w;
-      }
-      to += hw;
-    }
-    break;
-  }
-  case 2:
-  {
-    RGB565Type *from, *to;
-    to = ((RGB565Type * )buffer) + hw  - iw;
-    w = -w;
-    hw =  hw + 1;
-    from = (RGB565Type *)dataPtr;
-    for(ix = iw; -- ix >= 0;)
-    {
-      for(iy = ih; -- iy >= 0;)
-      {
-        *to = *from;
-        from += 1;
-        to += w;
-      }
-      to += hw;
-    }
-    break;
-  }
-  case 1:
-  {
-    L8Type *from, *to;
-    to = ((L8Type * )buffer) + hw  - iw;
-    w = -w;
-    hw =  hw + 1;
-    from = (L8Type *)dataPtr;
-    for(ix = iw; -- ix >= 0;)
-    {
-      for(iy = ih; -- iy >= 0;)
-      {
-        *to = *from;
-        from += 1;
-        to += w;
-      }
-      to += hw;
-    }
-    break;
-  }
-  default:
-    break;
-  }
-
-  return true;
-}
-
-bool JpegRotate90(unsigned char *buffer, int width, int height, int bpp)
-{
-  int  w, iw, ih, hw = 0;
-  int ix, iy = 0;
-  iw = width;
-  ih = height;
-  std::vector<unsigned char> data(width * height * bpp);
-  unsigned char *dataPtr = &data[0];
-  memcpy(dataPtr, buffer, width * height * bpp);
-  w = ih;
-  ih = iw;
-  iw = w;
-  hw = iw * ih;
-  hw = - hw - 1;
-  switch(bpp)
-  {
-  case 4:
-  {
-    RGBA8888Type *from, *to;
-    to = ((RGBA8888Type * )buffer) + iw  - 1;
-    from = (RGBA8888Type *)dataPtr;
-    for(ix = iw; -- ix >= 0;)
-    {
-      for(iy = ih; -- iy >= 0;)
-      {
-        *to = *from;
-        from += 1;
-        to += iw;
-      }
-      to += hw;
-    }
-    break;
-  }
-  case 3:
-  {
-    RGB888Type *from, *to;
-    to = ((RGB888Type * )buffer) + iw  - 1;
-    from = (RGB888Type *)dataPtr;
-    for(ix = iw; -- ix >= 0;)
-    {
-      for(iy = ih; -- iy >= 0;)
-      {
-        *to = *from;
-        from += 1;
-        to += iw;
-      }
-      to += hw;
-    }
-    break;
-  }
-  case 2:
-  {
-    RGB565Type *from, *to;
-    to = ((RGB565Type * )buffer) + iw  - 1;
-    from = (RGB565Type *)dataPtr;
-    for(ix = iw; -- ix >= 0;)
-    {
-      for(iy = ih; -- iy >= 0;)
-      {
-        *to = *from;
-        from += 1;
-        to += iw;
-      }
-      to += hw;
-    }
-    break;
-  }
-  case 1:
-  {
-    L8Type *from, *to;
-    to = ((L8Type * )buffer) + iw  - 1;
-    from = (L8Type *)dataPtr;
-    for(ix = iw; -- ix >= 0;)
-    {
-      for(iy = ih; -- iy >= 0;)
-      {
-        *to = *from;
-        from += 1;
-        to += iw;
-      }
-      to += hw;
-    }
-    break;
-  }
-  default:
-    break;
-  }
-
-  return true;
-}
-
-} // namespace TizenPlatform
-
-} // namespace Dali
-
index 4c6d783..c233fd5 100644 (file)
@@ -32,8 +32,6 @@ namespace Integration
   class Bitmap;
 }
 
-struct ImageAttributes;
-
 namespace TizenPlatform
 {
 
index e69d13c..c521ad2 100644 (file)
@@ -29,8 +29,6 @@ namespace Integration
   class Bitmap;
 }
 
-struct ImageAttributes;
-
 namespace TizenPlatform
 {
 
index 77b9422..484226b 100644 (file)
@@ -31,7 +31,6 @@ namespace Integration
 {
   class Bitmap;
 }
-struct ImageAttributes;
 
 namespace TizenPlatform
 {
index 6298cfc..30c94a5 100755 (executable)
@@ -28,7 +28,6 @@ namespace Integration
 {
   class Bitmap;
 }
-struct ImageAttributes;
 
 namespace TizenPlatform
 {