photosgallery/viewframework/tvout/src/glxhdmisurfaceupdater.cpp
branchRCL_3
changeset 13 bcb43dc84c44
parent 12 ce1c7ad1f18b
child 14 2dac0fdba72b
equal deleted inserted replaced
12:ce1c7ad1f18b 13:bcb43dc84c44
    40 const TInt KSingleStepForZoom = 10;
    40 const TInt KSingleStepForZoom = 10;
    41 // -----------------------------------------------------------------------------
    41 // -----------------------------------------------------------------------------
    42 // NewLC
    42 // NewLC
    43 // -----------------------------------------------------------------------------
    43 // -----------------------------------------------------------------------------
    44 CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL(RWindow* aWindow, const TDesC& aImageFile, 
    44 CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL(RWindow* aWindow, const TDesC& aImageFile, 
    45         TSize aImageDimensions, TInt aFrameCount, MGlxGenCallback* aCallBack)
    45                                                       MGlxGenCallback* aCallBack)
    46     {
    46     {
    47     TRACER("CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL()");
    47     TRACER("CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL()");
    48     CGlxHdmiSurfaceUpdater* self = new (ELeave) CGlxHdmiSurfaceUpdater(aWindow, aImageFile,
    48     CGlxHdmiSurfaceUpdater* self = new (ELeave) CGlxHdmiSurfaceUpdater(aWindow, aImageFile,
    49             aImageDimensions, aFrameCount, aCallBack);
    49                                                                     aCallBack);
    50     CleanupStack::PushL(self);
    50     CleanupStack::PushL(self);
    51     self->ConstructL(aImageDimensions);
    51     self->ConstructL();
    52     CleanupStack::Pop(self);
    52     CleanupStack::Pop(self);
    53     return self;
    53     return self;
    54     }
    54     }
    55 
    55 
    56 // -----------------------------------------------------------------------------
    56 // -----------------------------------------------------------------------------
   132     }
   132     }
   133 
   133 
   134 // -----------------------------------------------------------------------------
   134 // -----------------------------------------------------------------------------
   135 // CTor 
   135 // CTor 
   136 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   137 CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater(RWindow* aWindow, const TDesC& aImageFile, 
   137 CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater(RWindow* aWindow, 
   138         TSize aOrigImageDimensions, TInt aFrameCount, MGlxGenCallback* aCallBack): 
   138                           const TDesC& aImageFile, MGlxGenCallback* aCallBack): 
   139         iWindow(aWindow), iImagePath(aImageFile), iOrigImageDimensions(aOrigImageDimensions),
   139                           iWindow(aWindow), iImagePath(aImageFile), 
   140         iFrameCount(aFrameCount ),iCallBack(aCallBack)
   140                           iCallBack(aCallBack)
   141     {
   141     {
   142     TRACER("CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater()");
   142     TRACER("CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater()");
   143     // Implement nothing here
   143     // Implement nothing here
   144     }
   144     }
   145 
   145 
   146 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   147 // ConstructL 
   147 // ConstructL 
   148 // -----------------------------------------------------------------------------
   148 // -----------------------------------------------------------------------------
   149 void CGlxHdmiSurfaceUpdater::ConstructL(TSize /*aImageDimensions*/)
   149 void CGlxHdmiSurfaceUpdater::ConstructL()
   150     {
   150     {
   151     TRACER("CGlxHdmiSurfaceUpdater::ConstructL()");
   151     TRACER("CGlxHdmiSurfaceUpdater::ConstructL()");
   152     TInt error = iFsSession.Connect ();
   152     TInt error = iFsSession.Connect ();
   153     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() FsSession Connect error = %d", error);
   153     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() FsSession Connect error = %d", error);
   154     User::LeaveIfError(error);
   154     User::LeaveIfError(error);
   155     
   155     
   156     iBitmapReady = EFalse;
   156     iBitmapReady = EFalse;
   157     // Create the active object
   157     // Create the active object
   158     iGlxDecoderAO = CGlxHdmiDecoderAO::NewL(this, iFrameCount);
   158     iGlxDecoderAO = CGlxHdmiDecoderAO::NewL(this);
   159     CreateImageDecoderL(iImagePath);
   159     CreateImageDecoderL(iImagePath);
   160     CreateBitmapL();
   160     CreateBitmapL();
   161     CreateHdmiL();
   161     CreateHdmiL();
   162     error = iSurfUpdateSession.Connect();
   162     error = iSurfUpdateSession.Connect();
   163     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() Surface update Session Connect error = %d", error);
   163     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() Surface update Session Connect error = %d", error);
   166     
   166     
   167 #ifdef _DEBUG
   167 #ifdef _DEBUG
   168     iStartTime.HomeTime();
   168     iStartTime.HomeTime();
   169 #endif
   169 #endif
   170     //start decoding the image    
   170     //start decoding the image    
   171     iGlxDecoderAO->ConvertImageL(*iDecodedBitmap,0,iImageDecoder);    
   171     iGlxDecoderAO->ConvertImageL(*iDecodedBitmap,iImageDecoder);    
   172     
   172     
   173     iLeftCornerForZoom.iX = 0; 
   173     iLeftCornerForZoom.iX = 0; 
   174     iLeftCornerForZoom.iY = 0;
   174     iLeftCornerForZoom.iY = 0;
   175     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   175     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   176     iZoom = ETrue;
   176     iZoom = ETrue;
   177     }
   177     }
   178 
   178 
   179 // -----------------------------------------------------------------------------
   179 // -----------------------------------------------------------------------------
   180 // UpdateNewImageL 
   180 // UpdateNewImageL 
   181 // -----------------------------------------------------------------------------
   181 // -----------------------------------------------------------------------------
   182 void CGlxHdmiSurfaceUpdater::UpdateNewImageL(const TDesC& aImageFile, 
   182 void CGlxHdmiSurfaceUpdater::UpdateNewImageL(const TDesC& aImageFile)
   183         TInt /*aFrameCount*/,TSize aImageDimensions)
       
   184     {
   183     {
   185     TRACER("CGlxHdmiSurfaceUpdater::UpdateNewImageL()");
   184     TRACER("CGlxHdmiSurfaceUpdater::UpdateNewImageL()");
   186 	//Cancel the zoom timers if any
   185 	//Cancel the zoom timers if any
   187 	if(iTimer->IsActive())
   186 	if(iTimer->IsActive())
   188         {
   187         {
   189 		GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Cancel Timer");
   188 		GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Cancel Timer");
   190         iTimer->Cancel();
   189         iTimer->Cancel();
   191         }
   190         }
   192     iOrigImageDimensions = aImageDimensions;
   191     
   193 	iBitmapReady = EFalse;
   192 	iBitmapReady = EFalse;
   194 	iLeftCornerForZoom.iX = 0; 
   193 	iLeftCornerForZoom.iX = 0; 
   195 	iLeftCornerForZoom.iY = 0;
   194 	iLeftCornerForZoom.iY = 0;
   196     ReleaseContent();   
   195     ReleaseContent();   
   197     CreateImageDecoderL(aImageFile);    
   196     CreateImageDecoderL(aImageFile);    
   199     CreateHdmiL(EFalse);
   198     CreateHdmiL(EFalse);
   200 #ifdef _DEBUG
   199 #ifdef _DEBUG
   201     iStartTime.HomeTime();
   200     iStartTime.HomeTime();
   202 #endif
   201 #endif
   203     //start decoding the image
   202     //start decoding the image
   204     iGlxDecoderAO->ConvertImageL(*iDecodedBitmap,0,iImageDecoder);
   203     iGlxDecoderAO->ConvertImageL(*iDecodedBitmap,iImageDecoder);
   205     }
   204     }
   206 
   205 
   207 // -----------------------------------------------------------------------------
   206 // -----------------------------------------------------------------------------
   208 // CreateHDMI 
   207 // CreateHDMI 
   209 // -----------------------------------------------------------------------------
   208 // -----------------------------------------------------------------------------
   353 void CGlxHdmiSurfaceUpdater::CreateBitmapL()
   352 void CGlxHdmiSurfaceUpdater::CreateBitmapL()
   354     {
   353     {
   355     TRACER("CGlxHdmiSurfaceUpdater::StartImageDecodeL()");
   354     TRACER("CGlxHdmiSurfaceUpdater::StartImageDecodeL()");
   356     TSize scrnSize = iWindow->Size();
   355     TSize scrnSize = iWindow->Size();
   357     TSize targetBitmapSize;
   356     TSize targetBitmapSize;
   358     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - bitmapsize=%d, %d",iOrigImageDimensions.iWidth,iOrigImageDimensions.iHeight);
   357     TSize imageSize = iImageDecoder->FrameInfo().iOverallSizeInPixels;
       
   358     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - bitmapsize=%d, %d",imageSize.iWidth,imageSize.iHeight);
   359     TReal32 scaleFactor = 0.0f;
   359     TReal32 scaleFactor = 0.0f;
   360     if (scrnSize.iWidth * iOrigImageDimensions.iHeight > scrnSize.iHeight
   360     if (scrnSize.iWidth * imageSize.iHeight > scrnSize.iHeight
   361             * iOrigImageDimensions.iWidth)
   361             * imageSize.iWidth)
   362         {
   362         {
   363         scaleFactor = (TReal32) scrnSize.iHeight
   363         scaleFactor = (TReal32) scrnSize.iHeight
   364                 / (TReal32) iOrigImageDimensions.iHeight;
   364                 / (TReal32) imageSize.iHeight;
   365         }
   365         }
   366     else
   366     else
   367         {
   367         {
   368         scaleFactor = (TReal32) scrnSize.iWidth
   368         scaleFactor = (TReal32) scrnSize.iWidth
   369                 / (TReal32) iOrigImageDimensions.iWidth;
   369                 / (TReal32) imageSize.iWidth;
   370         }
   370         }
   371     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - scaleFactor=%f",scaleFactor);
   371     GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - scaleFactor=%f",scaleFactor);
   372     targetBitmapSize.iHeight = iOrigImageDimensions.iHeight * scaleFactor;
   372     targetBitmapSize.iHeight = imageSize.iHeight * scaleFactor;
   373     targetBitmapSize.iWidth = iOrigImageDimensions.iWidth * scaleFactor;
   373     targetBitmapSize.iWidth = imageSize.iWidth * scaleFactor;
   374 
   374 
   375     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - targetBitmapSize=%d, %d",targetBitmapSize.iWidth,targetBitmapSize.iHeight);
   375     GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - targetBitmapSize=%d, %d",targetBitmapSize.iWidth,targetBitmapSize.iHeight);
   376     //create the bitmap for the required size
   376     //create the bitmap for the required size
   377     iDecodedBitmap = new (ELeave) CFbsBitmap();
   377     iDecodedBitmap = new (ELeave) CFbsBitmap();
   378 
   378