|
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 <e32math.h> |
|
22 |
|
23 #include <imageconversion.h> |
|
24 #include <fbs.h> |
|
25 #include <glxtracer.h> |
|
26 #include <glxlog.h> |
|
27 |
|
28 #include "glxactivecallback.h" |
|
29 #include "glxhdmisurfaceupdater.h" |
|
30 #include "glxactivedecoder.h" |
|
31 |
|
32 // 720p image size |
|
33 const TInt KHdTvWidth = 1280; |
|
34 const TInt KHdTvHeight = 720; |
|
35 const TInt KMulFactorToCreateBitmap = 4; |
|
36 const TInt KZoomDelay = 10000; |
|
37 //100 , is decide for 20 steps of zooming , with each step being 5 pixels. |
|
38 const TInt KMaxZoomLimit = 100; |
|
39 //evey time we zoom , there is a increase in the ht amd width by 10 pixels. |
|
40 const TInt KSingleStepForZoom = 10; |
|
41 |
|
42 const TInt KSleepTime = 50*1000; // 100 ms |
|
43 // ----------------------------------------------------------------------------- |
|
44 // NewLC |
|
45 // ----------------------------------------------------------------------------- |
|
46 CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL(RWindow* aWindow, const TDesC& aImageFile, |
|
47 TSize aImageDimensions, TInt aFrameCount, MGlxGenCallback* aCallBack) |
|
48 { |
|
49 TRACER("CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL()"); |
|
50 CGlxHdmiSurfaceUpdater* self = new (ELeave) CGlxHdmiSurfaceUpdater(aWindow, aImageFile, |
|
51 aImageDimensions, aFrameCount, aCallBack); |
|
52 CleanupStack::PushL(self); |
|
53 self->ConstructL(aImageDimensions); |
|
54 CleanupStack::Pop(self); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // destructor |
|
60 // ----------------------------------------------------------------------------- |
|
61 CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater() |
|
62 { |
|
63 TRACER("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater()"); |
|
64 ReleaseContent(); |
|
65 if(iWindow) |
|
66 { |
|
67 iWindow->RemoveBackgroundSurface(ETrue); |
|
68 } |
|
69 if(iTimer->IsActive()) |
|
70 { |
|
71 iTimer->Cancel(); |
|
72 } |
|
73 delete iTimer; |
|
74 if (iGlxDecoderAO) |
|
75 { |
|
76 delete iGlxDecoderAO; |
|
77 } |
|
78 iGlxDecoderAO = NULL; |
|
79 iFsSession.Close(); |
|
80 if (iSurfManager) |
|
81 { |
|
82 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater() - Close"); |
|
83 iSurfUpdateSession.Close(); |
|
84 if (iSurfChunk) |
|
85 { |
|
86 iSurfChunk->Close(); |
|
87 } |
|
88 delete iSurfChunk; |
|
89 iSurfChunk = NULL; |
|
90 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater(). iSurfManager->CloseSurface()"); |
|
91 iSurfManager->CloseSurface(iSurfId); |
|
92 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::~CGlxHdmiSurfaceUpdater(). iSurfManager->Close()"); |
|
93 iSurfManager->Close(); |
|
94 delete iSurfManager; |
|
95 iSurfManager = NULL; |
|
96 } |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // ReleaseContent |
|
101 // ----------------------------------------------------------------------------- |
|
102 void CGlxHdmiSurfaceUpdater::ReleaseContent() |
|
103 { |
|
104 TRACER("void CGlxHdmiSurfaceUpdater::ReleaseContent()"); |
|
105 if ( iGlxDecoderAO ) |
|
106 { |
|
107 iGlxDecoderAO->Cancel(); |
|
108 } |
|
109 // Delete the animation timer |
|
110 if(iAnimationTimer && iAnimationTimer->IsActive()) |
|
111 { |
|
112 iAnimationTimer->Cancel(); |
|
113 delete iAnimationTimer; |
|
114 } |
|
115 for (TInt i=0; i<= iFrameCount-1; i++) |
|
116 { |
|
117 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ReleaseContent(). Releasing AnimBitmaps %d", i); |
|
118 delete(iDecodedBitmap[i]); |
|
119 iDecodedBitmap[i] = NULL; |
|
120 } |
|
121 if ( iSurfBufferAO->IsActive() ) |
|
122 { |
|
123 iSurfBufferAO->Cancel(); |
|
124 } |
|
125 if ( iImageDecoder ) |
|
126 { |
|
127 delete iImageDecoder; |
|
128 iImageDecoder = NULL; |
|
129 } |
|
130 iSurfUpdateSession.CancelAllUpdateNotifications(); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CTor |
|
135 // ----------------------------------------------------------------------------- |
|
136 CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater(RWindow* aWindow, const TDesC& aImageFile, |
|
137 TSize aOrigImageDimensions, TInt aFrameCount, MGlxGenCallback* aCallBack): |
|
138 iWindow(aWindow), iImagePath(aImageFile), iOrigImageDimensions(aOrigImageDimensions), |
|
139 iFrameCount(aFrameCount ),iCallBack(aCallBack) |
|
140 { |
|
141 TRACER("CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater()"); |
|
142 // Implement nothing here |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // ConstructL |
|
147 // ----------------------------------------------------------------------------- |
|
148 void CGlxHdmiSurfaceUpdater::ConstructL(TSize /*aImageDimensions*/) |
|
149 { |
|
150 TRACER("CGlxHdmiSurfaceUpdater::ConstructL()"); |
|
151 TInt error = iFsSession.Connect (); |
|
152 if ( KErrNone!= iFsSession.Connect () ) |
|
153 { |
|
154 User::LeaveIfError(error); |
|
155 } |
|
156 iBitmapReady = EFalse; |
|
157 iAnimCount = 0; |
|
158 // Create the active object |
|
159 iGlxDecoderAO = CGlxHdmiDecoderAO::NewL(this, iFrameCount); |
|
160 CreateImageDecoderL(iImagePath); |
|
161 CreateBitmapAndStartDecodingL(); |
|
162 CreateHdmiL(); |
|
163 error = iSurfUpdateSession.Connect(); |
|
164 #ifdef _DEBUG |
|
165 iStartTime.HomeTime(); |
|
166 #endif |
|
167 if (KErrNone !=error) |
|
168 { |
|
169 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() Surface update Session Connect Failed with error = %d", error); |
|
170 User::LeaveIfError(error); |
|
171 } |
|
172 iLeftCornerForZoom.iX = 0; |
|
173 iLeftCornerForZoom.iY = 0; |
|
174 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
175 iZoom = ETrue; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // UpdateNewImageL |
|
180 // ----------------------------------------------------------------------------- |
|
181 void CGlxHdmiSurfaceUpdater::UpdateNewImageL(const TDesC& aImageFile, |
|
182 TInt aFrameCount,TSize aImageDimensions) |
|
183 { |
|
184 TRACER("CGlxHdmiSurfaceUpdater::UpdateNewImageL()"); |
|
185 // First release the contents before proceeding further |
|
186 ReleaseContent(); |
|
187 iOrigImageDimensions = aImageDimensions; |
|
188 iFrameCount = aFrameCount; |
|
189 iBitmapReady = EFalse; |
|
190 iAnimCount = 0; |
|
191 |
|
192 CreateImageDecoderL(aImageFile); |
|
193 CreateBitmapAndStartDecodingL(); |
|
194 CreateHdmiL(EFalse); |
|
195 #ifdef _DEBUG |
|
196 iStartTime.HomeTime(); |
|
197 #endif |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CreateHDMI |
|
202 // ----------------------------------------------------------------------------- |
|
203 void CGlxHdmiSurfaceUpdater::CreateHdmiL(TBool aCreateSurface) |
|
204 { |
|
205 TRACER("CGlxHdmiSurfaceUpdater::CreateHdmiL()"); |
|
206 |
|
207 if (aCreateSurface) |
|
208 { |
|
209 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::CreateHdmiL() Create Surface"); |
|
210 CreateSurfaceL(); |
|
211 } |
|
212 |
|
213 // Active objects for double buffered draw signalling |
|
214 if(!iSurfBufferAO) |
|
215 { |
|
216 iSurfBufferAO = new(ELeave) CGlxActiveCallBack(TCallBack(SurfBuffer0Ready, this), |
|
217 CActive::EPriorityStandard-1); |
|
218 CActiveScheduler::Add(iSurfBufferAO); |
|
219 } |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CreateSurfaceL |
|
224 // ----------------------------------------------------------------------------- |
|
225 void CGlxHdmiSurfaceUpdater::CreateSurfaceL() |
|
226 { |
|
227 TRACER("CGlxHdmiSurfaceUpdater::CreateSurfaceL()"); |
|
228 TSize surfaceSize = iWindow->Size(); // create surface of the screen size, i.e 1280x720 |
|
229 iSurfManager = new(ELeave) RSurfaceManager(); |
|
230 TInt error = iSurfManager->Open(); |
|
231 if (error != KErrNone) |
|
232 { |
|
233 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::CreateSurfaceL Open Surface manager failed with error = %d", error); |
|
234 User::LeaveIfError(error); |
|
235 } |
|
236 RSurfaceManager::TSurfaceCreationAttributesBuf attributes; |
|
237 attributes().iPixelFormat = EUidPixelFormatARGB_8888;// EUidPixelFormatYUV_420Planar; |
|
238 attributes().iSize = surfaceSize; |
|
239 |
|
240 attributes().iBuffers = 1; |
|
241 attributes().iStride = surfaceSize.iWidth * KMulFactorToCreateBitmap; |
|
242 attributes().iAlignment = KMulFactorToCreateBitmap; |
|
243 attributes().iContiguous = EFalse; |
|
244 attributes().iMappable = ETrue; |
|
245 |
|
246 error = iSurfManager->CreateSurface(attributes, iSurfId); |
|
247 if(error) |
|
248 { |
|
249 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::CreateSurfaceL, Creating surface failed with error : %d",error); |
|
250 User::LeaveIfError(error); |
|
251 } |
|
252 //Map the surface and stride the surface info |
|
253 MapSurfaceL(); |
|
254 // Set the Configuration to the surface ID when creating a surface |
|
255 iConfig.SetSurfaceId(iSurfId); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // MapSurfaceL |
|
260 // ----------------------------------------------------------------------------- |
|
261 void CGlxHdmiSurfaceUpdater::MapSurfaceL() |
|
262 { |
|
263 TRACER("CGlxHdmiSurfaceUpdater::MapSurfaceL()"); |
|
264 |
|
265 //Create chunk to map it to the surface ID. |
|
266 iSurfChunk = new(ELeave) RChunk(); |
|
267 User::LeaveIfNull(iSurfChunk); |
|
268 TInt error = iSurfManager->MapSurface(iSurfId, *iSurfChunk); |
|
269 if(error!=KErrNone) |
|
270 { |
|
271 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::CreateSurfaceL(), MapSurface Failed wint error : %d",error); |
|
272 } |
|
273 |
|
274 // Get the info from the surfaceManager |
|
275 // and store pointers to the pixel data |
|
276 RSurfaceManager::TInfoBuf info; |
|
277 error = iSurfManager->SurfaceInfo(iSurfId, info); |
|
278 iSurfaceStride = info().iStride; |
|
279 User::LeaveIfError(error); |
|
280 TInt offset = 0; |
|
281 iSurfManager->GetBufferOffset( iSurfId, 0,offset); |
|
282 iSurfBuffer = iSurfChunk->Base()+offset; |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // SurfBuffer0Ready |
|
287 // ----------------------------------------------------------------------------- |
|
288 TInt CGlxHdmiSurfaceUpdater::SurfBuffer0Ready(TAny* /*aObject*/) |
|
289 { |
|
290 TRACER("CGlxHdmiSurfaceUpdater::SurfBuffer0Ready()"); |
|
291 return ETrue; |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // Refresh |
|
296 // ----------------------------------------------------------------------------- |
|
297 void CGlxHdmiSurfaceUpdater::Refresh() |
|
298 { |
|
299 TRACER("CGlxHdmiSurfaceUpdater::Refresh()"); |
|
300 // Advance animation |
|
301 // if the animation count is becoming maximum [8], then set it to zero, |
|
302 // such that it can animate again frm begining |
|
303 if (++iAnimCount >= iFrameCount) |
|
304 iAnimCount = 0; |
|
305 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::Refresh() animCOunt = %d",iAnimCount); |
|
306 // copy the decoded bitmap on to the surface |
|
307 SwapBuffers(); |
|
308 // Modify the surface position with respect to the buffer size |
|
309 ModifySurfacePostion(); |
|
310 // refresh the window |
|
311 iCallBack->DoGenCallback(); |
|
312 } |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // SwapBuffers |
|
316 // This is used to sawp the buffers shown and to be shown |
|
317 // After this is done, a refresh to the window should be done to refresh the TV |
|
318 // ----------------------------------------------------------------------------- |
|
319 void CGlxHdmiSurfaceUpdater::SwapBuffers() |
|
320 { |
|
321 TRACER("CGlxHdmiSurfaceUpdater::SwapBuffers()"); |
|
322 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::SwapBuffers() animCOunt = %d",iAnimCount); |
|
323 // Lock the heap so that subsequent call to dataaddress doesnt happen |
|
324 iDecodedBitmap[iAnimCount]->LockHeap(); |
|
325 |
|
326 // Data stride |
|
327 TUint fs = iDecodedBitmap[iAnimCount]->DataStride(); |
|
328 |
|
329 //Bitmap address from where the data has to be copied. |
|
330 TUint8* from = (TUint8*)iDecodedBitmap[iAnimCount]->DataAddress(); |
|
331 |
|
332 //surface chunk address to where the bitmap data has to be copied. |
|
333 TUint8* to = (TUint8*)iSurfBuffer; |
|
334 |
|
335 // To buffer (32 bit colors) |
|
336 TUint ts = iSurfaceStride; |
|
337 //No of bytes to be copied on to the surface. |
|
338 TUint bytes = iDecodedBitmap[iAnimCount]->SizeInPixels().iWidth * KMulFactorToCreateBitmap; |
|
339 |
|
340 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::SwapBuffers() - decodeSize width = %d and height %d", |
|
341 iDecodedBitmap[iAnimCount]->SizeInPixels().iWidth, iDecodedBitmap[iAnimCount]->SizeInPixels().iHeight ); |
|
342 |
|
343 // Copy the bitmap on to the surface. |
|
344 for (TInt y = iDecodedBitmap[iAnimCount]->SizeInPixels().iHeight; y >0; y--) |
|
345 { |
|
346 Mem::Copy(to, from, bytes); |
|
347 to += ts; |
|
348 from += fs; |
|
349 } |
|
350 iDecodedBitmap[iAnimCount]->UnlockHeap(); |
|
351 } |
|
352 |
|
353 // ----------------------------------------------------------------------------- |
|
354 // CreateBitmapL |
|
355 // ----------------------------------------------------------------------------- |
|
356 void CGlxHdmiSurfaceUpdater::CreateBitmapAndStartDecodingL() |
|
357 { |
|
358 TRACER("CGlxHdmiSurfaceUpdater::CreateBitmapAndStartDecodingL()"); |
|
359 TSize scrnSize = iWindow->Size(); |
|
360 TSize targetBitmapSize; |
|
361 if (iFrameCount>1) |
|
362 { |
|
363 iAnimationTimer = CPeriodic::NewL( CActive::EPriorityLow ); |
|
364 } |
|
365 |
|
366 // if (iFrameCount >1) |
|
367 // { |
|
368 // // For Gif images , use the same size of its dimensions, as Image decoder wont decode to different size. |
|
369 // GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::CreateBitmapAndStartDecodingL() -1"); |
|
370 // targetBitmapSize = iOrigImageDimensions; |
|
371 // } |
|
372 // else |
|
373 // { |
|
374 // for all other images, re calculate the size of the image based on aspect ratio and fit the screen |
|
375 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::CreateBitmapAndStartDecodingL() -2"); |
|
376 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::CreateBitmapAndStartDecodingL() - bitmapsize=%d, %d",iOrigImageDimensions.iWidth,iOrigImageDimensions.iHeight); |
|
377 TReal32 scaleFactor = 0.0f; |
|
378 if (scrnSize.iWidth * iOrigImageDimensions.iHeight > scrnSize.iHeight |
|
379 * iOrigImageDimensions.iWidth) |
|
380 { |
|
381 scaleFactor = (TReal32) scrnSize.iHeight |
|
382 / (TReal32) iOrigImageDimensions.iHeight; |
|
383 } |
|
384 else |
|
385 { |
|
386 scaleFactor = (TReal32) scrnSize.iWidth |
|
387 / (TReal32) iOrigImageDimensions.iWidth; |
|
388 } |
|
389 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::CreateBitmapAndStartDecodingL() - scaleFactor=%f",scaleFactor); |
|
390 targetBitmapSize.iHeight = iOrigImageDimensions.iHeight * scaleFactor; |
|
391 targetBitmapSize.iWidth = iOrigImageDimensions.iWidth * scaleFactor; |
|
392 // } |
|
393 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::CreateBitmapAndStartDecodingL() - targetBitmapSize=%d, %d",targetBitmapSize.iWidth,targetBitmapSize.iHeight); |
|
394 //create the bitmap for the required size |
|
395 iDecodedBitmap[iAnimCount] = new (ELeave) CFbsBitmap(); |
|
396 |
|
397 TInt err = iDecodedBitmap[iAnimCount]->Create(targetBitmapSize, EColor16MU); |
|
398 User::LeaveIfNull(iDecodedBitmap[iAnimCount]); |
|
399 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::CreateBitmapAndStartDecodingL() FrameCOunt = %d, AnimCOunt =%d",iFrameCount, iAnimCount); |
|
400 //start decoding the image |
|
401 iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[iAnimCount],iAnimCount,iImageDecoder); |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // HandleRunL |
|
406 // ----------------------------------------------------------------------------- |
|
407 void CGlxHdmiSurfaceUpdater::HandleRunL(TRequestStatus& aStatus) |
|
408 { |
|
409 TRACER("CGlxHdmiSurfaceUpdater::HandleRunL()"); |
|
410 |
|
411 if (iFrameCount >1 && iAnimCount !=iFrameCount-1) |
|
412 { |
|
413 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::HandleRunL() - gif image - iAnimCount= %d,FrameCOunt =%d",iAnimCount,iFrameCount); |
|
414 while(iAnimCount != iFrameCount-1 && !iGlxDecoderAO->IsActive()) |
|
415 { |
|
416 iAnimCount++; |
|
417 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::HandleRunL() - gif image - iAnimCount= %d",iAnimCount); |
|
418 CreateBitmapAndStartDecodingL(); |
|
419 } |
|
420 } |
|
421 else |
|
422 { |
|
423 #ifdef _DEBUG |
|
424 iStopTime.HomeTime(); |
|
425 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::HandleRunL() ConvertImageL took" |
|
426 " <%d> us", (TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64()); |
|
427 #endif |
|
428 if(aStatus.Int() !=KErrNone) |
|
429 { |
|
430 GLX_LOG_INFO1("HandleRunL - Convert failed with error=%d",aStatus.Int()); |
|
431 ShiftToCloningMode(); |
|
432 } |
|
433 else |
|
434 { |
|
435 iBitmapReady = ETrue; |
|
436 iZoomRectSz = iDecodedBitmap[iAnimCount]->SizeInPixels(); |
|
437 ProcessTvImageL(); |
|
438 } |
|
439 //release imagedecoder after the conversion is over |
|
440 if(iImageDecoder) |
|
441 { |
|
442 delete iImageDecoder; |
|
443 iImageDecoder = NULL; |
|
444 } |
|
445 } |
|
446 } |
|
447 |
|
448 // ----------------------------------------------------------------------------- |
|
449 // CreateImageDecoderL |
|
450 // ----------------------------------------------------------------------------- |
|
451 void CGlxHdmiSurfaceUpdater::ProcessTvImageL() |
|
452 { |
|
453 TRACER("CGlxHdmiSurfaceUpdater::ProcessTvImageL()"); |
|
454 if (iSurfBufferAO->iStatus != KRequestPending |
|
455 && !iSurfBufferAO->IsActive()) |
|
456 { |
|
457 Refresh(); |
|
458 iSurfBufferAO->iStatus = KRequestPending; |
|
459 iSurfBufferAO->SetActive(); |
|
460 iSurfUpdateSession.NotifyWhenAvailable(iSurfBufferAO->iStatus); |
|
461 TInt err = iSurfUpdateSession.SubmitUpdate(1, iSurfId, 0, NULL); |
|
462 // If the Animation framecount is more that 1, it means this is a gif image, |
|
463 // start the timer to refresh the TV |
|
464 if (iFrameCount>1) |
|
465 { |
|
466 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ProcessTvImageL() :Gif Image, ANimCOUnt =%d",iAnimCount); |
|
467 iAnimationTimer->Cancel(); |
|
468 |
|
469 // Next frame |
|
470 iAnimationTimer->Start(KSleepTime, KSleepTime, TCallBack(TimerCallbackL, this)); |
|
471 } |
|
472 } |
|
473 } |
|
474 // ----------------------------------------------------------------------------- |
|
475 // CreateImageDecoderL |
|
476 // ----------------------------------------------------------------------------- |
|
477 void CGlxHdmiSurfaceUpdater::CreateImageDecoderL(const TDesC& aImageFile) |
|
478 { |
|
479 TRACER("CGlxHdmiController::CreateImageDecoderL()"); |
|
480 // Create a decoder for the image in the named file |
|
481 TRAPD(error,iImageDecoder = CImageDecoder::FileNewL(iFsSession, |
|
482 aImageFile, CImageDecoder::EOptionNone, KNullUid)); |
|
483 if (error!=KErrNone) |
|
484 { |
|
485 User::Leave(error); |
|
486 } |
|
487 } |
|
488 |
|
489 // ----------------------------------------------------------------------------- |
|
490 // ActivateZoom |
|
491 // ----------------------------------------------------------------------------- |
|
492 void CGlxHdmiSurfaceUpdater::ActivateZoom() |
|
493 { |
|
494 TRACER("CGlxHdmiSurfaceUpdater::ActivateZoom()"); |
|
495 iZoom = ETrue; |
|
496 if (!(iFrameCount >1)) |
|
497 { |
|
498 if(!iTimer->IsActive() && iBitmapReady) |
|
499 { |
|
500 iTimer->Start(KZoomDelay,KZoomDelay,TCallBack( TimeOut,this )); |
|
501 } |
|
502 } |
|
503 } |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // DeactivateZoom |
|
507 // ----------------------------------------------------------------------------- |
|
508 void CGlxHdmiSurfaceUpdater::DeactivateZoom() |
|
509 { |
|
510 TRACER("CGlxHdmiSurfaceUpdater::DeactivateZoom()"); |
|
511 if(iDecodedBitmap[iAnimCount] && !(iFrameCount >1)) |
|
512 { |
|
513 TSize bitmapsize = iDecodedBitmap[iAnimCount]->SizeInPixels(); |
|
514 iConfig.SetViewport(TRect(0,0,bitmapsize.iWidth,bitmapsize.iHeight)); |
|
515 iConfig.SetExtent(TRect(0,0,bitmapsize.iWidth,bitmapsize.iHeight)); |
|
516 iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
517 } |
|
518 } |
|
519 |
|
520 // --------------------------------------------------------------------------- |
|
521 // TimeOut |
|
522 // --------------------------------------------------------------------------- |
|
523 // |
|
524 TInt CGlxHdmiSurfaceUpdater::TimeOut(TAny* aSelf) |
|
525 { |
|
526 TRACER("CGlxHdmiSurfaceUpdater::TimeOut"); |
|
527 if(aSelf) |
|
528 { |
|
529 CGlxHdmiSurfaceUpdater* self = static_cast <CGlxHdmiSurfaceUpdater*> (aSelf); |
|
530 if (self) |
|
531 { |
|
532 self->Zoom(ETrue); |
|
533 } |
|
534 } |
|
535 return KErrNone; |
|
536 } |
|
537 |
|
538 // ----------------------------------------------------------------------------- |
|
539 // TimerCallbackL |
|
540 // ----------------------------------------------------------------------------- |
|
541 TInt CGlxHdmiSurfaceUpdater::TimerCallbackL(TAny* aThis) |
|
542 { |
|
543 TRACER("CGlxHdmiSurfaceUpdater::TimerCallbackL()"); |
|
544 static_cast<CGlxHdmiSurfaceUpdater*>(aThis)->ProcessTimerEventL(); |
|
545 return NULL; |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // ProcessTimerEventL |
|
550 // ----------------------------------------------------------------------------- |
|
551 void CGlxHdmiSurfaceUpdater::ProcessTimerEventL() |
|
552 { |
|
553 TRACER("CGlxHdmiSurfaceUpdater::ProcessTimerEventL()"); |
|
554 ProcessTvImageL(); |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // Zoom |
|
559 // ----------------------------------------------------------------------------- |
|
560 void CGlxHdmiSurfaceUpdater::Zoom(TBool aZoom) |
|
561 { |
|
562 TRACER("CGlxHdmiSurfaceUpdater::Zoom()"); |
|
563 if(iLeftCornerForZoom.iX == KMaxZoomLimit) |
|
564 { |
|
565 iZoom = EFalse; |
|
566 } |
|
567 if(aZoom && iZoom) |
|
568 { |
|
569 iZoomRectSz.iWidth = TInt(iZoomRectSz.iWidth-KSingleStepForZoom); |
|
570 iZoomRectSz.iHeight = TInt(iZoomRectSz.iHeight-KSingleStepForZoom); |
|
571 iLeftCornerForZoom.iX =iLeftCornerForZoom.iX+KSingleStepForZoom/2; |
|
572 iLeftCornerForZoom.iY =iLeftCornerForZoom.iY+KSingleStepForZoom/2; |
|
573 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::Zoom()--- 2,iZoomRectSz.iWidth = %d, iZoomRectSz.iHeight = %d", iZoomRectSz.iWidth,iZoomRectSz.iHeight); |
|
574 iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,iLeftCornerForZoom.iY, |
|
575 iZoomRectSz.iWidth,iZoomRectSz.iHeight)); |
|
576 } |
|
577 else |
|
578 { |
|
579 iZoomRectSz.iWidth = TInt(iZoomRectSz.iWidth+KSingleStepForZoom); |
|
580 iZoomRectSz.iHeight = TInt(iZoomRectSz.iHeight+KSingleStepForZoom); |
|
581 iLeftCornerForZoom.iX =iLeftCornerForZoom.iX-KSingleStepForZoom/2; |
|
582 iLeftCornerForZoom.iY =iLeftCornerForZoom.iY-KSingleStepForZoom/2; |
|
583 if(iLeftCornerForZoom.iX == 0) |
|
584 { |
|
585 iTimer->Cancel(); |
|
586 iZoom = ETrue; |
|
587 } |
|
588 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::Zoom()--- 4,iZoomRectSz.iWidth = %d, iZoomRectSz.iHeight = %d", iZoomRectSz.iWidth,iZoomRectSz.iHeight); |
|
589 iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,iLeftCornerForZoom.iY, |
|
590 iZoomRectSz.iWidth,iZoomRectSz.iHeight)); |
|
591 } |
|
592 iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
593 } |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // ModifySurfacePostion |
|
597 // ----------------------------------------------------------------------------- |
|
598 void CGlxHdmiSurfaceUpdater::ModifySurfacePostion() |
|
599 { |
|
600 TRACER("CGlxHdmiSurfaceUpdater::ModifySurfacePostion()"); |
|
601 TSize bitmapSize = iDecodedBitmap[iAnimCount]->SizeInPixels(); |
|
602 TPoint startPoint(0,0); |
|
603 if (bitmapSize.iWidth <KHdTvWidth) |
|
604 { |
|
605 startPoint.iX = (KHdTvWidth - bitmapSize.iWidth)/2; |
|
606 } |
|
607 if (bitmapSize.iHeight <KHdTvHeight) |
|
608 { |
|
609 startPoint.iY = (KHdTvHeight - bitmapSize.iHeight)/2; |
|
610 } |
|
611 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - target bitmapsize=%d, %d",bitmapSize.iWidth,bitmapSize.iHeight); |
|
612 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - startPoint =%d, %d",startPoint.iX,startPoint.iY); |
|
613 |
|
614 // target |
|
615 iConfig.SetExtent(TRect(startPoint.iX,startPoint.iY,(KHdTvWidth-startPoint.iX), |
|
616 (KHdTvHeight-startPoint.iY))); |
|
617 // source |
|
618 iConfig.SetViewport(TRect(TPoint(0,0),TSize(bitmapSize.iWidth,bitmapSize.iHeight))); |
|
619 #ifdef _DEBUG |
|
620 TRect ex, vp; |
|
621 iConfig.GetExtent(ex); |
|
622 iConfig.GetViewport(vp); |
|
623 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - vp - TL=%d, %d",vp.iTl.iX,vp.iTl.iY); |
|
624 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - vp - BR=%d, %d",vp.iBr.iX,vp.iBr.iY); |
|
625 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - ex - TL=%d, %d",ex.iTl.iX,ex.iTl.iY); |
|
626 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - ex - BR=%d, %d",ex.iBr.iX,ex.iBr.iY); |
|
627 #endif |
|
628 iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
629 } |
|
630 |
|
631 // ----------------------------------------------------------------------------- |
|
632 // ShiftToCloningMode |
|
633 // ----------------------------------------------------------------------------- |
|
634 void CGlxHdmiSurfaceUpdater::ShiftToCloningMode() |
|
635 { |
|
636 TRACER("CGlxHdmiSurfaceUpdater::ShiftToCloningMode()"); |
|
637 iWindow->RemoveBackgroundSurface(ETrue); |
|
638 } |
|
639 |
|
640 // ----------------------------------------------------------------------------- |
|
641 // ShiftToPostingMode |
|
642 // ----------------------------------------------------------------------------- |
|
643 void CGlxHdmiSurfaceUpdater::ShiftToPostingMode() |
|
644 { |
|
645 TRACER("CGlxHdmiSurfaceUpdater::ShiftToPostingMode()"); |
|
646 #ifdef _DEBUG |
|
647 TRect ex, vp; |
|
648 iConfig.GetExtent(ex); |
|
649 iConfig.GetViewport(vp); |
|
650 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - vp - TL=%d, %d",vp.iTl.iX,vp.iTl.iY); |
|
651 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - vp - BR=%d, %d",vp.iBr.iX,vp.iBr.iY); |
|
652 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - ex - TL=%d, %d",ex.iTl.iX,ex.iTl.iY); |
|
653 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShiftToPostingMode() - ex - BR=%d, %d",ex.iBr.iX,ex.iBr.iY); |
|
654 #endif |
|
655 iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
656 } |