40 // Creates CAlfCrpPluginClient instance, returns error code. |
41 // Creates CAlfCrpPluginClient instance, returns error code. |
41 static TInt CreateAlfCrpClient(CAlfCrpPluginClient*& aClient); |
42 static TInt CreateAlfCrpClient(CAlfCrpPluginClient*& aClient); |
42 // Creates CAlfCrpPluginClient instance. |
43 // Creates CAlfCrpPluginClient instance. |
43 static CAlfCrpPluginClient* CreateAlfCrpClientL(); |
44 static CAlfCrpPluginClient* CreateAlfCrpClientL(); |
44 |
45 |
|
46 NONSHARABLE_CLASS( TAlfDrawerDirectClient ) : public MAlfDrawerScreenInterface |
|
47 { |
|
48 public: |
|
49 TAlfDrawerDirectClient( RAlfDirectClient& aClient ); |
|
50 TInt GetSizeAndRotation(TSize& aSize, TInt& aRotation); |
|
51 TInt ReadPixels(CFbsBitmap* aBitmap); |
|
52 |
|
53 private: |
|
54 RAlfDirectClient iClient; |
|
55 }; |
|
56 |
45 /** |
57 /** |
46 * Misc utility methods for CAlfDrawer. |
58 * Misc utility methods for CAlfDrawer. |
47 */ |
59 */ |
48 NONSHARABLE_CLASS(AlfDrawerUtils) |
60 NONSHARABLE_CLASS(AlfDrawerUtils) |
49 { |
61 { |
91 */ |
103 */ |
92 static void DoCopyScreenToBitmapL( |
104 static void DoCopyScreenToBitmapL( |
93 CWsScreenDevice& aDevice, |
105 CWsScreenDevice& aDevice, |
94 CFbsBitmap* aBitmap, |
106 CFbsBitmap* aBitmap, |
95 const TRect& aRect ); |
107 const TRect& aRect ); |
|
108 |
|
109 /** |
|
110 * Copies screen to bitmap using 'read pixels' operation. |
|
111 */ |
|
112 static void DoCopyScreenToBitmap2L( |
|
113 MAlfDrawerScreenInterface* aInterface, |
|
114 CFbsBitmap* aBitmap, |
|
115 const TRect& aRect ); |
96 |
116 |
97 }; |
117 }; |
98 |
118 |
99 // --------------------------------------------------------------------------- |
119 // --------------------------------------------------------------------------- |
100 // NewL |
120 // NewL |
185 __ALFLOGSTRING("DoCopyScreenToBitmapL begin"); |
205 __ALFLOGSTRING("DoCopyScreenToBitmapL begin"); |
186 |
206 |
187 RAlfDirectClient client; |
207 RAlfDirectClient client; |
188 CleanupClosePushL(client); |
208 CleanupClosePushL(client); |
189 |
209 |
|
210 TAlfDrawerDirectClient clientWrapper(client); |
|
211 DoCopyScreenToBitmap2L(&clientWrapper, aBitmap, aRect); |
|
212 |
|
213 CleanupStack::PopAndDestroy(); // CleanupClosePushL |
|
214 |
|
215 __ALFLOGSTRING("DoCopyScreenToBitmapL - Done"); |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // DoCopyScreenToBitmapL |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 void AlfDrawerUtils::DoCopyScreenToBitmap2L( |
|
223 MAlfDrawerScreenInterface* aInterface, |
|
224 CFbsBitmap* aBitmap, |
|
225 const TRect& aRect ) |
|
226 { |
190 // Get size & virtual rotation from ALF side. |
227 // Get size & virtual rotation from ALF side. |
191 // GetSizeAndRotation will also create session to server. |
228 // GetSizeAndRotation will also create session to server. |
192 |
229 |
193 TInt rotation = 0; |
230 TInt rotation = 0; |
194 TSize size; |
231 TSize size; |
195 User::LeaveIfError(client.GetSizeAndRotation(size, rotation)); |
232 User::LeaveIfError(aInterface->GetSizeAndRotation(size, rotation)); |
196 |
233 |
197 // Calculate device size in pixels (same as aDevice.SizeInPixels()) |
234 // Calculate device size in pixels (same as aDevice.SizeInPixels()) |
198 TSize deviceSize = size; |
235 TSize deviceSize = size; |
199 if (rotation == AlfDrawerUtils::ERotation90 || |
236 if (rotation == AlfDrawerUtils::ERotation90 || |
200 rotation == AlfDrawerUtils::ERotation270 ) |
237 rotation == AlfDrawerUtils::ERotation270 ) |
237 // Read pixels to temporary bitmap |
273 // Read pixels to temporary bitmap |
238 CFbsBitmap* surfaceBitmap = new (ELeave) CFbsBitmap; |
274 CFbsBitmap* surfaceBitmap = new (ELeave) CFbsBitmap; |
239 CleanupStack::PushL( surfaceBitmap ); |
275 CleanupStack::PushL( surfaceBitmap ); |
240 User::LeaveIfError( surfaceBitmap->Create( size, surfaceDisplayMode ) ); |
276 User::LeaveIfError( surfaceBitmap->Create( size, surfaceDisplayMode ) ); |
241 |
277 |
242 TInt err = client.ReadPixels( surfaceBitmap->Handle() ); |
278 TInt err = aInterface->ReadPixels( surfaceBitmap ); |
243 __ALFLOGSTRING1("DoCopyScreenToBitmapL - ReadPixels returned %d", err); |
279 __ALFLOGSTRING1("DoCopyScreenToBitmapL - ReadPixels returned %d", err); |
244 User::LeaveIfError( err ); |
280 User::LeaveIfError( err ); |
245 |
281 |
246 // Copy data |
282 // Copy data |
247 TInt surfaceStride = CFbsBitmap::ScanLineLength(size.iWidth, surfaceDisplayMode); |
283 TInt surfaceStride = CFbsBitmap::ScanLineLength(size.iWidth, surfaceDisplayMode); |
437 CleanupStack::PopAndDestroy( tempBitmapDevice ); |
473 CleanupStack::PopAndDestroy( tempBitmapDevice ); |
438 CleanupStack::PopAndDestroy( bitmap ); |
474 CleanupStack::PopAndDestroy( bitmap ); |
439 } |
475 } |
440 |
476 |
441 CleanupStack::PopAndDestroy( surfaceBitmap ); |
477 CleanupStack::PopAndDestroy( surfaceBitmap ); |
442 |
|
443 CleanupStack::PopAndDestroy(); // CleanupClosePushL |
|
444 |
|
445 __ALFLOGSTRING("DoCopyScreenToBitmapL - Done"); |
|
446 } |
478 } |
447 |
479 |
448 // --------------------------------------------------------------------------- |
480 // --------------------------------------------------------------------------- |
449 // Constructor |
481 // Constructor |
450 // --------------------------------------------------------------------------- |
482 // --------------------------------------------------------------------------- |
468 // --------------------------------------------------------------------------- |
500 // --------------------------------------------------------------------------- |
469 // |
501 // |
470 CAlfDrawer::TAlfDrawerData::TAlfDrawerData() |
502 CAlfDrawer::TAlfDrawerData::TAlfDrawerData() |
471 : iClient( NULL ) |
503 : iClient( NULL ) |
472 { |
504 { |
|
505 } |
|
506 |
|
507 // --------------------------------------------------------------------------- |
|
508 // CopyScreenToBitmap |
|
509 // --------------------------------------------------------------------------- |
|
510 // |
|
511 EXPORT_C TInt AlfDrawerInternal::CopyScreenToBitmap( |
|
512 MAlfDrawerScreenInterface* aInterface, |
|
513 CFbsBitmap* aBitmap, |
|
514 const TRect& aRect ) |
|
515 { |
|
516 TRAPD(err, AlfDrawerUtils::DoCopyScreenToBitmap2L(aInterface, aBitmap, aRect)); |
|
517 return err; |
473 } |
518 } |
474 |
519 |
475 // --------------------------------------------------------------------------- |
520 // --------------------------------------------------------------------------- |
476 // CreateAlfCrpClient |
521 // CreateAlfCrpClient |
477 // --------------------------------------------------------------------------- |
522 // --------------------------------------------------------------------------- |
493 client->ConstructL(); |
538 client->ConstructL(); |
494 CleanupStack::Pop( client ); |
539 CleanupStack::Pop( client ); |
495 return client; |
540 return client; |
496 } |
541 } |
497 |
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // TAlfDrawerDirectClient |
|
545 // --------------------------------------------------------------------------- |
|
546 // |
|
547 TAlfDrawerDirectClient::TAlfDrawerDirectClient( RAlfDirectClient& aClient ) |
|
548 : iClient( aClient ) |
|
549 { |
|
550 } |
|
551 |
|
552 // --------------------------------------------------------------------------- |
|
553 // GetSizeAndRotation |
|
554 // --------------------------------------------------------------------------- |
|
555 // |
|
556 TInt TAlfDrawerDirectClient::GetSizeAndRotation(TSize& aSize, TInt& aRotation) |
|
557 { |
|
558 return iClient.GetSizeAndRotation(aSize, aRotation); |
|
559 } |
|
560 |
|
561 // --------------------------------------------------------------------------- |
|
562 // ReadPixels |
|
563 // --------------------------------------------------------------------------- |
|
564 // |
|
565 TInt TAlfDrawerDirectClient::ReadPixels(CFbsBitmap* aBitmap) |
|
566 { |
|
567 return iClient.ReadPixels(aBitmap->Handle()); |
|
568 } |
|
569 |