taskswitcher/contextengine/tsfswpreviewprovider/wsplugin/src/previewprovidercrp.cpp
equal
deleted
inserted
replaced
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 TInt64 KMinTimeForOrientationSwitch = 500000; // 0.5 second |
36 const TInt KMinTimeForOrientationSwitch = 1; // 1 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( FALSE ); |
129 ScreenshotL(); |
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 TTimeIntervalMicroSeconds micSecondsFrom = currTime.MicroSecondsFrom( iScreenChangedTime ); |
175 TTimeIntervalSeconds secondsFrom; |
176 if ( micSecondsFrom.Int64() > KMinTimeForOrientationSwitch ) |
176 TInt err = currTime.SecondsFrom( iScreenChangedTime, secondsFrom ); |
|
177 if ( err != KErrNone || secondsFrom.Int() > KMinTimeForOrientationSwitch ) |
177 { |
178 { |
178 if ( iLastWgIdRedraw ) |
179 if ( iLastWgIdRedraw ) |
179 { |
180 { |
180 TRAP_IGNORE( ScreenshotL( FALSE ) ); |
181 TRAP_IGNORE( ScreenshotL() ); |
181 } |
182 } |
182 } |
183 } |
183 else |
184 else |
184 { |
185 { |
185 // Reset time to allow screenshot taking on next wg change |
186 // Reset time to allow screenshot taking on next wg change |
186 iScreenChangedTime = 0; |
187 iScreenChangedTime = 0; |
|
188 // Order screenshot rotation |
|
189 BitmapRotationNeeded( iPrevId?iPrevId:iPrevReg, iClockwiseRot ); |
187 } |
190 } |
188 iPrevReg = 0; |
191 iPrevReg = 0; |
189 } |
192 } |
190 iPrevId = wgId; |
193 iPrevId = wgId; |
191 iLastWgIdRedraw = EFalse; |
194 iLastWgIdRedraw = EFalse; |
193 else if ( aEvent.Type() == TWservCrEvent::EDeviceOrientationChanged ) |
196 else if ( aEvent.Type() == TWservCrEvent::EDeviceOrientationChanged ) |
194 { |
197 { |
195 iScreenChangedTime.HomeTime(); |
198 iScreenChangedTime.HomeTime(); |
196 if ( iLastWgIdRedraw ) |
199 if ( iLastWgIdRedraw ) |
197 { |
200 { |
198 TRAP_IGNORE( |
201 TRAP_IGNORE( ScreenshotL() ); |
199 ScreenshotL( TRUE ); |
|
200 ); |
|
201 } |
202 } |
202 } |
203 } |
203 else if ( aEvent.Type() == TWservCrEvent::EScreenDrawing ) |
204 else if ( aEvent.Type() == TWservCrEvent::EScreenDrawing ) |
204 { |
205 { |
205 iLastWgIdRedraw = ETrue; |
206 iLastWgIdRedraw = ETrue; |
210 |
211 |
211 // -------------------------------------------------------------------------- |
212 // -------------------------------------------------------------------------- |
212 // CPreviewProviderCRP::ScaleComplete |
213 // CPreviewProviderCRP::ScaleComplete |
213 // -------------------------------------------------------------------------- |
214 // -------------------------------------------------------------------------- |
214 // |
215 // |
215 void CPreviewProviderCRP::ScaleCompleteL( const CFbsBitmap& aBitmap, |
216 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 |
|
229 const TInt msg[] = { |
221 const TInt msg[] = { |
230 msgType, |
222 NPreviewMsg::EPreviewReady, |
231 iPrevId?iPrevId:iPrevReg, |
223 iPrevId?iPrevId:iPrevReg, |
232 aBitmap.Handle() |
224 aBitmap.Handle() |
233 }; |
225 }; |
234 TPckgC<TInt[sizeof(msg) / sizeof(TInt)]> buf(msg); |
226 TPckgC<TInt[sizeof(msg) / sizeof(TInt)]> buf(msg); |
235 User::LeaveIfError( SendMessage( buf ) ); |
227 User::LeaveIfError( SendMessage( buf ) ); |
258 SendMessage(buf); |
250 SendMessage(buf); |
259 |
251 |
260 TSLOG_OUT(); |
252 TSLOG_OUT(); |
261 } |
253 } |
262 |
254 |
|
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 |
263 // -------------------------------------------------------------------------- |
277 // -------------------------------------------------------------------------- |
264 // CPreviewProviderCRP::Register |
278 // CPreviewProviderCRP::Register |
265 // -------------------------------------------------------------------------- |
279 // -------------------------------------------------------------------------- |
266 // |
280 // |
267 void CPreviewProviderCRP::Register( TInt aWgId ) |
281 void CPreviewProviderCRP::Register( TInt aWgId ) |
297 |
311 |
298 // -------------------------------------------------------------------------- |
312 // -------------------------------------------------------------------------- |
299 // CPreviewProviderCRP::ScreenShotL |
313 // CPreviewProviderCRP::ScreenShotL |
300 // -------------------------------------------------------------------------- |
314 // -------------------------------------------------------------------------- |
301 // |
315 // |
302 void CPreviewProviderCRP::ScreenshotL( TBool aRotation ) |
316 void CPreviewProviderCRP::ScreenshotL() |
303 { |
317 { |
304 CFbsBitmap* screenshot = new (ELeave)CFbsBitmap(); |
318 CFbsBitmap* screenshot = new (ELeave)CFbsBitmap(); |
305 CleanupStack::PushL( screenshot ); |
319 CleanupStack::PushL( screenshot ); |
306 ScreenshotL( *screenshot ); |
320 ScreenshotL( *screenshot ); |
307 ScaleCompleteL( *screenshot, aRotation ); |
321 ScaleCompleteL( *screenshot ); |
308 iScreenshots.InsertL( screenshot, iScreenshots.Count() ); |
322 iScreenshots.InsertL( screenshot, iScreenshots.Count() ); |
309 CleanupStack::Pop( screenshot ); |
323 CleanupStack::Pop( screenshot ); |
310 CheckOverflow(); |
324 CheckOverflow(); |
311 } |
325 } |
312 |
326 |