os/mm/imagingandcamerafws/cameraunittest/src/ECamUnitTestPlugin/EnhanceFunctionality.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-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 "EnhanceFunctionality.h"
    17 #include "AdvancedSettings.h"
    18 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    19 #include <ecam/cameraoverlayconst.h>
    20 #endif
    21 
    22 CCamHistogram* CCamHistogram::NewL(CCamUnitTestPlugin& aOwner)
    23 	{
    24 	CCamHistogram* self = new (ELeave) CCamHistogram(aOwner);
    25 	CleanupStack::PushL(self);
    26 	self->ConstructL();
    27 	CleanupStack::Pop(self);
    28 	return self;
    29 	}
    30 	
    31 void CCamHistogram::ConstructL()
    32 	{
    33 	iHistograms = new (ELeave) CArrayFixFlat<CHistogram*>(1);
    34 	}
    35 
    36 CCamHistogram::CCamHistogram(CCamUnitTestPlugin& aOwner):iOwner(aOwner)
    37 	{
    38 	}
    39 	
    40 CCamHistogram::~CCamHistogram()
    41 	{
    42 	if(iHistograms != NULL)
    43 		{
    44 		TInt i=0;
    45 		TInt count = iHistograms->Count();
    46 		while(i<count)
    47 			{
    48 			delete iHistograms->At(i);
    49 			i++;
    50 			}
    51 		iHistograms->Reset();
    52 		delete iHistograms;
    53 		iHistograms = NULL;
    54 		}
    55 	}
    56 	
    57 TUint32 CCamHistogram::SupportedHistograms()
    58 	{
    59 	return CCamera::CCameraHistogram::ELuminance;
    60 	}
    61 	
    62 TUint CCamHistogram::PrepareHistogramL(CCamera::CCameraHistogram::THistogramType aType)
    63 	{
    64 	CHistogram* histogram = CHistogram::NewL(EFalse, aType, TPoint(0,0), TSize(0,0), TRgb(0));
    65 	iHistograms->AppendL(histogram);
    66 	TInt temp = iHistograms->Count();
    67 	return --temp;
    68 	}
    69 	
    70 TUint CCamHistogram::PrepareDSAHistogramL(CCamera::CCameraHistogram::THistogramType aType, const TPoint& aPosition, const TSize& aSize, const TRgb& aColor)
    71 	{
    72 	CHistogram* histogram = CHistogram::NewL(ETrue, aType, aPosition, aSize, aColor);
    73 	iHistograms->AppendL(histogram);
    74 	TInt temp = iHistograms->Count();
    75 	return --temp;
    76 	}
    77 	
    78 void CCamHistogram::StartHistogramL(TUint aHistHandle)
    79 	{
    80 	iHistograms->At(aHistHandle)->iActive = ETrue;
    81 	if(iHistograms->At(aHistHandle)->iDSA == EFalse)
    82 		{
    83 		TUid myuid;
    84 		myuid.iUid = KUidECamEventHistogramUidValue;
    85 		iOwner.Notify(myuid,0);	
    86 		}
    87 	}
    88 	
    89 void CCamHistogram::StopHistogramL(TUint aHistHandle)
    90 	{
    91 	iHistograms->At(aHistHandle)->iActive = EFalse;
    92 	}
    93 	
    94 void CCamHistogram::DestroyHistogramL(TUint aHistHandle)
    95 	{
    96 	delete iHistograms->At(aHistHandle);
    97 	iHistograms->Delete(aHistHandle);
    98 	}
    99 	
   100 void CCamHistogram::Release()
   101 	{
   102 	delete this;
   103 	}
   104 	
   105 void CCamHistogram::GetActiveHistogramsL(RArray<TUint>& /*aActiveHistograms*/)
   106 	{
   107 	//Not implemented
   108 	}
   109 	
   110 void CCamHistogram::UpdateDSAHistogramPropertiesL(TUint aHistHandle, const TPoint& aPosition, const TSize& aSize, const TRgb& aColor)
   111 	{
   112 	iHistograms->At(aHistHandle)->iPosition = aPosition;
   113 	iHistograms->At(aHistHandle)->iSize = aSize;
   114 	iHistograms->At(aHistHandle)->iColor = aColor;
   115 	}
   116 	
   117 void CCamHistogram::GetDSAHistogramPropertiesL(TUint aHistHandle, TPoint& aPosition, TSize& aSize, TRgb& aColor)
   118 	{
   119 	aPosition = iHistograms->At(aHistHandle)->iPosition;
   120 	aSize = iHistograms->At(aHistHandle)->iSize;
   121 	aColor = iHistograms->At(aHistHandle)->iColor;
   122 	}
   123 	
   124 MHistogramBuffer& CCamHistogram::HistogramDataL()
   125 	{
   126 	// not implemented
   127 	TInt a = 10;
   128 	return reinterpret_cast<MHistogramBuffer&> (a);
   129 	}
   130 	
   131 MHistogramBuffer& CCamHistogram::HistogramDataL(TUint /*aHistHandle*/)
   132 	{
   133 	// not implemented
   134 	TInt a = 10;
   135 	return reinterpret_cast<MHistogramBuffer&> (a);
   136 	}
   137 	
   138 /**
   139 * Defination for CHistogram Class 
   140 */
   141 CCamHistogram::CHistogram * CCamHistogram::CHistogram::NewL(TBool aDSA, CCamera::CCameraHistogram::THistogramType aType, TPoint aPosition, TSize aSize, TRgb aColor)
   142 	{
   143 	return new (ELeave) CCamHistogram::CHistogram(aDSA , aType, aPosition, aSize, aColor);
   144 	}
   145 	
   146 CCamHistogram::CHistogram::CHistogram(TBool aDSA, CCamera::CCameraHistogram::THistogramType /*aType*/, TPoint aPosition, TSize aSize, TRgb aColor):iDSA(aDSA),iPosition(aPosition),iSize(aSize),iColor(aColor)
   147 	{
   148 	}
   149 	
   150 CCamHistogram::CHistogram::~CHistogram()
   151 	{
   152 	}
   153 	
   154 /**
   155 *	For Snapshot
   156 *///-----------------------------------------------------------------------------------
   157 
   158 CCamSnapshot* CCamSnapshot::NewL(CCamUnitTestPlugin& aOwner)
   159 	{
   160 	return new (ELeave) CCamSnapshot(aOwner);
   161 	}
   162 	
   163 CCamSnapshot::~CCamSnapshot()
   164 	{
   165 	}
   166 	
   167 CCamSnapshot::CCamSnapshot(CCamUnitTestPlugin& aOwner):iOwner(aOwner)
   168 	{
   169 	}
   170 	
   171 TUint32 CCamSnapshot::SupportedFormats()
   172 	{
   173 	// Dummy implementation : Nothing to implement
   174 	return CCamera::EFormatJpeg;
   175 	}
   176 	
   177 void CCamSnapshot::PrepareSnapshotL(CCamera::TFormat aFormat, const TPoint& aPosition, const TSize& aSize, const TRgb& aBgColor, TBool aMaintainAspectRatio)
   178 	{
   179 	// Dummy implementation : 
   180 	iFormat = aFormat;
   181 	iPos = aPosition;
   182 	iSize = aSize;
   183 	iBgColor = aBgColor;
   184 	iAspRatio = aMaintainAspectRatio;
   185 	}
   186 
   187 void CCamSnapshot::PrepareSnapshotL(CCamera::TFormat aFormat, const TSize& aSize, TBool aMaintainAspectRatio)	
   188 	{
   189 	iFormat = aFormat;
   190 	iSize = aSize;
   191 	iAspRatio = aMaintainAspectRatio;
   192 	}
   193 
   194 TBool CCamSnapshot::IsSnapshotActive() const
   195 	{
   196 	// Dummy implementation :
   197 	return iActive;
   198 	}
   199 	
   200 void CCamSnapshot::StartSnapshot()
   201 	{
   202 	// Dummy implementation 
   203 	iActive = ETrue;
   204 	
   205 	TUid myuid;
   206 	myuid.iUid = KUidECamEventSnapshotUidValue;
   207 	iOwner.Notify(myuid,0);
   208 	}
   209 	
   210 void CCamSnapshot::StopSnapshot()
   211 	{
   212 	// Dummy implementation 
   213 	iActive = EFalse;
   214 	}
   215 	
   216 MCameraBuffer& CCamSnapshot::SnapshotDataL(RArray<TInt>& aFrameIndexOrder)
   217 	{
   218 	// Dummy implementation :
   219 	aFrameIndexOrder.Append(1);
   220 	TInt temp = 10;
   221 	return reinterpret_cast <MCameraBuffer&> (temp);
   222 	}
   223 
   224 void CCamSnapshot::SetBgColorL(const TRgb& aBgColor)
   225 	{
   226 	iBgColor = aBgColor;
   227 	if(iBgColor != aBgColor)
   228 		{
   229 		User::Leave(KErrNotSupported);
   230 		}
   231 	}
   232 	
   233 void CCamSnapshot::SetPositionL(const TPoint& aPosition)
   234 	{
   235 	iPos = aPosition;
   236 	if(iPos != aPosition)
   237 		{
   238 		User::Leave(KErrNotSupported);
   239 		}
   240 	}
   241 		
   242 void CCamSnapshot::Release()
   243 	{
   244 	delete this;
   245 	}
   246 
   247 
   248 /**
   249 *	For Overlay
   250 */// -----------------------------------------------------------------------------------
   251 
   252 CCamOverlay* CCamOverlay::NewL(CCamUnitTestPlugin& aOwner)
   253 	{
   254 	CDataGlobal* globalData = static_cast <CDataGlobal*> (Dll::Tls());
   255 	
   256 	if(!globalData)
   257 		{
   258 		globalData = new (ELeave) CDataGlobal;
   259 		CleanupStack::PushL(globalData);
   260 		
   261 		globalData->iReferenceCount = 0;
   262 		globalData->iCamOverlay = new (ELeave) CCamOverlay(aOwner);
   263 		CleanupStack::PushL(globalData->iCamOverlay);
   264 		globalData->iCamOverlay->ConstructL();
   265     	globalData->iCamOverlay->iRefCount = 1;
   266     	CleanupStack::Pop(globalData->iCamOverlay);
   267 		TInt error = Dll::SetTls(globalData);
   268 		if (error)
   269 			{
   270 			delete globalData->iCamOverlay;
   271 			User::Leave(error);
   272 			}
   273 		CleanupStack::Pop(globalData);
   274     	
   275 		return static_cast <CCamOverlay*> (globalData->iCamOverlay);
   276 		}
   277 	else
   278 		{
   279 		CCamOverlay* self = globalData->iCamOverlay;
   280 		
   281 		globalData->iReferenceCount++;
   282 		self->iRefCount = globalData->iReferenceCount + 1;
   283 		if (globalData->iReferenceCount == 1 )
   284 			{
   285 			delete globalData;
   286 			Dll::FreeTls();
   287 			}
   288 		else
   289 			{
   290 			TInt error = Dll::SetTls(globalData);
   291 			if (error)
   292 				{
   293 				delete globalData->iCamOverlay;
   294 				User::Leave(error);
   295 				}
   296 			}
   297 		return static_cast <CCamOverlay*> (self);		
   298 		}
   299 	}
   300 	
   301 void CCamOverlay::ConstructL()
   302 	{
   303 	iOverlays = new (ELeave) CArrayFixFlat<COverlay*>(1);
   304 	}
   305 	
   306 CCamOverlay::CCamOverlay(CCamUnitTestPlugin& aOwner):iOwner(aOwner)
   307 	{
   308 	}
   309 
   310 CCamOverlay::~CCamOverlay()
   311 	{
   312 	Dll::FreeTls();
   313 	// Dummy implementation 
   314 	if(iOverlays != NULL)
   315 		{
   316 		TInt i=0;
   317 		TInt count = iOverlays->Count();
   318 		while(i<count)
   319 			{
   320 			delete iOverlays->At(i);
   321 			i++;
   322 			}
   323 		iOverlays->Reset();
   324 		delete iOverlays;
   325 		iOverlays = NULL;
   326 		}
   327 	}
   328 
   329 void CCamOverlay::Release()
   330 	{
   331 	iRefCount--; 
   332 	if(!iRefCount)
   333 		{
   334 		delete this;
   335 		}
   336 	}
   337 
   338 TUint CCamOverlay::CreateOverlayL(const CCamera::CCameraOverlay::TOverlayParameters& aParameters, CFbsBitmap* aBitmap)
   339 	{
   340 	// Dummy implementation 
   341 	if((aParameters.Size() != sizeof(CCamera::CCameraOverlay::TOverlayParameters )) ||
   342 		aParameters.Version() != KECamOverlayParametersCurrentVersion)
   343 		{
   344 		User::Leave(KErrNotSupported);
   345 		}
   346 	
   347 	COverlay* overlay = COverlay::NewL(aParameters, aBitmap);
   348 	overlay->iZOrderReverse = 100 - aParameters.iZOrder;
   349 	iOverlays->AppendL(overlay);
   350 	TInt temp = iOverlays->Count();
   351 	return --temp;
   352 	}
   353 
   354 void CCamOverlay::SetOverlayBitmapL(TUint aOverlayHandleRef, const CFbsBitmap* aBitmap)
   355 	{
   356 	// Dummy implementation 
   357 	iOverlays->At(aOverlayHandleRef)->iBitmap = const_cast<CFbsBitmap*> (aBitmap);
   358 	}
   359 
   360 void CCamOverlay::GetOverlayBitmapL(TUint aOverlayHandleRef, CFbsBitmap* aBitmap)
   361 	{
   362 	// Dummy implementation 
   363 	TSize size = aBitmap->SizeInPixels();
   364 	TDisplayMode dispMode = aBitmap->DisplayMode();
   365 	
   366 	User::LeaveIfError(aBitmap->Duplicate(iOverlays->At(aOverlayHandleRef)->iBitmap->Handle()));
   367 	size = aBitmap->SizeInPixels();
   368 	dispMode = aBitmap->DisplayMode();
   369 	}
   370 
   371 void CCamOverlay::GetOverlayParametersL(TUint aOverlayHandle, CCamera::CCameraOverlay::TOverlayParameters& aInfo)
   372 	{
   373 	// Dummy implementation 
   374 	
   375 	aInfo.iCurrentModes	=	iOverlays->At(aOverlayHandle)->iOverlayParms.iCurrentModes;
   376 	aInfo.iCurrentTypes	=	iOverlays->At(aOverlayHandle)->iOverlayParms.iCurrentTypes;
   377 	aInfo.iAlphaValue	=	iOverlays->At(aOverlayHandle)->iOverlayParms.iAlphaValue;
   378 	aInfo.iPosition		=	iOverlays->At(aOverlayHandle)->iOverlayParms.iPosition;
   379 	aInfo.iZOrder		=	iOverlays->At(aOverlayHandle)->iOverlayParms.iZOrder;
   380 	
   381 	}
   382 
   383 void CCamOverlay::SetOverlayParametersL(TUint aOverlayHandle, const CCamera::CCameraOverlay::TOverlayParameters& aParameters)
   384 	{
   385 	// Dummy implementation 
   386 	iOverlays->At(aOverlayHandle)->iOverlayParms.iCurrentModes 	= aParameters.iCurrentModes;
   387 	iOverlays->At(aOverlayHandle)->iOverlayParms.iCurrentTypes 	= aParameters.iCurrentTypes;
   388 	iOverlays->At(aOverlayHandle)->iOverlayParms.iAlphaValue 	= aParameters.iAlphaValue;
   389 	iOverlays->At(aOverlayHandle)->iOverlayParms.iPosition 		= aParameters.iPosition;
   390 	iOverlays->At(aOverlayHandle)->iOverlayParms.iZOrder 		= aParameters.iZOrder;
   391 	
   392 	iOverlays->At(aOverlayHandle)->iZOrderReverse = 100 - aParameters.iZOrder;
   393 	}
   394 
   395 void CCamOverlay::ReleaseOverlay(TUint aOverlayHandle)
   396 	{
   397 	// Dummy implementation
   398 	delete iOverlays->At(aOverlayHandle);
   399 	iOverlays->Delete(aOverlayHandle);
   400 	}
   401 
   402 void CCamOverlay::GetOverlaySupport(CCamera::CCameraOverlay::TOverlaySupportInfo& aInfo)
   403 	{
   404 	// Dummy implementation 
   405 	if((aInfo.Size() != sizeof(CCamera::CCameraOverlay::TOverlaySupportInfo )) ||
   406 		aInfo.Version() != KECamOverlaySupportInfoCurrentVersion)
   407 		{
   408 		User::Leave(KErrNotSupported);
   409 		}
   410 	
   411 	aInfo.iSupportedModes = (CCamera::CCameraOverlay::EModeStillImageBurst << 1) - 1;
   412 	aInfo.iSupportedTypes = 1;
   413 	aInfo.iPerPlane = CCamera::CCameraOverlay::EBinary;
   414 	aInfo.iPerPixel = CCamera::CCameraOverlay::EBinary;
   415 	aInfo.iCanOverlap = EFalse;
   416 	}
   417 
   418 void CCamOverlay::GetAllOverlaysInZOrderL(RArray<TUint>& /*aOverlayHandles*/)
   419 	{
   420 	// Dummy implementation 
   421 	}
   422 	
   423 void CCamOverlay::SetAllOverlaysInZOrderL(const RArray<TUint>& /*aOverlayHandles*/)
   424 	{
   425 	// Dummy implementation 
   426 	}
   427 	
   428 void CCamOverlay::SetModifiableOverlayBitmapL(TUint aOverlayHandle, CFbsBitmap* aBitmap)
   429 	{
   430 	// Dummy implementation 
   431 	iOverlays->At(aOverlayHandle)->iBitmap = aBitmap;
   432 	}
   433 
   434 void CCamOverlay::GetAllOverlaysInZOrderL(CCamera::CCameraOverlay::TOverlayCameraMode aOverlayCameraMode, TInt aViewFinderHandle, RArray<TUint>& aOverlayHandles) const
   435 	{
   436 	// Dummy implementation
   437 	RArray<TInt> overlayFiltered;
   438 	
   439 	aOverlayHandles.Reset();
   440 		
   441 	// filter overlays for 'aOverlayCameraMode' and aViewFinderHandle (if applicable)
   442 	for(TInt index=0; index<iOverlays->Count(); index++)
   443 		{
   444 		if(iOverlays->At(index)->iOverlayParms.iCurrentModes & aOverlayCameraMode)
   445 			{
   446 			if(aOverlayCameraMode == CCamera::CCameraOverlay::EModeDirectViewfinder || aOverlayCameraMode == CCamera::CCameraOverlay::EModeClientViewfinder)
   447 				{
   448 				if(iOverlays->At(index)->iOverlayParms.iViewFinderHandle == aViewFinderHandle)
   449 					{
   450 					overlayFiltered.AppendL(index);
   451 					}
   452 				}
   453 			else
   454 				{
   455 				overlayFiltered.AppendL(index);	
   456 				}
   457 			}
   458 		}
   459 		
   460 	TUint zOrderMax = 0;
   461 	TInt maxZOrderHandle =0;
   462 	
   463 	while(overlayFiltered.Count())	
   464 		{
   465 		zOrderMax = 0;
   466 		maxZOrderHandle =0;
   467 		
   468 		//find out max Zorder and the handle of the overlay which has this max z-order
   469 		for(TInt index=0; index<overlayFiltered.Count(); index++)
   470 			{
   471 			if(iOverlays->At(index)->iOverlayParms.iZOrder > zOrderMax)
   472 				{
   473 				zOrderMax = iOverlays->At(index)->iOverlayParms.iZOrder;
   474 				maxZOrderHandle = index;
   475 				}
   476 			}
   477 			
   478 		aOverlayHandles.AppendL(maxZOrderHandle);
   479 		overlayFiltered.Remove(maxZOrderHandle);
   480 		}
   481 	
   482 	overlayFiltered.Close()	;
   483 	}
   484 	
   485 void CCamOverlay::SetAllOverlaysInZOrderL(CCamera::CCameraOverlay::TOverlayCameraMode aOverlayCameraMode, TInt aViewFinderHandle, const RArray<TUint>& aOverlayHandles)
   486 	{
   487 	//boundary checking
   488 	TBool available = EFalse;
   489 	TInt overlayIndex;
   490 	
   491 	for(TInt index=0; index<iOverlays->Count(); index++)
   492 		{
   493 		if(iOverlays->At(index)->iOverlayParms.iCurrentModes & aOverlayCameraMode)
   494 			{
   495 			if(aOverlayCameraMode == CCamera::CCameraOverlay::EModeDirectViewfinder || aOverlayCameraMode == CCamera::CCameraOverlay::EModeClientViewfinder)
   496 				{
   497 				if(iOverlays->At(index)->iOverlayParms.iViewFinderHandle == aViewFinderHandle)
   498 					{
   499 					available = ETrue;
   500 					}
   501 				}
   502 			else
   503 				{
   504 				available = ETrue;	
   505 				}
   506 			}
   507 			
   508 		overlayIndex = aOverlayHandles.Find(index);	
   509 		if(available)
   510 			{
   511 			if(overlayIndex == KErrNotFound)
   512 				{
   513 				User::Leave(KErrArgument);
   514 				}
   515 			}
   516 		else
   517 			{
   518 			if(overlayIndex != KErrNotFound)
   519 				{
   520 				User::Leave(KErrArgument);
   521 				}	
   522 			}
   523 		}// boundary checking complete
   524 		
   525 	//provide Z order values to aOverlayHandles
   526 	TUint decZorder = 100;
   527 	for(TInt index =0; index<aOverlayHandles.Count(); index++ )
   528 		{
   529 		iOverlays->At(aOverlayHandles[index])->iOverlayParms.iZOrder = decZorder;
   530 		iOverlays->At(aOverlayHandles[index])->iZOrderReverse = 100 - decZorder;
   531 		decZorder--;
   532 		}
   533 	
   534 	//setting the overlays in z-order
   535 	TInt offset = _FOFF(CCamOverlay::COverlay, iZOrderReverse);
   536 	TKeyArrayFix key(offset, ECmpTUint);
   537 	User::LeaveIfError(iOverlays->Sort(key));
   538 	}
   539 
   540 	
   541 /**
   542 * Defination for COverlay Class 
   543 */
   544 CCamOverlay::COverlay* CCamOverlay::COverlay::NewL(const CCamera::CCameraOverlay::TOverlayParameters& aParameters, CFbsBitmap* aBitmap)
   545 	{
   546 	CCamOverlay::COverlay* self = new (ELeave) CCamOverlay::COverlay(aParameters, aBitmap);
   547 	CleanupStack::PushL(self);
   548 	self->ConstructL();
   549 	CleanupStack::Pop(self);
   550 	return self;
   551 	}
   552 	
   553 void CCamOverlay::COverlay::ConstructL()
   554 	{
   555 	}
   556 
   557 CCamOverlay::COverlay::COverlay(const CCamera::CCameraOverlay::TOverlayParameters& aParameters, CFbsBitmap* aBitmap):iOverlayParms(aParameters), iBitmap(aBitmap)
   558 	{
   559 	}
   560 	
   561 CCamOverlay::COverlay::~COverlay ()
   562 	{
   563 	}
   564