photosgallery/viewframework/texturemanager/src/glxbitmapdecoderwrapper.cpp
branchRCL_3
changeset 32 78ad99c24f08
parent 18 bcb43dc84c44
child 47 f9e827349359
equal deleted inserted replaced
30:a60acebbbd9d 32:78ad99c24f08
    30 #include <mglxcache.h>
    30 #include <mglxcache.h>
    31 #include <oommonitorsession.h>
    31 #include <oommonitorsession.h>
    32 namespace
    32 namespace
    33 {
    33 {
    34 const TInt KGlxDecodingThreshold = 3000000;
    34 const TInt KGlxDecodingThreshold = 3000000;
       
    35 const TInt KGlxDecodingThresholdDimension = 2000;
    35 
    36 
    36 
    37 
    37 // Photos low_ram_threshold [8.637 MB] as in oomconfig.xml
    38 // Photos low_ram_threshold [8.637 MB] as in oomconfig.xml
    38 const TInt KGlxCriticalRAMForPhotos = 9056550;
    39 const TInt KGlxCriticalRAMForPhotos = 9056550;
    39 const TInt KGlxDecodeBitmapFactor = 3;
    40 const TInt KGlxDecodeBitmapFactor = 3;
   111     if (iImageDecoder)
   112     if (iImageDecoder)
   112         {
   113         {
   113         delete iImageDecoder;
   114         delete iImageDecoder;
   114         iImageDecoder = NULL;
   115         iImageDecoder = NULL;
   115         }
   116         }
       
   117     
       
   118     CImageDecoder::TOptions options = (CImageDecoder::TOptions)
       
   119             ( CImageDecoder::EOptionNoDither | CImageDecoder::EOptionAlwaysThread );
       
   120 
   116     // Use extended JPEG decoder
   121     // Use extended JPEG decoder
   117     TRAPD( err, iImageDecoder = CExtJpegDecoder::FileNewL(
   122     TRAPD( err, iImageDecoder = CExtJpegDecoder::FileNewL(
   118             CExtJpegDecoder::EHwImplementation, iFs, aSourceFileName, CImageDecoder::EOptionNone ) );
   123             CExtJpegDecoder::EHwImplementation, iFs, aSourceFileName, options  ) );
   119     if ( KErrNone != err )
   124     if ( KErrNone != err )
   120         {
   125         {
   121         GLX_LOG_INFO( "DoDecodeImageL:: ESwImplementation" );
   126         GLX_LOG_INFO( "DoDecodeImageL:: ESwImplementation" );
   122         TRAP(err,iImageDecoder = CExtJpegDecoder::FileNewL(
   127         TRAP(err,iImageDecoder = CExtJpegDecoder::FileNewL(
   123                 CExtJpegDecoder::ESwImplementation, iFs, aSourceFileName, CImageDecoder::EOptionNone ) );
   128                 CExtJpegDecoder::ESwImplementation, iFs, aSourceFileName, options  ) );
   124         if ( KErrNone != err )
   129         if ( KErrNone != err )
   125             {
   130             {
   126             GLX_LOG_INFO( "DoDecodeImageL:: CImageDecoder" );
   131             GLX_LOG_INFO( "DoDecodeImageL:: CImageDecoder" );
   127             // Not a JPEG - use standard decoder
   132             // Not a JPEG - use standard decoder
   128             iImageDecoder = CImageDecoder::FileNewL( iFs, aSourceFileName, CImageDecoder::EOptionNone );
   133             iImageDecoder = CImageDecoder::FileNewL( iFs, aSourceFileName, options  );
   129             isExtDecoderUsed = EFalse;
   134             isExtDecoderUsed = EFalse;
   130             }
   135             }
   131         }
   136         }
   132 #ifdef _DEBUG
   137 #ifdef _DEBUG
   133         iStopTime.HomeTime();
   138         iStopTime.HomeTime();
   180 //
   185 //
   181 void CGlxBitmapDecoderWrapper::DecodeImageL()
   186 void CGlxBitmapDecoderWrapper::DecodeImageL()
   182     {
   187     {
   183     TRACER("CGlxBitmapDecoderWrapper:: DecodeImageL ");
   188     TRACER("CGlxBitmapDecoderWrapper:: DecodeImageL ");
   184     TReal32 mFactor = 1;
   189     TReal32 mFactor = 1;
       
   190     TReal32 mFactor1 = 1;
       
   191     TReal32 mFactor2 = 1;
   185     //Set Size according to level and state
   192     //Set Size according to level and state
   186     TReal32 width = iOriginalSize.iWidth;
   193     TReal32 width = iOriginalSize.iWidth;
   187     TReal32 height = iOriginalSize.iHeight;
   194     TReal32 height = iOriginalSize.iHeight;
   188     GLX_LOG_INFO1("DecodeImageL:width=%f", width);
   195     GLX_LOG_INFO1("DecodeImageL:width=%f", width);
   189     GLX_LOG_INFO1("DecodeImageL:height=%f",height);
   196     GLX_LOG_INFO1("DecodeImageL:height=%f",height);
   190 
       
   191     
   197     
   192     if ( KGlxDecodingThreshold < (width * height))
   198     if ( KGlxDecodingThreshold < (width * height))
   193         {
   199         {
   194         mFactor = TReal32(KGlxDecodingThreshold) / (width*height);
   200         mFactor1 = TReal32(KGlxDecodingThreshold) / (width*height);
   195         }
   201         GLX_LOG_INFO1("mFactor1 =%f",mFactor1);
       
   202         }
       
   203     
       
   204     if ( KGlxDecodingThresholdDimension < width || KGlxDecodingThresholdDimension < height)
       
   205         {
       
   206         mFactor2 = TReal32(KGlxDecodingThresholdDimension) / Max(width, height);
       
   207         GLX_LOG_INFO1("mFactor2 =%f",mFactor2);
       
   208         }
       
   209 
       
   210     mFactor = Min(mFactor1 , mFactor2);
       
   211     GLX_LOG_INFO1("Final mFactor =%f",mFactor);
   196 
   212 
   197     // create the destination bitmap
   213     // create the destination bitmap
   198     if(!iBitmap)
   214     if(!iBitmap)
   199         {
   215         {
   200         TInt freeMemory = 0;
   216         TInt freeMemory = 0;