photosgallery/viewframework/tvout/src/glxhdmisurfaceupdater.cpp
branchRCL_3
changeset 35 420f6808bf21
parent 25 191387a8b767
child 47 f9e827349359
equal deleted inserted replaced
32:78ad99c24f08 35:420f6808bf21
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2  * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:    
    14  * Description:    
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include <graphics/surface.h>
    18 #include <graphics/surface.h>
    19 #include <graphics/surfacemanager.h>
    19 #include <graphics/surfacemanager.h>
    20 #include <graphics/surfaceupdateclient.h>
    20 #include <graphics/surfaceupdateclient.h>
       
    21 #include <graphics/surface_hints.h>
    21 #include <e32math.h>
    22 #include <e32math.h>
    22 #include <apgcli.h>
    23 #include <apgcli.h>
    23 
    24 
    24 #include <imageconversion.h> 
    25 #include <imageconversion.h> 
    25 #include <fbs.h>
    26 #include <fbs.h>
    43 _LIT(KMimeJpg,"image/jpg");
    44 _LIT(KMimeJpg,"image/jpg");
    44 
    45 
    45 // -----------------------------------------------------------------------------
    46 // -----------------------------------------------------------------------------
    46 // NewLC
    47 // NewLC
    47 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    48 CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL(RWindow* aWindow, const TDesC& aImageFile, 
    49 CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL(RWindow* aWindow,
    49                                                       CFbsBitmap* aFsBitmap, 
    50         const TDesC& aImageFile, const TDesC& aNextImageFile,
    50                                                       MGlxGenCallback* aCallBack)
    51         CFbsBitmap* aFsBitmap, MGlxGenCallback* aCallBack,
       
    52         MGlxHDMIDecoderObserver& aDecoderObserver)
    51     {
    53     {
    52     TRACER("CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL()");
    54     TRACER("CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL()");
    53     CGlxHdmiSurfaceUpdater* self = new (ELeave) CGlxHdmiSurfaceUpdater(aWindow, aCallBack);
    55     CGlxHdmiSurfaceUpdater* self = new (ELeave) CGlxHdmiSurfaceUpdater(
       
    56             aWindow, aCallBack, aDecoderObserver);
    54     CleanupStack::PushL(self);
    57     CleanupStack::PushL(self);
    55     self->ConstructL(aFsBitmap,aImageFile);
    58     self->ConstructL(aFsBitmap, aImageFile, aNextImageFile);
    56     CleanupStack::Pop(self);
    59     CleanupStack::Pop(self);
    57     return self;
    60     return self;
    58     }
    61     }
    59 
    62 
    60 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    61 // destructor 
    64 // destructor 
    62 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    63 CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater()
    66 CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater()
    64     {
    67     {
    65     TRACER("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater()");
    68     TRACER("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater()");
       
    69     GLX_LOG_INFO(
       
    70             "CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater()-EHdmiDisconnected");
       
    71     TRAP_IGNORE(iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDisconnected));
       
    72 
    66     ReleaseContent();
    73     ReleaseContent();
    67     if(iWindow)
    74     if (iWindow)
    68         {
    75         {
    69         iWindow->RemoveBackgroundSurface(ETrue);
    76         iWindow->RemoveBackgroundSurface(ETrue);
    70         }
    77         }
    71 	if(iTimer && iTimer->IsActive())	 	 	 // Check for a CPeriodic Instance
    78     if (iTimer && iTimer->IsActive()) // Check for a CPeriodic Instance
    72         {
    79         {
    73         iTimer->Cancel();
    80         iTimer->Cancel();
    74         }
    81         }
    75     delete iTimer;   
    82     delete iTimer;
    76     if (iGlxDecoderAO)
    83     if (iGlxDecoderAO)
    77         {
    84         {
    78         delete iGlxDecoderAO;
    85         delete iGlxDecoderAO;
    79         }        
    86         }
    80     iGlxDecoderAO = NULL;
    87     iGlxDecoderAO = NULL;
    81     iFsSession.Close();
    88     iFsSession.Close();
    82     if (iSurfManager)
    89     if (iSurfManager)
    83         {
    90         {
    84         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater() - Close"); 
    91         GLX_LOG_INFO(
    85         if(iSurfSessionConnected)
    92                 "CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater() - Close");
       
    93         if (iSurfSessionConnected)
    86             {
    94             {
    87             iSurfUpdateSession.Close();
    95             iSurfUpdateSession.Close();
    88             }
    96             }
    89         if (iSurfChunk)
    97         if (iSurfChunk)
    90             {
    98             {
    91             iSurfChunk->Close();
    99             iSurfChunk->Close();
    92             }            
   100             }
    93         delete iSurfChunk;
   101         delete iSurfChunk;
    94         iSurfChunk = NULL;        
   102         iSurfChunk = NULL;
    95         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater(). iSurfManager->CloseSurface()"); 
   103         GLX_LOG_INFO(
       
   104                 "CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater(). iSurfManager->CloseSurface()");
    96         iSurfManager->CloseSurface(iSurfId);
   105         iSurfManager->CloseSurface(iSurfId);
    97         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater(). iSurfManager->Close()"); 
   106         GLX_LOG_INFO(
       
   107                 "CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater(). iSurfManager->Close()");
    98         iSurfManager->Close();
   108         iSurfManager->Close();
    99         delete iSurfManager;
   109         delete iSurfManager;
   100         iSurfManager = NULL;       
   110         iSurfManager = NULL;
   101         }
   111         }
   102     }
   112     }
   103 
   113 
   104 // -----------------------------------------------------------------------------
   114 // -----------------------------------------------------------------------------
   105 // ReleaseContent 
   115 // ReleaseContent 
   106 // -----------------------------------------------------------------------------
   116 // -----------------------------------------------------------------------------
   107 void CGlxHdmiSurfaceUpdater::ReleaseContent()
   117 void CGlxHdmiSurfaceUpdater::ReleaseContent()
   108     {
   118     {
   109     TRACER("void CGlxHdmiSurfaceUpdater::ReleaseContent()"); 
   119     TRACER("void CGlxHdmiSurfaceUpdater::ReleaseContent()");
   110     if ( iGlxDecoderAO )
   120     if (iGlxDecoderAO)
   111         {
   121         {
   112         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -1");
   122         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -1");
   113         iGlxDecoderAO->Cancel();
   123         iGlxDecoderAO->Cancel();
   114         }
   124         }
   115     if (iFsBitmap)
   125     if (iFsBitmap)
   116         {
   126         {
   117         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -2");
   127         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -2");
   118         delete iFsBitmap;
   128         delete iFsBitmap;
   119         iFsBitmap = NULL;
   129         iFsBitmap = NULL;
   120         }
   130         }
   121     for (TInt i=0; i<=2 ; i++)
   131     for (TInt i = 0; i <= 2; i++)
   122         {
   132         {
   123         GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ReleaseContent() -3, %d", i);
   133         GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ReleaseContent() -3, %d", i);
   124         delete iDecodedBitmap[i];
   134         delete iDecodedBitmap[i];
   125         iDecodedBitmap[i]= NULL;
   135         iDecodedBitmap[i] = NULL;
   126         }
   136         }
   127     GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -4");
   137     GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -4");
   128     if(iSurfBufferAO && iSurfBufferAO->IsActive())
   138     if (iSurfBufferAO && iSurfBufferAO->IsActive())
   129         {
   139         {
   130         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -5");
   140         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -5");
   131 		iSurfBufferAO->Cancel();
   141         iSurfBufferAO->Cancel();
   132         }
   142         }
   133     if ( iImageDecoder )
   143     if (iImageDecoder)
   134         {
   144         {
   135         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -6");
   145         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -6");
   136         delete iImageDecoder;
   146         delete iImageDecoder;
   137         iImageDecoder = NULL;    
   147         iImageDecoder = NULL;
   138         }
   148         }
   139     if (iSurfSessionConnected &&  iSurfManager)
   149     if (iSurfSessionConnected && iSurfManager)
   140         {
   150         {
   141         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -7");
   151         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -7");
   142         iSurfUpdateSession.CancelAllUpdateNotifications();
   152         iSurfUpdateSession.CancelAllUpdateNotifications();
   143         }
   153         }
   144     if (iImagePath)
   154     if (iImagePath)
   150 
   160 
   151 // -----------------------------------------------------------------------------
   161 // -----------------------------------------------------------------------------
   152 // CTor 
   162 // CTor 
   153 // -----------------------------------------------------------------------------
   163 // -----------------------------------------------------------------------------
   154 CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater(RWindow* aWindow,
   164 CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater(RWindow* aWindow,
   155                           MGlxGenCallback* aCallBack): 
   165         MGlxGenCallback* aCallBack, MGlxHDMIDecoderObserver& aDecoderObserver) :
   156                           iWindow(aWindow), iCallBack(aCallBack), 
   166     iWindow(aWindow), iCallBack(aCallBack), iShwFsThumbnail(ETrue),
   157                           iShwFsThumbnail(ETrue), iIsNonJpeg(EFalse)
   167             iIsNonJpeg(EFalse), iDecoderObserver(aDecoderObserver)
   158     {
   168     {
   159     TRACER("CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater()");
   169     TRACER("CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater()");
   160     // Implement nothing here
   170     // Implement nothing here
   161     }
   171     }
   162 
   172 
   163 // -----------------------------------------------------------------------------
   173 // -----------------------------------------------------------------------------
   164 // ConstructL 
   174 // ConstructL 
   165 // -----------------------------------------------------------------------------
   175 // -----------------------------------------------------------------------------
   166 void CGlxHdmiSurfaceUpdater::ConstructL(CFbsBitmap* aFsBitmap, const TDesC& aImageFile)
   176 void CGlxHdmiSurfaceUpdater::ConstructL(CFbsBitmap* aFsBitmap,
       
   177         const TDesC& aImageFile, const TDesC& aNextImageFile)
   167     {
   178     {
   168     TRACER("CGlxHdmiSurfaceUpdater::ConstructL()");
   179     TRACER("CGlxHdmiSurfaceUpdater::ConstructL()");
   169     // Initiate the HDMI by assigning the necessary values
   180     // Initiate the HDMI by assigning the necessary values
   170     InitiateHdmiL(aFsBitmap,aImageFile);
   181     InitiateHdmiL(aFsBitmap, aImageFile, aNextImageFile);
   171     
   182 
   172     TInt error = iFsSession.Connect ();
   183     TInt error = iFsSession.Connect();
   173     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() FsSession Connect error = %d", error);
   184     GLX_LOG_INFO1(
       
   185             "CGlxHdmiSurfaceUpdater::ConstructL() FsSession Connect error = %d",
       
   186             error);
   174     User::LeaveIfError(error);
   187     User::LeaveIfError(error);
   175     iShiftToCloning = EFalse;
   188     iShiftToCloning = EFalse;
       
   189     iDecodingCurrent = EFalse;
       
   190     iDecodingNext = EFalse;
       
   191     iDecodingNextFailed = EFalse;
   176     // Create the active object
   192     // Create the active object
   177     iGlxDecoderAO = CGlxHdmiDecoderAO::NewL(this);
   193     iGlxDecoderAO = CGlxHdmiDecoderAO::NewL(this);
   178 
   194 
   179     // Create the HDMI Decoder
   195     // Create the HDMI Decoder
   180     CreateImageDecoderL();
   196     CreateImageDecoderL();
   181 
   197 
   182     // Create the Bitmap
   198     // Create the Bitmap
   183     CreateBitmapL();
   199     CreateBitmapL();
   184 
   200 
   185     // Create the surface and AO for updating the surface
   201     // Create the surface and AO for updating the surface
   186     TRAP_IGNORE(CreateHdmiL());
   202     TRAP_IGNORE( CreateHdmiL());
   187 
   203 
   188     if(iSurfManager)
   204     if (iSurfManager)
   189         {
   205         {
   190         error = iSurfUpdateSession.Connect();
   206         error = iSurfUpdateSession.Connect();
   191         GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() Surface update Session Connect error = %d", error);
   207         GLX_LOG_INFO1(
       
   208                 "CGlxHdmiSurfaceUpdater::ConstructL() Surface update Session Connect error = %d",
       
   209                 error);
   192         User::LeaveIfError(error);
   210         User::LeaveIfError(error);
   193         iSurfSessionConnected = ETrue;
   211         iSurfSessionConnected = ETrue;
   194 
   212 
   195         ShowFsThumbnailL();
   213         if (!aNextImageFile.Length())
       
   214             {
       
   215             ShowFsThumbnailL();
       
   216             }
       
   217         else
       
   218             {
       
   219             // Modify the surface position with respect to the buffer size 
       
   220             ModifySurfacePostion();
       
   221             }
   196 #ifdef _DEBUG
   222 #ifdef _DEBUG
   197         iStartTime.HomeTime();
   223         iStartTime.HomeTime();
   198 #endif
   224 #endif
   199         //start decoding the image    
   225         //start decoding the image    
   200         iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex],iImageDecoder);   
   226         iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex],
   201         }
   227                 iImageDecoder);
   202     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   228         iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingStarted);
       
   229         iDecodingCurrent = ETrue;
       
   230         }
       
   231     iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
   203     }
   232     }
   204 
   233 
   205 // -----------------------------------------------------------------------------
   234 // -----------------------------------------------------------------------------
   206 // UpdateNewImageL 
   235 // UpdateNewImageL 
   207 // -----------------------------------------------------------------------------
   236 // -----------------------------------------------------------------------------
   208 void CGlxHdmiSurfaceUpdater::UpdateNewImageL(const TDesC& aImageFile,CFbsBitmap* aFsBitmap)
   237 void CGlxHdmiSurfaceUpdater::UpdateNewImageL(const TDesC& aImageFile,
       
   238         const TDesC& aNextImageFile, CFbsBitmap* aFsBitmap)
   209     {
   239     {
   210     TRACER("CGlxHdmiSurfaceUpdater::UpdateNewImageL()");
   240     TRACER("CGlxHdmiSurfaceUpdater::UpdateNewImageL()");
   211     ReleaseContent();   
   241     if (!aImageFile.CompareC(*iImagePath) && !iDecodingCurrent
       
   242             && !iDecodingNext)
       
   243         {
       
   244         iNextImagePath = aNextImageFile.Alloc();
       
   245         GLX_LOG_INFO(
       
   246                 "CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Decoded Image is ready ");
       
   247         if (iDecodingNextFailed)
       
   248             {
       
   249             ShiftToCloningMode();
       
   250             iDecodingNextFailed = EFalse;
       
   251             }
       
   252         else if (iSurfManager)
       
   253             {
       
   254             iShwFsThumbnail = EFalse;
       
   255             if (iIsNonJpeg)
       
   256                 {
       
   257                 // if this is non jpeg image, make sure we scale the bitmap
       
   258                 ScaleDecodedBitmapL( ENonJpgDecodedBitmapIndex);
       
   259                 }
       
   260             // Modify the surface position with respect to the buffer size 
       
   261             ModifySurfacePostion();
       
   262             ProcessTvImage();
       
   263             iWindow->SetBackgroundSurface(iConfig, ETrue);
       
   264             iBitmapReady = ETrue;
       
   265             return;
       
   266             }
       
   267         }
       
   268     else
       
   269         {
       
   270         ReleaseContent();
       
   271         }
   212     // Initiate the HDMI by assigning the necessary values
   272     // Initiate the HDMI by assigning the necessary values
   213     InitiateHdmiL(aFsBitmap,aImageFile);
   273     InitiateHdmiL(aFsBitmap, aImageFile, aNextImageFile);
   214     //Cancel the zoom timers if any
   274     //Cancel the zoom timers if any
   215     if(iTimer->IsActive())
   275     if (iTimer->IsActive())
   216         {
   276         {
   217         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Cancel Timer");
   277         GLX_LOG_INFO(
       
   278                 "CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Cancel Timer");
   218         iTimer->Cancel();
   279         iTimer->Cancel();
   219         }
   280         }
   220 
   281 
   221     // Create the HDMI Decoder
   282     // Create the HDMI Decoder
   222     CreateImageDecoderL();
   283     CreateImageDecoderL();
   223 
   284 
   224     // Create the Bitmap
   285     // Create the Bitmap
   225     CreateBitmapL();
   286     CreateBitmapL();
   226     if(iSurfManager)
   287     if (iSurfManager)
   227         {
   288         {
   228         // Create the surface and AO for updating the surface
   289         // Create the surface and AO for updating the surface
   229         CreateHdmiL(EFalse);
   290         CreateHdmiL( EFalse);
   230         }
   291         }
   231     else
   292     else
   232         {
   293         {
   233         TRAP_IGNORE(CreateHdmiL(ETrue));
   294         TRAP_IGNORE( CreateHdmiL(ETrue));
   234         }
   295         }
   235 
   296 
   236 #ifdef _DEBUG
   297 #ifdef _DEBUG
   237     iStartTime.HomeTime();
   298     iStartTime.HomeTime();
   238 #endif
   299 #endif
   239     if(iSurfManager)
   300     if (iSurfManager)
   240         {
   301         {
   241         // Show FS Thumbnail
   302         // Show FS Thumbnail
   242         ShowFsThumbnailL();
   303         ShowFsThumbnailL();
   243         //start decoding the image
   304         //start decoding the image
   244         iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex],iImageDecoder);
   305         iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex],
       
   306                 iImageDecoder);
       
   307         iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingStarted);
       
   308         iDecodingCurrent = ETrue;
   245         }
   309         }
   246     }
   310     }
   247 
   311 
   248 // -----------------------------------------------------------------------------
   312 // -----------------------------------------------------------------------------
   249 // InitiateHdmiL 
   313 // InitiateHdmiL 
   250 // -----------------------------------------------------------------------------
   314 // -----------------------------------------------------------------------------
   251 void CGlxHdmiSurfaceUpdater::InitiateHdmiL(CFbsBitmap* aFsBitmap,const TDesC& aImageFile)
   315 void CGlxHdmiSurfaceUpdater::InitiateHdmiL(CFbsBitmap* aFsBitmap,
       
   316         const TDesC& aImageFile, const TDesC& aNextImageFile)
   252     {
   317     {
   253     TRACER("CGlxHdmiSurfaceUpdater::InitiateHdmiL()");
   318     TRACER("CGlxHdmiSurfaceUpdater::InitiateHdmiL()");
   254     iImagePath = aImageFile.Alloc();
   319     iImagePath = aImageFile.Alloc();
       
   320     iNextImagePath = aNextImageFile.Alloc();
   255     iFsBitmap = new (ELeave) CFbsBitmap;
   321     iFsBitmap = new (ELeave) CFbsBitmap;
   256     iFsBitmap->Duplicate(aFsBitmap->Handle());
   322     iFsBitmap->Duplicate(aFsBitmap->Handle());
   257     iIsNonJpeg = EFalse;
   323     iIsNonJpeg = EFalse;
   258     iTvScreenSize = iWindow->Size();
   324     iTvScreenSize = iWindow->Size();
   259 
   325 
   260     iBitmapReady = EFalse;
   326     iBitmapReady = EFalse;
   261     iLeftCornerForZoom.iX = 0; 
   327     iLeftCornerForZoom.iX = 0;
   262     iLeftCornerForZoom.iY = 0;
   328     iLeftCornerForZoom.iY = 0;
   263 
   329 
   264     iZoom = ETrue;
   330     iZoom = ETrue;
   265     }
   331     }
   266 
   332 
   268 // CreateHDMI 
   334 // CreateHDMI 
   269 // -----------------------------------------------------------------------------
   335 // -----------------------------------------------------------------------------
   270 void CGlxHdmiSurfaceUpdater::CreateHdmiL(TBool aCreateSurface)
   336 void CGlxHdmiSurfaceUpdater::CreateHdmiL(TBool aCreateSurface)
   271     {
   337     {
   272     TRACER("CGlxHdmiSurfaceUpdater::CreateHdmiL()");
   338     TRACER("CGlxHdmiSurfaceUpdater::CreateHdmiL()");
   273     
   339 
   274     if (aCreateSurface)
   340     if (aCreateSurface)
   275         {
   341         {
   276         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::CreateHdmiL() Create Surface");
   342         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::CreateHdmiL() Create Surface");
   277         CreateSurfaceL();        
   343         CreateSurfaceL();
   278         }
   344         }
   279     
   345 
   280     // Active objects for double buffered draw signalling
   346     // Active objects for double buffered draw signalling
   281     if(!iSurfBufferAO)
   347     if (!iSurfBufferAO)
   282         {
   348         {
   283         iSurfBufferAO = new(ELeave) CGlxActiveCallBack(TCallBack(SurfBuffer0Ready, this),
   349         iSurfBufferAO = new (ELeave) CGlxActiveCallBack(TCallBack(
   284                     CActive::EPriorityStandard-1);
   350                 SurfBuffer0ReadyL, this), CActive::EPriorityStandard - 1);
   285         CActiveScheduler::Add(iSurfBufferAO);    
   351         CActiveScheduler::Add( iSurfBufferAO);
   286         }
   352         }
   287     }
   353     }
   288 
   354 
   289 // -----------------------------------------------------------------------------
   355 // -----------------------------------------------------------------------------
   290 // CreateSurfaceL 
   356 // CreateSurfaceL 
   291 // -----------------------------------------------------------------------------
   357 // -----------------------------------------------------------------------------
   292 void CGlxHdmiSurfaceUpdater::CreateSurfaceL()
   358 void CGlxHdmiSurfaceUpdater::CreateSurfaceL()
   293     {
   359     {
   294     TRACER("CGlxHdmiSurfaceUpdater::CreateSurfaceL()");
   360     TRACER("CGlxHdmiSurfaceUpdater::CreateSurfaceL()");
   295     iSurfManager = new(ELeave) RSurfaceManager();
   361     iSurfManager = new (ELeave) RSurfaceManager();
   296     TInt error = iSurfManager->Open();
   362     TInt error = iSurfManager->Open();
   297     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::CreateSurfaceL Open Surface manager error = %d", error);
   363     GLX_LOG_INFO1(
       
   364             "CGlxHdmiSurfaceUpdater::CreateSurfaceL Open Surface manager error = %d",
       
   365             error);
   298     User::LeaveIfError(error);
   366     User::LeaveIfError(error);
   299     
   367 
       
   368     //Need to set the surface Hint for the surface to indicate
       
   369     //that photos do not need overscan compensation and the image will
       
   370     //be displayed in 720p resolution. 
       
   371     //Refer error: HJVA-85DD25 for more info.
       
   372     RSurfaceManager::THintPair surfHint;
       
   373     TUid uid(KNullUid);
       
   374     uid.iUid = surfaceHints::KSurfaceContent;
       
   375     surfHint.Set(uid, surfaceHints::EStillImage, EFalse);
       
   376 
   300     RSurfaceManager::TSurfaceCreationAttributesBuf attributes;
   377     RSurfaceManager::TSurfaceCreationAttributesBuf attributes;
   301     attributes().iPixelFormat           = EUidPixelFormatARGB_8888;// EUidPixelFormatYUV_420Planar;
   378     attributes().iPixelFormat = EUidPixelFormatARGB_8888;// EUidPixelFormatYUV_420Planar;
   302     attributes().iSize                  = iTvScreenSize;
   379     attributes().iSize = iTvScreenSize;
   303     
   380 
   304     attributes().iBuffers               = 1;
   381     attributes().iBuffers = 1;
   305     attributes().iStride                = iTvScreenSize.iWidth * KMulFactorToCreateBitmap;  
   382     attributes().iStride = iTvScreenSize.iWidth * KMulFactorToCreateBitmap;
   306     attributes().iAlignment             = KMulFactorToCreateBitmap;
   383     attributes().iAlignment = KMulFactorToCreateBitmap;
   307     attributes().iContiguous            = EFalse;
   384     attributes().iContiguous = EFalse;
   308     attributes().iMappable              = ETrue;
   385     attributes().iMappable = ETrue;
   309         
   386     attributes().iSurfaceHints = &surfHint;
       
   387     attributes().iHintCount = 1;
       
   388 
   310     error = iSurfManager->CreateSurface(attributes, iSurfId);
   389     error = iSurfManager->CreateSurface(attributes, iSurfId);
   311     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::CreateSurfaceL, Creating surface error : %d",error);
   390     GLX_LOG_INFO1(
   312     if(error == KErrNoMemory)
   391             "CGlxHdmiSurfaceUpdater::CreateSurfaceL, Creating surface error : %d",
   313     	{
   392             error);
   314     	GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::CreateSurfaceL(). iSurfManager->Close()"); 
   393     if (error == KErrNoMemory)
   315 		iSurfManager->Close();
   394         {
   316 		delete iSurfManager;
   395         GLX_LOG_INFO(
   317 		iSurfManager = NULL;
   396                 "CGlxHdmiSurfaceUpdater::CreateSurfaceL(). iSurfManager->Close()");
   318     	if(iShiftToCloning == EFalse)
   397         iSurfManager->Close();
   319     		{
   398         delete iSurfManager;
   320     		GlxGeneralUiUtilities::ShowErrorNoteL(error); // Show Low Memory Popup Once before shifting to Cloning Mode
   399         iSurfManager = NULL;
   321     		iShiftToCloning = ETrue;
   400         if (iShiftToCloning == EFalse)
   322     		}
   401             {
   323     	ShiftToCloningMode();	 	 	 	 	 	 	  // Shift from Posting Mode to Cloning Mode
   402             GlxGeneralUiUtilities::ShowErrorNoteL(error); // Show Low Memory Popup Once before shifting to Cloning Mode
   324     	}
   403             iShiftToCloning = ETrue;
       
   404             }
       
   405         ShiftToCloningMode(); // Shift from Posting Mode to Cloning Mode
       
   406         }
   325     User::LeaveIfError(error);
   407     User::LeaveIfError(error);
   326         
   408 
   327     //Map the surface and stride the surface info
   409     //Map the surface and stride the surface info
   328     MapSurfaceL();
   410     MapSurfaceL();
   329     // Set the Configuration to the surface ID when creating a surface
   411     // Set the Configuration to the surface ID when creating a surface
   330     iConfig.SetSurfaceId(iSurfId);
   412     iConfig.SetSurfaceId(iSurfId);
   331     }
   413     }
   334 // MapSurfaceL 
   416 // MapSurfaceL 
   335 // -----------------------------------------------------------------------------
   417 // -----------------------------------------------------------------------------
   336 void CGlxHdmiSurfaceUpdater::MapSurfaceL()
   418 void CGlxHdmiSurfaceUpdater::MapSurfaceL()
   337     {
   419     {
   338     TRACER("CGlxHdmiSurfaceUpdater::MapSurfaceL()");
   420     TRACER("CGlxHdmiSurfaceUpdater::MapSurfaceL()");
   339     
   421 
   340     //Create chunk to map it to the surface ID.
   422     //Create chunk to map it to the surface ID.
   341     iSurfChunk = new(ELeave) RChunk();
   423     iSurfChunk = new (ELeave) RChunk();
   342     User::LeaveIfNull(iSurfChunk);    
   424     User::LeaveIfNull( iSurfChunk);
   343     TInt error = iSurfManager->MapSurface(iSurfId, *iSurfChunk);
   425     TInt error = iSurfManager->MapSurface(iSurfId, *iSurfChunk);
   344     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::MapSurfaceL(), MapSurface error : %d",error);
   426     GLX_LOG_INFO1(
       
   427             "CGlxHdmiSurfaceUpdater::MapSurfaceL(), MapSurface error : %d",
       
   428             error);
   345     User::LeaveIfError(error);
   429     User::LeaveIfError(error);
   346     
   430 
   347     // Get the info from the surfaceManager
   431     // Get the info from the surfaceManager
   348     // and store pointers to the pixel data
   432     // and store pointers to the pixel data
   349     RSurfaceManager::TInfoBuf info;
   433     RSurfaceManager::TInfoBuf info;
   350     error = iSurfManager->SurfaceInfo(iSurfId, info);
   434     error = iSurfManager->SurfaceInfo(iSurfId, info);
   351     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::MapSurfaceL(), SurfaceInfo error : %d",error);
   435     GLX_LOG_INFO1(
   352     User::LeaveIfError(error);  
   436             "CGlxHdmiSurfaceUpdater::MapSurfaceL(), SurfaceInfo error : %d",
   353     
   437             error);
   354     iSurfaceStride = info().iStride;    
   438     User::LeaveIfError(error);
       
   439 
       
   440     iSurfaceStride = info().iStride;
   355     TInt offset = 0;
   441     TInt offset = 0;
   356     iSurfManager->GetBufferOffset( iSurfId, 0,offset);
   442     iSurfManager->GetBufferOffset(iSurfId, 0, offset);
   357     iSurfBuffer = iSurfChunk->Base()+offset;
   443     iSurfBuffer = iSurfChunk->Base() + offset;
   358     }
   444     }
   359 
   445 
   360 // -----------------------------------------------------------------------------
   446 // -----------------------------------------------------------------------------
   361 // SurfBuffer0Ready 
   447 // SurfBuffer0ReadyL 
   362 // -----------------------------------------------------------------------------
   448 // -----------------------------------------------------------------------------
   363 TInt CGlxHdmiSurfaceUpdater::SurfBuffer0Ready(TAny* /*aObject*/)
   449 TInt CGlxHdmiSurfaceUpdater::SurfBuffer0ReadyL(TAny* aObject)
   364     {
   450     {
   365     TRACER("CGlxHdmiSurfaceUpdater::SurfBuffer0Ready()");
   451     TRACER("CGlxHdmiSurfaceUpdater::SurfBuffer0ReadyL()");
       
   452     CGlxHdmiSurfaceUpdater* self =
       
   453             reinterpret_cast<CGlxHdmiSurfaceUpdater*> (aObject);
       
   454     if (!self->iShwFsThumbnail)
       
   455         {
       
   456         self->iDecodingCurrent = EFalse;
       
   457         if (self->iNextImagePath->Length())
       
   458             {
       
   459             self->DecodeNextImageL();
       
   460             }
       
   461         else
       
   462             {
       
   463             self->iDecoderObserver.HandleHDMIDecodingEventL(
       
   464                     EHdmiDecodingCompleted);
       
   465             }
       
   466         }
   366     return ETrue;
   467     return ETrue;
   367     }
   468     }
   368 
   469 
   369 // -----------------------------------------------------------------------------
   470 // -----------------------------------------------------------------------------
   370 // Refresh 
   471 // Refresh 
   371 // -----------------------------------------------------------------------------
   472 // -----------------------------------------------------------------------------
   372 void CGlxHdmiSurfaceUpdater::Refresh()
   473 void CGlxHdmiSurfaceUpdater::Refresh()
   373     {
   474     {
   374     TRACER("CGlxHdmiSurfaceUpdater::Refresh()");
   475     TRACER("CGlxHdmiSurfaceUpdater::Refresh()");
   375     // copy the decoded bitmap on to the surface
   476     // copy the decoded bitmap on to the surface
   376     SwapBuffers();     
   477     SwapBuffers();
   377 
   478 
   378     // refresh the window
   479     // refresh the window
   379     iCallBack->DoGenCallback();       
   480     iCallBack->DoGenCallback();
   380     }
   481     }
   381 
   482 
   382 // -----------------------------------------------------------------------------
   483 // -----------------------------------------------------------------------------
   383 // SwapBuffers
   484 // SwapBuffers
   384 // This is used to sawp the buffers shown and to be shown 
   485 // This is used to sawp the buffers shown and to be shown 
   385 // After this is done, a refresh to the window should be done to refresh the TV
   486 // After this is done, a refresh to the window should be done to refresh the TV
   386 // -----------------------------------------------------------------------------
   487 // -----------------------------------------------------------------------------
   387 void CGlxHdmiSurfaceUpdater::SwapBuffers()
   488 void CGlxHdmiSurfaceUpdater::SwapBuffers()
   388     {
   489     {
   389     TRACER("CGlxHdmiSurfaceUpdater::SwapBuffers()"); 
   490     TRACER("CGlxHdmiSurfaceUpdater::SwapBuffers()");
   390     TInt bitmapIndex = KErrNotFound;
   491     TInt bitmapIndex = KErrNotFound;
   391     
   492 
   392     if (iShwFsThumbnail) // show FS thumbnail
   493     if (iShwFsThumbnail) // show FS thumbnail
   393         {
   494         {
   394         bitmapIndex = EFSBitmapIndex;
   495         bitmapIndex = EFSBitmapIndex;
   395         }
   496         }
   396     else if(iIsNonJpeg && !iShwFsThumbnail) // this indicates it is non jpeg image and decoding finished
   497     else if (iIsNonJpeg && !iShwFsThumbnail) // this indicates it is non jpeg image and decoding finished
   397         {
   498         {
   398         bitmapIndex = ENonJpgDecodedBitmapIndex;
   499         bitmapIndex = ENonJpgDecodedBitmapIndex;
   399         }
   500         }
   400     else                // if none of the above state means it is jpeg image and decoding finished
   501     else // if none of the above state means it is jpeg image and decoding finished
   401         {
   502         {
   402         bitmapIndex = EJpgDecodedBitmapIndex;
   503         bitmapIndex = EJpgDecodedBitmapIndex;
   403         }
   504         }
   404         
   505 
   405     // Lock the heap so that subsequent call to dataaddress doesnt happen
   506     // Lock the heap so that subsequent call to dataaddress doesnt happen
   406     iDecodedBitmap[bitmapIndex]->LockHeap();    
   507     iDecodedBitmap[bitmapIndex]->LockHeap();
   407 
   508 
   408     // Data stride
   509     // Data stride
   409     TUint fs = iDecodedBitmap[bitmapIndex]->DataStride();    
   510     TUint fs = iDecodedBitmap[bitmapIndex]->DataStride();
   410 
   511 
   411     //Bitmap address from where the data has to be copied.
   512     //Bitmap address from where the data has to be copied.
   412     TUint8* from = (TUint8*)iDecodedBitmap[bitmapIndex]->DataAddress();
   513     TUint8* from = (TUint8*) iDecodedBitmap[bitmapIndex]->DataAddress();
   413 
   514 
   414     //surface chunk address to where the bitmap data has to be copied.
   515     //surface chunk address to where the bitmap data has to be copied.
   415     TUint8* to = (TUint8*)iSurfBuffer;    
   516     TUint8* to = (TUint8*) iSurfBuffer;
   416 
   517 
   417     // To buffer (32 bit colors)
   518     // To buffer (32 bit colors)
   418     TUint ts = iSurfaceStride;
   519     TUint ts = iSurfaceStride;
   419     //No of bytes to be copied on to the surface.
   520     //No of bytes to be copied on to the surface.
   420     TUint bytes = iDecodedBitmap[bitmapIndex]->SizeInPixels().iWidth * KMulFactorToCreateBitmap;
   521     TUint bytes = iDecodedBitmap[bitmapIndex]->SizeInPixels().iWidth
   421 
   522             * KMulFactorToCreateBitmap;
   422     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::SwapBuffers() - decodeSize width = %d and height %d",
   523 
   423             iDecodedBitmap[bitmapIndex]->SizeInPixels().iWidth, 
   524     GLX_LOG_INFO2(
   424             iDecodedBitmap[bitmapIndex]->SizeInPixels().iHeight );
   525             "CGlxHdmiSurfaceUpdater::SwapBuffers() - decodeSize width = %d and height %d",
       
   526             iDecodedBitmap[bitmapIndex]->SizeInPixels().iWidth,
       
   527             iDecodedBitmap[bitmapIndex]->SizeInPixels().iHeight);
   425 
   528 
   426     // Copy the bitmap on to the surface.
   529     // Copy the bitmap on to the surface.
   427     for (TInt y = iDecodedBitmap[bitmapIndex]->SizeInPixels().iHeight; y >0; y--)
   530     for (TInt y = iDecodedBitmap[bitmapIndex]->SizeInPixels().iHeight; y > 0; y--)
   428         {
   531         {
   429         Mem::Copy(to, from, bytes);        
   532         Mem::Copy(to, from, bytes);
   430         to += ts;        
   533         to += ts;
   431         from += fs;        
   534         from += fs;
   432         }            
   535         }
   433     iDecodedBitmap[bitmapIndex]->UnlockHeap();
   536     iDecodedBitmap[bitmapIndex]->UnlockHeap();
   434     }
   537     }
   435 
   538 
   436 // -----------------------------------------------------------------------------
   539 // -----------------------------------------------------------------------------
   437 // CreateBitmapL 
   540 // CreateBitmapL 
   438 // -----------------------------------------------------------------------------
   541 // -----------------------------------------------------------------------------
   439 void CGlxHdmiSurfaceUpdater::CreateBitmapL()
   542 void CGlxHdmiSurfaceUpdater::CreateBitmapL()
   440     {
   543     {
   441     TRACER("CGlxHdmiSurfaceUpdater::CreateBitmapL()");
   544     TRACER("CGlxHdmiSurfaceUpdater::CreateBitmapL()");
   442     TSize imageSize = iImageDecoder->FrameInfo().iOverallSizeInPixels;
   545     TSize imageSize = iImageDecoder->FrameInfo().iOverallSizeInPixels;
   443     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - bitmapsize=%d, %d",
   546     GLX_LOG_INFO2(
   444             imageSize.iWidth,imageSize.iHeight);
   547             "CGlxHdmiSurfaceUpdater::StartImageDecodeL() - bitmapsize=%d, %d",
       
   548             imageSize.iWidth, imageSize.iHeight);
   445     TReal32 scaleFactor = 0.0f;
   549     TReal32 scaleFactor = 0.0f;
   446     if (iTvScreenSize.iWidth * imageSize.iHeight > iTvScreenSize.iHeight
   550     if (iTvScreenSize.iWidth * imageSize.iHeight > iTvScreenSize.iHeight
   447             * imageSize.iWidth)
   551             * imageSize.iWidth)
   448         {
   552         {
   449         scaleFactor = (TReal32) iTvScreenSize.iHeight
   553         scaleFactor = (TReal32) iTvScreenSize.iHeight
   452     else
   556     else
   453         {
   557         {
   454         scaleFactor = (TReal32) iTvScreenSize.iWidth
   558         scaleFactor = (TReal32) iTvScreenSize.iWidth
   455                 / (TReal32) imageSize.iWidth;
   559                 / (TReal32) imageSize.iWidth;
   456         }
   560         }
   457     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - scaleFactor=%f",scaleFactor);
   561     GLX_LOG_INFO1(
       
   562             "CGlxHdmiSurfaceUpdater::StartImageDecodeL() - scaleFactor=%f",
       
   563             scaleFactor);
   458     iTargetBitmapSize.iHeight = imageSize.iHeight * scaleFactor;
   564     iTargetBitmapSize.iHeight = imageSize.iHeight * scaleFactor;
   459     iTargetBitmapSize.iWidth = imageSize.iWidth * scaleFactor;
   565     iTargetBitmapSize.iWidth = imageSize.iWidth * scaleFactor;
   460 	GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - targetBitmapSize=%d, %d",
   566     GLX_LOG_INFO2(
   461 	        iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight);
   567             "CGlxHdmiSurfaceUpdater::StartImageDecodeL() - targetBitmapSize=%d, %d",
       
   568             iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight);
   462     //create the bitmap for the required size
   569     //create the bitmap for the required size
   463     iDecodedBitmap[EJpgDecodedBitmapIndex] = new (ELeave) CFbsBitmap();
   570     iDecodedBitmap[EJpgDecodedBitmapIndex] = new (ELeave) CFbsBitmap();
   464     // to check if the Mimetype is supported by the decoder to to arbitary scaling
   571     // to check if the Mimetype is supported by the decoder to to arbitary scaling
   465     // if not then we recalculate the size
   572     // if not then we recalculate the size
   466     TInt err = iDecodedBitmap[EJpgDecodedBitmapIndex]->Create(ReCalculateSizeL(), EColor16MU);
   573     TInt err = iDecodedBitmap[EJpgDecodedBitmapIndex]->Create(
   467     User::LeaveIfNull(iDecodedBitmap[EJpgDecodedBitmapIndex]);
   574             ReCalculateSizeL(), EColor16MU);
       
   575     User::LeaveIfNull( iDecodedBitmap[EJpgDecodedBitmapIndex]);
   468     }
   576     }
   469 
   577 
   470 // -----------------------------------------------------------------------------
   578 // -----------------------------------------------------------------------------
   471 // DoesMimeTypeNeedsRecalculateL()
   579 // DoesMimeTypeNeedsRecalculateL()
   472 // -----------------------------------------------------------------------------
   580 // -----------------------------------------------------------------------------
   475     {
   583     {
   476     TRACER("CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL");
   584     TRACER("CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL");
   477     RApaLsSession session;
   585     RApaLsSession session;
   478     TDataType mimeType;
   586     TDataType mimeType;
   479     TUid uid;
   587     TUid uid;
   480     
   588 
   481     User::LeaveIfError( session.Connect() );
   589     User::LeaveIfError(session.Connect());
   482     CleanupClosePushL( session );
   590     CleanupClosePushL(session);
   483     User::LeaveIfError( session.AppForDocument( iImagePath->Des(), uid, mimeType ) );
   591     User::LeaveIfError(session.AppForDocument(iImagePath->Des(), uid,
       
   592             mimeType));
   484     CleanupStack::PopAndDestroy(&session);
   593     CleanupStack::PopAndDestroy(&session);
   485     
   594 
   486     if (mimeType.Des().Compare(KMimeJpeg)==0 ||
   595     if (mimeType.Des().Compare(KMimeJpeg) == 0 || mimeType.Des().Compare(
   487             mimeType.Des().Compare(KMimeJpg)==0)
   596             KMimeJpg) == 0)
   488         {
   597         {
   489         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL - jpeg");
   598         GLX_LOG_INFO(
       
   599                 "CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL - jpeg");
   490         return EFalse;
   600         return EFalse;
   491         }
   601         }
   492     else
   602     else
   493         {
   603         {
   494         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL - non jpeg");
   604         GLX_LOG_INFO(
   495         return ETrue; 
   605                 "CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL - non jpeg");
       
   606         return ETrue;
   496         }
   607         }
   497     }
   608     }
   498 
   609 
   499 // -----------------------------------------------------------------------------
   610 // -----------------------------------------------------------------------------
   500 // ReCalculateSize 
   611 // ReCalculateSize 
   501 // -----------------------------------------------------------------------------
   612 // -----------------------------------------------------------------------------
   502 TSize CGlxHdmiSurfaceUpdater::ReCalculateSizeL()
   613 TSize CGlxHdmiSurfaceUpdater::ReCalculateSizeL()
   503     {
   614     {
   504     TRACER("CGlxHdmiSurfaceUpdater::ReCalculateSizeL()");
   615     TRACER("CGlxHdmiSurfaceUpdater::ReCalculateSizeL()");
   505     if(DoesMimeTypeNeedsRecalculateL())
   616     if (DoesMimeTypeNeedsRecalculateL())
   506         {
   617         {
   507         iIsNonJpeg = ETrue;
   618         iIsNonJpeg = ETrue;
   508         TSize fullFrameSize = iImageDecoder->FrameInfo().iOverallSizeInPixels;
   619         TSize fullFrameSize = iImageDecoder->FrameInfo().iOverallSizeInPixels;
   509         // calculate the reduction factor on what size we need
   620         // calculate the reduction factor on what size we need
   510         TInt reductionFactor = iImageDecoder->ReductionFactor(fullFrameSize, iTargetBitmapSize);
   621         TInt reductionFactor = iImageDecoder->ReductionFactor(fullFrameSize,
       
   622                 iTargetBitmapSize);
   511         // get the reduced size onto destination size
   623         // get the reduced size onto destination size
   512         TSize destSize;
   624         TSize destSize;
   513         User::LeaveIfError(iImageDecoder->ReducedSize(fullFrameSize, reductionFactor, destSize));
   625         User::LeaveIfError(iImageDecoder->ReducedSize(fullFrameSize,
   514         GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ReCalculateSizeL() - destSize=%d, %d",destSize.iWidth,destSize.iHeight);
   626                 reductionFactor, destSize));
       
   627         GLX_LOG_INFO2(
       
   628                 "CGlxHdmiSurfaceUpdater::ReCalculateSizeL() - destSize=%d, %d",
       
   629                 destSize.iWidth, destSize.iHeight);
   515         return destSize;
   630         return destSize;
   516         }
   631         }
   517     else
   632     else
   518         {
   633         {
   519         return iTargetBitmapSize;
   634         return iTargetBitmapSize;
   530 #ifdef _DEBUG
   645 #ifdef _DEBUG
   531     iStopTime.HomeTime();
   646     iStopTime.HomeTime();
   532     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::HandleRunL() ConvertImageL took"
   647     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::HandleRunL() ConvertImageL took"
   533             " <%d> us", (TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64());
   648             " <%d> us", (TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64());
   534 #endif
   649 #endif
   535     if(aStatus.Int() !=KErrNone)
   650     if (iDecodingNext)
   536         {
   651         {
   537         GLX_LOG_INFO("HandleRunL - Convert failed");
   652         iDecodingNext = EFalse;
   538         ShiftToCloningMode();
   653         if (aStatus.Int() != KErrNone)
   539         }
   654             {
   540     else if(iSurfManager)
   655             GLX_LOG_INFO("HandleRunL - Next Convert failed");
   541         {        
   656             iDecodingNextFailed = ETrue;
   542         iShwFsThumbnail = EFalse;
   657             }
   543         if (iIsNonJpeg)
   658         //Inform the observer that image decoding is completed
   544             {
   659         GLX_LOG_INFO(
   545             // if this is non jpeg image, make sure we scale the bitmap
   660                 "CGlxHdmiSurfaceUpdater::HandleRunL-EHdmiDecodingCompleted");
   546             ScaleDecodedBitmapL(ENonJpgDecodedBitmapIndex);
   661         iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingCompleted);
   547             }
   662         }
   548         ProcessTvImage();
   663     else
   549 		iBitmapReady = ETrue;
   664         {
   550         }
   665         iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingFirstCompleted);
   551 	//release imagedecoder after the conversion is over		
   666         if (aStatus.Int() != KErrNone)
   552     if(iImageDecoder)
   667             {
       
   668             GLX_LOG_INFO("HandleRunL - Convert failed");
       
   669             ShiftToCloningMode();
       
   670             }
       
   671         else if (iSurfManager)
       
   672             {
       
   673             iShwFsThumbnail = EFalse;
       
   674             if (iIsNonJpeg)
       
   675                 {
       
   676                 // if this is non jpeg image, make sure we scale the bitmap
       
   677                 ScaleDecodedBitmapL( ENonJpgDecodedBitmapIndex);
       
   678                 }
       
   679             ProcessTvImage();
       
   680             iBitmapReady = ETrue;
       
   681             }
       
   682         }
       
   683     //release imagedecoder after the conversion is over
       
   684     if (iImageDecoder)
   553         {
   685         {
   554         delete iImageDecoder;
   686         delete iImageDecoder;
   555         iImageDecoder = NULL;    
   687         iImageDecoder = NULL;
   556         }
   688         }
   557     }
   689     }
   558 
   690 
   559 // -----------------------------------------------------------------------------
   691 // -----------------------------------------------------------------------------
   560 // CreateImageDecoderL 
   692 // CreateImageDecoderL 
   561 // -----------------------------------------------------------------------------
   693 // -----------------------------------------------------------------------------
   562 void CGlxHdmiSurfaceUpdater::CreateImageDecoderL()
   694 void CGlxHdmiSurfaceUpdater::CreateImageDecoderL()
   563     {
   695     {
   564     TRACER("CGlxHdmiController::CreateImageDecoderL()");
   696     TRACER("CGlxHdmiController::CreateImageDecoderL()");
   565      // Create a decoder for the image in the named file
   697     // Create a decoder for the image in the named file
   566     TRAPD(error,iImageDecoder = CImageDecoder::FileNewL(iFsSession, 
   698     TRAPD(error, iImageDecoder = CImageDecoder::FileNewL(iFsSession,
   567             iImagePath->Des(), CImageDecoder::EOptionNone, KNullUid));
   699             iImagePath->Des(), CImageDecoder::EOptionNone, KNullUid));
   568     GLX_LOG_INFO1("CreateImageDecoderL CImageDecoder:FileNewL error %d",error);
   700     GLX_LOG_INFO1("CreateImageDecoderL CImageDecoder:FileNewL error %d",
   569     User::LeaveIfError(error);
   701             error);
       
   702     User::LeaveIfError( error);
   570     }
   703     }
   571 
   704 
   572 // -----------------------------------------------------------------------------
   705 // -----------------------------------------------------------------------------
   573 // ActivateZoom 
   706 // ActivateZoom 
   574 // -----------------------------------------------------------------------------
   707 // -----------------------------------------------------------------------------
   575 void CGlxHdmiSurfaceUpdater::ActivateZoom(TBool aAutoZoomOut)
   708 void CGlxHdmiSurfaceUpdater::ActivateZoom(TBool aAutoZoomOut)
   576     {
   709     {
   577     TRACER("CGlxHdmiSurfaceUpdater::ActivateZoom()");
   710     TRACER("CGlxHdmiSurfaceUpdater::ActivateZoom()");
   578     iZoom = ETrue;
   711     iZoom = ETrue;
   579     iAutoZoomOut = aAutoZoomOut;
   712     iAutoZoomOut = aAutoZoomOut;
   580     if(iTimer->IsActive())
   713     if (iTimer->IsActive())
   581         {
   714         {
   582 		GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ActivateZoom() - Cancel Timer");
   715         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ActivateZoom() - Cancel Timer");
   583         iTimer->Cancel();
   716         iTimer->Cancel();
   584         }
   717         }
   585     
   718 
   586     if(!iTimer->IsActive() && iBitmapReady)
   719     if (!iTimer->IsActive() && iBitmapReady)
   587        {
   720         {
   588 	   GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ActivateZoom() - Start Timer");
   721         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ActivateZoom() - Start Timer");
   589        iTimer->Start(KZoomDelay,KZoomDelay,TCallBack( TimeOut,this ));
   722         iTimer->Start(KZoomDelay, KZoomDelay, TCallBack(TimeOut, this));
   590        }
   723         }
   591     }
   724     }
   592 
   725 
   593 // -----------------------------------------------------------------------------
   726 // -----------------------------------------------------------------------------
   594 // DeactivateZoom 
   727 // DeactivateZoom 
   595 // -----------------------------------------------------------------------------
   728 // -----------------------------------------------------------------------------
   596 void CGlxHdmiSurfaceUpdater::DeactivateZoom()
   729 void CGlxHdmiSurfaceUpdater::DeactivateZoom()
   597     {
   730     {
   598     TRACER("CGlxHdmiSurfaceUpdater::DeactivateZoom()");
   731     TRACER("CGlxHdmiSurfaceUpdater::DeactivateZoom()");
   599     
   732 
   600     if(iTimer->IsActive())
   733     if (iTimer->IsActive())
   601         {
   734         {
   602 		GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::DeactivateZoom() - Cancel Timer");
   735         GLX_LOG_INFO(
       
   736                 "CGlxHdmiSurfaceUpdater::DeactivateZoom() - Cancel Timer");
   603         iTimer->Cancel();
   737         iTimer->Cancel();
   604         }
   738         }
   605     if(!iTimer->IsActive() && iBitmapReady && iLeftCornerForZoom.iX)
   739     if (!iTimer->IsActive() && iBitmapReady && iLeftCornerForZoom.iX)
   606        {
   740         {
   607 	   GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::DeactivateZoom() - Start Timer");
   741         GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::DeactivateZoom() - Start Timer");
   608 	   iZoom = EFalse;
   742         iZoom = EFalse;
   609        iTimer->Start(KZoomDelay,KZoomDelay,TCallBack( TimeOut,this ));
   743         iTimer->Start(KZoomDelay, KZoomDelay, TCallBack(TimeOut, this));
   610        }
   744         }
   611     }
   745     }
   612 
   746 
   613 // ---------------------------------------------------------------------------
   747 // ---------------------------------------------------------------------------
   614 // TimeOut
   748 // TimeOut
   615 // ---------------------------------------------------------------------------
   749 // ---------------------------------------------------------------------------
   616 //  
   750 //  
   617 TInt CGlxHdmiSurfaceUpdater::TimeOut(TAny* aSelf)
   751 TInt CGlxHdmiSurfaceUpdater::TimeOut(TAny* aSelf)
   618     {
   752     {
   619     TRACER("CGlxHdmiSurfaceUpdater::TimeOut");
   753     TRACER("CGlxHdmiSurfaceUpdater::TimeOut");
   620     if(aSelf)
   754     if (aSelf)
   621         {
   755         {
   622         CGlxHdmiSurfaceUpdater* self = static_cast <CGlxHdmiSurfaceUpdater*> (aSelf);
   756         CGlxHdmiSurfaceUpdater* self =
       
   757                 static_cast<CGlxHdmiSurfaceUpdater*> (aSelf);
   623         if (self)
   758         if (self)
   624             {            
   759             {
   625              self->Zoom(ETrue);
   760             self->Zoom(ETrue);
   626             }
   761             }
   627         }
   762         }
   628     return KErrNone;
   763     return KErrNone;
   629     }
   764     }
   630 
   765 
   632 // Zoom 
   767 // Zoom 
   633 // -----------------------------------------------------------------------------
   768 // -----------------------------------------------------------------------------
   634 void CGlxHdmiSurfaceUpdater::Zoom(TBool aZoom)
   769 void CGlxHdmiSurfaceUpdater::Zoom(TBool aZoom)
   635     {
   770     {
   636     TRACER("CGlxHdmiSurfaceUpdater::Zoom()");
   771     TRACER("CGlxHdmiSurfaceUpdater::Zoom()");
   637 	
   772 
   638 	if(!iBitmapReady)
   773     if (!iBitmapReady)
   639 		{
   774         {
   640 		return;
   775         return;
   641 		}
   776         }
   642 		
   777 
   643     if(iLeftCornerForZoom.iX == KMaxZoomLimit)
   778     if (iLeftCornerForZoom.iX == KMaxZoomLimit)
   644         {
   779         {
   645         iZoom = EFalse;
   780         iZoom = EFalse;
   646         //If autozoomout is not set then cancel the timer and do
   781         //If autozoomout is not set then cancel the timer and do
   647         //the zoom out on DeactivateZoom.
   782         //the zoom out on DeactivateZoom.
   648         if(!iAutoZoomOut)
   783         if (!iAutoZoomOut)
   649             {
   784             {
   650             iTimer->Cancel();			
   785             iTimer->Cancel();
   651             }
   786             }
   652         }    
   787         }
   653     if(aZoom && iZoom)
   788     if (aZoom && iZoom)
   654         {
   789         {
   655         iTargetBitmapSize.iWidth = TInt(iTargetBitmapSize.iWidth-KSingleStepForZoom);
   790         iTargetBitmapSize.iWidth = TInt(iTargetBitmapSize.iWidth
   656         iTargetBitmapSize.iHeight = TInt(iTargetBitmapSize.iHeight-KSingleStepForZoom);
   791                 - KSingleStepForZoom);
   657         iLeftCornerForZoom.iX =iLeftCornerForZoom.iX+KSingleStepForZoom/2;
   792         iTargetBitmapSize.iHeight = TInt(iTargetBitmapSize.iHeight
   658         iLeftCornerForZoom.iY =iLeftCornerForZoom.iY+KSingleStepForZoom/2;           
   793                 - KSingleStepForZoom);
   659         GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::Zoom()--- 2,iTargetBitmapSize.iWidth = %d, iTargetBitmapSize.iHeight = %d", iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight);
   794         iLeftCornerForZoom.iX = iLeftCornerForZoom.iX + KSingleStepForZoom
   660         iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,iLeftCornerForZoom.iY,
   795                 / 2;
   661                 iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight));
   796         iLeftCornerForZoom.iY = iLeftCornerForZoom.iY + KSingleStepForZoom
       
   797                 / 2;
       
   798         GLX_LOG_INFO2(
       
   799                 "CGlxHdmiSurfaceUpdater::Zoom()--- 2,iTargetBitmapSize.iWidth = %d, iTargetBitmapSize.iHeight = %d",
       
   800                 iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight);
       
   801         iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,
       
   802                 iLeftCornerForZoom.iY, iTargetBitmapSize.iWidth,
       
   803                 iTargetBitmapSize.iHeight));
   662         }
   804         }
   663     else
   805     else
   664         {
   806         {
   665         iTargetBitmapSize.iWidth = TInt(iTargetBitmapSize.iWidth+KSingleStepForZoom);
   807         iTargetBitmapSize.iWidth = TInt(iTargetBitmapSize.iWidth
   666         iTargetBitmapSize.iHeight = TInt(iTargetBitmapSize.iHeight+KSingleStepForZoom);
   808                 + KSingleStepForZoom);
   667         iLeftCornerForZoom.iX =iLeftCornerForZoom.iX-KSingleStepForZoom/2;
   809         iTargetBitmapSize.iHeight = TInt(iTargetBitmapSize.iHeight
   668         iLeftCornerForZoom.iY =iLeftCornerForZoom.iY-KSingleStepForZoom/2; 
   810                 + KSingleStepForZoom);
   669         if(iLeftCornerForZoom.iX == 0)
   811         iLeftCornerForZoom.iX = iLeftCornerForZoom.iX - KSingleStepForZoom
       
   812                 / 2;
       
   813         iLeftCornerForZoom.iY = iLeftCornerForZoom.iY - KSingleStepForZoom
       
   814                 / 2;
       
   815         if (iLeftCornerForZoom.iX == 0)
   670             {
   816             {
   671             iTimer->Cancel();
   817             iTimer->Cancel();
   672             iZoom = ETrue;
   818             iZoom = ETrue;
   673             }
   819             }
   674         GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::Zoom()--- 4,iTargetBitmapSize.iWidth = %d, iTargetBitmapSize.iHeight = %d", iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight);
   820         GLX_LOG_INFO2(
   675         iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,iLeftCornerForZoom.iY,
   821                 "CGlxHdmiSurfaceUpdater::Zoom()--- 4,iTargetBitmapSize.iWidth = %d, iTargetBitmapSize.iHeight = %d",
   676                 iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight));
   822                 iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight);
   677         }
   823         iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,
   678     iWindow->SetBackgroundSurface(iConfig, ETrue);   
   824                 iLeftCornerForZoom.iY, iTargetBitmapSize.iWidth,
       
   825                 iTargetBitmapSize.iHeight));
       
   826         }
       
   827     iWindow->SetBackgroundSurface(iConfig, ETrue);
   679     }
   828     }
   680 
   829 
   681 // -----------------------------------------------------------------------------
   830 // -----------------------------------------------------------------------------
   682 // ModifySurfacePostion 
   831 // ModifySurfacePostion 
   683 // -----------------------------------------------------------------------------
   832 // -----------------------------------------------------------------------------
   684 void CGlxHdmiSurfaceUpdater::ModifySurfacePostion()
   833 void CGlxHdmiSurfaceUpdater::ModifySurfacePostion()
   685 	{
   834     {
   686 	TRACER("CGlxHdmiSurfaceUpdater::ModifySurfacePostion()");
   835     TRACER("CGlxHdmiSurfaceUpdater::ModifySurfacePostion()");
   687 	TPoint startPoint(0,0);
   836     TPoint startPoint(0, 0);
   688 	if (iTargetBitmapSize.iWidth <iTvScreenSize.iWidth)
   837     if (iTargetBitmapSize.iWidth < iTvScreenSize.iWidth)
   689 	    {
   838         {
   690 	    startPoint.iX = (iTvScreenSize.iWidth - iTargetBitmapSize.iWidth)/2; 
   839         startPoint.iX = (iTvScreenSize.iWidth - iTargetBitmapSize.iWidth) / 2;
   691 	    }
   840         }
   692 	if (iTargetBitmapSize.iHeight <iTvScreenSize.iHeight)
   841     if (iTargetBitmapSize.iHeight < iTvScreenSize.iHeight)
   693 	    {
   842         {
   694 	    startPoint.iY = (iTvScreenSize.iHeight - iTargetBitmapSize.iHeight)/2;
   843         startPoint.iY = (iTvScreenSize.iHeight - iTargetBitmapSize.iHeight)
   695 	    }
   844                 / 2;
   696     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - target iTargetBitmapSize=%d, %d",
   845         }
   697             iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight);
   846     GLX_LOG_INFO2(
   698     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - startPoint =%d, %d",
   847             "CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - target iTargetBitmapSize=%d, %d",
   699             startPoint.iX,startPoint.iY);
   848             iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight);
       
   849     GLX_LOG_INFO2(
       
   850             "CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - startPoint =%d, %d",
       
   851             startPoint.iX, startPoint.iY);
   700 
   852 
   701     // target
   853     // target
   702     iConfig.SetExtent(TRect(startPoint.iX,startPoint.iY,(iTvScreenSize.iWidth-startPoint.iX),
   854     iConfig.SetExtent(TRect(startPoint.iX, startPoint.iY,
   703             (iTvScreenSize.iHeight-startPoint.iY)));
   855             (iTvScreenSize.iWidth - startPoint.iX), (iTvScreenSize.iHeight
       
   856                     - startPoint.iY)));
   704     // source
   857     // source
   705     iConfig.SetViewport(TRect(TPoint(0,0),TSize(iTargetBitmapSize.iWidth,
   858     iConfig.SetViewport(TRect(TPoint(0, 0), TSize(iTargetBitmapSize.iWidth,
   706             iTargetBitmapSize.iHeight)));
   859             iTargetBitmapSize.iHeight)));
   707 #ifdef _DEBUG
   860 #ifdef _DEBUG
   708     TRect ex, vp;
   861     TRect ex, vp;
   709     iConfig.GetExtent(ex);
   862     iConfig.GetExtent(ex);
   710     iConfig.GetViewport(vp);
   863     iConfig.GetViewport(vp);
   717 
   870 
   718 // -----------------------------------------------------------------------------
   871 // -----------------------------------------------------------------------------
   719 // ShiftToCloningMode 
   872 // ShiftToCloningMode 
   720 // -----------------------------------------------------------------------------
   873 // -----------------------------------------------------------------------------
   721 void CGlxHdmiSurfaceUpdater::ShiftToCloningMode()
   874 void CGlxHdmiSurfaceUpdater::ShiftToCloningMode()
   722 	{
   875     {
   723 	TRACER("CGlxHdmiSurfaceUpdater::ShiftToCloningMode()");
   876     TRACER("CGlxHdmiSurfaceUpdater::ShiftToCloningMode()");
   724 	iWindow->RemoveBackgroundSurface(ETrue);
   877     iWindow->RemoveBackgroundSurface(ETrue);
   725 	}
   878     }
   726 	
   879 
   727 // -----------------------------------------------------------------------------
   880 // -----------------------------------------------------------------------------
   728 // ShiftToPostingMode 
   881 // ShiftToPostingMode 
   729 // -----------------------------------------------------------------------------
   882 // -----------------------------------------------------------------------------
   730 void CGlxHdmiSurfaceUpdater::ShiftToPostingMode()
   883 void CGlxHdmiSurfaceUpdater::ShiftToPostingMode()
   731 	{
   884     {
   732 	TRACER("CGlxHdmiSurfaceUpdater::ShiftToPostingMode()");
   885     TRACER("CGlxHdmiSurfaceUpdater::ShiftToPostingMode()");
   733 	if(iSurfManager)
   886     if (iSurfManager)
   734 		{
   887         {
   735 #ifdef _DEBUG
   888 #ifdef _DEBUG
   736 		TRect ex, vp;
   889         TRect ex, vp;
   737 		iConfig.GetExtent(ex);
   890         iConfig.GetExtent(ex);
   738 		iConfig.GetViewport(vp);
   891         iConfig.GetViewport(vp);
   739 		GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - vp - TL=%d, %d",vp.iTl.iX,vp.iTl.iY);
   892         GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - vp - TL=%d, %d",vp.iTl.iX,vp.iTl.iY);
   740 		GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - vp - BR=%d, %d",vp.iBr.iX,vp.iBr.iY);
   893         GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - vp - BR=%d, %d",vp.iBr.iX,vp.iBr.iY);
   741 		GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - ex - TL=%d, %d",ex.iTl.iX,ex.iTl.iY);
   894         GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - ex - TL=%d, %d",ex.iTl.iX,ex.iTl.iY);
   742 		GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - ex - BR=%d, %d",ex.iBr.iX,ex.iBr.iY);
   895         GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - ex - BR=%d, %d",ex.iBr.iX,ex.iBr.iY);
   743 #endif
   896 #endif
   744 		iWindow->SetBackgroundSurface(iConfig, ETrue);
   897         iWindow->SetBackgroundSurface(iConfig, ETrue);
   745 		iShiftToCloning = EFalse;
   898         iShiftToCloning = EFalse;
   746 		}
   899         }
   747 	}
   900     }
   748 
   901 
   749 // -----------------------------------------------------------------------------
   902 // -----------------------------------------------------------------------------
   750 // ShowFsThumbnailL 
   903 // ShowFsThumbnailL 
   751 // -----------------------------------------------------------------------------
   904 // -----------------------------------------------------------------------------
   752 void CGlxHdmiSurfaceUpdater::ShowFsThumbnailL()
   905 void CGlxHdmiSurfaceUpdater::ShowFsThumbnailL()
   753     {
   906     {
   754     TRACER("CGlxHdmiSurfaceUpdater::ShowFsThumbnailL()");
   907     TRACER("CGlxHdmiSurfaceUpdater::ShowFsThumbnailL()");
   755     iShwFsThumbnail = ETrue;
   908     iShwFsThumbnail = ETrue;
   756     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShowFsThumbnailL() iTargetBitmapSize Width=%d, Height=%d",
   909     GLX_LOG_INFO2(
   757             iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight);
   910             "CGlxHdmiSurfaceUpdater::ShowFsThumbnailL() iTargetBitmapSize Width=%d, Height=%d",
       
   911             iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight);
   758     // Modify the surface position with respect to the buffer size 
   912     // Modify the surface position with respect to the buffer size 
   759     ModifySurfacePostion();
   913     ModifySurfacePostion();
   760     // this is for FS thumbnail stored in array pointer 0
   914     // this is for FS thumbnail stored in array pointer 0
   761     ScaleDecodedBitmapL(EFSBitmapIndex);
   915     ScaleDecodedBitmapL( EFSBitmapIndex);
   762     // Process the Image to TV
   916     // Process the Image to TV
   763     ProcessTvImage();
   917     ProcessTvImage();
   764     // set the surface onto background
   918     // set the surface onto background
   765     iWindow->SetBackgroundSurface(iConfig, ETrue); 
   919     iWindow->SetBackgroundSurface(iConfig, ETrue);
   766     }
   920     }
   767 
   921 
   768 // -----------------------------------------------------------------------------
   922 // -----------------------------------------------------------------------------
   769 // ScaleDecodedBitmapL 
   923 // ScaleDecodedBitmapL 
   770 // -----------------------------------------------------------------------------
   924 // -----------------------------------------------------------------------------
   771 void CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL(TInt aBitmapIndex)
   925 void CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL(TInt aBitmapIndex)
   772     {
   926     {
   773     TRACER("CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL()");
   927     TRACER("CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL()");
   774     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL() iTargetBitmapSize Width=%d, Height=%d",
   928     GLX_LOG_INFO2(
   775             iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight);
   929             "CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL() iTargetBitmapSize Width=%d, Height=%d",
       
   930             iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight);
   776 
   931 
   777     if (iDecodedBitmap[aBitmapIndex])
   932     if (iDecodedBitmap[aBitmapIndex])
   778         {
   933         {
   779         delete iDecodedBitmap[aBitmapIndex];
   934         delete iDecodedBitmap[aBitmapIndex];
   780         iDecodedBitmap[aBitmapIndex] = NULL;
   935         iDecodedBitmap[aBitmapIndex] = NULL;
   781         }
   936         }
   782     iDecodedBitmap[aBitmapIndex] = new (ELeave) CFbsBitmap();
   937     iDecodedBitmap[aBitmapIndex] = new (ELeave) CFbsBitmap();
   783     // create destination with size
   938     // create destination with size
   784     TInt err = iDecodedBitmap[aBitmapIndex]->Create(iTargetBitmapSize, EColor16MU);
   939     TInt err = iDecodedBitmap[aBitmapIndex]->Create(iTargetBitmapSize,
   785     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL() creating bitmap error, err=%d",err);
   940             EColor16MU);
   786     User::LeaveIfNull(iDecodedBitmap[aBitmapIndex]);
   941     GLX_LOG_INFO1(
       
   942             "CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL() creating bitmap error, err=%d",
       
   943             err);
       
   944     User::LeaveIfNull( iDecodedBitmap[aBitmapIndex]);
   787 
   945 
   788     // Create bitmap device for destination bitmap
   946     // Create bitmap device for destination bitmap
   789     CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(iDecodedBitmap[aBitmapIndex]);
   947     CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(
       
   948             iDecodedBitmap[aBitmapIndex]);
   790     CleanupStack::PushL(bitmapDevice);
   949     CleanupStack::PushL(bitmapDevice);
   791     
   950 
   792     CFbsBitGc* bitmapGc = CFbsBitGc::NewL();
   951     CFbsBitGc* bitmapGc = CFbsBitGc::NewL();
   793     CleanupStack::PushL(bitmapGc);
   952     CleanupStack::PushL(bitmapGc);
   794     bitmapGc->Activate(bitmapDevice);
   953     bitmapGc->Activate(bitmapDevice);
   795     if (aBitmapIndex==EFSBitmapIndex)
   954     if (aBitmapIndex == EFSBitmapIndex)
   796         {
   955         {
   797         // scale the source bitmap which is a FS bitmap
   956         // scale the source bitmap which is a FS bitmap
   798         bitmapGc->DrawBitmap(TRect(iTargetBitmapSize), iFsBitmap);
   957         bitmapGc->DrawBitmap(TRect(iTargetBitmapSize), iFsBitmap);
   799         }
   958         }
   800     else
   959     else
   801         {
   960         {
   802         // scale the source bitmap which is a decoded bitmap
   961         // scale the source bitmap which is a decoded bitmap
   803         bitmapGc->DrawBitmap(TRect(iTargetBitmapSize), iDecodedBitmap[EJpgDecodedBitmapIndex]);
   962         bitmapGc->DrawBitmap(TRect(iTargetBitmapSize),
   804         }
   963                 iDecodedBitmap[EJpgDecodedBitmapIndex]);
   805     
   964         }
       
   965 
   806     CleanupStack::PopAndDestroy(bitmapGc);
   966     CleanupStack::PopAndDestroy(bitmapGc);
   807     CleanupStack::PopAndDestroy(bitmapDevice);
   967     CleanupStack::PopAndDestroy(bitmapDevice);
   808 
   968 
   809     }
   969     }
   810 
   970 
   820         Refresh();
   980         Refresh();
   821         iSurfBufferAO->iStatus = KRequestPending;
   981         iSurfBufferAO->iStatus = KRequestPending;
   822         iSurfBufferAO->SetActive();
   982         iSurfBufferAO->SetActive();
   823         iSurfUpdateSession.NotifyWhenAvailable(iSurfBufferAO->iStatus);
   983         iSurfUpdateSession.NotifyWhenAvailable(iSurfBufferAO->iStatus);
   824         TInt err = iSurfUpdateSession.SubmitUpdate(1, iSurfId, 0, NULL);
   984         TInt err = iSurfUpdateSession.SubmitUpdate(1, iSurfId, 0, NULL);
   825         GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ProcessTvImage() Surfaceupdatesession error %d",err);
   985         GLX_LOG_INFO1(
   826         }
   986                 "CGlxHdmiSurfaceUpdater::ProcessTvImage() Surfaceupdatesession error %d",
   827     }
   987                 err);
   828 
   988         }
   829 
   989     }
   830 
   990 
       
   991 // -----------------------------------------------------------------------------
       
   992 // DecodeNextImageL 
       
   993 // -----------------------------------------------------------------------------
       
   994 void CGlxHdmiSurfaceUpdater::DecodeNextImageL()
       
   995     {
       
   996     TRACER("CGlxHdmiSurfaceUpdater::DecodeNextImageL()");
       
   997     ReleaseContent();
       
   998     iImagePath = iNextImagePath->Alloc();
       
   999     if (iNextImagePath)
       
  1000         {
       
  1001         delete iNextImagePath;
       
  1002         iNextImagePath = NULL;
       
  1003         }
       
  1004     iIsNonJpeg = EFalse;
       
  1005     GLX_LOG_INFO("Before - iWindow->Size()");
       
  1006     iTvScreenSize = iWindow->Size();
       
  1007     GLX_LOG_INFO("After - iWindow->Size()");
       
  1008     iBitmapReady = EFalse;
       
  1009     iLeftCornerForZoom.iX = 0;
       
  1010     iLeftCornerForZoom.iY = 0;
       
  1011     iZoom = ETrue;
       
  1012     //Cancel the zoom timers if any
       
  1013     if (iTimer && iTimer->IsActive())
       
  1014         {
       
  1015         GLX_LOG_INFO(
       
  1016                 "CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Cancel Timer");
       
  1017         iTimer->Cancel();
       
  1018         }
       
  1019     // Create the HDMI Decoder
       
  1020     CreateImageDecoderL();
       
  1021     // Create the Bitmap
       
  1022     CreateBitmapL();
       
  1023     if (iSurfManager)
       
  1024         {
       
  1025         // Create the surface and AO for updating the surface
       
  1026         CreateHdmiL( EFalse);
       
  1027         }
       
  1028     else
       
  1029         {
       
  1030         TRAP_IGNORE( CreateHdmiL(ETrue));
       
  1031         }
       
  1032 
       
  1033 #ifdef _DEBUG
       
  1034     iStartTime.HomeTime();
       
  1035 #endif
       
  1036     if (iSurfManager)
       
  1037         {
       
  1038         //start decoding the image
       
  1039         iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex],
       
  1040                 iImageDecoder);
       
  1041         iDecodingNext = ETrue;
       
  1042         iDecodingNextFailed = EFalse;
       
  1043         //Inform the Observer that decoding has started
       
  1044         iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingStarted);
       
  1045         }
       
  1046     }
       
  1047