64
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: CAlfDrawer implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#include <alf/alfdrawer.h>
|
|
22 |
#include <alf/alfdirectclient.h>
|
|
23 |
#include "alfcrppluginclient.h"
|
|
24 |
#include "alflogger.h"
|
|
25 |
#include "alfdrawerinternal.h"
|
|
26 |
|
|
27 |
#include <coemain.h>
|
|
28 |
#include <w32std.h>
|
|
29 |
#include <fbs.h>
|
|
30 |
|
|
31 |
// Class to hold internal alf drawer data.
|
|
32 |
NONSHARABLE_CLASS( CAlfDrawer::TAlfDrawerData )
|
|
33 |
{
|
|
34 |
public:
|
|
35 |
TAlfDrawerData();
|
|
36 |
|
|
37 |
public:
|
|
38 |
CAlfCrpPluginClient* iClient;
|
|
39 |
};
|
|
40 |
|
|
41 |
// Creates CAlfCrpPluginClient instance, returns error code.
|
|
42 |
static TInt CreateAlfCrpClient(CAlfCrpPluginClient*& aClient);
|
|
43 |
// Creates CAlfCrpPluginClient instance.
|
|
44 |
static CAlfCrpPluginClient* CreateAlfCrpClientL();
|
|
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 |
|
|
57 |
/**
|
|
58 |
* Misc utility methods for CAlfDrawer.
|
|
59 |
*/
|
|
60 |
NONSHARABLE_CLASS(AlfDrawerUtils)
|
|
61 |
{
|
|
62 |
public:
|
|
63 |
|
|
64 |
enum TRotation
|
|
65 |
{
|
|
66 |
ERotationNone,
|
|
67 |
ERotation90,
|
|
68 |
ERotation180,
|
|
69 |
ERotation270
|
|
70 |
};
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Inverse rotate.
|
|
74 |
*/
|
|
75 |
static void RotateBack(TInt aVirtualRotation, TRect& aRect, TSize aScreenSize)
|
|
76 |
{
|
|
77 |
if( aVirtualRotation == ERotation90 || aVirtualRotation == ERotation270 )
|
|
78 |
{
|
|
79 |
RotateRect( aVirtualRotation, aRect, aScreenSize, ETrue );
|
|
80 |
}
|
|
81 |
else if( aVirtualRotation == ERotation180 )
|
|
82 |
{
|
|
83 |
RotateRect( aVirtualRotation, aRect, aScreenSize, EFalse );
|
|
84 |
}
|
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Rotate rect
|
|
89 |
*/
|
|
90 |
static void RotateRect(TInt aDirection, TRect& aRect, TSize aScreenSize, TBool aMirror)
|
|
91 |
{
|
|
92 |
if (aMirror) aDirection = (aDirection+2)%4; // magic
|
|
93 |
for (;aDirection > 0; aDirection--)
|
|
94 |
{
|
|
95 |
TSize rotatedSize(aRect.Size().iHeight, aRect.Size().iWidth);
|
|
96 |
aRect = TRect(TPoint(aRect.iTl.iY, aScreenSize.iWidth - aRect.iTl.iX - rotatedSize.iHeight ), rotatedSize);
|
|
97 |
aScreenSize = TSize(aScreenSize.iHeight, aScreenSize.iWidth);
|
|
98 |
}
|
|
99 |
}
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Copies screen to bitmap using 'read pixels' operation.
|
|
103 |
*/
|
|
104 |
static void DoCopyScreenToBitmapL(
|
|
105 |
CWsScreenDevice& aDevice,
|
|
106 |
CFbsBitmap* aBitmap,
|
|
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 );
|
|
116 |
|
|
117 |
};
|
|
118 |
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
// NewL
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
EXPORT_C CAlfDrawer* CAlfDrawer::NewL()
|
|
124 |
{
|
|
125 |
CAlfDrawer* self = new (ELeave) CAlfDrawer;
|
|
126 |
CleanupStack::PushL( self );
|
|
127 |
self->ConstructL();
|
|
128 |
CleanupStack::Pop( self );
|
|
129 |
return self;
|
|
130 |
}
|
|
131 |
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
// Destructor
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
EXPORT_C CAlfDrawer::~CAlfDrawer()
|
|
137 |
{
|
|
138 |
if ( iData )
|
|
139 |
{
|
|
140 |
delete iData->iClient;
|
|
141 |
delete iData;
|
|
142 |
}
|
|
143 |
}
|
|
144 |
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
// Finish
|
|
147 |
// ---------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
EXPORT_C TInt CAlfDrawer::Finish()
|
|
150 |
{
|
|
151 |
// First perform RWsSession finish operation to ensure
|
|
152 |
// that all drawing commands have been issued to renderstage.
|
|
153 |
TInt err = CCoeEnv::Static()->WsSession().Finish();
|
|
154 |
|
|
155 |
// Then create CRP instance (if needed).
|
|
156 |
if ( err == KErrNone && !iData->iClient )
|
|
157 |
{
|
|
158 |
err = CreateAlfCrpClient( iData->iClient );
|
|
159 |
}
|
|
160 |
|
|
161 |
// Finally, wait until alf side has finished rendering.
|
|
162 |
if ( err == KErrNone && iData->iClient )
|
|
163 |
{
|
|
164 |
iData->iClient->Synchronize();
|
|
165 |
}
|
|
166 |
|
|
167 |
return err;
|
|
168 |
}
|
|
169 |
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
// FallbackCopyScreenToBitmap
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
EXPORT_C TInt CAlfDrawer::FallbackCopyScreenToBitmap(
|
|
175 |
CWsScreenDevice& aDevice,
|
|
176 |
CFbsBitmap* aBitmap,
|
|
177 |
const TRect& aRect)
|
|
178 |
{
|
|
179 |
TRAPD(err, AlfDrawerUtils::DoCopyScreenToBitmapL(aDevice, aBitmap, aRect));
|
|
180 |
return err;
|
|
181 |
}
|
|
182 |
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
// DoCopyScreenToBitmapL
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
void AlfDrawerUtils::DoCopyScreenToBitmapL(
|
|
188 |
CWsScreenDevice& aDevice,
|
|
189 |
CFbsBitmap* aBitmap,
|
|
190 |
const TRect& aRect )
|
|
191 |
{
|
|
192 |
if (aDevice.GetScreenNumber() != 0) // only screen 0 supported for now
|
|
193 |
{
|
|
194 |
User::Leave(KErrNotSupported);
|
|
195 |
}
|
|
196 |
|
|
197 |
if ( !aBitmap ||
|
|
198 |
!aBitmap->Handle() ||
|
|
199 |
aBitmap->IsCompressedInRAM() ||
|
|
200 |
aBitmap->ExtendedBitmapType() != KNullUid )
|
|
201 |
{
|
|
202 |
User::Leave(KErrArgument);
|
|
203 |
}
|
|
204 |
|
|
205 |
__ALFLOGSTRING("DoCopyScreenToBitmapL begin");
|
|
206 |
|
|
207 |
RAlfDirectClient client;
|
|
208 |
CleanupClosePushL(client);
|
|
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 |
{
|
|
227 |
// Get size & virtual rotation from ALF side.
|
|
228 |
// GetSizeAndRotation will also create session to server.
|
|
229 |
|
|
230 |
TInt rotation = 0;
|
|
231 |
TSize size;
|
|
232 |
User::LeaveIfError(aInterface->GetSizeAndRotation(size, rotation));
|
|
233 |
|
|
234 |
// Calculate device size in pixels (same as aDevice.SizeInPixels())
|
|
235 |
TSize deviceSize = size;
|
|
236 |
if (rotation == AlfDrawerUtils::ERotation90 ||
|
|
237 |
rotation == AlfDrawerUtils::ERotation270 )
|
|
238 |
{
|
|
239 |
deviceSize.iWidth = size.iHeight;
|
|
240 |
deviceSize.iHeight = size.iWidth;
|
|
241 |
}
|
|
242 |
|
|
243 |
// Clip aRect to screen boundaries
|
|
244 |
TRect actualRect(deviceSize);
|
|
245 |
actualRect.Intersection(aRect);
|
|
246 |
|
|
247 |
__ALFLOGSTRING2("DoCopyScreenToBitmapL - requested rect origin %d x %d", actualRect.iTl.iX, actualRect.iTl.iY ) ;
|
|
248 |
__ALFLOGSTRING2("DoCopyScreenToBitmapL - requested rect %d x %d", actualRect.Size().iWidth, actualRect.Size().iHeight ) ;
|
|
249 |
__ALFLOGSTRING2("DoCopyScreenToBitmapL - bitmap rect %d x %d", aBitmap->SizeInPixels().iWidth, aBitmap->SizeInPixels().iHeight );
|
|
250 |
__ALFLOGSTRING1("DoCopyScreenToBitmapL - bitmap mode %d", aBitmap->DisplayMode() );
|
|
251 |
|
|
252 |
if ( TRect( aBitmap->SizeInPixels() ).IsEmpty() ||
|
|
253 |
actualRect.IsEmpty() )
|
|
254 |
{
|
|
255 |
__ALFLOGSTRING("DoCopyScreenToBitmapL - empty rect or zero bitmap size");
|
|
256 |
return;
|
|
257 |
}
|
|
258 |
|
|
259 |
// Select display mode.
|
|
260 |
|
|
261 |
TDisplayMode surfaceDisplayMode = EColor64K;
|
|
262 |
TDisplayMode bitmapDisplayMode = aBitmap->DisplayMode();
|
|
263 |
if ( bitmapDisplayMode == EColor16MU ||
|
|
264 |
bitmapDisplayMode == EColor16MA ||
|
|
265 |
bitmapDisplayMode == EColor16MAP )
|
|
266 |
{
|
|
267 |
surfaceDisplayMode = bitmapDisplayMode;
|
|
268 |
}
|
|
269 |
|
|
270 |
__ALFLOGSTRING3("DoCopyScreenToBitmapL - surface size %d x %d, mode %d",
|
|
271 |
size.iWidth, size.iHeight, surfaceDisplayMode ) ;
|
|
272 |
|
|
273 |
// Read pixels to temporary bitmap
|
|
274 |
CFbsBitmap* surfaceBitmap = new (ELeave) CFbsBitmap;
|
|
275 |
CleanupStack::PushL( surfaceBitmap );
|
|
276 |
User::LeaveIfError( surfaceBitmap->Create( size, surfaceDisplayMode ) );
|
|
277 |
|
|
278 |
TInt err = aInterface->ReadPixels( surfaceBitmap );
|
|
279 |
__ALFLOGSTRING1("DoCopyScreenToBitmapL - ReadPixels returned %d", err);
|
|
280 |
User::LeaveIfError( err );
|
|
281 |
|
|
282 |
// Copy data
|
|
283 |
TInt surfaceStride = CFbsBitmap::ScanLineLength(size.iWidth, surfaceDisplayMode);
|
|
284 |
__ALFLOGSTRING2("DoCopyScreenToBitmapL - DisplayMode %d, Stride %d", surfaceDisplayMode, surfaceStride);
|
|
285 |
|
|
286 |
TDisplayMode displayMode = surfaceDisplayMode;
|
|
287 |
|
|
288 |
TInt8 bytesPerPixel = 2;
|
|
289 |
switch( displayMode )
|
|
290 |
{
|
|
291 |
case EColor64K:
|
|
292 |
{
|
|
293 |
bytesPerPixel = 2;
|
|
294 |
break;
|
|
295 |
}
|
|
296 |
case EColor16MU:
|
|
297 |
case EColor16MA:
|
|
298 |
case EColor16MAP:
|
|
299 |
{
|
|
300 |
bytesPerPixel = 4;
|
|
301 |
break;
|
|
302 |
}
|
|
303 |
|
|
304 |
default:
|
|
305 |
{
|
|
306 |
__ALFLOGSTRING1("DoCopyScreenToBitmapL - display mode not supported %d", displayMode);
|
|
307 |
User::Leave( KErrNotSupported );
|
|
308 |
}
|
|
309 |
}
|
|
310 |
|
|
311 |
// actualRect (/aRect) must be converted to correct coordinate system.
|
|
312 |
TRect surfaceRect(actualRect);
|
|
313 |
AlfDrawerUtils::RotateBack(rotation, surfaceRect, deviceSize);
|
|
314 |
surfaceRect.Intersection(TRect(size));
|
|
315 |
|
|
316 |
__ALFLOGSTRING2("DoCopyScreenToBitmapL - surface rect tl %d x %d", surfaceRect.iTl.iX, surfaceRect.iTl.iY ) ;
|
|
317 |
__ALFLOGSTRING2("DoCopyScreenToBitmapL - surface rect size %d x %d", surfaceRect.Size().iWidth, surfaceRect.Size().iHeight ) ;
|
|
318 |
|
|
319 |
CFbsBitmap* bitmap = NULL;
|
|
320 |
TBool needTempBitmap = ETrue;
|
|
321 |
|
|
322 |
if( aBitmap->DisplayMode() == displayMode && actualRect == aRect && aBitmap->SizeInPixels() == aRect.Size() )
|
|
323 |
{
|
|
324 |
// Copy data direcly to given bitmap
|
|
325 |
bitmap = aBitmap;
|
|
326 |
needTempBitmap = EFalse;
|
|
327 |
}
|
|
328 |
else
|
|
329 |
{
|
|
330 |
// Create temporary bitmap which maches the sufrace's pixel format and source rect size
|
|
331 |
bitmap = new (ELeave) CFbsBitmap;
|
|
332 |
CleanupStack::PushL( bitmap );
|
|
333 |
TInt err = bitmap->Create( actualRect.Size(), displayMode );
|
|
334 |
__ALFLOGSTRING1("DoCopyScreenToBitmapL - Create returned %d", err );
|
|
335 |
User::LeaveIfError( err );
|
|
336 |
__ALFLOGSTRING("DoCopyScreenToBitmapL - display mode or size don't mach -> using temp bitmap" );
|
|
337 |
}
|
|
338 |
|
|
339 |
surfaceBitmap->BeginDataAccess();
|
|
340 |
bitmap->BeginDataAccess();
|
|
341 |
|
|
342 |
TUint8* surfacePtr = (TUint8*)surfaceBitmap->DataAddress() + surfaceStride * surfaceRect.iTl.iY;
|
|
343 |
|
|
344 |
TUint8* bitmapPtr = (TUint8*)bitmap->DataAddress();
|
|
345 |
TInt rowBegin = surfaceRect.iTl.iX * bytesPerPixel;
|
|
346 |
TInt captureBitmapWidth = surfaceRect.Width() * bytesPerPixel;
|
|
347 |
|
|
348 |
const TSize bitmapSize = bitmap->SizeInPixels();
|
|
349 |
|
|
350 |
// Initialize with direct copy case parameters
|
|
351 |
TInt bitmapPtrColumnDelta = bytesPerPixel;
|
|
352 |
TInt bitmapPtrRowDelta = bitmap->DataStride();
|
|
353 |
|
|
354 |
const TSize surfaceRectSize(surfaceRect.Size());
|
|
355 |
if ( rotation == AlfDrawerUtils::ERotationNone )
|
|
356 |
{
|
|
357 |
__ALFLOGSTRING("DoCopyScreenToBitmapL - direct copy") ;
|
|
358 |
|
|
359 |
// Direct copy case
|
|
360 |
for ( TInt row = surfaceRectSize.iHeight - 1 ; row >= 0 ; --row )
|
|
361 |
{
|
|
362 |
// Copy only the desired part of the bitmap
|
|
363 |
memcpy( bitmapPtr,
|
|
364 |
surfacePtr + rowBegin,
|
|
365 |
captureBitmapWidth );
|
|
366 |
surfacePtr += surfaceStride;
|
|
367 |
bitmapPtr += bitmap->DataStride();
|
|
368 |
}
|
|
369 |
}
|
|
370 |
else
|
|
371 |
{
|
|
372 |
// Handle rotation cases
|
|
373 |
//
|
|
374 |
// 0 degree case
|
|
375 |
// A B C
|
|
376 |
// 1 2 3
|
|
377 |
// 90 degrees anti-clockwise
|
|
378 |
// C 3
|
|
379 |
// B 2
|
|
380 |
// A 1
|
|
381 |
// 180 degrees anti-clockwise
|
|
382 |
// 3 2 1
|
|
383 |
// C B A
|
|
384 |
// 270 degrees anti-clockwise
|
|
385 |
// 1 A
|
|
386 |
// 2 B
|
|
387 |
// 3 C
|
|
388 |
//
|
|
389 |
switch (rotation)
|
|
390 |
{
|
|
391 |
case AlfDrawerUtils::ERotation90:
|
|
392 |
bitmapPtrColumnDelta = -bitmap->DataStride();
|
|
393 |
bitmapPtrRowDelta = bytesPerPixel;
|
|
394 |
bitmapPtr += ( bitmapSize.iHeight - 1 ) * bitmap->DataStride();
|
|
395 |
break;
|
|
396 |
case AlfDrawerUtils::ERotation180:
|
|
397 |
bitmapPtrColumnDelta = -bytesPerPixel;
|
|
398 |
bitmapPtrRowDelta = -bitmap->DataStride();
|
|
399 |
bitmapPtr += ( bitmapSize.iHeight - 1 ) * bitmap->DataStride() + ( bitmapSize.iWidth - 1 ) * bytesPerPixel;
|
|
400 |
break;
|
|
401 |
case AlfDrawerUtils::ERotation270:
|
|
402 |
bitmapPtrColumnDelta = bitmap->DataStride();
|
|
403 |
bitmapPtrRowDelta = -bytesPerPixel;
|
|
404 |
bitmapPtr += ( bitmapSize.iWidth - 1 ) * bytesPerPixel;
|
|
405 |
break;
|
|
406 |
default:
|
|
407 |
break;
|
|
408 |
}
|
|
409 |
|
|
410 |
// We go through surface row by row, column by column and
|
|
411 |
// copy pixel data to appropriate place to bitmap
|
|
412 |
if ( bytesPerPixel == 4 )
|
|
413 |
{
|
|
414 |
__ALFLOGSTRING("DoCopyScreenToBitmapL - four bytes per pixel, rotated copy") ;
|
|
415 |
|
|
416 |
for ( TInt row = surfaceRectSize.iHeight - 1 ; row >= 0 ; --row )
|
|
417 |
{
|
|
418 |
TUint8* rowBitmapPtr = bitmapPtr;
|
|
419 |
TUint8* rowSurfacePtr = surfacePtr + rowBegin;
|
|
420 |
for ( TInt column = surfaceRectSize.iWidth - 1 ; column >= 0 ; --column )
|
|
421 |
{
|
|
422 |
*((TUint32*)rowBitmapPtr) = *((TUint32*)rowSurfacePtr);
|
|
423 |
|
|
424 |
rowBitmapPtr += bitmapPtrColumnDelta;
|
|
425 |
rowSurfacePtr += bytesPerPixel;
|
|
426 |
}
|
|
427 |
|
|
428 |
surfacePtr += surfaceStride;
|
|
429 |
bitmapPtr += bitmapPtrRowDelta;
|
|
430 |
}
|
|
431 |
}
|
|
432 |
else
|
|
433 |
{
|
|
434 |
// Now bytesPerPixel == 2
|
|
435 |
__ALFLOGSTRING("DoCopyScreenToBitmapL - two bytes per pixel, rotated copy") ;
|
|
436 |
for ( TInt row = surfaceRectSize.iHeight - 1 ; row >= 0 ; --row )
|
|
437 |
{
|
|
438 |
TUint8* rowBitmapPtr = bitmapPtr;
|
|
439 |
TUint8* rowSurfacePtr = surfacePtr + rowBegin;
|
|
440 |
for ( TInt column = surfaceRectSize.iWidth - 1 ; column >= 0 ; --column )
|
|
441 |
{
|
|
442 |
*((TUint16*)rowBitmapPtr) = *((TUint16*)rowSurfacePtr);
|
|
443 |
|
|
444 |
rowBitmapPtr += bitmapPtrColumnDelta;
|
|
445 |
rowSurfacePtr += bytesPerPixel;
|
|
446 |
}
|
|
447 |
|
|
448 |
surfacePtr += surfaceStride;
|
|
449 |
bitmapPtr += bitmapPtrRowDelta;
|
|
450 |
}
|
|
451 |
}
|
|
452 |
}
|
|
453 |
__ALFLOGSTRING("DoCopyScreenToBitmapL - copy finished" );
|
|
454 |
surfaceBitmap->EndDataAccess(ETrue);
|
|
455 |
bitmap->EndDataAccess();
|
|
456 |
|
|
457 |
if( !needTempBitmap )
|
|
458 |
{
|
|
459 |
bitmap = NULL;
|
|
460 |
}
|
|
461 |
else // bitblit the temporary bitmap to given bitmap
|
|
462 |
{
|
|
463 |
CFbsBitmapDevice* tempBitmapDevice = CFbsBitmapDevice::NewL( aBitmap );
|
|
464 |
CleanupStack::PushL( tempBitmapDevice );
|
|
465 |
CFbsBitGc* tempBitmapGc = NULL;
|
|
466 |
User::LeaveIfError( tempBitmapDevice->CreateContext( tempBitmapGc ) );
|
|
467 |
CleanupStack::PushL( tempBitmapGc );
|
|
468 |
|
|
469 |
tempBitmapGc->SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
|
|
470 |
tempBitmapGc->BitBlt( TPoint(), bitmap );
|
|
471 |
|
|
472 |
CleanupStack::PopAndDestroy( tempBitmapGc );
|
|
473 |
CleanupStack::PopAndDestroy( tempBitmapDevice );
|
|
474 |
CleanupStack::PopAndDestroy( bitmap );
|
|
475 |
}
|
|
476 |
|
|
477 |
CleanupStack::PopAndDestroy( surfaceBitmap );
|
|
478 |
}
|
|
479 |
|
|
480 |
// ---------------------------------------------------------------------------
|
|
481 |
// Constructor
|
|
482 |
// ---------------------------------------------------------------------------
|
|
483 |
//
|
|
484 |
CAlfDrawer::CAlfDrawer()
|
|
485 |
{
|
|
486 |
}
|
|
487 |
|
|
488 |
// ---------------------------------------------------------------------------
|
|
489 |
// ConstructL
|
|
490 |
// ---------------------------------------------------------------------------
|
|
491 |
//
|
|
492 |
void CAlfDrawer::ConstructL()
|
|
493 |
{
|
|
494 |
iData = new (ELeave) TAlfDrawerData;
|
|
495 |
CreateAlfCrpClient( iData->iClient );
|
|
496 |
}
|
|
497 |
|
|
498 |
// ---------------------------------------------------------------------------
|
|
499 |
// Constructor
|
|
500 |
// ---------------------------------------------------------------------------
|
|
501 |
//
|
|
502 |
CAlfDrawer::TAlfDrawerData::TAlfDrawerData()
|
|
503 |
: iClient( NULL )
|
|
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;
|
|
518 |
}
|
|
519 |
|
|
520 |
// ---------------------------------------------------------------------------
|
|
521 |
// CreateAlfCrpClient
|
|
522 |
// ---------------------------------------------------------------------------
|
|
523 |
//
|
|
524 |
static TInt CreateAlfCrpClient(CAlfCrpPluginClient*& aClient)
|
|
525 |
{
|
|
526 |
TRAPD(err, aClient = CreateAlfCrpClientL());
|
|
527 |
return err;
|
|
528 |
}
|
|
529 |
|
|
530 |
// ---------------------------------------------------------------------------
|
|
531 |
// CreateAlfCrpClientL
|
|
532 |
// ---------------------------------------------------------------------------
|
|
533 |
//
|
|
534 |
static CAlfCrpPluginClient* CreateAlfCrpClientL()
|
|
535 |
{
|
|
536 |
CAlfCrpPluginClient* client = new (ELeave) CAlfCrpPluginClient;
|
|
537 |
CleanupStack::PushL( client );
|
|
538 |
client->ConstructL();
|
|
539 |
CleanupStack::Pop( client );
|
|
540 |
return client;
|
|
541 |
}
|
|
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 |
|