author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:58:58 +0300 | |
branch | RCL_3 |
changeset 88 | 3321d3e205b6 |
parent 83 | 5456b4e8b3a8 |
child 102 | ba63c83f4716 |
permissions | -rw-r--r-- |
83 | 1 |
/* |
2 |
* Copyright (c) 2008 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: Preview provider ECOM plugin |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include <bldvariant.hrh> |
|
20 |
#ifdef SYMBIAN_BUILD_GCE |
|
21 |
#define NGA |
|
22 |
#endif |
|
23 |
||
24 |
#include "previewprovidercrp.h" |
|
25 |
#include "previewmsg.h" |
|
26 |
#include "previewprovidercrplogging.h" |
|
27 |
#include <ecom/implementationproxy.h> |
|
28 |
#include <s32mem.h> //RDesReadStream |
|
29 |
||
30 |
#ifdef NGA |
|
31 |
#include <graphics/wsscreendevice.h> |
|
32 |
#endif |
|
33 |
||
34 |
// CONSTANTS |
|
35 |
const TInt KImpId( 0x20016BEC ); |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
36 |
const TInt64 KMinTimeForOrientationSwitch = 500000; // 0.5 second |
83 | 37 |
|
38 |
// -------------------------------------------------------------------------- |
|
39 |
// CPreviewProviderCRP::CreateL |
|
40 |
// -------------------------------------------------------------------------- |
|
41 |
// |
|
42 |
CWsGraphicDrawer* CPreviewProviderCRP::CreateL() |
|
43 |
{ |
|
44 |
CPreviewProviderCRP* crp = new (ELeave) CPreviewProviderCRP(); |
|
45 |
CleanupStack::PushL( crp ); |
|
46 |
crp->ConstructL(); |
|
47 |
CleanupStack::Pop( crp ); |
|
48 |
return crp; |
|
49 |
} |
|
50 |
||
51 |
// -------------------------------------------------------------------------- |
|
52 |
// CPreviewProviderCRP::ConstructL |
|
53 |
// -------------------------------------------------------------------------- |
|
54 |
// |
|
55 |
void CPreviewProviderCRP::ConstructL() |
|
56 |
{ |
|
57 |
iLastWgIdRedraw = ETrue; |
|
58 |
} |
|
59 |
||
60 |
// -------------------------------------------------------------------------- |
|
61 |
// CPreviewProviderCRP::~CPreviewProviderCRP |
|
62 |
// -------------------------------------------------------------------------- |
|
63 |
// |
|
64 |
CPreviewProviderCRP::~CPreviewProviderCRP() |
|
65 |
{ |
|
66 |
Env().UnregisterEventHandler( this ); |
|
67 |
iScreenshots.ResetAndDestroy(); |
|
68 |
iWgIds.Close(); |
|
69 |
} |
|
70 |
||
71 |
// -------------------------------------------------------------------------- |
|
72 |
// CPreviewProviderCRP::DoDraw |
|
73 |
// -------------------------------------------------------------------------- |
|
74 |
// |
|
75 |
void CPreviewProviderCRP::DoDraw( MWsGc& /*aGc*/, const TRect& /*aRect*/, |
|
76 |
const TDesC8& /*aData*/) const |
|
77 |
{ |
|
78 |
//draws nothing |
|
79 |
} |
|
80 |
||
81 |
// -------------------------------------------------------------------------- |
|
82 |
// CPreviewProviderCRP::HandleMessage |
|
83 |
// -------------------------------------------------------------------------- |
|
84 |
// |
|
85 |
void CPreviewProviderCRP::HandleMessage( const TDesC8& aData ) |
|
86 |
{ |
|
87 |
TRAP_IGNORE( DoHandleMessageL( aData ) ); |
|
88 |
} |
|
89 |
||
90 |
// -------------------------------------------------------------------------- |
|
91 |
// CPreviewProviderCRP::DoHandleMessageL |
|
92 |
// -------------------------------------------------------------------------- |
|
93 |
// |
|
94 |
void CPreviewProviderCRP::DoHandleMessageL( const TDesC8& aData ) |
|
95 |
{ |
|
96 |
TSLOG_CONTEXT( DoHandleMessageL, TSLOG_LOCAL ); |
|
97 |
TSLOG_IN(); |
|
98 |
||
99 |
RDesReadStream in( aData ); |
|
100 |
switch( in.ReadInt32L() ) |
|
101 |
{ |
|
102 |
case NPreviewMsg::ERegister: |
|
103 |
{ |
|
104 |
const TInt id = in.ReadInt32L(); |
|
105 |
Register( id ); |
|
106 |
} |
|
107 |
break; |
|
108 |
case NPreviewMsg::EUnregister: |
|
109 |
{ |
|
110 |
const TInt id = in.ReadInt32L(); |
|
111 |
Unregister( id ); |
|
112 |
} |
|
113 |
break; |
|
114 |
case NPreviewMsg::EChangeScreen: |
|
115 |
{ |
|
116 |
const TInt screen = in.ReadInt32L(); |
|
117 |
if ( Env().ScreenCount() ) |
|
118 |
{ |
|
119 |
iScreen = screen; |
|
120 |
} |
|
121 |
} |
|
122 |
break; |
|
123 |
case NPreviewMsg::ESetPreviewParam: |
|
124 |
iScreenshotSize.iWidth = in.ReadInt32L(); |
|
125 |
iScreenshotSize.iHeight = in.ReadInt32L(); |
|
126 |
iScreenshotMode = static_cast<TDisplayMode>( in.ReadInt32L() ); |
|
127 |
break; |
|
128 |
case NPreviewMsg::ETakePreview: |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
129 |
ScreenshotL( FALSE ); |
83 | 130 |
break; |
131 |
case NPreviewMsg::EAckPreviewReady: |
|
132 |
RemoveScreenshot( in.ReadInt32L() ); |
|
133 |
break; |
|
134 |
} |
|
135 |
||
136 |
TSLOG_OUT(); |
|
137 |
} |
|
138 |
||
139 |
// -------------------------------------------------------------------------- |
|
140 |
// CPreviewProviderCRP::ConstructL |
|
141 |
// -------------------------------------------------------------------------- |
|
142 |
// |
|
143 |
void CPreviewProviderCRP::ConstructL( MWsGraphicDrawerEnvironment& aEnv, |
|
144 |
const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& /*aData*/ ) |
|
145 |
{ |
|
146 |
TSLOG_CONTEXT( ConstructL, TSLOG_LOCAL ); |
|
147 |
TSLOG_IN(); |
|
148 |
||
149 |
BaseConstructL( aEnv, aId, aOwner ); |
|
150 |
aEnv.RegisterEventHandler( this, this, TWservCrEvent::EWindowGroupChanged | |
|
151 |
TWservCrEvent::EDeviceOrientationChanged | |
|
152 |
TWservCrEvent::EScreenDrawing ); |
|
153 |
iScreenChangedTime = 0; |
|
154 |
||
155 |
TSLOG_OUT(); |
|
156 |
} |
|
157 |
||
158 |
// -------------------------------------------------------------------------- |
|
159 |
// CPreviewProviderCRP::DoHandleEvent |
|
160 |
// -------------------------------------------------------------------------- |
|
161 |
// |
|
162 |
void CPreviewProviderCRP::DoHandleEvent( const TWservCrEvent& aEvent ) |
|
163 |
{ |
|
164 |
TSLOG_CONTEXT( DoHandleEvent, TSLOG_LOCAL ); |
|
165 |
TSLOG_IN(); |
|
166 |
||
167 |
if ( aEvent.Type() == TWservCrEvent::EWindowGroupChanged ) |
|
168 |
{ |
|
169 |
const TInt wgId = aEvent.WindowGroupIdentifier(); |
|
170 |
if ( iWgIds.FindInOrder( iPrevId ) >= 0 || |
|
171 |
( iPrevId == 0 && iPrevReg != 0 ) ) |
|
172 |
{ |
|
173 |
TTime currTime; |
|
174 |
currTime.HomeTime(); |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
175 |
TTimeIntervalMicroSeconds micSecondsFrom = currTime.MicroSecondsFrom( iScreenChangedTime ); |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
176 |
if ( micSecondsFrom.Int64() > KMinTimeForOrientationSwitch ) |
83 | 177 |
{ |
178 |
if ( iLastWgIdRedraw ) |
|
179 |
{ |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
180 |
TRAP_IGNORE( ScreenshotL( FALSE ) ); |
83 | 181 |
} |
182 |
} |
|
183 |
else |
|
184 |
{ |
|
185 |
// Reset time to allow screenshot taking on next wg change |
|
186 |
iScreenChangedTime = 0; |
|
187 |
} |
|
188 |
iPrevReg = 0; |
|
189 |
} |
|
190 |
iPrevId = wgId; |
|
191 |
iLastWgIdRedraw = EFalse; |
|
192 |
} |
|
193 |
else if ( aEvent.Type() == TWservCrEvent::EDeviceOrientationChanged ) |
|
194 |
{ |
|
195 |
iScreenChangedTime.HomeTime(); |
|
196 |
if ( iLastWgIdRedraw ) |
|
197 |
{ |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
198 |
TRAP_IGNORE( |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
199 |
ScreenshotL( TRUE ); |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
200 |
); |
83 | 201 |
} |
202 |
} |
|
203 |
else if ( aEvent.Type() == TWservCrEvent::EScreenDrawing ) |
|
204 |
{ |
|
205 |
iLastWgIdRedraw = ETrue; |
|
206 |
} |
|
207 |
||
208 |
TSLOG_OUT(); |
|
209 |
} |
|
210 |
||
211 |
// -------------------------------------------------------------------------- |
|
212 |
// CPreviewProviderCRP::ScaleComplete |
|
213 |
// -------------------------------------------------------------------------- |
|
214 |
// |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
215 |
void CPreviewProviderCRP::ScaleCompleteL( const CFbsBitmap& aBitmap, |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
216 |
TBool aRotation ) |
83 | 217 |
{ |
218 |
TSLOG_CONTEXT( ScaleComplete, TSLOG_LOCAL ); |
|
219 |
TSLOG_IN(); |
|
220 |
||
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
221 |
TInt msgType = NPreviewMsg::EPreviewReady; |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
222 |
if ( aRotation ) |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
223 |
{ |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
224 |
msgType = iClockwiseRot ? |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
225 |
NPreviewMsg::EBitmapRotationNeeded90 : |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
226 |
NPreviewMsg::EBitmapRotationNeeded270; |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
227 |
} |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
228 |
|
83 | 229 |
const TInt msg[] = { |
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
230 |
msgType, |
83 | 231 |
iPrevId?iPrevId:iPrevReg, |
232 |
aBitmap.Handle() |
|
233 |
}; |
|
234 |
TPckgC<TInt[sizeof(msg) / sizeof(TInt)]> buf(msg); |
|
235 |
User::LeaveIfError( SendMessage( buf ) ); |
|
236 |
TSLOG3( TSLOG_INFO, "size = %dx%d handle = %d", |
|
237 |
aBitmap.SizeInPixels().iWidth, |
|
238 |
aBitmap.SizeInPixels().iHeight, |
|
239 |
aBitmap.Handle() ); |
|
240 |
TSLOG_OUT(); |
|
241 |
} |
|
242 |
||
243 |
// -------------------------------------------------------------------------- |
|
244 |
// CPreviewProviderCRP::UnregisterComplete |
|
245 |
// -------------------------------------------------------------------------- |
|
246 |
// |
|
247 |
void CPreviewProviderCRP::UnregisterComplete( TInt aWgId ) |
|
248 |
{ |
|
249 |
TSLOG_CONTEXT( UnregisterComplete, TSLOG_LOCAL ); |
|
250 |
TSLOG_IN(); |
|
251 |
||
252 |
const TInt msg[] = { |
|
253 |
NPreviewMsg::EUnregisterReady, |
|
254 |
aWgId, |
|
255 |
0 |
|
256 |
}; |
|
257 |
TPckgC<TInt[sizeof(msg) / sizeof(TInt)]> buf(msg); |
|
258 |
SendMessage(buf); |
|
259 |
||
260 |
TSLOG_OUT(); |
|
261 |
} |
|
262 |
||
263 |
// -------------------------------------------------------------------------- |
|
264 |
// CPreviewProviderCRP::Register |
|
265 |
// -------------------------------------------------------------------------- |
|
266 |
// |
|
267 |
void CPreviewProviderCRP::Register( TInt aWgId ) |
|
268 |
{ |
|
269 |
TSLOG_CONTEXT( Register, TSLOG_LOCAL ); |
|
270 |
TSLOG_IN(); |
|
271 |
||
272 |
iPrevReg = aWgId; |
|
273 |
iWgIds.InsertInOrder( aWgId ); |
|
274 |
||
275 |
TSLOG_OUT(); |
|
276 |
} |
|
277 |
||
278 |
// -------------------------------------------------------------------------- |
|
279 |
// CPreviewProviderCRP::Unregister |
|
280 |
// -------------------------------------------------------------------------- |
|
281 |
// |
|
282 |
void CPreviewProviderCRP::Unregister( TInt aWgId ) |
|
283 |
{ |
|
284 |
TSLOG_CONTEXT( Unregister, TSLOG_LOCAL ); |
|
285 |
TSLOG_IN(); |
|
286 |
||
287 |
const TInt index = iWgIds.FindInOrder( aWgId ); |
|
288 |
if ( index >= 0 ) |
|
289 |
{ |
|
290 |
iWgIds.Remove( index ); |
|
291 |
} |
|
292 |
||
293 |
UnregisterComplete( aWgId ); |
|
294 |
||
295 |
TSLOG_OUT(); |
|
296 |
} |
|
297 |
||
298 |
// -------------------------------------------------------------------------- |
|
299 |
// CPreviewProviderCRP::ScreenShotL |
|
300 |
// -------------------------------------------------------------------------- |
|
301 |
// |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
302 |
void CPreviewProviderCRP::ScreenshotL( TBool aRotation ) |
83 | 303 |
{ |
304 |
CFbsBitmap* screenshot = new (ELeave)CFbsBitmap(); |
|
305 |
CleanupStack::PushL( screenshot ); |
|
306 |
ScreenshotL( *screenshot ); |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
307 |
ScaleCompleteL( *screenshot, aRotation ); |
83 | 308 |
iScreenshots.InsertL( screenshot, iScreenshots.Count() ); |
309 |
CleanupStack::Pop( screenshot ); |
|
310 |
CheckOverflow(); |
|
311 |
} |
|
312 |
||
313 |
// -------------------------------------------------------------------------- |
|
314 |
// CPreviewProviderCRP::ScreenShotL |
|
315 |
// -------------------------------------------------------------------------- |
|
316 |
// |
|
317 |
void CPreviewProviderCRP::ScreenshotL(CFbsBitmap& aBitmap) |
|
318 |
{ |
|
319 |
TSLOG_CONTEXT( ScreenShot, TSLOG_LOCAL ); |
|
320 |
TSLOG_IN(); |
|
321 |
||
322 |
if( 0 > iScreen || Env().ScreenCount() <= iScreen ) |
|
323 |
{ |
|
324 |
//screen offset out of range. skip request |
|
325 |
User::Leave(KErrArgument); |
|
326 |
} |
|
327 |
// Find the screen resolution |
|
328 |
MWsScreenConfig* screenConfig = |
|
329 |
Env().Screen( iScreen )->ObjectInterface<MWsScreenConfig>(); |
|
330 |
||
331 |
const TSize sz = screenConfig->ScreenModeSizeInPixels(); |
|
332 |
||
333 |
// Get the screen buffer (containing screenshot data) |
|
334 |
MWsFrontBuffer* screenFront = |
|
335 |
Env().Screen( iScreen )->ObjectInterface<MWsFrontBuffer>(); |
|
336 |
||
337 |
// With NGA we do not support downscaling of the screenshots. |
|
338 |
// So use the size of the screen if no screenshot size has been explicitly |
|
339 |
// set or if the old method for taking screenshots is not available. |
|
340 |
if ( iScreenshotSize.iWidth == 0 || |
|
341 |
iScreenshotSize.iHeight == 0 || |
|
342 |
!screenFront ) |
|
343 |
{ |
|
344 |
iScreenshotSize = sz; |
|
345 |
} |
|
346 |
||
347 |
// Mark direction for possible rotation |
|
348 |
iClockwiseRot = iScreenshotSize.iWidth > iScreenshotSize.iHeight; |
|
349 |
||
350 |
// Use the the same DisplayMode as for the source image |
|
351 |
// so override the display mode, ignoring any requests. |
|
352 |
iScreenshotMode = screenConfig->DisplayMode(); |
|
353 |
||
354 |
TSLOG3( TSLOG_INFO, "iShotSize: %dx%d mode: %d", |
|
355 |
iScreenshotSize.iWidth, iScreenshotSize.iHeight, iScreenshotMode ); |
|
356 |
||
357 |
aBitmap.Reset(); |
|
358 |
User::LeaveIfError( aBitmap.Create( iScreenshotSize, iScreenshotMode ) ); |
|
359 |
||
360 |
// Check if front buffer is available. |
|
361 |
// Will always be NULL with NGA. |
|
362 |
if ( screenFront ) |
|
363 |
{ |
|
364 |
TSLOG0( TSLOG_INFO, "non-NGA, using front buffer" ); |
|
365 |
FrontBufferScreenShot( aBitmap, *screenFront, sz, screenConfig->Stride() ); |
|
366 |
} |
|
367 |
#ifdef NGA |
|
368 |
else |
|
369 |
{ |
|
370 |
TSLOG0( TSLOG_INFO, "NGA, using CopyScreenToBitmapL" ); |
|
371 |
MWsScreenDevice* screenDevice = static_cast<MWsScreenDevice*>( |
|
372 |
Env().Screen( iScreen )->ResolveObjectInterface( |
|
373 |
MWsScreenDevice::EWsObjectInterfaceId ) ); |
|
374 |
User::LeaveIfNull( screenDevice ); |
|
375 |
screenDevice->CopyScreenToBitmapL( &aBitmap, iScreenshotSize ); |
|
376 |
} |
|
377 |
#endif |
|
378 |
TSLOG_OUT(); |
|
379 |
} |
|
380 |
||
381 |
// -------------------------------------------------------------------------- |
|
382 |
// CPreviewProviderCRP::RemoveScreenshot |
|
383 |
// -------------------------------------------------------------------------- |
|
384 |
// |
|
385 |
void CPreviewProviderCRP::RemoveScreenshot( TInt aBitmapHandle ) |
|
386 |
{ |
|
387 |
for( int iter(0); iter < iScreenshots.Count(); ++iter ) |
|
388 |
{ |
|
389 |
if( iScreenshots[iter]->Handle() == aBitmapHandle ) |
|
390 |
{ |
|
391 |
delete iScreenshots[iter]; |
|
392 |
iScreenshots.Remove(iter); |
|
393 |
break; |
|
394 |
} |
|
395 |
} |
|
396 |
} |
|
397 |
||
398 |
// -------------------------------------------------------------------------- |
|
399 |
// CPreviewProviderCRP::CheckOverflow |
|
400 |
// -------------------------------------------------------------------------- |
|
401 |
// |
|
402 |
void CPreviewProviderCRP::CheckOverflow() |
|
403 |
{ |
|
404 |
TInt overflow( iScreenshots.Count() - KMaxShots); |
|
405 |
while( 0 < overflow-- ) |
|
406 |
{ |
|
407 |
delete iScreenshots[0]; |
|
408 |
iScreenshots.Remove(0); |
|
409 |
} |
|
410 |
} |
|
411 |
||
412 |
// -------------------------------------------------------------------------- |
|
413 |
// CPreviewProviderCRP::FrontBufferScreenShot |
|
414 |
// -------------------------------------------------------------------------- |
|
415 |
// |
|
416 |
void CPreviewProviderCRP::FrontBufferScreenShot( CFbsBitmap& aBitmap, |
|
417 |
MWsFrontBuffer& aFront, |
|
418 |
const TSize& aSrcSize, |
|
419 |
TInt aSrcStride ) |
|
420 |
{ |
|
421 |
TSLOG_CONTEXT( CPreviewProviderCRP::FrontBufferScreenShot, TSLOG_LOCAL ); |
|
422 |
TSLOG_IN(); |
|
423 |
||
424 |
const TUint8* src = static_cast<const TUint8*> ( aFront.GetBits() ); |
|
425 |
TSLOG1( TSLOG_INFO, "src address = [%d]", src ); |
|
426 |
||
427 |
TInt srcstride( aSrcStride ); |
|
428 |
TInt srcwidth( aSrcSize.iWidth ); |
|
429 |
TInt srcheight( aSrcSize.iHeight ); |
|
430 |
TInt dststride( aBitmap.DataStride() ); |
|
431 |
TInt dstheight( iScreenshotSize.iHeight ); |
|
432 |
TInt dstwidth( iScreenshotSize.iWidth ); |
|
433 |
TInt stepdst( dststride / dstwidth ); |
|
434 |
TInt stepsrc( srcstride / srcwidth ); |
|
435 |
// scale must be TInt type |
|
436 |
TInt scaleX( aSrcSize.iWidth / iScreenshotSize.iWidth ); |
|
437 |
TInt scaleY( aSrcSize.iHeight / iScreenshotSize.iHeight ); |
|
438 |
||
439 |
aBitmap.LockHeap(); |
|
440 |
||
441 |
TUint8* dst = ( TUint8* ) aBitmap.DataAddress(); |
|
442 |
||
443 |
TInt minWidth = Min( srcwidth, dstwidth ); |
|
444 |
TInt minHeight = Min( srcheight, dstheight ); |
|
445 |
TInt minStep = Min( stepsrc, stepdst ); |
|
446 |
||
447 |
for ( TInt y = minHeight; y > 0; y-- ) |
|
448 |
{ |
|
449 |
for ( TInt x = minWidth; x > 0; x-- ) |
|
450 |
{ |
|
451 |
Mem::Copy( dst, src, minStep ); |
|
452 |
dst += stepdst; |
|
453 |
src += scaleX*stepdst; |
|
454 |
} |
|
455 |
src += srcstride - scaleX * stepdst * minWidth; |
|
456 |
src += ( scaleY - 1 ) * srcstride; |
|
457 |
} |
|
458 |
||
459 |
aBitmap.UnlockHeap(); |
|
460 |
TSLOG_OUT(); |
|
461 |
} |
|
462 |
||
463 |
// -------------------------------------------------------------------------- |
|
464 |
// KImplementationTable |
|
465 |
// -------------------------------------------------------------------------- |
|
466 |
// |
|
467 |
LOCAL_C const TImplementationProxy KImplementationTable[] = |
|
468 |
{ |
|
469 |
IMPLEMENTATION_PROXY_ENTRY(KImpId, CPreviewProviderCRP::CreateL) |
|
470 |
}; |
|
471 |
||
472 |
// -------------------------------------------------------------------------- |
|
473 |
// ImplementationGroupProxy |
|
474 |
// -------------------------------------------------------------------------- |
|
475 |
// |
|
476 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
477 |
{ |
|
478 |
aTableCount = (sizeof(KImplementationTable) / sizeof(TImplementationProxy)); |
|
479 |
return KImplementationTable; |
|
480 |
} |
|
481 |
||
482 |
||
483 |
// End of file |