author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:32:09 +0300 | |
branch | RCL_3 |
changeset 75 | 01504893d9cb |
parent 68 | 5b238bc8ffb6 |
permissions | -rw-r--r-- |
60 | 1 |
/* |
2 |
* Copyright (c) 2008-2009 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <graphics/surface.h> |
|
19 |
#include <graphics/surfacemanager.h> |
|
20 |
#include <graphics/surfaceupdateclient.h> |
|
21 |
#include <graphics/surface_hints.h> |
|
22 |
#include <e32math.h> |
|
23 |
#include <apgcli.h> |
|
24 |
||
25 |
#include <imageconversion.h> |
|
26 |
#include <fbs.h> |
|
27 |
#include <glxtracer.h> |
|
28 |
#include <glxlog.h> |
|
29 |
#include <glxgeneraluiutilities.h> |
|
30 |
||
31 |
#include "glxactivecallback.h" |
|
32 |
#include "glxhdmisurfaceupdater.h" |
|
33 |
#include "glxactivedecoder.h" |
|
34 |
#include <bitdev.h> |
|
35 |
||
36 |
const TInt KMulFactorToCreateBitmap = 4; |
|
37 |
const TInt KZoomDelay = 10000; |
|
38 |
//100 , is decide for 20 steps of zooming , with each step being 5 pixels. |
|
39 |
const TInt KMaxZoomLimit = 100; |
|
40 |
//evey time we zoom , there is a increase in the ht amd width by 10 pixels. |
|
41 |
const TInt KSingleStepForZoom = 10; |
|
42 |
||
43 |
_LIT(KMimeJpeg,"image/jpeg"); |
|
44 |
_LIT(KMimeJpg,"image/jpg"); |
|
45 |
||
46 |
// ----------------------------------------------------------------------------- |
|
47 |
// NewLC |
|
48 |
// ----------------------------------------------------------------------------- |
|
49 |
CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL(RWindow* aWindow, |
|
50 |
const TDesC& aImageFile, const TDesC& aNextImageFile, |
|
51 |
CFbsBitmap* aFsBitmap, MGlxGenCallback* aCallBack, |
|
52 |
MGlxHDMIDecoderObserver& aDecoderObserver) |
|
53 |
{ |
|
54 |
TRACER("CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL()"); |
|
55 |
CGlxHdmiSurfaceUpdater* self = new (ELeave) CGlxHdmiSurfaceUpdater( |
|
56 |
aWindow, aCallBack, aDecoderObserver); |
|
57 |
CleanupStack::PushL(self); |
|
58 |
self->ConstructL(aFsBitmap, aImageFile, aNextImageFile); |
|
59 |
CleanupStack::Pop(self); |
|
60 |
return self; |
|
61 |
} |
|
62 |
||
63 |
// ----------------------------------------------------------------------------- |
|
64 |
// destructor |
|
65 |
// ----------------------------------------------------------------------------- |
|
66 |
CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater() |
|
67 |
{ |
|
68 |
TRACER("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater()"); |
|
69 |
GLX_LOG_INFO( |
|
70 |
"CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater()-EHdmiDisconnected"); |
|
71 |
TRAP_IGNORE(iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDisconnected)); |
|
72 |
||
73 |
ReleaseContent(); |
|
74 |
if (iWindow) |
|
75 |
{ |
|
76 |
iWindow->RemoveBackgroundSurface(ETrue); |
|
77 |
} |
|
78 |
if (iTimer && iTimer->IsActive()) // Check for a CPeriodic Instance |
|
79 |
{ |
|
80 |
iTimer->Cancel(); |
|
81 |
} |
|
82 |
delete iTimer; |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
83 |
if (iGlxDecoderAO) |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
84 |
{ |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
85 |
delete iGlxDecoderAO; |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
86 |
} |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
87 |
iGlxDecoderAO = NULL; |
60 | 88 |
iFsSession.Close(); |
89 |
if (iSurfManager) |
|
90 |
{ |
|
91 |
GLX_LOG_INFO( |
|
92 |
"CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater() - Close"); |
|
93 |
if (iSurfSessionConnected) |
|
94 |
{ |
|
95 |
iSurfUpdateSession.Close(); |
|
96 |
} |
|
97 |
if (iSurfChunk) |
|
98 |
{ |
|
99 |
iSurfChunk->Close(); |
|
100 |
} |
|
101 |
delete iSurfChunk; |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
102 |
iSurfChunk = NULL; |
60 | 103 |
GLX_LOG_INFO( |
104 |
"CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater(). iSurfManager->CloseSurface()"); |
|
105 |
iSurfManager->CloseSurface(iSurfId); |
|
106 |
GLX_LOG_INFO( |
|
107 |
"CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater(). iSurfManager->Close()"); |
|
108 |
iSurfManager->Close(); |
|
109 |
delete iSurfManager; |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
110 |
iSurfManager = NULL; |
60 | 111 |
} |
112 |
} |
|
113 |
||
114 |
// ----------------------------------------------------------------------------- |
|
115 |
// ReleaseContent |
|
116 |
// ----------------------------------------------------------------------------- |
|
117 |
void CGlxHdmiSurfaceUpdater::ReleaseContent() |
|
118 |
{ |
|
119 |
TRACER("void CGlxHdmiSurfaceUpdater::ReleaseContent()"); |
|
120 |
if (iGlxDecoderAO) |
|
121 |
{ |
|
122 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -1"); |
|
123 |
iGlxDecoderAO->Cancel(); |
|
124 |
} |
|
125 |
if (iFsBitmap) |
|
126 |
{ |
|
127 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -2"); |
|
128 |
delete iFsBitmap; |
|
129 |
iFsBitmap = NULL; |
|
130 |
} |
|
131 |
for (TInt i = 0; i <= 2; i++) |
|
132 |
{ |
|
133 |
GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ReleaseContent() -3, %d", i); |
|
134 |
delete iDecodedBitmap[i]; |
|
135 |
iDecodedBitmap[i] = NULL; |
|
136 |
} |
|
137 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -4"); |
|
138 |
if (iSurfBufferAO && iSurfBufferAO->IsActive()) |
|
139 |
{ |
|
140 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -5"); |
|
141 |
iSurfBufferAO->Cancel(); |
|
142 |
} |
|
143 |
if (iImageDecoder) |
|
144 |
{ |
|
145 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -6"); |
|
146 |
delete iImageDecoder; |
|
147 |
iImageDecoder = NULL; |
|
148 |
} |
|
149 |
if (iSurfSessionConnected && iSurfManager) |
|
150 |
{ |
|
151 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -7"); |
|
152 |
iSurfUpdateSession.CancelAllUpdateNotifications(); |
|
153 |
} |
|
154 |
if (iImagePath) |
|
155 |
{ |
|
156 |
delete iImagePath; |
|
157 |
iImagePath = NULL; |
|
158 |
} |
|
159 |
} |
|
160 |
||
161 |
// ----------------------------------------------------------------------------- |
|
162 |
// CTor |
|
163 |
// ----------------------------------------------------------------------------- |
|
164 |
CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater(RWindow* aWindow, |
|
165 |
MGlxGenCallback* aCallBack, MGlxHDMIDecoderObserver& aDecoderObserver) : |
|
166 |
iWindow(aWindow), iCallBack(aCallBack), iShwFsThumbnail(ETrue), |
|
167 |
iIsNonJpeg(EFalse), iDecoderObserver(aDecoderObserver) |
|
168 |
{ |
|
169 |
TRACER("CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater()"); |
|
170 |
// Implement nothing here |
|
171 |
} |
|
172 |
||
173 |
// ----------------------------------------------------------------------------- |
|
174 |
// ConstructL |
|
175 |
// ----------------------------------------------------------------------------- |
|
176 |
void CGlxHdmiSurfaceUpdater::ConstructL(CFbsBitmap* aFsBitmap, |
|
177 |
const TDesC& aImageFile, const TDesC& aNextImageFile) |
|
178 |
{ |
|
179 |
TRACER("CGlxHdmiSurfaceUpdater::ConstructL()"); |
|
180 |
// Initiate the HDMI by assigning the necessary values |
|
181 |
InitiateHdmiL(aFsBitmap, aImageFile, aNextImageFile); |
|
182 |
||
183 |
TInt error = iFsSession.Connect(); |
|
184 |
GLX_LOG_INFO1( |
|
185 |
"CGlxHdmiSurfaceUpdater::ConstructL() FsSession Connect error = %d", |
|
186 |
error); |
|
187 |
User::LeaveIfError(error); |
|
188 |
iShiftToCloning = EFalse; |
|
189 |
iDecodingCurrent = EFalse; |
|
190 |
iDecodingNext = EFalse; |
|
191 |
iDecodingNextFailed = EFalse; |
|
192 |
// Create the active object |
|
193 |
iGlxDecoderAO = CGlxHdmiDecoderAO::NewL(this); |
|
194 |
||
195 |
// Create the HDMI Decoder |
|
196 |
CreateImageDecoderL(); |
|
197 |
||
198 |
// Create the Bitmap |
|
199 |
CreateBitmapL(); |
|
200 |
||
201 |
// Create the surface and AO for updating the surface |
|
202 |
TRAP_IGNORE( CreateHdmiL()); |
|
203 |
||
204 |
if (iSurfManager) |
|
205 |
{ |
|
206 |
error = iSurfUpdateSession.Connect(); |
|
207 |
GLX_LOG_INFO1( |
|
208 |
"CGlxHdmiSurfaceUpdater::ConstructL() Surface update Session Connect error = %d", |
|
209 |
error); |
|
210 |
User::LeaveIfError(error); |
|
211 |
iSurfSessionConnected = ETrue; |
|
212 |
||
213 |
if (!aNextImageFile.Length()) |
|
214 |
{ |
|
215 |
ShowFsThumbnailL(); |
|
216 |
} |
|
217 |
else |
|
218 |
{ |
|
219 |
// Modify the surface position with respect to the buffer size |
|
220 |
ModifySurfacePostion(); |
|
221 |
} |
|
222 |
#ifdef _DEBUG |
|
223 |
iStartTime.HomeTime(); |
|
224 |
#endif |
|
225 |
//start decoding the image |
|
226 |
iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex], |
|
227 |
iImageDecoder); |
|
228 |
iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingStarted); |
|
229 |
iDecodingCurrent = ETrue; |
|
230 |
} |
|
231 |
iTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
232 |
} |
|
233 |
||
234 |
// ----------------------------------------------------------------------------- |
|
235 |
// UpdateNewImageL |
|
236 |
// ----------------------------------------------------------------------------- |
|
237 |
void CGlxHdmiSurfaceUpdater::UpdateNewImageL(const TDesC& aImageFile, |
|
238 |
const TDesC& aNextImageFile, CFbsBitmap* aFsBitmap) |
|
239 |
{ |
|
240 |
TRACER("CGlxHdmiSurfaceUpdater::UpdateNewImageL()"); |
|
241 |
if (!aImageFile.CompareC(*iImagePath) && !iDecodingCurrent |
|
242 |
&& !iDecodingNext) |
|
243 |
{ |
|
244 |
iNextImagePath = aNextImageFile.Alloc(); |
|
245 |
GLX_LOG_INFO( |
|
246 |
"CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Decoded Image is ready "); |
|
247 |
if (iDecodingNextFailed) |
|
248 |
{ |
|
249 |
ShiftToCloningMode(); |
|
250 |
iDecodingNextFailed = EFalse; |
|
251 |
} |
|
252 |
else if (iSurfManager) |
|
253 |
{ |
|
254 |
iShwFsThumbnail = EFalse; |
|
255 |
if (iIsNonJpeg) |
|
256 |
{ |
|
257 |
// if this is non jpeg image, make sure we scale the bitmap |
|
258 |
ScaleDecodedBitmapL( ENonJpgDecodedBitmapIndex); |
|
259 |
} |
|
260 |
// Modify the surface position with respect to the buffer size |
|
261 |
ModifySurfacePostion(); |
|
262 |
ProcessTvImage(); |
|
263 |
iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
264 |
iBitmapReady = ETrue; |
|
265 |
return; |
|
266 |
} |
|
267 |
} |
|
268 |
else |
|
269 |
{ |
|
270 |
ReleaseContent(); |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
271 |
if (iNextImagePath) |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
272 |
{ |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
273 |
delete iNextImagePath; |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
274 |
iNextImagePath = NULL; |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
275 |
} |
60 | 276 |
// Ongoing decoding is cancelled if any,reset the decoding flags. |
277 |
iDecodingNext = EFalse; |
|
278 |
iDecodingCurrent = EFalse; |
|
279 |
} |
|
280 |
// Initiate the HDMI by assigning the necessary values |
|
281 |
InitiateHdmiL(aFsBitmap, aImageFile, aNextImageFile); |
|
282 |
//Cancel the zoom timers if any |
|
283 |
if (iTimer->IsActive()) |
|
284 |
{ |
|
285 |
GLX_LOG_INFO( |
|
286 |
"CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Cancel Timer"); |
|
287 |
iTimer->Cancel(); |
|
288 |
} |
|
289 |
||
290 |
// Create the HDMI Decoder |
|
291 |
CreateImageDecoderL(); |
|
292 |
||
293 |
// Create the Bitmap |
|
294 |
CreateBitmapL(); |
|
295 |
if (iSurfManager) |
|
296 |
{ |
|
297 |
// Create the surface and AO for updating the surface |
|
298 |
CreateHdmiL( EFalse); |
|
299 |
} |
|
300 |
else |
|
301 |
{ |
|
302 |
TRAP_IGNORE( CreateHdmiL(ETrue)); |
|
303 |
} |
|
304 |
||
305 |
#ifdef _DEBUG |
|
306 |
iStartTime.HomeTime(); |
|
307 |
#endif |
|
308 |
if (iSurfManager) |
|
309 |
{ |
|
310 |
// Show FS Thumbnail |
|
311 |
ShowFsThumbnailL(); |
|
312 |
//start decoding the image |
|
313 |
iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex], |
|
314 |
iImageDecoder); |
|
315 |
iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingStarted); |
|
316 |
iDecodingCurrent = ETrue; |
|
317 |
} |
|
318 |
} |
|
319 |
||
320 |
// ----------------------------------------------------------------------------- |
|
321 |
// InitiateHdmiL |
|
322 |
// ----------------------------------------------------------------------------- |
|
323 |
void CGlxHdmiSurfaceUpdater::InitiateHdmiL(CFbsBitmap* aFsBitmap, |
|
324 |
const TDesC& aImageFile, const TDesC& aNextImageFile) |
|
325 |
{ |
|
326 |
TRACER("CGlxHdmiSurfaceUpdater::InitiateHdmiL()"); |
|
327 |
iImagePath = aImageFile.Alloc(); |
|
328 |
iNextImagePath = aNextImageFile.Alloc(); |
|
329 |
iFsBitmap = new (ELeave) CFbsBitmap; |
|
330 |
iFsBitmap->Duplicate(aFsBitmap->Handle()); |
|
331 |
iIsNonJpeg = EFalse; |
|
332 |
iTvScreenSize = iWindow->Size(); |
|
333 |
||
334 |
iBitmapReady = EFalse; |
|
335 |
iLeftCornerForZoom.iX = 0; |
|
336 |
iLeftCornerForZoom.iY = 0; |
|
337 |
||
338 |
iZoom = ETrue; |
|
339 |
} |
|
340 |
||
341 |
// ----------------------------------------------------------------------------- |
|
342 |
// CreateHDMI |
|
343 |
// ----------------------------------------------------------------------------- |
|
344 |
void CGlxHdmiSurfaceUpdater::CreateHdmiL(TBool aCreateSurface) |
|
345 |
{ |
|
346 |
TRACER("CGlxHdmiSurfaceUpdater::CreateHdmiL()"); |
|
347 |
||
348 |
if (aCreateSurface) |
|
349 |
{ |
|
350 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::CreateHdmiL() Create Surface"); |
|
351 |
CreateSurfaceL(); |
|
352 |
} |
|
353 |
||
354 |
// Active objects for double buffered draw signalling |
|
355 |
if (!iSurfBufferAO) |
|
356 |
{ |
|
357 |
iSurfBufferAO = new (ELeave) CGlxActiveCallBack(TCallBack( |
|
358 |
SurfBuffer0ReadyL, this), CActive::EPriorityStandard - 1); |
|
359 |
CActiveScheduler::Add( iSurfBufferAO); |
|
360 |
} |
|
361 |
} |
|
362 |
||
363 |
// ----------------------------------------------------------------------------- |
|
364 |
// CreateSurfaceL |
|
365 |
// ----------------------------------------------------------------------------- |
|
366 |
void CGlxHdmiSurfaceUpdater::CreateSurfaceL() |
|
367 |
{ |
|
368 |
TRACER("CGlxHdmiSurfaceUpdater::CreateSurfaceL()"); |
|
369 |
iSurfManager = new (ELeave) RSurfaceManager(); |
|
370 |
TInt error = iSurfManager->Open(); |
|
371 |
GLX_LOG_INFO1( |
|
372 |
"CGlxHdmiSurfaceUpdater::CreateSurfaceL Open Surface manager error = %d", |
|
373 |
error); |
|
374 |
User::LeaveIfError(error); |
|
375 |
||
376 |
//Need to set the surface Hint for the surface to indicate |
|
377 |
//that photos do not need overscan compensation and the image will |
|
378 |
//be displayed in 720p resolution. |
|
379 |
//Refer error: HJVA-85DD25 for more info. |
|
380 |
RSurfaceManager::THintPair surfHint; |
|
381 |
TUid uid(KNullUid); |
|
382 |
uid.iUid = surfaceHints::KSurfaceContent; |
|
383 |
surfHint.Set(uid, surfaceHints::EStillImage, EFalse); |
|
384 |
||
385 |
RSurfaceManager::TSurfaceCreationAttributesBuf attributes; |
|
386 |
attributes().iPixelFormat = EUidPixelFormatARGB_8888;// EUidPixelFormatYUV_420Planar; |
|
387 |
attributes().iSize = iTvScreenSize; |
|
388 |
||
389 |
attributes().iBuffers = 1; |
|
390 |
attributes().iStride = iTvScreenSize.iWidth * KMulFactorToCreateBitmap; |
|
391 |
attributes().iAlignment = KMulFactorToCreateBitmap; |
|
392 |
attributes().iContiguous = EFalse; |
|
393 |
attributes().iMappable = ETrue; |
|
394 |
attributes().iSurfaceHints = &surfHint; |
|
395 |
attributes().iHintCount = 1; |
|
396 |
||
397 |
error = iSurfManager->CreateSurface(attributes, iSurfId); |
|
398 |
GLX_LOG_INFO1( |
|
399 |
"CGlxHdmiSurfaceUpdater::CreateSurfaceL, Creating surface error : %d", |
|
400 |
error); |
|
401 |
if (error == KErrNoMemory) |
|
402 |
{ |
|
403 |
GLX_LOG_INFO( |
|
404 |
"CGlxHdmiSurfaceUpdater::CreateSurfaceL(). iSurfManager->Close()"); |
|
405 |
iSurfManager->Close(); |
|
406 |
delete iSurfManager; |
|
407 |
iSurfManager = NULL; |
|
408 |
if (iShiftToCloning == EFalse) |
|
409 |
{ |
|
410 |
GlxGeneralUiUtilities::ShowErrorNoteL(error); // Show Low Memory Popup Once before shifting to Cloning Mode |
|
411 |
iShiftToCloning = ETrue; |
|
412 |
} |
|
413 |
ShiftToCloningMode(); // Shift from Posting Mode to Cloning Mode |
|
414 |
} |
|
415 |
User::LeaveIfError(error); |
|
416 |
||
417 |
//Map the surface and stride the surface info |
|
418 |
MapSurfaceL(); |
|
419 |
// Set the Configuration to the surface ID when creating a surface |
|
420 |
iConfig.SetSurfaceId(iSurfId); |
|
421 |
} |
|
422 |
||
423 |
// ----------------------------------------------------------------------------- |
|
424 |
// MapSurfaceL |
|
425 |
// ----------------------------------------------------------------------------- |
|
426 |
void CGlxHdmiSurfaceUpdater::MapSurfaceL() |
|
427 |
{ |
|
428 |
TRACER("CGlxHdmiSurfaceUpdater::MapSurfaceL()"); |
|
429 |
||
430 |
//Create chunk to map it to the surface ID. |
|
431 |
iSurfChunk = new (ELeave) RChunk(); |
|
432 |
User::LeaveIfNull( iSurfChunk); |
|
433 |
TInt error = iSurfManager->MapSurface(iSurfId, *iSurfChunk); |
|
434 |
GLX_LOG_INFO1( |
|
435 |
"CGlxHdmiSurfaceUpdater::MapSurfaceL(), MapSurface error : %d", |
|
436 |
error); |
|
437 |
User::LeaveIfError(error); |
|
438 |
||
439 |
// Get the info from the surfaceManager |
|
440 |
// and store pointers to the pixel data |
|
441 |
RSurfaceManager::TInfoBuf info; |
|
442 |
error = iSurfManager->SurfaceInfo(iSurfId, info); |
|
443 |
GLX_LOG_INFO1( |
|
444 |
"CGlxHdmiSurfaceUpdater::MapSurfaceL(), SurfaceInfo error : %d", |
|
445 |
error); |
|
446 |
User::LeaveIfError(error); |
|
447 |
||
448 |
iSurfaceStride = info().iStride; |
|
449 |
TInt offset = 0; |
|
450 |
iSurfManager->GetBufferOffset(iSurfId, 0, offset); |
|
451 |
iSurfBuffer = iSurfChunk->Base() + offset; |
|
452 |
} |
|
453 |
||
454 |
// ----------------------------------------------------------------------------- |
|
455 |
// SurfBuffer0ReadyL |
|
456 |
// ----------------------------------------------------------------------------- |
|
457 |
TInt CGlxHdmiSurfaceUpdater::SurfBuffer0ReadyL(TAny* aObject) |
|
458 |
{ |
|
459 |
TRACER("CGlxHdmiSurfaceUpdater::SurfBuffer0ReadyL()"); |
|
460 |
CGlxHdmiSurfaceUpdater* self = |
|
461 |
reinterpret_cast<CGlxHdmiSurfaceUpdater*> (aObject); |
|
462 |
if (!self->iShwFsThumbnail) |
|
463 |
{ |
|
464 |
self->iDecodingCurrent = EFalse; |
|
465 |
if (self->iNextImagePath->Length()) |
|
466 |
{ |
|
467 |
self->DecodeNextImageL(); |
|
468 |
} |
|
469 |
else |
|
470 |
{ |
|
471 |
self->iDecoderObserver.HandleHDMIDecodingEventL( |
|
472 |
EHdmiDecodingCompleted); |
|
473 |
} |
|
474 |
} |
|
475 |
return ETrue; |
|
476 |
} |
|
477 |
||
478 |
// ----------------------------------------------------------------------------- |
|
479 |
// Refresh |
|
480 |
// ----------------------------------------------------------------------------- |
|
481 |
void CGlxHdmiSurfaceUpdater::Refresh() |
|
482 |
{ |
|
483 |
TRACER("CGlxHdmiSurfaceUpdater::Refresh()"); |
|
484 |
// copy the decoded bitmap on to the surface |
|
485 |
SwapBuffers(); |
|
486 |
||
487 |
// refresh the window |
|
488 |
iCallBack->DoGenCallback(); |
|
489 |
} |
|
490 |
||
491 |
// ----------------------------------------------------------------------------- |
|
492 |
// SwapBuffers |
|
493 |
// This is used to sawp the buffers shown and to be shown |
|
494 |
// After this is done, a refresh to the window should be done to refresh the TV |
|
495 |
// ----------------------------------------------------------------------------- |
|
496 |
void CGlxHdmiSurfaceUpdater::SwapBuffers() |
|
497 |
{ |
|
498 |
TRACER("CGlxHdmiSurfaceUpdater::SwapBuffers()"); |
|
499 |
TInt bitmapIndex = KErrNotFound; |
|
500 |
||
501 |
if (iShwFsThumbnail) // show FS thumbnail |
|
502 |
{ |
|
503 |
bitmapIndex = EFSBitmapIndex; |
|
504 |
} |
|
505 |
else if (iIsNonJpeg && !iShwFsThumbnail) // this indicates it is non jpeg image and decoding finished |
|
506 |
{ |
|
507 |
bitmapIndex = ENonJpgDecodedBitmapIndex; |
|
508 |
} |
|
509 |
else // if none of the above state means it is jpeg image and decoding finished |
|
510 |
{ |
|
511 |
bitmapIndex = EJpgDecodedBitmapIndex; |
|
512 |
} |
|
513 |
||
514 |
// Lock the heap so that subsequent call to dataaddress doesnt happen |
|
515 |
iDecodedBitmap[bitmapIndex]->LockHeap(); |
|
516 |
||
517 |
// Data stride |
|
518 |
TUint fs = iDecodedBitmap[bitmapIndex]->DataStride(); |
|
519 |
||
520 |
//Bitmap address from where the data has to be copied. |
|
521 |
TUint8* from = (TUint8*) iDecodedBitmap[bitmapIndex]->DataAddress(); |
|
522 |
||
523 |
//surface chunk address to where the bitmap data has to be copied. |
|
524 |
TUint8* to = (TUint8*) iSurfBuffer; |
|
525 |
||
526 |
// To buffer (32 bit colors) |
|
527 |
TUint ts = iSurfaceStride; |
|
528 |
//No of bytes to be copied on to the surface. |
|
529 |
TUint bytes = iDecodedBitmap[bitmapIndex]->SizeInPixels().iWidth |
|
530 |
* KMulFactorToCreateBitmap; |
|
531 |
||
532 |
GLX_LOG_INFO2( |
|
533 |
"CGlxHdmiSurfaceUpdater::SwapBuffers() - decodeSize width = %d and height %d", |
|
534 |
iDecodedBitmap[bitmapIndex]->SizeInPixels().iWidth, |
|
535 |
iDecodedBitmap[bitmapIndex]->SizeInPixels().iHeight); |
|
536 |
||
537 |
// Copy the bitmap on to the surface. |
|
538 |
for (TInt y = iDecodedBitmap[bitmapIndex]->SizeInPixels().iHeight; y > 0; y--) |
|
539 |
{ |
|
540 |
Mem::Copy(to, from, bytes); |
|
541 |
to += ts; |
|
542 |
from += fs; |
|
543 |
} |
|
544 |
iDecodedBitmap[bitmapIndex]->UnlockHeap(); |
|
545 |
} |
|
546 |
||
547 |
// ----------------------------------------------------------------------------- |
|
548 |
// CreateBitmapL |
|
549 |
// ----------------------------------------------------------------------------- |
|
550 |
void CGlxHdmiSurfaceUpdater::CreateBitmapL() |
|
551 |
{ |
|
552 |
TRACER("CGlxHdmiSurfaceUpdater::CreateBitmapL()"); |
|
553 |
TSize imageSize = iImageDecoder->FrameInfo().iOverallSizeInPixels; |
|
554 |
GLX_LOG_INFO2( |
|
555 |
"CGlxHdmiSurfaceUpdater::StartImageDecodeL() - bitmapsize=%d, %d", |
|
556 |
imageSize.iWidth, imageSize.iHeight); |
|
557 |
TReal32 scaleFactor = 0.0f; |
|
558 |
if (iTvScreenSize.iWidth * imageSize.iHeight > iTvScreenSize.iHeight |
|
559 |
* imageSize.iWidth) |
|
560 |
{ |
|
561 |
scaleFactor = (TReal32) iTvScreenSize.iHeight |
|
562 |
/ (TReal32) imageSize.iHeight; |
|
563 |
} |
|
564 |
else |
|
565 |
{ |
|
566 |
scaleFactor = (TReal32) iTvScreenSize.iWidth |
|
567 |
/ (TReal32) imageSize.iWidth; |
|
568 |
} |
|
569 |
GLX_LOG_INFO1( |
|
570 |
"CGlxHdmiSurfaceUpdater::StartImageDecodeL() - scaleFactor=%f", |
|
571 |
scaleFactor); |
|
572 |
iTargetBitmapSize.iHeight = imageSize.iHeight * scaleFactor; |
|
573 |
iTargetBitmapSize.iWidth = imageSize.iWidth * scaleFactor; |
|
574 |
GLX_LOG_INFO2( |
|
575 |
"CGlxHdmiSurfaceUpdater::StartImageDecodeL() - targetBitmapSize=%d, %d", |
|
576 |
iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight); |
|
577 |
//create the bitmap for the required size |
|
578 |
iDecodedBitmap[EJpgDecodedBitmapIndex] = new (ELeave) CFbsBitmap(); |
|
579 |
// to check if the Mimetype is supported by the decoder to to arbitary scaling |
|
580 |
// if not then we recalculate the size |
|
581 |
TInt err = iDecodedBitmap[EJpgDecodedBitmapIndex]->Create( |
|
582 |
ReCalculateSizeL(), EColor16MU); |
|
583 |
User::LeaveIfNull( iDecodedBitmap[EJpgDecodedBitmapIndex]); |
|
584 |
} |
|
585 |
||
586 |
// ----------------------------------------------------------------------------- |
|
587 |
// DoesMimeTypeNeedsRecalculateL() |
|
588 |
// ----------------------------------------------------------------------------- |
|
589 |
// |
|
590 |
TBool CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL() |
|
591 |
{ |
|
592 |
TRACER("CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL"); |
|
593 |
RApaLsSession session; |
|
594 |
TDataType mimeType; |
|
595 |
TUid uid; |
|
596 |
||
597 |
User::LeaveIfError(session.Connect()); |
|
598 |
CleanupClosePushL(session); |
|
599 |
User::LeaveIfError(session.AppForDocument(iImagePath->Des(), uid, |
|
600 |
mimeType)); |
|
601 |
CleanupStack::PopAndDestroy(&session); |
|
602 |
||
603 |
if (mimeType.Des().Compare(KMimeJpeg) == 0 || mimeType.Des().Compare( |
|
604 |
KMimeJpg) == 0) |
|
605 |
{ |
|
606 |
GLX_LOG_INFO( |
|
607 |
"CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL - jpeg"); |
|
608 |
return EFalse; |
|
609 |
} |
|
610 |
else |
|
611 |
{ |
|
612 |
GLX_LOG_INFO( |
|
613 |
"CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL - non jpeg"); |
|
614 |
return ETrue; |
|
615 |
} |
|
616 |
} |
|
617 |
||
618 |
// ----------------------------------------------------------------------------- |
|
619 |
// ReCalculateSize |
|
620 |
// ----------------------------------------------------------------------------- |
|
621 |
TSize CGlxHdmiSurfaceUpdater::ReCalculateSizeL() |
|
622 |
{ |
|
623 |
TRACER("CGlxHdmiSurfaceUpdater::ReCalculateSizeL()"); |
|
624 |
if (DoesMimeTypeNeedsRecalculateL()) |
|
625 |
{ |
|
626 |
iIsNonJpeg = ETrue; |
|
627 |
TSize fullFrameSize = iImageDecoder->FrameInfo().iOverallSizeInPixels; |
|
628 |
// calculate the reduction factor on what size we need |
|
629 |
TInt reductionFactor = iImageDecoder->ReductionFactor(fullFrameSize, |
|
630 |
iTargetBitmapSize); |
|
631 |
// get the reduced size onto destination size |
|
632 |
TSize destSize; |
|
633 |
User::LeaveIfError(iImageDecoder->ReducedSize(fullFrameSize, |
|
634 |
reductionFactor, destSize)); |
|
635 |
GLX_LOG_INFO2( |
|
636 |
"CGlxHdmiSurfaceUpdater::ReCalculateSizeL() - destSize=%d, %d", |
|
637 |
destSize.iWidth, destSize.iHeight); |
|
638 |
return destSize; |
|
639 |
} |
|
640 |
else |
|
641 |
{ |
|
642 |
return iTargetBitmapSize; |
|
643 |
} |
|
644 |
} |
|
645 |
||
646 |
// ----------------------------------------------------------------------------- |
|
647 |
// HandleRunL |
|
648 |
// ----------------------------------------------------------------------------- |
|
649 |
void CGlxHdmiSurfaceUpdater::HandleRunL(TRequestStatus& aStatus) |
|
650 |
{ |
|
651 |
TRACER("CGlxHdmiSurfaceUpdater::HandleRunL()"); |
|
652 |
||
653 |
#ifdef _DEBUG |
|
654 |
iStopTime.HomeTime(); |
|
655 |
GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::HandleRunL() ConvertImageL took" |
|
656 |
" <%d> us", (TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64()); |
|
657 |
#endif |
|
658 |
if (iDecodingNext) |
|
659 |
{ |
|
660 |
iDecodingNext = EFalse; |
|
661 |
if (aStatus.Int() != KErrNone) |
|
662 |
{ |
|
663 |
GLX_LOG_INFO("HandleRunL - Next Convert failed"); |
|
664 |
iDecodingNextFailed = ETrue; |
|
665 |
} |
|
666 |
//Inform the observer that image decoding is completed |
|
667 |
GLX_LOG_INFO( |
|
668 |
"CGlxHdmiSurfaceUpdater::HandleRunL-EHdmiDecodingCompleted"); |
|
669 |
iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingCompleted); |
|
670 |
} |
|
671 |
else |
|
672 |
{ |
|
673 |
iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingFirstCompleted); |
|
674 |
if (aStatus.Int() != KErrNone) |
|
675 |
{ |
|
676 |
GLX_LOG_INFO("HandleRunL - Convert failed"); |
|
677 |
ShiftToCloningMode(); |
|
678 |
} |
|
679 |
else if (iSurfManager) |
|
680 |
{ |
|
681 |
iShwFsThumbnail = EFalse; |
|
682 |
if (iIsNonJpeg) |
|
683 |
{ |
|
684 |
// if this is non jpeg image, make sure we scale the bitmap |
|
685 |
ScaleDecodedBitmapL( ENonJpgDecodedBitmapIndex); |
|
686 |
} |
|
687 |
ProcessTvImage(); |
|
688 |
iBitmapReady = ETrue; |
|
689 |
} |
|
690 |
} |
|
691 |
//release imagedecoder after the conversion is over |
|
692 |
if (iImageDecoder) |
|
693 |
{ |
|
694 |
delete iImageDecoder; |
|
695 |
iImageDecoder = NULL; |
|
696 |
} |
|
697 |
} |
|
698 |
||
699 |
// ----------------------------------------------------------------------------- |
|
700 |
// CreateImageDecoderL |
|
701 |
// ----------------------------------------------------------------------------- |
|
702 |
void CGlxHdmiSurfaceUpdater::CreateImageDecoderL() |
|
703 |
{ |
|
704 |
TRACER("CGlxHdmiController::CreateImageDecoderL()"); |
|
705 |
// Create a decoder for the image in the named file |
|
706 |
TRAPD(error, iImageDecoder = CImageDecoder::FileNewL(iFsSession, |
|
707 |
iImagePath->Des(), CImageDecoder::EOptionAlwaysThread, KNullUid)); |
|
708 |
GLX_LOG_INFO1("CreateImageDecoderL CImageDecoder:FileNewL error %d", |
|
709 |
error); |
|
710 |
User::LeaveIfError( error); |
|
711 |
} |
|
712 |
||
713 |
// ----------------------------------------------------------------------------- |
|
714 |
// ActivateZoom |
|
715 |
// ----------------------------------------------------------------------------- |
|
716 |
void CGlxHdmiSurfaceUpdater::ActivateZoom(TBool aAutoZoomOut) |
|
717 |
{ |
|
718 |
TRACER("CGlxHdmiSurfaceUpdater::ActivateZoom()"); |
|
719 |
iZoom = ETrue; |
|
720 |
iAutoZoomOut = aAutoZoomOut; |
|
721 |
if (iTimer->IsActive()) |
|
722 |
{ |
|
723 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ActivateZoom() - Cancel Timer"); |
|
724 |
iTimer->Cancel(); |
|
725 |
} |
|
726 |
||
727 |
if (!iTimer->IsActive() && iBitmapReady) |
|
728 |
{ |
|
729 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ActivateZoom() - Start Timer"); |
|
730 |
iTimer->Start(KZoomDelay, KZoomDelay, TCallBack(TimeOut, this)); |
|
731 |
} |
|
732 |
} |
|
733 |
||
734 |
// ----------------------------------------------------------------------------- |
|
735 |
// DeactivateZoom |
|
736 |
// ----------------------------------------------------------------------------- |
|
737 |
void CGlxHdmiSurfaceUpdater::DeactivateZoom() |
|
738 |
{ |
|
739 |
TRACER("CGlxHdmiSurfaceUpdater::DeactivateZoom()"); |
|
740 |
||
741 |
if (iTimer->IsActive()) |
|
742 |
{ |
|
743 |
GLX_LOG_INFO( |
|
744 |
"CGlxHdmiSurfaceUpdater::DeactivateZoom() - Cancel Timer"); |
|
745 |
iTimer->Cancel(); |
|
746 |
} |
|
747 |
if (!iTimer->IsActive() && iBitmapReady && iLeftCornerForZoom.iX) |
|
748 |
{ |
|
749 |
GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::DeactivateZoom() - Start Timer"); |
|
750 |
iZoom = EFalse; |
|
751 |
iTimer->Start(KZoomDelay, KZoomDelay, TCallBack(TimeOut, this)); |
|
752 |
} |
|
753 |
} |
|
754 |
||
755 |
// --------------------------------------------------------------------------- |
|
756 |
// TimeOut |
|
757 |
// --------------------------------------------------------------------------- |
|
758 |
// |
|
759 |
TInt CGlxHdmiSurfaceUpdater::TimeOut(TAny* aSelf) |
|
760 |
{ |
|
761 |
TRACER("CGlxHdmiSurfaceUpdater::TimeOut"); |
|
762 |
if (aSelf) |
|
763 |
{ |
|
764 |
CGlxHdmiSurfaceUpdater* self = |
|
765 |
static_cast<CGlxHdmiSurfaceUpdater*> (aSelf); |
|
766 |
if (self) |
|
767 |
{ |
|
768 |
self->Zoom(ETrue); |
|
769 |
} |
|
770 |
} |
|
771 |
return KErrNone; |
|
772 |
} |
|
773 |
||
774 |
// ----------------------------------------------------------------------------- |
|
775 |
// Zoom |
|
776 |
// ----------------------------------------------------------------------------- |
|
777 |
void CGlxHdmiSurfaceUpdater::Zoom(TBool aZoom) |
|
778 |
{ |
|
779 |
TRACER("CGlxHdmiSurfaceUpdater::Zoom()"); |
|
780 |
||
781 |
if (!iBitmapReady) |
|
782 |
{ |
|
783 |
return; |
|
784 |
} |
|
785 |
||
786 |
if (iLeftCornerForZoom.iX == KMaxZoomLimit) |
|
787 |
{ |
|
788 |
iZoom = EFalse; |
|
789 |
//If autozoomout is not set then cancel the timer and do |
|
790 |
//the zoom out on DeactivateZoom. |
|
791 |
if (!iAutoZoomOut) |
|
792 |
{ |
|
793 |
iTimer->Cancel(); |
|
794 |
} |
|
795 |
} |
|
796 |
if (aZoom && iZoom) |
|
797 |
{ |
|
798 |
iTargetBitmapSize.iWidth = TInt(iTargetBitmapSize.iWidth |
|
799 |
- KSingleStepForZoom); |
|
800 |
iTargetBitmapSize.iHeight = TInt(iTargetBitmapSize.iHeight |
|
801 |
- KSingleStepForZoom); |
|
802 |
iLeftCornerForZoom.iX = iLeftCornerForZoom.iX + KSingleStepForZoom |
|
803 |
/ 2; |
|
804 |
iLeftCornerForZoom.iY = iLeftCornerForZoom.iY + KSingleStepForZoom |
|
805 |
/ 2; |
|
806 |
GLX_LOG_INFO2( |
|
807 |
"CGlxHdmiSurfaceUpdater::Zoom()--- 2,iTargetBitmapSize.iWidth = %d, iTargetBitmapSize.iHeight = %d", |
|
808 |
iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight); |
|
809 |
iConfig.SetViewport(TRect(iLeftCornerForZoom.iX, |
|
810 |
iLeftCornerForZoom.iY, iTargetBitmapSize.iWidth, |
|
811 |
iTargetBitmapSize.iHeight)); |
|
812 |
} |
|
813 |
else |
|
814 |
{ |
|
815 |
iTargetBitmapSize.iWidth = TInt(iTargetBitmapSize.iWidth |
|
816 |
+ KSingleStepForZoom); |
|
817 |
iTargetBitmapSize.iHeight = TInt(iTargetBitmapSize.iHeight |
|
818 |
+ KSingleStepForZoom); |
|
819 |
iLeftCornerForZoom.iX = iLeftCornerForZoom.iX - KSingleStepForZoom |
|
820 |
/ 2; |
|
821 |
iLeftCornerForZoom.iY = iLeftCornerForZoom.iY - KSingleStepForZoom |
|
822 |
/ 2; |
|
823 |
if (iLeftCornerForZoom.iX == 0) |
|
824 |
{ |
|
825 |
iTimer->Cancel(); |
|
826 |
iZoom = ETrue; |
|
827 |
} |
|
828 |
GLX_LOG_INFO2( |
|
829 |
"CGlxHdmiSurfaceUpdater::Zoom()--- 4,iTargetBitmapSize.iWidth = %d, iTargetBitmapSize.iHeight = %d", |
|
830 |
iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight); |
|
831 |
iConfig.SetViewport(TRect(iLeftCornerForZoom.iX, |
|
832 |
iLeftCornerForZoom.iY, iTargetBitmapSize.iWidth, |
|
833 |
iTargetBitmapSize.iHeight)); |
|
834 |
} |
|
835 |
iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
836 |
} |
|
837 |
||
838 |
// ----------------------------------------------------------------------------- |
|
839 |
// ModifySurfacePostion |
|
840 |
// ----------------------------------------------------------------------------- |
|
841 |
void CGlxHdmiSurfaceUpdater::ModifySurfacePostion() |
|
842 |
{ |
|
843 |
TRACER("CGlxHdmiSurfaceUpdater::ModifySurfacePostion()"); |
|
844 |
TPoint startPoint(0, 0); |
|
845 |
if (iTargetBitmapSize.iWidth < iTvScreenSize.iWidth) |
|
846 |
{ |
|
847 |
startPoint.iX = (iTvScreenSize.iWidth - iTargetBitmapSize.iWidth) / 2; |
|
848 |
} |
|
849 |
if (iTargetBitmapSize.iHeight < iTvScreenSize.iHeight) |
|
850 |
{ |
|
851 |
startPoint.iY = (iTvScreenSize.iHeight - iTargetBitmapSize.iHeight) |
|
852 |
/ 2; |
|
853 |
} |
|
854 |
GLX_LOG_INFO2( |
|
855 |
"CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - target iTargetBitmapSize=%d, %d", |
|
856 |
iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight); |
|
857 |
GLX_LOG_INFO2( |
|
858 |
"CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - startPoint =%d, %d", |
|
859 |
startPoint.iX, startPoint.iY); |
|
860 |
||
861 |
// target |
|
862 |
iConfig.SetExtent(TRect(startPoint.iX, startPoint.iY, |
|
863 |
(iTvScreenSize.iWidth - startPoint.iX), (iTvScreenSize.iHeight |
|
864 |
- startPoint.iY))); |
|
865 |
// source |
|
866 |
iConfig.SetViewport(TRect(TPoint(0, 0), TSize(iTargetBitmapSize.iWidth, |
|
867 |
iTargetBitmapSize.iHeight))); |
|
868 |
#ifdef _DEBUG |
|
869 |
TRect ex, vp; |
|
870 |
iConfig.GetExtent(ex); |
|
871 |
iConfig.GetViewport(vp); |
|
872 |
GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - vp - TL=%d, %d",vp.iTl.iX,vp.iTl.iY); |
|
873 |
GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - vp - BR=%d, %d",vp.iBr.iX,vp.iBr.iY); |
|
874 |
GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - ex - TL=%d, %d",ex.iTl.iX,ex.iTl.iY); |
|
875 |
GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - ex - BR=%d, %d",ex.iBr.iX,ex.iBr.iY); |
|
876 |
#endif |
|
877 |
} |
|
878 |
||
879 |
// ----------------------------------------------------------------------------- |
|
880 |
// ShiftToCloningMode |
|
881 |
// ----------------------------------------------------------------------------- |
|
882 |
void CGlxHdmiSurfaceUpdater::ShiftToCloningMode() |
|
883 |
{ |
|
884 |
TRACER("CGlxHdmiSurfaceUpdater::ShiftToCloningMode()"); |
|
885 |
iWindow->RemoveBackgroundSurface(ETrue); |
|
886 |
} |
|
887 |
||
888 |
// ----------------------------------------------------------------------------- |
|
889 |
// ShiftToPostingMode |
|
890 |
// ----------------------------------------------------------------------------- |
|
891 |
void CGlxHdmiSurfaceUpdater::ShiftToPostingMode() |
|
892 |
{ |
|
893 |
TRACER("CGlxHdmiSurfaceUpdater::ShiftToPostingMode()"); |
|
894 |
if (iSurfManager) |
|
895 |
{ |
|
896 |
#ifdef _DEBUG |
|
897 |
TRect ex, vp; |
|
898 |
iConfig.GetExtent(ex); |
|
899 |
iConfig.GetViewport(vp); |
|
900 |
GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - vp - TL=%d, %d",vp.iTl.iX,vp.iTl.iY); |
|
901 |
GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - vp - BR=%d, %d",vp.iBr.iX,vp.iBr.iY); |
|
902 |
GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - ex - TL=%d, %d",ex.iTl.iX,ex.iTl.iY); |
|
903 |
GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - ex - BR=%d, %d",ex.iBr.iX,ex.iBr.iY); |
|
904 |
#endif |
|
905 |
iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
906 |
iShiftToCloning = EFalse; |
|
907 |
} |
|
908 |
} |
|
909 |
||
910 |
// ----------------------------------------------------------------------------- |
|
911 |
// ShowFsThumbnailL |
|
912 |
// ----------------------------------------------------------------------------- |
|
913 |
void CGlxHdmiSurfaceUpdater::ShowFsThumbnailL() |
|
914 |
{ |
|
915 |
TRACER("CGlxHdmiSurfaceUpdater::ShowFsThumbnailL()"); |
|
916 |
iShwFsThumbnail = ETrue; |
|
917 |
GLX_LOG_INFO2( |
|
918 |
"CGlxHdmiSurfaceUpdater::ShowFsThumbnailL() iTargetBitmapSize Width=%d, Height=%d", |
|
919 |
iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight); |
|
920 |
// Modify the surface position with respect to the buffer size |
|
921 |
ModifySurfacePostion(); |
|
922 |
// this is for FS thumbnail stored in array pointer 0 |
|
923 |
ScaleDecodedBitmapL( EFSBitmapIndex); |
|
924 |
// Process the Image to TV |
|
925 |
ProcessTvImage(); |
|
926 |
// set the surface onto background |
|
927 |
iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
928 |
} |
|
929 |
||
930 |
// ----------------------------------------------------------------------------- |
|
931 |
// ScaleDecodedBitmapL |
|
932 |
// ----------------------------------------------------------------------------- |
|
933 |
void CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL(TInt aBitmapIndex) |
|
934 |
{ |
|
935 |
TRACER("CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL()"); |
|
936 |
GLX_LOG_INFO2( |
|
937 |
"CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL() iTargetBitmapSize Width=%d, Height=%d", |
|
938 |
iTargetBitmapSize.iWidth, iTargetBitmapSize.iHeight); |
|
939 |
||
940 |
if (iDecodedBitmap[aBitmapIndex]) |
|
941 |
{ |
|
942 |
delete iDecodedBitmap[aBitmapIndex]; |
|
943 |
iDecodedBitmap[aBitmapIndex] = NULL; |
|
944 |
} |
|
945 |
iDecodedBitmap[aBitmapIndex] = new (ELeave) CFbsBitmap(); |
|
946 |
// create destination with size |
|
947 |
TInt err = iDecodedBitmap[aBitmapIndex]->Create(iTargetBitmapSize, |
|
948 |
EColor16MU); |
|
949 |
GLX_LOG_INFO1( |
|
950 |
"CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL() creating bitmap error, err=%d", |
|
951 |
err); |
|
952 |
User::LeaveIfNull( iDecodedBitmap[aBitmapIndex]); |
|
953 |
||
954 |
// Create bitmap device for destination bitmap |
|
955 |
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL( |
|
956 |
iDecodedBitmap[aBitmapIndex]); |
|
957 |
CleanupStack::PushL(bitmapDevice); |
|
958 |
||
959 |
CFbsBitGc* bitmapGc = CFbsBitGc::NewL(); |
|
960 |
CleanupStack::PushL(bitmapGc); |
|
961 |
bitmapGc->Activate(bitmapDevice); |
|
962 |
if (aBitmapIndex == EFSBitmapIndex) |
|
963 |
{ |
|
964 |
// scale the source bitmap which is a FS bitmap |
|
965 |
bitmapGc->DrawBitmap(TRect(iTargetBitmapSize), iFsBitmap); |
|
966 |
} |
|
967 |
else |
|
968 |
{ |
|
969 |
// scale the source bitmap which is a decoded bitmap |
|
970 |
bitmapGc->DrawBitmap(TRect(iTargetBitmapSize), |
|
971 |
iDecodedBitmap[EJpgDecodedBitmapIndex]); |
|
972 |
} |
|
973 |
||
974 |
CleanupStack::PopAndDestroy(bitmapGc); |
|
975 |
CleanupStack::PopAndDestroy(bitmapDevice); |
|
976 |
||
977 |
} |
|
978 |
||
979 |
// ----------------------------------------------------------------------------- |
|
980 |
// ProcessTvImage |
|
981 |
// ----------------------------------------------------------------------------- |
|
982 |
void CGlxHdmiSurfaceUpdater::ProcessTvImage() |
|
983 |
{ |
|
984 |
TRACER("CGlxHdmiSurfaceUpdater::ProcessTvImage()"); |
|
985 |
if (iSurfBufferAO->iStatus != KRequestPending |
|
986 |
&& !iSurfBufferAO->IsActive()) |
|
987 |
{ |
|
988 |
Refresh(); |
|
989 |
iSurfBufferAO->iStatus = KRequestPending; |
|
990 |
iSurfBufferAO->SetActive(); |
|
991 |
iSurfUpdateSession.NotifyWhenAvailable(iSurfBufferAO->iStatus); |
|
992 |
TInt err = iSurfUpdateSession.SubmitUpdate(1, iSurfId, 0, NULL); |
|
993 |
GLX_LOG_INFO1( |
|
994 |
"CGlxHdmiSurfaceUpdater::ProcessTvImage() Surfaceupdatesession error %d", |
|
995 |
err); |
|
996 |
} |
|
997 |
} |
|
998 |
||
999 |
// ----------------------------------------------------------------------------- |
|
1000 |
// DecodeNextImageL |
|
1001 |
// ----------------------------------------------------------------------------- |
|
1002 |
void CGlxHdmiSurfaceUpdater::DecodeNextImageL() |
|
1003 |
{ |
|
1004 |
TRACER("CGlxHdmiSurfaceUpdater::DecodeNextImageL()"); |
|
1005 |
ReleaseContent(); |
|
1006 |
iImagePath = iNextImagePath->Alloc(); |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
1007 |
if (iNextImagePath) |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
1008 |
{ |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
1009 |
delete iNextImagePath; |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
1010 |
iNextImagePath = NULL; |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
1011 |
} |
60 | 1012 |
iIsNonJpeg = EFalse; |
1013 |
GLX_LOG_INFO("Before - iWindow->Size()"); |
|
1014 |
iTvScreenSize = iWindow->Size(); |
|
1015 |
GLX_LOG_INFO("After - iWindow->Size()"); |
|
1016 |
iBitmapReady = EFalse; |
|
1017 |
iLeftCornerForZoom.iX = 0; |
|
1018 |
iLeftCornerForZoom.iY = 0; |
|
1019 |
iZoom = ETrue; |
|
1020 |
//Cancel the zoom timers if any |
|
1021 |
if (iTimer && iTimer->IsActive()) |
|
1022 |
{ |
|
1023 |
GLX_LOG_INFO( |
|
1024 |
"CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Cancel Timer"); |
|
1025 |
iTimer->Cancel(); |
|
1026 |
} |
|
1027 |
// Create the HDMI Decoder |
|
1028 |
CreateImageDecoderL(); |
|
1029 |
// Create the Bitmap |
|
1030 |
CreateBitmapL(); |
|
1031 |
if (iSurfManager) |
|
1032 |
{ |
|
1033 |
// Create the surface and AO for updating the surface |
|
1034 |
CreateHdmiL( EFalse); |
|
1035 |
} |
|
1036 |
else |
|
1037 |
{ |
|
1038 |
TRAP_IGNORE( CreateHdmiL(ETrue)); |
|
1039 |
} |
|
1040 |
||
1041 |
#ifdef _DEBUG |
|
1042 |
iStartTime.HomeTime(); |
|
1043 |
#endif |
|
1044 |
if (iSurfManager) |
|
1045 |
{ |
|
1046 |
//start decoding the image |
|
1047 |
iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex], |
|
1048 |
iImageDecoder); |
|
1049 |
iDecodingNext = ETrue; |
|
1050 |
iDecodingNextFailed = EFalse; |
|
1051 |
//Inform the Observer that decoding has started |
|
1052 |
iDecoderObserver.HandleHDMIDecodingEventL(EHdmiDecodingStarted); |
|
1053 |
} |
|
1054 |
} |
|
1055 |