17 |
17 |
18 #include <graphics/surface.h> |
18 #include <graphics/surface.h> |
19 #include <graphics/surfacemanager.h> |
19 #include <graphics/surfacemanager.h> |
20 #include <graphics/surfaceupdateclient.h> |
20 #include <graphics/surfaceupdateclient.h> |
21 #include <e32math.h> |
21 #include <e32math.h> |
|
22 #include <apgcli.h> |
22 |
23 |
23 #include <imageconversion.h> |
24 #include <imageconversion.h> |
24 #include <fbs.h> |
25 #include <fbs.h> |
25 #include <glxtracer.h> |
26 #include <glxtracer.h> |
26 #include <glxlog.h> |
27 #include <glxlog.h> |
27 #include <glxgeneraluiutilities.h> |
28 #include <glxgeneraluiutilities.h> |
28 |
29 |
29 #include "glxactivecallback.h" |
30 #include "glxactivecallback.h" |
30 #include "glxhdmisurfaceupdater.h" |
31 #include "glxhdmisurfaceupdater.h" |
31 #include "glxactivedecoder.h" |
32 #include "glxactivedecoder.h" |
32 |
33 #include <bitdev.h> |
33 // 720p image size |
34 |
34 const TInt KHdTvWidth = 1280; |
|
35 const TInt KHdTvHeight = 720; |
|
36 const TInt KMulFactorToCreateBitmap = 4; |
35 const TInt KMulFactorToCreateBitmap = 4; |
37 const TInt KZoomDelay = 10000; |
36 const TInt KZoomDelay = 10000; |
38 //100 , is decide for 20 steps of zooming , with each step being 5 pixels. |
37 //100 , is decide for 20 steps of zooming , with each step being 5 pixels. |
39 const TInt KMaxZoomLimit = 100; |
38 const TInt KMaxZoomLimit = 100; |
40 //evey time we zoom , there is a increase in the ht amd width by 10 pixels. |
39 //evey time we zoom , there is a increase in the ht amd width by 10 pixels. |
41 const TInt KSingleStepForZoom = 10; |
40 const TInt KSingleStepForZoom = 10; |
|
41 |
|
42 _LIT(KMimeJpeg,"image/jpeg"); |
|
43 _LIT(KMimeJpg,"image/jpg"); |
|
44 |
42 // ----------------------------------------------------------------------------- |
45 // ----------------------------------------------------------------------------- |
43 // NewLC |
46 // NewLC |
44 // ----------------------------------------------------------------------------- |
47 // ----------------------------------------------------------------------------- |
45 CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL(RWindow* aWindow, const TDesC& aImageFile, |
48 CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL(RWindow* aWindow, const TDesC& aImageFile, |
|
49 CFbsBitmap* aFsBitmap, |
46 MGlxGenCallback* aCallBack) |
50 MGlxGenCallback* aCallBack) |
47 { |
51 { |
48 TRACER("CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL()"); |
52 TRACER("CGlxHdmiSurfaceUpdater* CGlxHdmiSurfaceUpdater::NewL()"); |
49 CGlxHdmiSurfaceUpdater* self = new (ELeave) CGlxHdmiSurfaceUpdater(aWindow, aImageFile, |
53 CGlxHdmiSurfaceUpdater* self = new (ELeave) CGlxHdmiSurfaceUpdater(aWindow, aCallBack); |
50 aCallBack); |
|
51 CleanupStack::PushL(self); |
54 CleanupStack::PushL(self); |
52 self->ConstructL(); |
55 self->ConstructL(aFsBitmap,aImageFile); |
53 CleanupStack::Pop(self); |
56 CleanupStack::Pop(self); |
54 return self; |
57 return self; |
55 } |
58 } |
56 |
59 |
57 // ----------------------------------------------------------------------------- |
60 // ----------------------------------------------------------------------------- |
104 void CGlxHdmiSurfaceUpdater::ReleaseContent() |
107 void CGlxHdmiSurfaceUpdater::ReleaseContent() |
105 { |
108 { |
106 TRACER("void CGlxHdmiSurfaceUpdater::ReleaseContent()"); |
109 TRACER("void CGlxHdmiSurfaceUpdater::ReleaseContent()"); |
107 if ( iGlxDecoderAO ) |
110 if ( iGlxDecoderAO ) |
108 { |
111 { |
|
112 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -1"); |
109 iGlxDecoderAO->Cancel(); |
113 iGlxDecoderAO->Cancel(); |
110 } |
114 } |
111 |
115 if (iFsBitmap) |
112 if ( iDecodedBitmap ) |
116 { |
113 { |
117 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -2"); |
114 delete iDecodedBitmap; |
118 delete iFsBitmap; |
115 iDecodedBitmap= NULL; |
119 iFsBitmap = NULL; |
116 } |
120 } |
117 |
121 for (TInt i=0; i<=2 ; i++) |
|
122 { |
|
123 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ReleaseContent() -3, %d", i); |
|
124 delete iDecodedBitmap[i]; |
|
125 iDecodedBitmap[i]= NULL; |
|
126 } |
|
127 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -4"); |
118 if(iSurfBufferAO && iSurfBufferAO->IsActive()) |
128 if(iSurfBufferAO && iSurfBufferAO->IsActive()) |
119 { |
129 { |
|
130 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -5"); |
120 iSurfBufferAO->Cancel(); |
131 iSurfBufferAO->Cancel(); |
121 } |
132 } |
122 |
|
123 if ( iImageDecoder ) |
133 if ( iImageDecoder ) |
124 { |
134 { |
|
135 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -6"); |
125 delete iImageDecoder; |
136 delete iImageDecoder; |
126 iImageDecoder = NULL; |
137 iImageDecoder = NULL; |
127 } |
138 } |
128 |
|
129 if (iSurfSessionConnected && iSurfManager) |
139 if (iSurfSessionConnected && iSurfManager) |
130 { |
140 { |
|
141 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::ReleaseContent() -7"); |
131 iSurfUpdateSession.CancelAllUpdateNotifications(); |
142 iSurfUpdateSession.CancelAllUpdateNotifications(); |
132 } |
143 } |
|
144 if (iImagePath) |
|
145 { |
|
146 delete iImagePath; |
|
147 iImagePath = NULL; |
|
148 } |
133 } |
149 } |
134 |
150 |
135 // ----------------------------------------------------------------------------- |
151 // ----------------------------------------------------------------------------- |
136 // CTor |
152 // CTor |
137 // ----------------------------------------------------------------------------- |
153 // ----------------------------------------------------------------------------- |
138 CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater(RWindow* aWindow, |
154 CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater(RWindow* aWindow, |
139 const TDesC& aImageFile, MGlxGenCallback* aCallBack): |
155 MGlxGenCallback* aCallBack): |
140 iWindow(aWindow), iImagePath(aImageFile), |
156 iWindow(aWindow), iCallBack(aCallBack), |
141 iCallBack(aCallBack) |
157 iShwFsThumbnail(ETrue), iIsNonJpeg(EFalse) |
142 { |
158 { |
143 TRACER("CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater()"); |
159 TRACER("CGlxHdmiSurfaceUpdater::CGlxHdmiSurfaceUpdater()"); |
144 // Implement nothing here |
160 // Implement nothing here |
145 } |
161 } |
146 |
162 |
147 // ----------------------------------------------------------------------------- |
163 // ----------------------------------------------------------------------------- |
148 // ConstructL |
164 // ConstructL |
149 // ----------------------------------------------------------------------------- |
165 // ----------------------------------------------------------------------------- |
150 void CGlxHdmiSurfaceUpdater::ConstructL() |
166 void CGlxHdmiSurfaceUpdater::ConstructL(CFbsBitmap* aFsBitmap, const TDesC& aImageFile) |
151 { |
167 { |
152 TRACER("CGlxHdmiSurfaceUpdater::ConstructL()"); |
168 TRACER("CGlxHdmiSurfaceUpdater::ConstructL()"); |
|
169 // Initiate the HDMI by assigning the necessary values |
|
170 InitiateHdmiL(aFsBitmap,aImageFile); |
|
171 |
153 TInt error = iFsSession.Connect (); |
172 TInt error = iFsSession.Connect (); |
154 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() FsSession Connect error = %d", error); |
173 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() FsSession Connect error = %d", error); |
155 User::LeaveIfError(error); |
174 User::LeaveIfError(error); |
156 |
|
157 iBitmapReady = EFalse; |
|
158 iShiftToCloning = EFalse; |
175 iShiftToCloning = EFalse; |
159 // Create the active object |
176 // Create the active object |
160 iGlxDecoderAO = CGlxHdmiDecoderAO::NewL(this); |
177 iGlxDecoderAO = CGlxHdmiDecoderAO::NewL(this); |
161 CreateImageDecoderL(iImagePath); |
178 |
|
179 // Create the HDMI Decoder |
|
180 CreateImageDecoderL(); |
|
181 |
|
182 // Create the Bitmap |
162 CreateBitmapL(); |
183 CreateBitmapL(); |
|
184 |
|
185 // Create the surface and AO for updating the surface |
163 TRAP_IGNORE(CreateHdmiL()); |
186 TRAP_IGNORE(CreateHdmiL()); |
|
187 |
164 if(iSurfManager) |
188 if(iSurfManager) |
165 { |
189 { |
166 error = iSurfUpdateSession.Connect(); |
190 error = iSurfUpdateSession.Connect(); |
167 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() Surface update Session Connect error = %d", error); |
191 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ConstructL() Surface update Session Connect error = %d", error); |
168 User::LeaveIfError(error); |
192 User::LeaveIfError(error); |
169 iSurfSessionConnected = ETrue; |
193 iSurfSessionConnected = ETrue; |
170 |
194 |
|
195 ShowFsThumbnailL(); |
171 #ifdef _DEBUG |
196 #ifdef _DEBUG |
172 iStartTime.HomeTime(); |
197 iStartTime.HomeTime(); |
173 #endif |
198 #endif |
174 //start decoding the image |
199 //start decoding the image |
175 iGlxDecoderAO->ConvertImageL(*iDecodedBitmap,iImageDecoder); |
200 iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex],iImageDecoder); |
176 } |
201 } |
177 iLeftCornerForZoom.iX = 0; |
|
178 iLeftCornerForZoom.iY = 0; |
|
179 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
202 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
180 iZoom = ETrue; |
|
181 } |
203 } |
182 |
204 |
183 // ----------------------------------------------------------------------------- |
205 // ----------------------------------------------------------------------------- |
184 // UpdateNewImageL |
206 // UpdateNewImageL |
185 // ----------------------------------------------------------------------------- |
207 // ----------------------------------------------------------------------------- |
186 void CGlxHdmiSurfaceUpdater::UpdateNewImageL(const TDesC& aImageFile) |
208 void CGlxHdmiSurfaceUpdater::UpdateNewImageL(const TDesC& aImageFile,CFbsBitmap* aFsBitmap) |
187 { |
209 { |
188 TRACER("CGlxHdmiSurfaceUpdater::UpdateNewImageL()"); |
210 TRACER("CGlxHdmiSurfaceUpdater::UpdateNewImageL()"); |
189 //Cancel the zoom timers if any |
211 ReleaseContent(); |
190 if(iTimer->IsActive()) |
212 // Initiate the HDMI by assigning the necessary values |
191 { |
213 InitiateHdmiL(aFsBitmap,aImageFile); |
192 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Cancel Timer"); |
214 //Cancel the zoom timers if any |
|
215 if(iTimer->IsActive()) |
|
216 { |
|
217 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::UpdateNewImageL() - Cancel Timer"); |
193 iTimer->Cancel(); |
218 iTimer->Cancel(); |
194 } |
219 } |
195 |
220 |
196 iBitmapReady = EFalse; |
221 // Create the HDMI Decoder |
197 iLeftCornerForZoom.iX = 0; |
222 CreateImageDecoderL(); |
198 iLeftCornerForZoom.iY = 0; |
223 |
199 ReleaseContent(); |
224 // Create the Bitmap |
200 CreateImageDecoderL(aImageFile); |
|
201 CreateBitmapL(); |
225 CreateBitmapL(); |
202 if(iSurfManager) |
226 if(iSurfManager) |
203 { |
227 { |
204 CreateHdmiL(EFalse); |
228 // Create the surface and AO for updating the surface |
205 } |
229 CreateHdmiL(EFalse); |
|
230 } |
206 else |
231 else |
207 { |
232 { |
208 TRAP_IGNORE(CreateHdmiL(ETrue)); |
233 TRAP_IGNORE(CreateHdmiL(ETrue)); |
209 } |
234 } |
|
235 |
210 #ifdef _DEBUG |
236 #ifdef _DEBUG |
211 iStartTime.HomeTime(); |
237 iStartTime.HomeTime(); |
212 #endif |
238 #endif |
213 if(iSurfManager) |
239 if(iSurfManager) |
214 { |
240 { |
215 //start decoding the image |
241 // Show FS Thumbnail |
216 iGlxDecoderAO->ConvertImageL(*iDecodedBitmap,iImageDecoder); |
242 ShowFsThumbnailL(); |
217 } |
243 //start decoding the image |
|
244 iGlxDecoderAO->ConvertImageL(*iDecodedBitmap[EJpgDecodedBitmapIndex],iImageDecoder); |
|
245 } |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // InitiateHdmiL |
|
250 // ----------------------------------------------------------------------------- |
|
251 void CGlxHdmiSurfaceUpdater::InitiateHdmiL(CFbsBitmap* aFsBitmap,const TDesC& aImageFile) |
|
252 { |
|
253 TRACER("CGlxHdmiSurfaceUpdater::InitiateHdmiL()"); |
|
254 iImagePath = aImageFile.Alloc(); |
|
255 iFsBitmap = new (ELeave) CFbsBitmap; |
|
256 iFsBitmap->Duplicate(aFsBitmap->Handle()); |
|
257 iIsNonJpeg = EFalse; |
|
258 iTvScreenSize = iWindow->Size(); |
|
259 |
|
260 iBitmapReady = EFalse; |
|
261 iLeftCornerForZoom.iX = 0; |
|
262 iLeftCornerForZoom.iY = 0; |
|
263 |
|
264 iZoom = ETrue; |
218 } |
265 } |
219 |
266 |
220 // ----------------------------------------------------------------------------- |
267 // ----------------------------------------------------------------------------- |
221 // CreateHDMI |
268 // CreateHDMI |
222 // ----------------------------------------------------------------------------- |
269 // ----------------------------------------------------------------------------- |
243 // CreateSurfaceL |
290 // CreateSurfaceL |
244 // ----------------------------------------------------------------------------- |
291 // ----------------------------------------------------------------------------- |
245 void CGlxHdmiSurfaceUpdater::CreateSurfaceL() |
292 void CGlxHdmiSurfaceUpdater::CreateSurfaceL() |
246 { |
293 { |
247 TRACER("CGlxHdmiSurfaceUpdater::CreateSurfaceL()"); |
294 TRACER("CGlxHdmiSurfaceUpdater::CreateSurfaceL()"); |
248 TSize surfaceSize = iWindow->Size(); // create surface of the screen size, i.e 1280x720 |
|
249 iSurfManager = new(ELeave) RSurfaceManager(); |
295 iSurfManager = new(ELeave) RSurfaceManager(); |
250 TInt error = iSurfManager->Open(); |
296 TInt error = iSurfManager->Open(); |
251 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::CreateSurfaceL Open Surface manager error = %d", error); |
297 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::CreateSurfaceL Open Surface manager error = %d", error); |
252 User::LeaveIfError(error); |
298 User::LeaveIfError(error); |
253 |
299 |
254 RSurfaceManager::TSurfaceCreationAttributesBuf attributes; |
300 RSurfaceManager::TSurfaceCreationAttributesBuf attributes; |
255 attributes().iPixelFormat = EUidPixelFormatARGB_8888;// EUidPixelFormatYUV_420Planar; |
301 attributes().iPixelFormat = EUidPixelFormatARGB_8888;// EUidPixelFormatYUV_420Planar; |
256 attributes().iSize = surfaceSize; |
302 attributes().iSize = iTvScreenSize; |
257 |
303 |
258 attributes().iBuffers = 1; |
304 attributes().iBuffers = 1; |
259 attributes().iStride = surfaceSize.iWidth * KMulFactorToCreateBitmap; |
305 attributes().iStride = iTvScreenSize.iWidth * KMulFactorToCreateBitmap; |
260 attributes().iAlignment = KMulFactorToCreateBitmap; |
306 attributes().iAlignment = KMulFactorToCreateBitmap; |
261 attributes().iContiguous = EFalse; |
307 attributes().iContiguous = EFalse; |
262 attributes().iMappable = ETrue; |
308 attributes().iMappable = ETrue; |
263 |
309 |
264 error = iSurfManager->CreateSurface(attributes, iSurfId); |
310 error = iSurfManager->CreateSurface(attributes, iSurfId); |
340 // After this is done, a refresh to the window should be done to refresh the TV |
385 // After this is done, a refresh to the window should be done to refresh the TV |
341 // ----------------------------------------------------------------------------- |
386 // ----------------------------------------------------------------------------- |
342 void CGlxHdmiSurfaceUpdater::SwapBuffers() |
387 void CGlxHdmiSurfaceUpdater::SwapBuffers() |
343 { |
388 { |
344 TRACER("CGlxHdmiSurfaceUpdater::SwapBuffers()"); |
389 TRACER("CGlxHdmiSurfaceUpdater::SwapBuffers()"); |
345 |
390 TInt bitmapIndex = KErrNotFound; |
|
391 |
|
392 if (iShwFsThumbnail) // show FS thumbnail |
|
393 { |
|
394 bitmapIndex = EFSBitmapIndex; |
|
395 } |
|
396 else if(iIsNonJpeg && !iShwFsThumbnail) // this indicates it is non jpeg image and decoding finished |
|
397 { |
|
398 bitmapIndex = ENonJpgDecodedBitmapIndex; |
|
399 } |
|
400 else // if none of the above state means it is jpeg image and decoding finished |
|
401 { |
|
402 bitmapIndex = EJpgDecodedBitmapIndex; |
|
403 } |
|
404 |
346 // Lock the heap so that subsequent call to dataaddress doesnt happen |
405 // Lock the heap so that subsequent call to dataaddress doesnt happen |
347 iDecodedBitmap->LockHeap(); |
406 iDecodedBitmap[bitmapIndex]->LockHeap(); |
348 |
407 |
349 // Data stride |
408 // Data stride |
350 TUint fs = iDecodedBitmap->DataStride(); |
409 TUint fs = iDecodedBitmap[bitmapIndex]->DataStride(); |
351 |
410 |
352 //Bitmap address from where the data has to be copied. |
411 //Bitmap address from where the data has to be copied. |
353 TUint8* from = (TUint8*)iDecodedBitmap->DataAddress(); |
412 TUint8* from = (TUint8*)iDecodedBitmap[bitmapIndex]->DataAddress(); |
354 |
413 |
355 //surface chunk address to where the bitmap data has to be copied. |
414 //surface chunk address to where the bitmap data has to be copied. |
356 TUint8* to = (TUint8*)iSurfBuffer; |
415 TUint8* to = (TUint8*)iSurfBuffer; |
357 |
416 |
358 // To buffer (32 bit colors) |
417 // To buffer (32 bit colors) |
359 TUint ts = iSurfaceStride; |
418 TUint ts = iSurfaceStride; |
360 //No of bytes to be copied on to the surface. |
419 //No of bytes to be copied on to the surface. |
361 TUint bytes = iDecodedBitmap->SizeInPixels().iWidth * KMulFactorToCreateBitmap; |
420 TUint bytes = iDecodedBitmap[bitmapIndex]->SizeInPixels().iWidth * KMulFactorToCreateBitmap; |
362 |
421 |
363 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::SwapBuffers() - decodeSize width = %d and height %d", |
422 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::SwapBuffers() - decodeSize width = %d and height %d", |
364 iDecodedBitmap->SizeInPixels().iWidth, iDecodedBitmap->SizeInPixels().iHeight ); |
423 iDecodedBitmap[bitmapIndex]->SizeInPixels().iWidth, |
365 |
424 iDecodedBitmap[bitmapIndex]->SizeInPixels().iHeight ); |
|
425 |
366 // Copy the bitmap on to the surface. |
426 // Copy the bitmap on to the surface. |
367 for (TInt y = iDecodedBitmap->SizeInPixels().iHeight; y >0; y--) |
427 for (TInt y = iDecodedBitmap[bitmapIndex]->SizeInPixels().iHeight; y >0; y--) |
368 { |
428 { |
369 Mem::Copy(to, from, bytes); |
429 Mem::Copy(to, from, bytes); |
370 to += ts; |
430 to += ts; |
371 from += fs; |
431 from += fs; |
372 } |
432 } |
373 iDecodedBitmap->UnlockHeap(); |
433 iDecodedBitmap[bitmapIndex]->UnlockHeap(); |
374 } |
434 } |
375 |
435 |
376 // ----------------------------------------------------------------------------- |
436 // ----------------------------------------------------------------------------- |
377 // StartImageDecodeL |
437 // CreateBitmapL |
378 // ----------------------------------------------------------------------------- |
438 // ----------------------------------------------------------------------------- |
379 void CGlxHdmiSurfaceUpdater::CreateBitmapL() |
439 void CGlxHdmiSurfaceUpdater::CreateBitmapL() |
380 { |
440 { |
381 TRACER("CGlxHdmiSurfaceUpdater::StartImageDecodeL()"); |
441 TRACER("CGlxHdmiSurfaceUpdater::CreateBitmapL()"); |
382 TSize scrnSize = iWindow->Size(); |
|
383 TSize targetBitmapSize; |
|
384 TSize imageSize = iImageDecoder->FrameInfo().iOverallSizeInPixels; |
442 TSize imageSize = iImageDecoder->FrameInfo().iOverallSizeInPixels; |
385 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - bitmapsize=%d, %d",imageSize.iWidth,imageSize.iHeight); |
443 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - bitmapsize=%d, %d", |
|
444 imageSize.iWidth,imageSize.iHeight); |
386 TReal32 scaleFactor = 0.0f; |
445 TReal32 scaleFactor = 0.0f; |
387 if (scrnSize.iWidth * imageSize.iHeight > scrnSize.iHeight |
446 if (iTvScreenSize.iWidth * imageSize.iHeight > iTvScreenSize.iHeight |
388 * imageSize.iWidth) |
447 * imageSize.iWidth) |
389 { |
448 { |
390 scaleFactor = (TReal32) scrnSize.iHeight |
449 scaleFactor = (TReal32) iTvScreenSize.iHeight |
391 / (TReal32) imageSize.iHeight; |
450 / (TReal32) imageSize.iHeight; |
392 } |
451 } |
393 else |
452 else |
394 { |
453 { |
395 scaleFactor = (TReal32) scrnSize.iWidth |
454 scaleFactor = (TReal32) iTvScreenSize.iWidth |
396 / (TReal32) imageSize.iWidth; |
455 / (TReal32) imageSize.iWidth; |
397 } |
456 } |
398 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - scaleFactor=%f",scaleFactor); |
457 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - scaleFactor=%f",scaleFactor); |
399 targetBitmapSize.iHeight = imageSize.iHeight * scaleFactor; |
458 iTargetBitmapSize.iHeight = imageSize.iHeight * scaleFactor; |
400 targetBitmapSize.iWidth = imageSize.iWidth * scaleFactor; |
459 iTargetBitmapSize.iWidth = imageSize.iWidth * scaleFactor; |
401 |
460 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - targetBitmapSize=%d, %d", |
402 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::StartImageDecodeL() - targetBitmapSize=%d, %d",targetBitmapSize.iWidth,targetBitmapSize.iHeight); |
461 iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight); |
403 //create the bitmap for the required size |
462 //create the bitmap for the required size |
404 iDecodedBitmap = new (ELeave) CFbsBitmap(); |
463 iDecodedBitmap[EJpgDecodedBitmapIndex] = new (ELeave) CFbsBitmap(); |
405 |
464 // to check if the Mimetype is supported by the decoder to to arbitary scaling |
406 TInt err = iDecodedBitmap->Create(targetBitmapSize, EColor16MU); |
465 // if not then we recalculate the size |
407 User::LeaveIfNull(iDecodedBitmap); |
466 TInt err = iDecodedBitmap[EJpgDecodedBitmapIndex]->Create(ReCalculateSizeL(), EColor16MU); |
|
467 User::LeaveIfNull(iDecodedBitmap[EJpgDecodedBitmapIndex]); |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // DoesMimeTypeNeedsRecalculateL() |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 TBool CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL() |
|
475 { |
|
476 TRACER("CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL"); |
|
477 RApaLsSession session; |
|
478 TDataType mimeType; |
|
479 TUid uid; |
|
480 |
|
481 User::LeaveIfError( session.Connect() ); |
|
482 CleanupClosePushL( session ); |
|
483 User::LeaveIfError( session.AppForDocument( iImagePath->Des(), uid, mimeType ) ); |
|
484 CleanupStack::PopAndDestroy(&session); |
|
485 |
|
486 if (mimeType.Des().Compare(KMimeJpeg)==0 || |
|
487 mimeType.Des().Compare(KMimeJpg)==0) |
|
488 { |
|
489 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL - jpeg"); |
|
490 return EFalse; |
|
491 } |
|
492 else |
|
493 { |
|
494 GLX_LOG_INFO("CGlxHdmiSurfaceUpdater::DoesMimeTypeNeedsRecalculateL - non jpeg"); |
|
495 return ETrue; |
|
496 } |
|
497 } |
|
498 |
|
499 // ----------------------------------------------------------------------------- |
|
500 // ReCalculateSize |
|
501 // ----------------------------------------------------------------------------- |
|
502 TSize CGlxHdmiSurfaceUpdater::ReCalculateSizeL() |
|
503 { |
|
504 TRACER("CGlxHdmiSurfaceUpdater::ReCalculateSizeL()"); |
|
505 if(DoesMimeTypeNeedsRecalculateL()) |
|
506 { |
|
507 iIsNonJpeg = ETrue; |
|
508 TSize fullFrameSize = iImageDecoder->FrameInfo().iOverallSizeInPixels; |
|
509 // calculate the reduction factor on what size we need |
|
510 TInt reductionFactor = iImageDecoder->ReductionFactor(fullFrameSize, iTargetBitmapSize); |
|
511 // get the reduced size onto destination size |
|
512 TSize destSize; |
|
513 User::LeaveIfError(iImageDecoder->ReducedSize(fullFrameSize, reductionFactor, destSize)); |
|
514 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ReCalculateSizeL() - destSize=%d, %d",destSize.iWidth,destSize.iHeight); |
|
515 return destSize; |
|
516 } |
|
517 else |
|
518 { |
|
519 return iTargetBitmapSize; |
|
520 } |
408 } |
521 } |
409 |
522 |
410 // ----------------------------------------------------------------------------- |
523 // ----------------------------------------------------------------------------- |
411 // HandleRunL |
524 // HandleRunL |
412 // ----------------------------------------------------------------------------- |
525 // ----------------------------------------------------------------------------- |
447 } |
557 } |
448 |
558 |
449 // ----------------------------------------------------------------------------- |
559 // ----------------------------------------------------------------------------- |
450 // CreateImageDecoderL |
560 // CreateImageDecoderL |
451 // ----------------------------------------------------------------------------- |
561 // ----------------------------------------------------------------------------- |
452 void CGlxHdmiSurfaceUpdater::CreateImageDecoderL(const TDesC& aImageFile) |
562 void CGlxHdmiSurfaceUpdater::CreateImageDecoderL() |
453 { |
563 { |
454 TRACER("CGlxHdmiController::CreateImageDecoderL()"); |
564 TRACER("CGlxHdmiController::CreateImageDecoderL()"); |
455 // Create a decoder for the image in the named file |
565 // Create a decoder for the image in the named file |
456 TRAPD(error,iImageDecoder = CImageDecoder::FileNewL(iFsSession, |
566 TRAPD(error,iImageDecoder = CImageDecoder::FileNewL(iFsSession, |
457 aImageFile, CImageDecoder::EOptionNone, KNullUid)); |
567 iImagePath->Des(), CImageDecoder::EOptionNone, KNullUid)); |
458 GLX_LOG_INFO1("CreateImageDecoderL CImageDecoder:FileNewL error %d",error); |
568 GLX_LOG_INFO1("CreateImageDecoderL CImageDecoder:FileNewL error %d",error); |
459 User::LeaveIfError(error); |
569 User::LeaveIfError(error); |
460 |
|
461 } |
570 } |
462 |
571 |
463 // ----------------------------------------------------------------------------- |
572 // ----------------------------------------------------------------------------- |
464 // ActivateZoom |
573 // ActivateZoom |
465 // ----------------------------------------------------------------------------- |
574 // ----------------------------------------------------------------------------- |
541 iTimer->Cancel(); |
650 iTimer->Cancel(); |
542 } |
651 } |
543 } |
652 } |
544 if(aZoom && iZoom) |
653 if(aZoom && iZoom) |
545 { |
654 { |
546 iZoomRectSz.iWidth = TInt(iZoomRectSz.iWidth-KSingleStepForZoom); |
655 iTargetBitmapSize.iWidth = TInt(iTargetBitmapSize.iWidth-KSingleStepForZoom); |
547 iZoomRectSz.iHeight = TInt(iZoomRectSz.iHeight-KSingleStepForZoom); |
656 iTargetBitmapSize.iHeight = TInt(iTargetBitmapSize.iHeight-KSingleStepForZoom); |
548 iLeftCornerForZoom.iX =iLeftCornerForZoom.iX+KSingleStepForZoom/2; |
657 iLeftCornerForZoom.iX =iLeftCornerForZoom.iX+KSingleStepForZoom/2; |
549 iLeftCornerForZoom.iY =iLeftCornerForZoom.iY+KSingleStepForZoom/2; |
658 iLeftCornerForZoom.iY =iLeftCornerForZoom.iY+KSingleStepForZoom/2; |
550 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::Zoom()--- 2,iZoomRectSz.iWidth = %d, iZoomRectSz.iHeight = %d", iZoomRectSz.iWidth,iZoomRectSz.iHeight); |
659 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::Zoom()--- 2,iTargetBitmapSize.iWidth = %d, iTargetBitmapSize.iHeight = %d", iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight); |
551 iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,iLeftCornerForZoom.iY, |
660 iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,iLeftCornerForZoom.iY, |
552 iZoomRectSz.iWidth,iZoomRectSz.iHeight)); |
661 iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight)); |
553 } |
662 } |
554 else |
663 else |
555 { |
664 { |
556 iZoomRectSz.iWidth = TInt(iZoomRectSz.iWidth+KSingleStepForZoom); |
665 iTargetBitmapSize.iWidth = TInt(iTargetBitmapSize.iWidth+KSingleStepForZoom); |
557 iZoomRectSz.iHeight = TInt(iZoomRectSz.iHeight+KSingleStepForZoom); |
666 iTargetBitmapSize.iHeight = TInt(iTargetBitmapSize.iHeight+KSingleStepForZoom); |
558 iLeftCornerForZoom.iX =iLeftCornerForZoom.iX-KSingleStepForZoom/2; |
667 iLeftCornerForZoom.iX =iLeftCornerForZoom.iX-KSingleStepForZoom/2; |
559 iLeftCornerForZoom.iY =iLeftCornerForZoom.iY-KSingleStepForZoom/2; |
668 iLeftCornerForZoom.iY =iLeftCornerForZoom.iY-KSingleStepForZoom/2; |
560 if(iLeftCornerForZoom.iX == 0) |
669 if(iLeftCornerForZoom.iX == 0) |
561 { |
670 { |
562 iTimer->Cancel(); |
671 iTimer->Cancel(); |
563 iZoom = ETrue; |
672 iZoom = ETrue; |
564 } |
673 } |
565 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::Zoom()--- 4,iZoomRectSz.iWidth = %d, iZoomRectSz.iHeight = %d", iZoomRectSz.iWidth,iZoomRectSz.iHeight); |
674 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::Zoom()--- 4,iTargetBitmapSize.iWidth = %d, iTargetBitmapSize.iHeight = %d", iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight); |
566 iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,iLeftCornerForZoom.iY, |
675 iConfig.SetViewport(TRect(iLeftCornerForZoom.iX,iLeftCornerForZoom.iY, |
567 iZoomRectSz.iWidth,iZoomRectSz.iHeight)); |
676 iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight)); |
568 } |
677 } |
569 iWindow->SetBackgroundSurface(iConfig, ETrue); |
678 iWindow->SetBackgroundSurface(iConfig, ETrue); |
570 } |
679 } |
571 |
680 |
572 // ----------------------------------------------------------------------------- |
681 // ----------------------------------------------------------------------------- |
573 // ModifySurfacePostion |
682 // ModifySurfacePostion |
574 // ----------------------------------------------------------------------------- |
683 // ----------------------------------------------------------------------------- |
575 void CGlxHdmiSurfaceUpdater::ModifySurfacePostion() |
684 void CGlxHdmiSurfaceUpdater::ModifySurfacePostion() |
576 { |
685 { |
577 TRACER("CGlxHdmiSurfaceUpdater::ModifySurfacePostion()"); |
686 TRACER("CGlxHdmiSurfaceUpdater::ModifySurfacePostion()"); |
578 TSize bitmapSize = iDecodedBitmap->SizeInPixels(); |
|
579 TPoint startPoint(0,0); |
687 TPoint startPoint(0,0); |
580 if (bitmapSize.iWidth <KHdTvWidth) |
688 if (iTargetBitmapSize.iWidth <iTvScreenSize.iWidth) |
581 { |
689 { |
582 startPoint.iX = (KHdTvWidth - bitmapSize.iWidth)/2; |
690 startPoint.iX = (iTvScreenSize.iWidth - iTargetBitmapSize.iWidth)/2; |
583 } |
691 } |
584 if (bitmapSize.iHeight <KHdTvHeight) |
692 if (iTargetBitmapSize.iHeight <iTvScreenSize.iHeight) |
585 { |
693 { |
586 startPoint.iY = (KHdTvHeight - bitmapSize.iHeight)/2; |
694 startPoint.iY = (iTvScreenSize.iHeight - iTargetBitmapSize.iHeight)/2; |
587 } |
695 } |
588 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - target bitmapsize=%d, %d",bitmapSize.iWidth,bitmapSize.iHeight); |
696 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - target iTargetBitmapSize=%d, %d", |
589 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - startPoint =%d, %d",startPoint.iX,startPoint.iY); |
697 iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight); |
|
698 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - startPoint =%d, %d", |
|
699 startPoint.iX,startPoint.iY); |
590 |
700 |
591 // target |
701 // target |
592 iConfig.SetExtent(TRect(startPoint.iX,startPoint.iY,(KHdTvWidth-startPoint.iX), |
702 iConfig.SetExtent(TRect(startPoint.iX,startPoint.iY,(iTvScreenSize.iWidth-startPoint.iX), |
593 (KHdTvHeight-startPoint.iY))); |
703 (iTvScreenSize.iHeight-startPoint.iY))); |
594 // source |
704 // source |
595 iConfig.SetViewport(TRect(TPoint(0,0),TSize(bitmapSize.iWidth,bitmapSize.iHeight))); |
705 iConfig.SetViewport(TRect(TPoint(0,0),TSize(iTargetBitmapSize.iWidth, |
|
706 iTargetBitmapSize.iHeight))); |
596 #ifdef _DEBUG |
707 #ifdef _DEBUG |
597 TRect ex, vp; |
708 TRect ex, vp; |
598 iConfig.GetExtent(ex); |
709 iConfig.GetExtent(ex); |
599 iConfig.GetViewport(vp); |
710 iConfig.GetViewport(vp); |
600 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - vp - TL=%d, %d",vp.iTl.iX,vp.iTl.iY); |
711 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - vp - TL=%d, %d",vp.iTl.iX,vp.iTl.iY); |
601 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - vp - BR=%d, %d",vp.iBr.iX,vp.iBr.iY); |
712 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - vp - BR=%d, %d",vp.iBr.iX,vp.iBr.iY); |
602 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - ex - TL=%d, %d",ex.iTl.iX,ex.iTl.iY); |
713 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - ex - TL=%d, %d",ex.iTl.iX,ex.iTl.iY); |
603 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - ex - BR=%d, %d",ex.iBr.iX,ex.iBr.iY); |
714 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ModifySurfacePostion() - ex - BR=%d, %d",ex.iBr.iX,ex.iBr.iY); |
604 #endif |
715 #endif |
605 iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
606 } |
716 } |
607 |
717 |
608 // ----------------------------------------------------------------------------- |
718 // ----------------------------------------------------------------------------- |
609 // ShiftToCloningMode |
719 // ShiftToCloningMode |
610 // ----------------------------------------------------------------------------- |
720 // ----------------------------------------------------------------------------- |
633 #endif |
743 #endif |
634 iWindow->SetBackgroundSurface(iConfig, ETrue); |
744 iWindow->SetBackgroundSurface(iConfig, ETrue); |
635 iShiftToCloning = EFalse; |
745 iShiftToCloning = EFalse; |
636 } |
746 } |
637 } |
747 } |
|
748 |
|
749 // ----------------------------------------------------------------------------- |
|
750 // ShowFsThumbnailL |
|
751 // ----------------------------------------------------------------------------- |
|
752 void CGlxHdmiSurfaceUpdater::ShowFsThumbnailL() |
|
753 { |
|
754 TRACER("CGlxHdmiSurfaceUpdater::ShowFsThumbnailL()"); |
|
755 iShwFsThumbnail = ETrue; |
|
756 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ShowFsThumbnailL() iTargetBitmapSize Width=%d, Height=%d", |
|
757 iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight); |
|
758 // Modify the surface position with respect to the buffer size |
|
759 ModifySurfacePostion(); |
|
760 // this is for FS thumbnail stored in array pointer 0 |
|
761 ScaleDecodedBitmapL(EFSBitmapIndex); |
|
762 // Process the Image to TV |
|
763 ProcessTvImage(); |
|
764 // set the surface onto background |
|
765 iWindow->SetBackgroundSurface(iConfig, ETrue); |
|
766 } |
|
767 |
|
768 // ----------------------------------------------------------------------------- |
|
769 // ScaleDecodedBitmapL |
|
770 // ----------------------------------------------------------------------------- |
|
771 void CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL(TInt aBitmapIndex) |
|
772 { |
|
773 TRACER("CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL()"); |
|
774 GLX_LOG_INFO2("CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL() iTargetBitmapSize Width=%d, Height=%d", |
|
775 iTargetBitmapSize.iWidth,iTargetBitmapSize.iHeight); |
|
776 |
|
777 if (iDecodedBitmap[aBitmapIndex]) |
|
778 { |
|
779 delete iDecodedBitmap[aBitmapIndex]; |
|
780 iDecodedBitmap[aBitmapIndex] = NULL; |
|
781 } |
|
782 iDecodedBitmap[aBitmapIndex] = new (ELeave) CFbsBitmap(); |
|
783 // create destination with size |
|
784 TInt err = iDecodedBitmap[aBitmapIndex]->Create(iTargetBitmapSize, EColor16MU); |
|
785 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ScaleDecodedBitmapL() creating bitmap error, err=%d",err); |
|
786 User::LeaveIfNull(iDecodedBitmap[aBitmapIndex]); |
|
787 |
|
788 // Create bitmap device for destination bitmap |
|
789 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(iDecodedBitmap[aBitmapIndex]); |
|
790 CleanupStack::PushL(bitmapDevice); |
|
791 |
|
792 CFbsBitGc* bitmapGc = CFbsBitGc::NewL(); |
|
793 CleanupStack::PushL(bitmapGc); |
|
794 bitmapGc->Activate(bitmapDevice); |
|
795 if (aBitmapIndex==EFSBitmapIndex) |
|
796 { |
|
797 // scale the source bitmap which is a FS bitmap |
|
798 bitmapGc->DrawBitmap(TRect(iTargetBitmapSize), iFsBitmap); |
|
799 } |
|
800 else |
|
801 { |
|
802 // scale the source bitmap which is a decoded bitmap |
|
803 bitmapGc->DrawBitmap(TRect(iTargetBitmapSize), iDecodedBitmap[EJpgDecodedBitmapIndex]); |
|
804 } |
|
805 |
|
806 CleanupStack::PopAndDestroy(bitmapGc); |
|
807 CleanupStack::PopAndDestroy(bitmapDevice); |
|
808 |
|
809 } |
|
810 |
|
811 // ----------------------------------------------------------------------------- |
|
812 // ProcessTvImage |
|
813 // ----------------------------------------------------------------------------- |
|
814 void CGlxHdmiSurfaceUpdater::ProcessTvImage() |
|
815 { |
|
816 TRACER("CGlxHdmiSurfaceUpdater::ProcessTvImage()"); |
|
817 if (iSurfBufferAO->iStatus != KRequestPending |
|
818 && !iSurfBufferAO->IsActive()) |
|
819 { |
|
820 Refresh(); |
|
821 iSurfBufferAO->iStatus = KRequestPending; |
|
822 iSurfBufferAO->SetActive(); |
|
823 iSurfUpdateSession.NotifyWhenAvailable(iSurfBufferAO->iStatus); |
|
824 TInt err = iSurfUpdateSession.SubmitUpdate(1, iSurfId, 0, NULL); |
|
825 GLX_LOG_INFO1("CGlxHdmiSurfaceUpdater::ProcessTvImage() Surfaceupdatesession error %d",err); |
|
826 } |
|
827 } |
|
828 |
|
829 |
|
830 |