imagingandcamerafws/imagingfws/src/pluginextensionmanager.cpp
branchRCL_3
changeset 50 948c7f65f6d4
parent 0 40261b775718
equal deleted inserted replaced
49:735348f59235 50:948c7f65f6d4
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <icl/imageconversionextension.h>
       
    17 #include <icl/imagecodec.h>
       
    18 #include <icl/imagedata.h>
       
    19 #include "ImageClientMain.h"
       
    20 #include "fwextconstants.h"
       
    21 #include "pluginextensionmanager.h"
       
    22 #include "ImageProcessorPriv.h"
       
    23 
       
    24 const TUint KAllOperationCapabilities = TImageConvOperation::ERotation90DegreesClockwise |
       
    25 										TImageConvOperation::ERotation180DegreesClockwise |
       
    26 										TImageConvOperation::ERotation270DegreesClockwise |
       
    27 										TImageConvOperation::EMirrorHorizontalAxis |
       
    28 										TImageConvOperation::EMirrorVerticalAxis;
       
    29 
       
    30 const TUint KImageCornerCount = 4;
       
    31 const TUint8 KImageTLCoord = 0x00;
       
    32 const TUint8 KImageTRCoord = 0x10;
       
    33 const TUint8 KImageBLCoord = 0x01;
       
    34 const TUint8 KImageBRCoord = 0x11;
       
    35 
       
    36 /**
       
    37 Generic extension container for codec plugin use.
       
    38 */
       
    39 EXPORT_C CPluginExtensionManager* CPluginExtensionManager::NewL(MReadCodecExtension* aReadCodec)
       
    40 	{
       
    41 	return new (ELeave) CPluginExtensionManager(aReadCodec);
       
    42 	}
       
    43 
       
    44 CPluginExtensionManager::CPluginExtensionManager(MReadCodecExtension* aReadCodec)
       
    45 :iReadCodec(aReadCodec)
       
    46 	{
       
    47 	}
       
    48 
       
    49 EXPORT_C CPluginExtensionManager::~CPluginExtensionManager()
       
    50 	{
       
    51 	delete iOperationExtension;
       
    52 	delete iScalerExtension;
       
    53 	}
       
    54 
       
    55 EXPORT_C void CPluginExtensionManager::ResetCodecExtension(MReadCodecExtension* aReadCodec)
       
    56 	{
       
    57 	iReadCodec = aReadCodec;
       
    58 	}
       
    59 
       
    60 EXPORT_C TInt CPluginExtensionManager::ConvertScalingCoeffToReductionFactor(TInt aScalingCoeff)
       
    61 	{
       
    62 	return aScalingCoeff == 1 ? 0 : -(aScalingCoeff+1);
       
    63 	}
       
    64 
       
    65 EXPORT_C void CPluginExtensionManager::GetExtensionL(TUid aExtUid, MImageConvExtension*& aExtPtr)
       
    66 	{
       
    67 	switch(aExtUid.iUid)
       
    68 		{
       
    69 		case KUidImageConvExtOperationValue:
       
    70 			{
       
    71 			if(!iOperationExtension)
       
    72 				{
       
    73 				iOperationExtension = COperationExtension::NewL();
       
    74 				aExtPtr = iOperationExtension;
       
    75 				}
       
    76 			else 
       
    77 				{
       
    78 				aExtPtr = iOperationExtension;
       
    79 				//this extension might have been created for auto rotation before so reset the reference count
       
    80 				if (!iOperationExtension->iRefCount) 
       
    81 					{
       
    82 					iOperationExtension->iRefCount = 1;
       
    83 					}
       
    84 				}
       
    85 			break;
       
    86 			}
       
    87 		case KUidImageConvExtScalerValue:
       
    88 			{
       
    89 			if(!iScalerExtension)
       
    90 				{
       
    91 				iScalerExtension = CScalerExtension::NewL();
       
    92 				aExtPtr = iScalerExtension;
       
    93 				}
       
    94 			else 
       
    95 				{
       
    96 				aExtPtr = iScalerExtension;
       
    97 				}
       
    98 			break;
       
    99 			}
       
   100 		default:
       
   101 			{
       
   102 			User::Leave(KErrNotSupported);
       
   103 			}
       
   104 		}
       
   105 	}
       
   106 
       
   107 EXPORT_C void CPluginExtensionManager::CreateExtensionForAutoRotateL() 
       
   108 	{
       
   109 	if(!iOperationExtension)
       
   110 		{
       
   111 		iOperationExtension = COperationExtension::NewL();
       
   112 		iOperationExtension->iRefCount = 0;// this extension is not referenced as no high level API icl extension is created
       
   113 		}
       
   114 	}
       
   115 
       
   116 /*
       
   117 Called by the plugin with the size of the original image
       
   118 */
       
   119 EXPORT_C TInt CPluginExtensionManager::GetDestinationSize(TSize& aOriginalSize)
       
   120 	{
       
   121 	TSize destinationSize = aOriginalSize;
       
   122 	TInt err = KErrNone;
       
   123 	
       
   124 	if(!iClippingRect.IsEmpty())
       
   125 		{
       
   126 		// Check for validity, as client may have switched main<->thumb
       
   127 		TRect clipRect(iClippingRect);
       
   128 		clipRect.Intersection(aOriginalSize);
       
   129 		if(clipRect == iClippingRect)
       
   130 			{
       
   131 			// Clipping rect set and valid
       
   132 			destinationSize = iClippingRect.Size();
       
   133 			}
       
   134 		else
       
   135 			{
       
   136 			err = KErrArgument;
       
   137 			return err;
       
   138 			}
       
   139 		}
       
   140 	
       
   141 	if(iOperationExtension && iOperationExtension->DimensionsSwapped())
       
   142 		{
       
   143 		// switch orientation
       
   144 		destinationSize.SetSize(destinationSize.iHeight, destinationSize.iWidth);
       
   145 		}
       
   146 
       
   147 	if(iScalerExtension)
       
   148 		{
       
   149 		if(iScalerExtension->ScaleCmd() != CScalerExtension::EScalerExtFullSize)
       
   150 			{
       
   151 			TInt scalingCoeff = 1; // full size
       
   152 			err = GetScalingCoefficient(scalingCoeff, &destinationSize);
       
   153 			if(err != KErrNone)
       
   154 				{
       
   155 				return err;
       
   156 				}
       
   157 
       
   158 			ASSERT(iReadCodec);
       
   159 			err = iReadCodec->GetReducedSize(destinationSize, scalingCoeff, destinationSize);
       
   160 			if(err != KErrNone)
       
   161 				{
       
   162 				return err;
       
   163 				}
       
   164 			}
       
   165 		}
       
   166 
       
   167 	aOriginalSize = destinationSize;
       
   168 	return err;
       
   169 	}
       
   170 
       
   171 /*
       
   172 Validate the clipping rectangle.
       
   173 */
       
   174 EXPORT_C void CPluginExtensionManager::SetClippingRectL(const TRect* aClipRect, const RPointerArray<TFrameInfo>& aFrameInfo)
       
   175 	{
       
   176 	if(!aClipRect)
       
   177 		{
       
   178 		//reset and return
       
   179 		iClippingRect.SetRect(0,0,0,0);
       
   180 		return;
       
   181 		}
       
   182 
       
   183 	if(aClipRect->IsEmpty() || !aClipRect->IsNormalized())
       
   184 		{
       
   185 		User::Leave(KErrArgument);
       
   186 		}
       
   187 
       
   188 	// Check if this crop rect falls within at least one frame.
       
   189 	for(TInt i = 0; i < aFrameInfo.Count(); i++)
       
   190 		{
       
   191 		const TFrameInfo& frame = *aFrameInfo[i];
       
   192 
       
   193 		TRect clipTest(*aClipRect);
       
   194 		clipTest.Intersection(frame.iFrameCoordsInPixels);
       
   195 		if(clipTest == *aClipRect) // clipping rect within/same as the image rect
       
   196 			{
       
   197 			iClippingRect = *aClipRect;
       
   198 			return;
       
   199 			}
       
   200 		}
       
   201 	User::Leave(KErrArgument);
       
   202 	}
       
   203 
       
   204 /*
       
   205 Has the clipping rectangle extension been set?
       
   206 */
       
   207 EXPORT_C TBool CPluginExtensionManager::ClippingRectExtensionRequested() const
       
   208 	{
       
   209 	if(!iClippingRect.IsEmpty())
       
   210 		{
       
   211 		return ETrue;
       
   212 		}
       
   213 	return EFalse;
       
   214 	}
       
   215 
       
   216 
       
   217 /*
       
   218 Has the scaler extension been set?
       
   219 */
       
   220 EXPORT_C TBool CPluginExtensionManager::ScalerExtensionRequested() const
       
   221 	{
       
   222 	if (iScalerExtension)
       
   223 		{
       
   224 		return (iScalerExtension->ScaleCmd() != CScalerExtension::EScalerExtFullSize);
       
   225 		}
       
   226 
       
   227  	return EFalse;
       
   228 	}
       
   229 
       
   230 /*
       
   231 Has the operation extension been set?
       
   232 */
       
   233 EXPORT_C TBool CPluginExtensionManager::OperationExtensionRequested() const
       
   234 	{
       
   235 	if(iOperationExtension && iOperationExtension->HasBeenSet())
       
   236 		{
       
   237 		return ETrue;
       
   238 		}
       
   239 	return EFalse;
       
   240 	}
       
   241 
       
   242 /*
       
   243 Return the clipping rectangle (may or may not have been set by client).
       
   244 */
       
   245 EXPORT_C TRect CPluginExtensionManager::ClippingRect()
       
   246 	{
       
   247 	return iClippingRect;
       
   248 	}
       
   249 
       
   250 /*
       
   251 Returns the scaling coefficient set by the client.  If the scaling coefficient
       
   252 has been set directly by the client (i.e. calling
       
   253 TImageConvScaler::SetScalingL(TInt aScalingCoeff, ...) then this function will
       
   254 return that.  If the client has set scaling using the desired size (i.e.
       
   255 calling TImageConvScaler::SetScalingL(TSize& aDesiredSize, ...) then this function
       
   256 will calculate the appropriate scaling coefficient.
       
   257 
       
   258 @param	aScalingCoeff 		The scaling coefficient to be returned.
       
   259 @param	aOriginalSize		A pointer to the original size of the image.  Default is NULL.
       
   260 @return KErrNone 			If the call was successful.
       
   261 @return KErrArgument		If the aOriginalSize argument is NULL when
       
   262 							SetScaling() has been set with a desired size.
       
   263 @return KErrNotSupported	If client has not requested a scaling operation or the plugin
       
   264 							is not capable of scaling to the set size.
       
   265 @return						One of the system wide error codes.
       
   266 
       
   267 @see TImageConvScaler::SetScalingL(TInt aScalingCoeff, TImageConvScaler::TScalerQuality aScalingQuality)
       
   268 @see TImageConvScaler::SetScalingL(const TSize& aDesiredSize, TImageConvScaler::TScalerQuality aQuality, TBool aLockAspectRatio)
       
   269 @see TScalerCaps
       
   270 */
       
   271 EXPORT_C TInt CPluginExtensionManager::GetScalingCoefficient(TInt& aScalingCoeff, const TSize* aOriginalSize) const
       
   272 	{
       
   273 	if(iScalerExtension)
       
   274 		{
       
   275 		switch(iScalerExtension->ScaleCmd())
       
   276 			{
       
   277 			case CScalerExtension::EScalerExtFullSize:
       
   278 				{
       
   279 				aScalingCoeff = 1; // Full size
       
   280 				return KErrNone;
       
   281 				}
       
   282 			case CScalerExtension::EScalerExtUseScalingCoeff:
       
   283 				{
       
   284 				return iScalerExtension->GetScalingCoefficient(aScalingCoeff);
       
   285 				}
       
   286 			case CScalerExtension::EScalerExtUseDesiredSize:
       
   287 				{
       
   288 				// desired size has been set so we need to validate the
       
   289 				// aOriginalSize arg, which can be NULL
       
   290 				if(aOriginalSize == NULL)
       
   291 					{
       
   292 					return KErrArgument;
       
   293 					}
       
   294 
       
   295 				TSize reducedSize;
       
   296 				TInt err = iScalerExtension->GetDesiredSize(reducedSize);
       
   297 				if(err != KErrNone)
       
   298 					{
       
   299 					return err;
       
   300 					}
       
   301 
       
   302 				ASSERT(iReadCodec);
       
   303 				aScalingCoeff = iReadCodec->ScalingCoefficient(*aOriginalSize, reducedSize);
       
   304 				if(!iScalerExtension->ScalingCoefficientSupported(aScalingCoeff))
       
   305 					{
       
   306 					return KErrNotSupported;
       
   307 					}
       
   308 				return KErrNone;
       
   309 				}
       
   310 			default:
       
   311 				{
       
   312 				Panic(EInvalidFwExtensionCall);
       
   313 				}
       
   314 			}
       
   315 		}
       
   316 	return KErrNotSupported;
       
   317 	}
       
   318 
       
   319 /*
       
   320 Get the desired scaler size set by client.
       
   321 */
       
   322 EXPORT_C TInt CPluginExtensionManager::GetScalerDesiredSize(TSize& aDesiredSize) const
       
   323 	{
       
   324 	if(iScalerExtension)
       
   325 		{
       
   326 		return iScalerExtension->GetDesiredSize(aDesiredSize);
       
   327 		}
       
   328 	return KErrNotSupported;
       
   329 	}
       
   330 
       
   331 /*
       
   332 Get the scaler quality setting set by client.
       
   333 */
       
   334 EXPORT_C TInt CPluginExtensionManager::GetScalerQuality(TImageConvScaler::TScalerQuality& aQuality) const
       
   335 	{
       
   336 	if(iScalerExtension)
       
   337 		{
       
   338 		return iScalerExtension->GetScalerQuality(aQuality);
       
   339 		}
       
   340 	return KErrNotSupported;
       
   341 	}
       
   342 
       
   343 /*
       
   344 Has the client requested that scaling, when using the desired size, is to
       
   345 maintain the aspect ratio.
       
   346 */
       
   347 EXPORT_C TBool CPluginExtensionManager::ScalerMaintainAspectRatio() const
       
   348 	{
       
   349 	if(iScalerExtension)
       
   350 		{
       
   351 		return iScalerExtension->LockAspectRatioSet();
       
   352 		}
       
   353 	return EFalse;
       
   354 	}
       
   355 
       
   356 /*
       
   357 Passes the data that has been set in the extensions by the client, to the image processor.
       
   358 
       
   359 @param aImageProcessor	A pointer to the CImageProcessorExtension that is to have the extension data
       
   360 						passed to it.
       
   361 @leave					A range of system wide error codes.
       
   362 */
       
   363 EXPORT_C void CPluginExtensionManager::TransferExtensionDataL(CImageProcessorExtension* aImageProcessor)
       
   364 	{
       
   365 	ASSERT(aImageProcessor);
       
   366 
       
   367 	if(!iClippingRect.IsEmpty())
       
   368 		{
       
   369 		aImageProcessor->SetClippingRect(iClippingRect);
       
   370 		}
       
   371 
       
   372 	if(iScalerExtension)
       
   373 		{
       
   374 		switch(iScalerExtension->ScaleCmd())
       
   375 			{
       
   376 			case CScalerExtension::EScalerExtFullSize:
       
   377 				{
       
   378 				TInt scalingCoeff = 1; // assume full size
       
   379 				aImageProcessor->SetScaling(scalingCoeff);
       
   380 				break;
       
   381 				}
       
   382 			case CScalerExtension::EScalerExtUseScalingCoeff:
       
   383 				{
       
   384 				TInt scalingCoeff = 1; // assume full size
       
   385 				User::LeaveIfError(iScalerExtension->GetScalingCoefficient(scalingCoeff));
       
   386 				aImageProcessor->SetScaling(scalingCoeff);
       
   387 				break;
       
   388 				}
       
   389 			case CScalerExtension::EScalerExtUseDesiredSize:
       
   390 				{
       
   391 				TSize desiredSize;
       
   392 				User::LeaveIfError(iScalerExtension->GetDesiredSize(desiredSize));
       
   393 				aImageProcessor->SetScaling(desiredSize);
       
   394 				break;
       
   395 				}
       
   396 			default:
       
   397 				{
       
   398 				Panic(EInvalidFwExtensionCall);
       
   399 				}
       
   400 			}
       
   401 		}
       
   402 
       
   403 	aImageProcessor->SetOperation(Operation());
       
   404 	}
       
   405 
       
   406 /**
       
   407 Gets the operations that have been set in the operation extension.  This is in the
       
   408 form of TTransformOptions and so the caller can determine the overall orientation.
       
   409 
       
   410 @return TTransformOptions	The orientation of the image.
       
   411 
       
   412 @see TTransformOptions
       
   413 @see MImageConvOperation::AddOperationL
       
   414 */
       
   415 EXPORT_C TTransformOptions CPluginExtensionManager::Operation() const
       
   416 	{
       
   417 	if(iOperationExtension)
       
   418 		{
       
   419 		return iOperationExtension->Operation();
       
   420 		}
       
   421 	return EDecodeNormal;
       
   422 	}
       
   423 
       
   424 /**
       
   425 Gets the operations that have been set in the operation extension. If the auto rotation flag 
       
   426 is set the auto rotation operations are inserted before other operations. 
       
   427 This is in the form of TTransformOptions and so the caller can determine the overall orientation.
       
   428 
       
   429 @param aAutoRotationFlag	An auto rotation flag to define auto rotation operations required.
       
   430 
       
   431 @return TTransformOptions	The orientation of the image.
       
   432 
       
   433 @see TTransformOptions
       
   434 @see MImageConvOperation::AddOperationL
       
   435 */
       
   436 EXPORT_C TTransformOptions CPluginExtensionManager::OperationL(TUint16 aAutoRotationFlag) const
       
   437 	{
       
   438 	if(iOperationExtension)
       
   439 		{
       
   440 		switch (aAutoRotationFlag)
       
   441 			{
       
   442 			case 1:
       
   443 				break;
       
   444 		
       
   445 			case 2:
       
   446 				iOperationExtension->InsertOperationL(TImageConvOperation::EMirrorHorizontalAxis, 0);
       
   447 				break;
       
   448 
       
   449 			case 3:
       
   450 				iOperationExtension->InsertOperationL(TImageConvOperation::ERotation180DegreesClockwise, 0);
       
   451 				break;
       
   452 			
       
   453 			case 4:
       
   454 				iOperationExtension->InsertOperationL(TImageConvOperation::EMirrorVerticalAxis, 0);
       
   455 				break;
       
   456 			
       
   457 			case 5:
       
   458 				iOperationExtension->InsertOperationL(TImageConvOperation::EMirrorVerticalAxis, 0);
       
   459 				iOperationExtension->InsertOperationL(TImageConvOperation::ERotation90DegreesClockwise, 0);
       
   460 				break;
       
   461 			
       
   462 			case 6:
       
   463 				iOperationExtension->InsertOperationL(TImageConvOperation::ERotation90DegreesClockwise, 0);
       
   464 				break;
       
   465 			
       
   466 			case 7:
       
   467 				iOperationExtension->InsertOperationL(TImageConvOperation::EMirrorHorizontalAxis , 0);
       
   468 				iOperationExtension->InsertOperationL(TImageConvOperation::ERotation90DegreesClockwise, 0);
       
   469 				break;
       
   470 			
       
   471 			case 8:
       
   472 				iOperationExtension->InsertOperationL(TImageConvOperation::ERotation270DegreesClockwise, 0);
       
   473 				break;
       
   474 			}
       
   475 		}
       
   476 		
       
   477 	return iOperationExtension->Operation();
       
   478 	}
       
   479 
       
   480 /**
       
   481 Based on the client-provided operations, have the dimensions of the image been
       
   482 swapped?
       
   483 */
       
   484 EXPORT_C TBool CPluginExtensionManager::DimensionsSwapped() const
       
   485 	{
       
   486 	return (iOperationExtension && iOperationExtension->DimensionsSwapped());
       
   487 	}
       
   488 
       
   489 /**
       
   490 Generic plugin codec operation extension
       
   491 */
       
   492 COperationExtension* COperationExtension::NewL()
       
   493 	{
       
   494 	return new (ELeave) COperationExtension();
       
   495 	}
       
   496 
       
   497 COperationExtension::COperationExtension()
       
   498 :iRefCount(1), iCapabilities(KAllOperationCapabilities)
       
   499 	{
       
   500 	}
       
   501 
       
   502 COperationExtension::~COperationExtension()
       
   503 	{
       
   504 	ASSERT(iRefCount == 0);
       
   505 	iOperationStack.Close();
       
   506 	}
       
   507 
       
   508 TUid COperationExtension::Uid() const
       
   509 	{
       
   510 	return KICLOperationUid;
       
   511 	}
       
   512 
       
   513 void COperationExtension::IncrementRef()
       
   514 	{
       
   515 	iRefCount++;
       
   516 	}
       
   517 
       
   518 void COperationExtension::Release()
       
   519 	{
       
   520 	iRefCount--;
       
   521 	}
       
   522 
       
   523 TUint COperationExtension::Capabilities() const
       
   524 	{
       
   525 	return iCapabilities;
       
   526 	}
       
   527 
       
   528 void COperationExtension::AddOperationL(TImageConvOperation::TOperation aOperation)
       
   529 	{
       
   530 	iOperationStack.AppendL(aOperation);
       
   531 	}
       
   532 
       
   533 void COperationExtension::InsertOperationL(TImageConvOperation::TOperation aOperation, TInt aPos)
       
   534 	{
       
   535 	iOperationStack.InsertL(aOperation, aPos);
       
   536 	}
       
   537 
       
   538 void COperationExtension::ClearOperationStack()
       
   539 	{
       
   540 	iOperationStack.Reset();
       
   541 	}
       
   542 
       
   543 TBool COperationExtension::HasBeenSet()
       
   544 	{
       
   545 	return iOperationStack.Count() > 0;
       
   546 	}
       
   547 
       
   548 /**
       
   549 Based on the client-provided operations, have the dimensions of the image been
       
   550 swapped?
       
   551 */
       
   552 TBool COperationExtension::DimensionsSwapped() const
       
   553 	{
       
   554 	TBool rotate = EFalse;
       
   555 	for(TInt i = 0; i < iOperationStack.Count(); i++)
       
   556 		{
       
   557 		if(iOperationStack[i] == TImageConvOperation::ERotation90DegreesClockwise ||
       
   558 			iOperationStack[i] == TImageConvOperation::ERotation270DegreesClockwise)
       
   559 			{
       
   560 			rotate = !rotate;
       
   561 			}
       
   562 		}
       
   563 	return rotate;
       
   564 	}
       
   565 
       
   566 TTransformOptions COperationExtension::Operation() const
       
   567 	{
       
   568 	TUint8 imageCornerCoord[KImageCornerCount];
       
   569 	imageCornerCoord[0] = KImageTLCoord;
       
   570 	imageCornerCoord[1] = KImageTRCoord;
       
   571 	imageCornerCoord[2] = KImageBLCoord;
       
   572 	imageCornerCoord[3] = KImageBRCoord;
       
   573 
       
   574 	for(TInt i = 0; i < iOperationStack.Count(); i++)
       
   575 		{
       
   576 		switch(iOperationStack[i])
       
   577 			{
       
   578 			case TImageConvOperation::ERotation90DegreesClockwise:
       
   579 				{
       
   580 				TUint8 tempVal = imageCornerCoord[0];
       
   581 				imageCornerCoord[0] = imageCornerCoord[2];
       
   582 				imageCornerCoord[2] = imageCornerCoord[3];
       
   583 				imageCornerCoord[3] = imageCornerCoord[1];
       
   584 				imageCornerCoord[1] = tempVal;
       
   585 
       
   586 				break;
       
   587 				}
       
   588 			case TImageConvOperation::ERotation180DegreesClockwise:
       
   589 				{
       
   590 				TUint8 tempVal = imageCornerCoord[0];
       
   591 				imageCornerCoord[0] = imageCornerCoord[3];
       
   592 				imageCornerCoord[3] = tempVal;
       
   593 				tempVal = imageCornerCoord[1];
       
   594 				imageCornerCoord[1] = imageCornerCoord[2];
       
   595 				imageCornerCoord[2] = tempVal;
       
   596 
       
   597 				break;
       
   598 				}
       
   599 			case TImageConvOperation::ERotation270DegreesClockwise:
       
   600 				{
       
   601 				TUint8 tempVal = imageCornerCoord[0];
       
   602 				imageCornerCoord[0] = imageCornerCoord[1];
       
   603 				imageCornerCoord[1] = imageCornerCoord[3];
       
   604 				imageCornerCoord[3] = imageCornerCoord[2];
       
   605 				imageCornerCoord[2] = tempVal;
       
   606 
       
   607 				break;
       
   608 				}
       
   609 			case TImageConvOperation::EMirrorHorizontalAxis:
       
   610 				{
       
   611 				TUint8 tempVal = imageCornerCoord[0];
       
   612 				imageCornerCoord[0] = imageCornerCoord[2];
       
   613 				imageCornerCoord[2] = tempVal;
       
   614 				tempVal = imageCornerCoord[1];
       
   615 				imageCornerCoord[1] = imageCornerCoord[3];
       
   616 				imageCornerCoord[3] = tempVal;
       
   617 
       
   618 				break;
       
   619 				}
       
   620 			case TImageConvOperation::EMirrorVerticalAxis:
       
   621 				{
       
   622 				TUint8 tempVal = imageCornerCoord[0];
       
   623 				imageCornerCoord[0] = imageCornerCoord[1];
       
   624 				imageCornerCoord[1] = tempVal;
       
   625 				tempVal = imageCornerCoord[2];
       
   626 				imageCornerCoord[2] = imageCornerCoord[3];
       
   627 				imageCornerCoord[3] = tempVal;
       
   628 
       
   629 				break;
       
   630 				}
       
   631 			default:
       
   632 				{
       
   633 				Panic(EInvalidFwExtensionCall);
       
   634 				}
       
   635 			}
       
   636 		}
       
   637 	return *(reinterpret_cast<TTransformOptions*>(&imageCornerCoord));
       
   638 	}
       
   639 
       
   640 /**
       
   641 Generic plugin codec scaler extension
       
   642 */
       
   643 CScalerExtension* CScalerExtension::NewL()
       
   644 	{
       
   645 	return new (ELeave) CScalerExtension();
       
   646 	}
       
   647 
       
   648 CScalerExtension::CScalerExtension()
       
   649 :iRefCount(1), iCommand(CScalerExtension::EScalerExtFullSize),
       
   650 iScalingCoefficient(1), iQuality(TImageConvScaler::EMediumQuality),
       
   651 iLockAspectRatio(ETrue)
       
   652 	{
       
   653 	}
       
   654 
       
   655 CScalerExtension::~CScalerExtension()
       
   656 	{
       
   657 	ASSERT(iRefCount == 0);
       
   658 	}
       
   659 
       
   660 TUid CScalerExtension::Uid() const
       
   661 	{
       
   662 	return KICLScalerUid;
       
   663 	}
       
   664 
       
   665 void CScalerExtension::IncrementRef()
       
   666 	{
       
   667 	iRefCount++;
       
   668 	}
       
   669 
       
   670 void CScalerExtension::Release()
       
   671 	{
       
   672 	iRefCount--;
       
   673 	}
       
   674 
       
   675 void CScalerExtension::GetCapabilities(TScalerCaps& aCaps) const
       
   676 	{
       
   677 	aCaps = TScalerCaps();
       
   678 	}
       
   679 
       
   680 void CScalerExtension::SetScalingL(const TSize& aDesiredSize, TImageConvScaler::TScalerQuality aQuality, TBool aLockAspectRatio)
       
   681 	{
       
   682 	if(aDesiredSize.iWidth <= 0 || aDesiredSize.iHeight <= 0)
       
   683 		{
       
   684 		User::Leave(KErrArgument);
       
   685 		}
       
   686 
       
   687 	if(!aLockAspectRatio && iCapabilities.MustPreserveAspectRatio())
       
   688 		{
       
   689 		User::Leave(KErrNotSupported);
       
   690 		}
       
   691 
       
   692 	// reset scaling coeff to full size
       
   693 	iScalingCoefficient = 1;
       
   694 
       
   695 	iCommand = CScalerExtension::EScalerExtUseDesiredSize;
       
   696 	iDesiredSize = aDesiredSize;
       
   697 	iQuality = aQuality;
       
   698 	}
       
   699 
       
   700 void CScalerExtension::SetScalingL(TInt aScalingCoeff, TImageConvScaler::TScalerQuality aScalingQuality)
       
   701 	{
       
   702 	if(!ScalingCoefficientSupported(aScalingCoeff))
       
   703 		{
       
   704 		User::Leave(KErrNotSupported);
       
   705 		}
       
   706 
       
   707 	// reset desired size
       
   708 	iDesiredSize.SetSize(0,0);
       
   709 
       
   710 	// check if reset to full size
       
   711 	if(aScalingCoeff == -1 || aScalingCoeff == 1)
       
   712 		{
       
   713 		iCommand = CScalerExtension::EScalerExtFullSize;
       
   714 		}
       
   715 	else
       
   716 		{
       
   717 		iCommand = CScalerExtension::EScalerExtUseScalingCoeff;
       
   718 		}
       
   719 	iScalingCoefficient = aScalingCoeff;
       
   720 	iQuality = aScalingQuality;
       
   721 	}
       
   722 
       
   723 CScalerExtension::TScalerCmd CScalerExtension::ScaleCmd() const
       
   724 	{
       
   725 	return iCommand;
       
   726 	}
       
   727 
       
   728 TInt CScalerExtension::GetScalingCoefficient(TInt& aScalingCoeff) const
       
   729 	{
       
   730 	if(iCommand == CScalerExtension::EScalerExtUseScalingCoeff)
       
   731 		{
       
   732 		aScalingCoeff = iScalingCoefficient;
       
   733 		return KErrNone;
       
   734 		}
       
   735 	return KErrNotSupported;
       
   736 	}
       
   737 
       
   738 TInt CScalerExtension::GetDesiredSize(TSize& aDesiredSize) const
       
   739 	{
       
   740 	if(iCommand == CScalerExtension::EScalerExtUseDesiredSize)
       
   741 		{
       
   742 		aDesiredSize = iDesiredSize;
       
   743 		return KErrNone;
       
   744 		}
       
   745 	return KErrNotSupported;
       
   746 	}
       
   747 
       
   748 // Checks if a given scaling coefficient is supported.
       
   749 TBool CScalerExtension::ScalingCoefficientSupported(TInt aScalingCoeff) const
       
   750 	{
       
   751 	if(aScalingCoeff > iCapabilities.MaxUpscaleLimit() ||
       
   752 		aScalingCoeff < iCapabilities.MaxDownscaleLimit() ||
       
   753 		aScalingCoeff == 0)
       
   754 		{
       
   755 		return EFalse;
       
   756 		}
       
   757 	return ETrue;
       
   758 	}
       
   759 
       
   760 TInt CScalerExtension::GetScalerQuality(TImageConvScaler::TScalerQuality& aQuality) const
       
   761 	{
       
   762 	aQuality = iQuality;
       
   763 	return KErrNone;
       
   764 	}
       
   765 
       
   766 TBool CScalerExtension::LockAspectRatioSet() const
       
   767 	{
       
   768 	return iLockAspectRatio;
       
   769 	}
       
   770