114 { |
113 { |
115 TN_DEBUG1("CThumbnailScaleTask()::~CThumbnailScaleTask() delete original bitmap from pool"); |
114 TN_DEBUG1("CThumbnailScaleTask()::~CThumbnailScaleTask() delete original bitmap from pool"); |
116 |
115 |
117 // Original bitmap is owned by server, decrease reference count |
116 // Original bitmap is owned by server, decrease reference count |
118 iServer.DeleteBitmapFromPool( iBitmap->Handle()); |
117 iServer.DeleteBitmapFromPool( iBitmap->Handle()); |
119 } |
|
120 |
|
121 if ( iScaledBitmapHandle ) |
|
122 { |
|
123 TN_DEBUG1("CThumbnailScaleTask()::~CThumbnailScaleTask() delete scaled bitmap from pool"); |
|
124 |
|
125 // Scaled bitmap is owned by server, decrease reference count |
|
126 iServer.DeleteBitmapFromPool( iScaledBitmapHandle ); |
|
127 } |
118 } |
128 |
119 |
129 // Scaled bitmap is owned by us, delete now |
120 // Scaled bitmap is owned by us, delete now |
130 delete iScaledBitmap; |
121 delete iScaledBitmap; |
131 } |
122 } |
367 } |
358 } |
368 } |
359 } |
369 |
360 |
370 if ( ClientThreadAlive() ) |
361 if ( ClientThreadAlive() ) |
371 { |
362 { |
372 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap handle to params"); |
|
373 |
|
374 TThumbnailRequestParams& params = iParamsBuf(); |
363 TThumbnailRequestParams& params = iParamsBuf(); |
375 iMessage.ReadL( 0, iParamsBuf ); |
364 iMessage.ReadL( 0, iParamsBuf ); |
376 |
365 |
377 // if need to add scaled bitmap to pool |
366 // if need to add scaled bitmap to pool |
378 if (iBitmapToPool) |
367 if (iBitmapToPool) |
379 { |
368 { |
380 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap to pool"); |
369 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap handle to params"); |
381 |
370 |
382 params.iBitmapHandle = iScaledBitmap->Handle(); |
371 params.iBitmapHandle = iScaledBitmap->Handle(); |
383 |
|
384 iServer.AddBitmapToPoolL( iRequestId.iSession, iScaledBitmap, iRequestId ); |
|
385 iScaledBitmapHandle = params.iBitmapHandle; |
|
386 } |
372 } |
387 |
373 |
388 if( params.iQualityPreference == CThumbnailManager::EOptimizeForQualityWithPreview |
374 if( params.iQualityPreference == CThumbnailManager::EOptimizeForQualityWithPreview |
389 && iEXIF && !iDoStore) |
375 && iEXIF && !iDoStore) |
390 { |
376 { |
|
377 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() EThumbnailPreviewThumbnail"); |
|
378 |
391 // this is upscaled preview image |
379 // this is upscaled preview image |
392 params.iControlFlags = EThumbnailPreviewThumbnail; |
380 params.iControlFlags = EThumbnailPreviewThumbnail; |
393 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() EThumbnailPreviewThumbnail"); |
|
394 } |
381 } |
395 |
|
396 // Server owns the bitmap now. If the code below leaves, we will |
|
397 // release the bitmap reference in destructor using iScaledBitmapHandle. |
|
398 if (iBitmapToPool) |
|
399 { |
|
400 iScaledBitmap = NULL; |
|
401 } |
|
402 |
382 |
403 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() write params to message"); |
383 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() write params to message"); |
404 |
384 |
405 // pass bitmap handle to client |
385 // pass bitmap handle to client |
406 iMessage.WriteL( 0, iParamsBuf ); |
386 iMessage.WriteL( 0, iParamsBuf ); |
407 |
387 |
408 // Successfully completed the message. The client will send |
388 if (iBitmapToPool) |
409 // EReleaseBitmap message later to delete the bitmap from pool. |
389 { |
410 // CThumbnailScaleTask is no longer responsible for that. |
390 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap to pool"); |
411 iScaledBitmapHandle = 0; |
391 |
|
392 iServer.AddBitmapToPoolL( iRequestId.iSession, iScaledBitmap, iRequestId ); |
|
393 iScaledBitmap = NULL; // Server owns the bitmap now |
|
394 } |
412 } |
395 } |
413 |
396 |
414 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() - end"); |
397 TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() - end"); |
415 } |
398 } |
416 |
399 |