26 #include "thumbnailprovider.h" |
26 #include "thumbnailprovider.h" |
27 #include "thumbnailserver.h" |
27 #include "thumbnailserver.h" |
28 #include "thumbnailmanagerconstants.h" |
28 #include "thumbnailmanagerconstants.h" |
29 #include "thumbnaillog.h" |
29 #include "thumbnaillog.h" |
30 #include "thumbnailpanic.h" |
30 #include "thumbnailpanic.h" |
31 #include "OstTraceDefinitions.h" |
|
32 #ifdef OST_TRACE_COMPILER_IN_USE |
|
33 #include "thumbnailscaletaskTraces.h" |
|
34 #endif |
|
35 |
|
36 |
31 |
37 |
32 |
38 // ======== MEMBER FUNCTIONS ======== |
33 // ======== MEMBER FUNCTIONS ======== |
39 |
34 |
40 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
81 iDisplayMode( aDisplayMode ), iFilename( aFilename ), iTargetUri( aTargetUri ), |
76 iDisplayMode( aDisplayMode ), iFilename( aFilename ), iTargetUri( aTargetUri ), |
82 iThumbnailSize(aThumbnailSize), iModified(aModified), |
77 iThumbnailSize(aThumbnailSize), iModified(aModified), |
83 iBitmapToPool(aBitmapToPool), iEXIF(aEXIF), iVirtualUri( aVirtualUri ) |
78 iBitmapToPool(aBitmapToPool), iEXIF(aEXIF), iVirtualUri( aVirtualUri ) |
84 { |
79 { |
85 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::CThumbnailScaleTask()", this ); |
80 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::CThumbnailScaleTask()", this ); |
86 OstTrace1( TRACE_NORMAL, CTHUMBNAILSCALETASK_CTHUMBNAILSCALETASK, "CThumbnailScaleTask::CThumbnailScaleTask;this=%o", this ); |
|
87 |
81 |
88 iRequestId = aRequestId; |
82 iRequestId = aRequestId; |
89 } |
83 } |
90 |
84 |
91 |
85 |
118 iServer.CancelScale(); |
112 iServer.CancelScale(); |
119 |
113 |
120 if ( iBitmapInPool && iBitmap ) |
114 if ( iBitmapInPool && iBitmap ) |
121 { |
115 { |
122 TN_DEBUG1("CThumbnailScaleTask()::~CThumbnailScaleTask() delete original bitmap from pool"); |
116 TN_DEBUG1("CThumbnailScaleTask()::~CThumbnailScaleTask() delete original bitmap from pool"); |
123 OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSCALETASK_CTHUMBNAILSCALETASK, "CThumbnailScaleTask::~CThumbnailScaleTask - delete original bitmap from pool" ); |
|
124 |
117 |
125 // Original bitmap is owned by server, decrease reference count |
118 // Original bitmap is owned by server, decrease reference count |
126 iServer.DeleteBitmapFromPool( iBitmap->Handle()); |
119 iServer.DeleteBitmapFromPool( iBitmap->Handle()); |
127 } |
120 } |
128 |
121 |
137 // --------------------------------------------------------------------------- |
130 // --------------------------------------------------------------------------- |
138 // |
131 // |
139 void CThumbnailScaleTask::StartL() |
132 void CThumbnailScaleTask::StartL() |
140 { |
133 { |
141 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL()", this ); |
134 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL()", this ); |
142 OstTrace1( TRACE_NORMAL, CTHUMBNAILSCALETASK_STARTL, "CThumbnailScaleTask::StartL;this=%o", this ); |
|
143 |
135 |
144 CThumbnailTask::StartL(); |
136 CThumbnailTask::StartL(); |
145 |
137 |
146 if ( !iCrop ) |
138 if ( !iCrop ) |
147 { |
139 { |
148 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - cropping OFF", this ); |
140 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - cropping OFF", this ); |
149 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSCALETASK_STARTL, "CThumbnailScaleTask::StartL - cropping OFF;this=%o", this ); |
|
150 |
141 |
151 // target size at max, keep aspect ratio |
142 // target size at max, keep aspect ratio |
152 CalculateTargetSize(); |
143 CalculateTargetSize(); |
153 } |
144 } |
154 else |
145 else |
155 { |
146 { |
156 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - cropping ON", this ); |
147 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - cropping ON", this ); |
157 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSCALETASK_STARTL, "CThumbnailScaleTask::StartL - cropping ON;this=%o", this ); |
|
158 |
148 |
159 // exact target size, crop excess |
149 // exact target size, crop excess |
160 CalculateCropRectangle(); |
150 CalculateCropRectangle(); |
161 } |
151 } |
162 |
152 |
163 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - sizes calculated", this ); |
153 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - sizes calculated", this ); |
164 OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILSCALETASK_STARTL, "CThumbnailScaleTask::StartL - sizes calculated;this=%o", this ); |
|
165 |
154 |
166 #ifdef _DEBUG |
155 #ifdef _DEBUG |
167 aStart.UniversalTime(); |
156 aStart.UniversalTime(); |
168 #endif |
157 #endif |
169 |
158 |
174 TSize bitmapSize = iBitmap->SizeInPixels(); |
163 TSize bitmapSize = iBitmap->SizeInPixels(); |
175 |
164 |
176 if(bitmapSize.iHeight == iTargetSize.iHeight && bitmapSize.iWidth == iTargetSize.iWidth) |
165 if(bitmapSize.iHeight == iTargetSize.iHeight && bitmapSize.iWidth == iTargetSize.iWidth) |
177 { |
166 { |
178 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - no need for scaling", this); |
167 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - no need for scaling", this); |
179 OstTrace1( TRACE_NORMAL, DUP4_CTHUMBNAILSCALETASK_STARTL, "CThumbnailScaleTask::StartL - no need for scaling;this=%o", this ); |
|
180 |
168 |
181 // copy bitmap 1:1 |
169 // copy bitmap 1:1 |
182 User::LeaveIfError( iScaledBitmap->Create( bitmapSize, iBitmap->DisplayMode() )); |
170 User::LeaveIfError( iScaledBitmap->Create( bitmapSize, iBitmap->DisplayMode() )); |
183 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(iScaledBitmap); |
171 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(iScaledBitmap); |
184 CleanupStack::PushL(device); |
172 CleanupStack::PushL(device); |
193 ResetMessageData(); |
181 ResetMessageData(); |
194 } |
182 } |
195 else |
183 else |
196 { |
184 { |
197 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - scaling", this); |
185 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - scaling", this); |
198 OstTrace1( TRACE_NORMAL, DUP5_CTHUMBNAILSCALETASK_STARTL, "CThumbnailScaleTask::StartL - scaling;this=%o", this ); |
|
199 |
186 |
200 User::LeaveIfError( iScaledBitmap->Create( iTargetSize, iBitmap->DisplayMode() )); |
187 User::LeaveIfError( iScaledBitmap->Create( iTargetSize, iBitmap->DisplayMode() )); |
201 iServer.ScaleBitmapL( iStatus, * iBitmap, * iScaledBitmap, iCropRectangle ); |
188 iServer.ScaleBitmapL( iStatus, * iBitmap, * iScaledBitmap, iCropRectangle ); |
202 SetActive(); |
189 SetActive(); |
203 } |
190 } |
204 |
191 |
205 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() end", this ); |
192 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() end", this ); |
206 OstTrace1( TRACE_NORMAL, DUP6_CTHUMBNAILSCALETASK_STARTL, "CThumbnailScaleTask::StartL - end;this=%o", this ); |
|
207 } |
193 } |
208 |
194 |
209 |
195 |
210 // --------------------------------------------------------------------------- |
196 // --------------------------------------------------------------------------- |
211 // CThumbnailScaleTask::RunL() |
197 // CThumbnailScaleTask::RunL() |
214 void CThumbnailScaleTask::RunL() |
200 void CThumbnailScaleTask::RunL() |
215 { |
201 { |
216 TInt err = iStatus.Int(); |
202 TInt err = iStatus.Int(); |
217 |
203 |
218 TN_DEBUG3( "CThumbnailScaleTask(0x%08x)::RunL() err=%d)", this, err ); |
204 TN_DEBUG3( "CThumbnailScaleTask(0x%08x)::RunL() err=%d)", this, err ); |
219 OstTrace1( TRACE_NORMAL, CTHUMBNAILSCALETASK_RUNL, "CThumbnailScaleTask::RunL;this=%o", this ); |
|
220 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSCALETASK_RUNL, "CThumbnailScaleTask::RunL;err=%d", err ); |
|
221 |
205 |
222 #ifdef _DEBUG |
206 #ifdef _DEBUG |
223 aStop.UniversalTime(); |
207 aStop.UniversalTime(); |
224 TInt tookTime = (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000; |
|
225 TN_DEBUG2( "CThumbnailScaleTask::RunL() scale took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); |
208 TN_DEBUG2( "CThumbnailScaleTask::RunL() scale took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); |
226 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSCALETASK_RUNL, "CThumbnailScaleTask::RunL - scale took ms;tookTime=%d", tookTime ); |
|
227 #endif |
209 #endif |
228 |
210 |
229 if ( !err ) |
211 if ( !err ) |
230 { |
212 { |
231 TRAP( err, StoreAndCompleteL()); |
213 TRAP( err, StoreAndCompleteL()); |
241 // --------------------------------------------------------------------------- |
223 // --------------------------------------------------------------------------- |
242 // |
224 // |
243 void CThumbnailScaleTask::DoCancel() |
225 void CThumbnailScaleTask::DoCancel() |
244 { |
226 { |
245 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::DoCancel()", this ); |
227 TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::DoCancel()", this ); |
246 OstTrace1( TRACE_NORMAL, CTHUMBNAILSCALETASK_DOCANCEL, "CThumbnailScaleTask::DoCancel;this=%o", this ); |
|
247 iServer.CancelScale(); |
228 iServer.CancelScale(); |
248 } |
229 } |
249 |
230 |
250 |
231 |
251 // --------------------------------------------------------------------------- |
232 // --------------------------------------------------------------------------- |
350 // |
331 // |
351 void CThumbnailScaleTask::StoreAndCompleteL() |
332 void CThumbnailScaleTask::StoreAndCompleteL() |
352 { |
333 { |
353 TN_DEBUG6( "CThumbnailScaleTask(0x%08x)::StoreAndCompleteL() iFilename=%S, iThumbnailSize=%d, iBitmap=0x%08x, iScaledBitmap=0x%08x)", |
334 TN_DEBUG6( "CThumbnailScaleTask(0x%08x)::StoreAndCompleteL() iFilename=%S, iThumbnailSize=%d, iBitmap=0x%08x, iScaledBitmap=0x%08x)", |
354 this, &iFilename, iThumbnailSize, iBitmap, iScaledBitmap ); |
335 this, &iFilename, iThumbnailSize, iBitmap, iScaledBitmap ); |
355 OstTrace1( TRACE_NORMAL, CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL;this=%o", this ); |
|
356 OstTraceExt1( TRACE_NORMAL, DUP1_CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL;iFilename=%S", iFilename ); |
|
357 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL;iBitmap=%o", iBitmap ); |
|
358 |
|
359 |
336 |
360 // do not store TN if quality is too low eg. orignal size of image is smaller than requested size |
337 // do not store TN if quality is too low eg. orignal size of image is smaller than requested size |
361 // (do not store upscaled images) |
338 // (do not store upscaled images) |
362 if ( (iTargetSizeTN.iWidth > iOriginalSize.iWidth || iTargetSizeTN.iHeight > iOriginalSize.iHeight) && iEXIF) |
339 if ( (iTargetSizeTN.iWidth > iOriginalSize.iWidth || iTargetSizeTN.iHeight > iOriginalSize.iHeight) && iEXIF) |
363 { |
340 { |
364 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() too low quality"); |
341 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() too low quality"); |
365 OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL - too low quality" ); |
|
366 iDoStore = EFalse; |
342 iDoStore = EFalse; |
367 } |
343 } |
368 |
344 |
369 TN_DEBUG3("CThumbnailScaleTask(0x%08x)::StoreAndCompleteL() iDoStore = %d", this, iDoStore); |
345 TN_DEBUG3("CThumbnailScaleTask(0x%08x)::StoreAndCompleteL() iDoStore = %d", this, iDoStore); |
370 OstTrace1( TRACE_NORMAL, DUP4_CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL;this=%o", this ); |
|
371 |
346 |
372 if ( iDoStore ) |
347 if ( iDoStore ) |
373 { |
348 { |
374 if (iTargetUri != KNullDesC) |
349 if (iTargetUri != KNullDesC) |
375 { |
350 { |
400 |
375 |
401 // if need to add scaled bitmap to pool |
376 // if need to add scaled bitmap to pool |
402 if (iBitmapToPool) |
377 if (iBitmapToPool) |
403 { |
378 { |
404 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap handle to params"); |
379 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap handle to params"); |
405 OstTrace0( TRACE_NORMAL, DUP5_CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL" ); |
|
406 |
380 |
407 params.iBitmapHandle = iScaledBitmap->Handle(); |
381 params.iBitmapHandle = iScaledBitmap->Handle(); |
408 } |
382 } |
409 |
383 |
410 if( params.iQualityPreference == CThumbnailManager::EOptimizeForQualityWithPreview |
384 if( params.iQualityPreference == CThumbnailManager::EOptimizeForQualityWithPreview |
411 && iEXIF && !iDoStore) |
385 && iEXIF && !iDoStore) |
412 { |
386 { |
413 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() EThumbnailPreviewThumbnail"); |
387 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() EThumbnailPreviewThumbnail"); |
414 OstTrace0( TRACE_NORMAL, DUP6_CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL - EThumbnailPreviewThumbnail" ); |
388 |
415 |
|
416 // this is upscaled preview image |
389 // this is upscaled preview image |
417 params.iControlFlags = EThumbnailPreviewThumbnail; |
390 params.iControlFlags = EThumbnailPreviewThumbnail; |
418 } |
391 } |
419 |
392 |
420 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() write params to message"); |
393 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() write params to message"); |
421 OstTrace0( TRACE_NORMAL, DUP7_CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL - write params to message" ); |
|
422 |
394 |
423 // pass bitmap handle to client |
395 // pass bitmap handle to client |
424 iMessage.WriteL( 0, iParamsBuf ); |
396 iMessage.WriteL( 0, iParamsBuf ); |
425 |
397 |
426 if (iBitmapToPool) |
398 if (iBitmapToPool) |
427 { |
399 { |
428 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap to pool"); |
400 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap to pool"); |
429 OstTrace0( TRACE_NORMAL, DUP8_CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL - scaled bitmap to pool" ); |
401 |
430 |
|
431 iServer.AddBitmapToPoolL( iRequestId.iSession, iScaledBitmap, iRequestId ); |
402 iServer.AddBitmapToPoolL( iRequestId.iSession, iScaledBitmap, iRequestId ); |
432 iScaledBitmap = NULL; // Server owns the bitmap now |
403 iScaledBitmap = NULL; // Server owns the bitmap now |
433 } |
404 } |
434 } |
405 } |
435 |
406 |
436 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() - end"); |
407 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() - end"); |
437 OstTrace0( TRACE_NORMAL, DUP9_CTHUMBNAILSCALETASK_STOREANDCOMPLETEL, "CThumbnailScaleTask::StoreAndCompleteL - end" ); |
|
438 } |
408 } |
439 |
409 |
440 |
410 |
441 // --------------------------------------------------------------------------- |
411 // --------------------------------------------------------------------------- |
442 // CThumbnailScaleTask::StoreAndCompleteL() |
412 // CThumbnailScaleTask::StoreAndCompleteL() |