taskswitcher/contextengine/tsfswpreviewprovider/wsplugin/src/previewprovidercrp.cpp
branchRCL_3
changeset 88 3321d3e205b6
parent 83 5456b4e8b3a8
child 102 ba63c83f4716
equal deleted inserted replaced
83:5456b4e8b3a8 88:3321d3e205b6
    31 #include <graphics/wsscreendevice.h>
    31 #include <graphics/wsscreendevice.h>
    32 #endif
    32 #endif
    33 
    33 
    34 // CONSTANTS
    34 // CONSTANTS
    35 const TInt KImpId( 0x20016BEC );
    35 const TInt KImpId( 0x20016BEC );
    36 const TInt KMinTimeForOrientationSwitch = 1; // 1 second
    36 const TInt64 KMinTimeForOrientationSwitch = 500000; // 0.5 second
    37 
    37 
    38 // --------------------------------------------------------------------------
    38 // --------------------------------------------------------------------------
    39 // CPreviewProviderCRP::CreateL
    39 // CPreviewProviderCRP::CreateL
    40 // --------------------------------------------------------------------------
    40 // --------------------------------------------------------------------------
    41 //
    41 //
   124             iScreenshotSize.iWidth = in.ReadInt32L();
   124             iScreenshotSize.iWidth = in.ReadInt32L();
   125             iScreenshotSize.iHeight = in.ReadInt32L();
   125             iScreenshotSize.iHeight = in.ReadInt32L();
   126             iScreenshotMode = static_cast<TDisplayMode>( in.ReadInt32L() );
   126             iScreenshotMode = static_cast<TDisplayMode>( in.ReadInt32L() );
   127             break;
   127             break;
   128         case NPreviewMsg::ETakePreview:
   128         case NPreviewMsg::ETakePreview:
   129             ScreenshotL();
   129             ScreenshotL( FALSE );
   130             break;
   130             break;
   131         case NPreviewMsg::EAckPreviewReady:
   131         case NPreviewMsg::EAckPreviewReady:
   132             RemoveScreenshot( in.ReadInt32L() );
   132             RemoveScreenshot( in.ReadInt32L() );
   133             break;
   133             break;
   134         }
   134         }
   170         if ( iWgIds.FindInOrder( iPrevId ) >= 0 ||
   170         if ( iWgIds.FindInOrder( iPrevId ) >= 0 ||
   171             ( iPrevId == 0 &&  iPrevReg != 0 ) )
   171             ( iPrevId == 0 &&  iPrevReg != 0 ) )
   172             {
   172             {
   173             TTime currTime;
   173             TTime currTime;
   174             currTime.HomeTime();
   174             currTime.HomeTime();
   175             TTimeIntervalSeconds secondsFrom;
   175             TTimeIntervalMicroSeconds micSecondsFrom = currTime.MicroSecondsFrom( iScreenChangedTime );
   176             TInt err = currTime.SecondsFrom( iScreenChangedTime, secondsFrom );
   176             if ( micSecondsFrom.Int64() > KMinTimeForOrientationSwitch )
   177             if ( err != KErrNone || secondsFrom.Int() > KMinTimeForOrientationSwitch )
       
   178                 {
   177                 {
   179                 if ( iLastWgIdRedraw )
   178                 if ( iLastWgIdRedraw )
   180                     {
   179                     {
   181                     TRAP_IGNORE( ScreenshotL() );
   180                     TRAP_IGNORE( ScreenshotL( FALSE ) );
   182                     }
   181                     }
   183                 }
   182                 }
   184             else
   183             else
   185                 {
   184                 {
   186                 // Reset time to allow screenshot taking on next wg change
   185                 // Reset time to allow screenshot taking on next wg change
   187                 iScreenChangedTime = 0;
   186                 iScreenChangedTime = 0;
   188                 // Order screenshot rotation
       
   189                 BitmapRotationNeeded( iPrevId?iPrevId:iPrevReg, iClockwiseRot );
       
   190                 }
   187                 }
   191             iPrevReg = 0;
   188             iPrevReg = 0;
   192             }
   189             }
   193         iPrevId = wgId;
   190         iPrevId = wgId;
   194         iLastWgIdRedraw = EFalse;
   191         iLastWgIdRedraw = EFalse;
   196     else if ( aEvent.Type() == TWservCrEvent::EDeviceOrientationChanged )
   193     else if ( aEvent.Type() == TWservCrEvent::EDeviceOrientationChanged )
   197         {
   194         {
   198         iScreenChangedTime.HomeTime();
   195         iScreenChangedTime.HomeTime();
   199         if ( iLastWgIdRedraw )
   196         if ( iLastWgIdRedraw )
   200             {
   197             {
   201             TRAP_IGNORE( ScreenshotL() );
   198             TRAP_IGNORE( 
       
   199                 ScreenshotL( TRUE ); 
       
   200                 );
   202             }
   201             }
   203         }
   202         }
   204     else if ( aEvent.Type() == TWservCrEvent::EScreenDrawing )
   203     else if ( aEvent.Type() == TWservCrEvent::EScreenDrawing )
   205         {
   204         {
   206         iLastWgIdRedraw = ETrue;
   205         iLastWgIdRedraw = ETrue;
   211     
   210     
   212 // --------------------------------------------------------------------------
   211 // --------------------------------------------------------------------------
   213 // CPreviewProviderCRP::ScaleComplete
   212 // CPreviewProviderCRP::ScaleComplete
   214 // --------------------------------------------------------------------------
   213 // --------------------------------------------------------------------------
   215 //    
   214 //    
   216 void CPreviewProviderCRP::ScaleCompleteL( const CFbsBitmap& aBitmap )
   215 void CPreviewProviderCRP::ScaleCompleteL( const CFbsBitmap& aBitmap, 
       
   216                     TBool aRotation )
   217     {
   217     {
   218     TSLOG_CONTEXT( ScaleComplete, TSLOG_LOCAL );
   218     TSLOG_CONTEXT( ScaleComplete, TSLOG_LOCAL );
   219     TSLOG_IN();
   219     TSLOG_IN();
   220     
   220     
       
   221     TInt msgType = NPreviewMsg::EPreviewReady;
       
   222     if ( aRotation )
       
   223         {
       
   224         msgType = iClockwiseRot ? 
       
   225                 NPreviewMsg::EBitmapRotationNeeded90 : 
       
   226                 NPreviewMsg::EBitmapRotationNeeded270;
       
   227         }
       
   228     
   221     const TInt msg[] = {
   229     const TInt msg[] = {
   222             NPreviewMsg::EPreviewReady,
   230             msgType,
   223             iPrevId?iPrevId:iPrevReg,
   231             iPrevId?iPrevId:iPrevReg,
   224             aBitmap.Handle()
   232             aBitmap.Handle()
   225             };
   233             };
   226     TPckgC<TInt[sizeof(msg) / sizeof(TInt)]> buf(msg);
   234     TPckgC<TInt[sizeof(msg) / sizeof(TInt)]> buf(msg);
   227     User::LeaveIfError( SendMessage( buf ) );
   235     User::LeaveIfError( SendMessage( buf ) );
   250     SendMessage(buf);
   258     SendMessage(buf);
   251     
   259     
   252     TSLOG_OUT();
   260     TSLOG_OUT();
   253     }
   261     }
   254 
   262 
   255 
       
   256 // --------------------------------------------------------------------------
       
   257 // CPreviewProviderCRP::BitmapRotationNeeded
       
   258 // --------------------------------------------------------------------------
       
   259 //
       
   260 void CPreviewProviderCRP::BitmapRotationNeeded( TInt aWgId, TBool aClockwise )
       
   261     {
       
   262     TSLOG_CONTEXT( BitmapRotationNeeded, TSLOG_LOCAL );
       
   263     TSLOG_IN();
       
   264     
       
   265     const TInt msg[] = {
       
   266             aClockwise ? NPreviewMsg::EBitmapRotationNeeded90 : NPreviewMsg::EBitmapRotationNeeded270,
       
   267             aWgId,
       
   268             0
       
   269             };
       
   270     TPckgC<TInt[sizeof(msg) / sizeof(TInt)]> buf(msg);
       
   271     SendMessage(buf);
       
   272     
       
   273     TSLOG_OUT();
       
   274     }
       
   275 
       
   276 
       
   277 // --------------------------------------------------------------------------
   263 // --------------------------------------------------------------------------
   278 // CPreviewProviderCRP::Register
   264 // CPreviewProviderCRP::Register
   279 // --------------------------------------------------------------------------
   265 // --------------------------------------------------------------------------
   280 //    
   266 //    
   281 void CPreviewProviderCRP::Register( TInt aWgId )
   267 void CPreviewProviderCRP::Register( TInt aWgId )
   311 
   297 
   312 // --------------------------------------------------------------------------
   298 // --------------------------------------------------------------------------
   313 // CPreviewProviderCRP::ScreenShotL
   299 // CPreviewProviderCRP::ScreenShotL
   314 // --------------------------------------------------------------------------
   300 // --------------------------------------------------------------------------
   315 //
   301 //
   316 void CPreviewProviderCRP::ScreenshotL()
   302 void CPreviewProviderCRP::ScreenshotL( TBool aRotation )
   317     {
   303     {
   318     CFbsBitmap* screenshot = new (ELeave)CFbsBitmap();
   304     CFbsBitmap* screenshot = new (ELeave)CFbsBitmap();
   319     CleanupStack::PushL( screenshot );
   305     CleanupStack::PushL( screenshot );
   320     ScreenshotL( *screenshot );
   306     ScreenshotL( *screenshot );
   321     ScaleCompleteL( *screenshot );
   307     ScaleCompleteL( *screenshot, aRotation );
   322     iScreenshots.InsertL( screenshot, iScreenshots.Count() );
   308     iScreenshots.InsertL( screenshot, iScreenshots.Count() );
   323     CleanupStack::Pop( screenshot );
   309     CleanupStack::Pop( screenshot );
   324     CheckOverflow();
   310     CheckOverflow();
   325     }
   311     }
   326 
   312