os/mm/imagingandcamerafws/cameraunittest/src/ECamUnitTestPlugin/EnhanceFunctionality.cpp
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "EnhanceFunctionality.h"
17 #include "AdvancedSettings.h"
18 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
19 #include <ecam/cameraoverlayconst.h>
22 CCamHistogram* CCamHistogram::NewL(CCamUnitTestPlugin& aOwner)
24 CCamHistogram* self = new (ELeave) CCamHistogram(aOwner);
25 CleanupStack::PushL(self);
27 CleanupStack::Pop(self);
31 void CCamHistogram::ConstructL()
33 iHistograms = new (ELeave) CArrayFixFlat<CHistogram*>(1);
36 CCamHistogram::CCamHistogram(CCamUnitTestPlugin& aOwner):iOwner(aOwner)
40 CCamHistogram::~CCamHistogram()
42 if(iHistograms != NULL)
45 TInt count = iHistograms->Count();
48 delete iHistograms->At(i);
57 TUint32 CCamHistogram::SupportedHistograms()
59 return CCamera::CCameraHistogram::ELuminance;
62 TUint CCamHistogram::PrepareHistogramL(CCamera::CCameraHistogram::THistogramType aType)
64 CHistogram* histogram = CHistogram::NewL(EFalse, aType, TPoint(0,0), TSize(0,0), TRgb(0));
65 iHistograms->AppendL(histogram);
66 TInt temp = iHistograms->Count();
70 TUint CCamHistogram::PrepareDSAHistogramL(CCamera::CCameraHistogram::THistogramType aType, const TPoint& aPosition, const TSize& aSize, const TRgb& aColor)
72 CHistogram* histogram = CHistogram::NewL(ETrue, aType, aPosition, aSize, aColor);
73 iHistograms->AppendL(histogram);
74 TInt temp = iHistograms->Count();
78 void CCamHistogram::StartHistogramL(TUint aHistHandle)
80 iHistograms->At(aHistHandle)->iActive = ETrue;
81 if(iHistograms->At(aHistHandle)->iDSA == EFalse)
84 myuid.iUid = KUidECamEventHistogramUidValue;
85 iOwner.Notify(myuid,0);
89 void CCamHistogram::StopHistogramL(TUint aHistHandle)
91 iHistograms->At(aHistHandle)->iActive = EFalse;
94 void CCamHistogram::DestroyHistogramL(TUint aHistHandle)
96 delete iHistograms->At(aHistHandle);
97 iHistograms->Delete(aHistHandle);
100 void CCamHistogram::Release()
105 void CCamHistogram::GetActiveHistogramsL(RArray<TUint>& /*aActiveHistograms*/)
110 void CCamHistogram::UpdateDSAHistogramPropertiesL(TUint aHistHandle, const TPoint& aPosition, const TSize& aSize, const TRgb& aColor)
112 iHistograms->At(aHistHandle)->iPosition = aPosition;
113 iHistograms->At(aHistHandle)->iSize = aSize;
114 iHistograms->At(aHistHandle)->iColor = aColor;
117 void CCamHistogram::GetDSAHistogramPropertiesL(TUint aHistHandle, TPoint& aPosition, TSize& aSize, TRgb& aColor)
119 aPosition = iHistograms->At(aHistHandle)->iPosition;
120 aSize = iHistograms->At(aHistHandle)->iSize;
121 aColor = iHistograms->At(aHistHandle)->iColor;
124 MHistogramBuffer& CCamHistogram::HistogramDataL()
128 return reinterpret_cast<MHistogramBuffer&> (a);
131 MHistogramBuffer& CCamHistogram::HistogramDataL(TUint /*aHistHandle*/)
135 return reinterpret_cast<MHistogramBuffer&> (a);
139 * Defination for CHistogram Class
141 CCamHistogram::CHistogram * CCamHistogram::CHistogram::NewL(TBool aDSA, CCamera::CCameraHistogram::THistogramType aType, TPoint aPosition, TSize aSize, TRgb aColor)
143 return new (ELeave) CCamHistogram::CHistogram(aDSA , aType, aPosition, aSize, aColor);
146 CCamHistogram::CHistogram::CHistogram(TBool aDSA, CCamera::CCameraHistogram::THistogramType /*aType*/, TPoint aPosition, TSize aSize, TRgb aColor):iDSA(aDSA),iPosition(aPosition),iSize(aSize),iColor(aColor)
150 CCamHistogram::CHistogram::~CHistogram()
156 *///-----------------------------------------------------------------------------------
158 CCamSnapshot* CCamSnapshot::NewL(CCamUnitTestPlugin& aOwner)
160 return new (ELeave) CCamSnapshot(aOwner);
163 CCamSnapshot::~CCamSnapshot()
167 CCamSnapshot::CCamSnapshot(CCamUnitTestPlugin& aOwner):iOwner(aOwner)
171 TUint32 CCamSnapshot::SupportedFormats()
173 // Dummy implementation : Nothing to implement
174 return CCamera::EFormatJpeg;
177 void CCamSnapshot::PrepareSnapshotL(CCamera::TFormat aFormat, const TPoint& aPosition, const TSize& aSize, const TRgb& aBgColor, TBool aMaintainAspectRatio)
179 // Dummy implementation :
184 iAspRatio = aMaintainAspectRatio;
187 void CCamSnapshot::PrepareSnapshotL(CCamera::TFormat aFormat, const TSize& aSize, TBool aMaintainAspectRatio)
191 iAspRatio = aMaintainAspectRatio;
194 TBool CCamSnapshot::IsSnapshotActive() const
196 // Dummy implementation :
200 void CCamSnapshot::StartSnapshot()
202 // Dummy implementation
206 myuid.iUid = KUidECamEventSnapshotUidValue;
207 iOwner.Notify(myuid,0);
210 void CCamSnapshot::StopSnapshot()
212 // Dummy implementation
216 MCameraBuffer& CCamSnapshot::SnapshotDataL(RArray<TInt>& aFrameIndexOrder)
218 // Dummy implementation :
219 aFrameIndexOrder.Append(1);
221 return reinterpret_cast <MCameraBuffer&> (temp);
224 void CCamSnapshot::SetBgColorL(const TRgb& aBgColor)
227 if(iBgColor != aBgColor)
229 User::Leave(KErrNotSupported);
233 void CCamSnapshot::SetPositionL(const TPoint& aPosition)
236 if(iPos != aPosition)
238 User::Leave(KErrNotSupported);
242 void CCamSnapshot::Release()
250 */// -----------------------------------------------------------------------------------
252 CCamOverlay* CCamOverlay::NewL(CCamUnitTestPlugin& aOwner)
254 CDataGlobal* globalData = static_cast <CDataGlobal*> (Dll::Tls());
258 globalData = new (ELeave) CDataGlobal;
259 CleanupStack::PushL(globalData);
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);
270 delete globalData->iCamOverlay;
273 CleanupStack::Pop(globalData);
275 return static_cast <CCamOverlay*> (globalData->iCamOverlay);
279 CCamOverlay* self = globalData->iCamOverlay;
281 globalData->iReferenceCount++;
282 self->iRefCount = globalData->iReferenceCount + 1;
283 if (globalData->iReferenceCount == 1 )
290 TInt error = Dll::SetTls(globalData);
293 delete globalData->iCamOverlay;
297 return static_cast <CCamOverlay*> (self);
301 void CCamOverlay::ConstructL()
303 iOverlays = new (ELeave) CArrayFixFlat<COverlay*>(1);
306 CCamOverlay::CCamOverlay(CCamUnitTestPlugin& aOwner):iOwner(aOwner)
310 CCamOverlay::~CCamOverlay()
313 // Dummy implementation
314 if(iOverlays != NULL)
317 TInt count = iOverlays->Count();
320 delete iOverlays->At(i);
329 void CCamOverlay::Release()
338 TUint CCamOverlay::CreateOverlayL(const CCamera::CCameraOverlay::TOverlayParameters& aParameters, CFbsBitmap* aBitmap)
340 // Dummy implementation
341 if((aParameters.Size() != sizeof(CCamera::CCameraOverlay::TOverlayParameters )) ||
342 aParameters.Version() != KECamOverlayParametersCurrentVersion)
344 User::Leave(KErrNotSupported);
347 COverlay* overlay = COverlay::NewL(aParameters, aBitmap);
348 overlay->iZOrderReverse = 100 - aParameters.iZOrder;
349 iOverlays->AppendL(overlay);
350 TInt temp = iOverlays->Count();
354 void CCamOverlay::SetOverlayBitmapL(TUint aOverlayHandleRef, const CFbsBitmap* aBitmap)
356 // Dummy implementation
357 iOverlays->At(aOverlayHandleRef)->iBitmap = const_cast<CFbsBitmap*> (aBitmap);
360 void CCamOverlay::GetOverlayBitmapL(TUint aOverlayHandleRef, CFbsBitmap* aBitmap)
362 // Dummy implementation
363 TSize size = aBitmap->SizeInPixels();
364 TDisplayMode dispMode = aBitmap->DisplayMode();
366 User::LeaveIfError(aBitmap->Duplicate(iOverlays->At(aOverlayHandleRef)->iBitmap->Handle()));
367 size = aBitmap->SizeInPixels();
368 dispMode = aBitmap->DisplayMode();
371 void CCamOverlay::GetOverlayParametersL(TUint aOverlayHandle, CCamera::CCameraOverlay::TOverlayParameters& aInfo)
373 // Dummy implementation
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;
383 void CCamOverlay::SetOverlayParametersL(TUint aOverlayHandle, const CCamera::CCameraOverlay::TOverlayParameters& aParameters)
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;
392 iOverlays->At(aOverlayHandle)->iZOrderReverse = 100 - aParameters.iZOrder;
395 void CCamOverlay::ReleaseOverlay(TUint aOverlayHandle)
397 // Dummy implementation
398 delete iOverlays->At(aOverlayHandle);
399 iOverlays->Delete(aOverlayHandle);
402 void CCamOverlay::GetOverlaySupport(CCamera::CCameraOverlay::TOverlaySupportInfo& aInfo)
404 // Dummy implementation
405 if((aInfo.Size() != sizeof(CCamera::CCameraOverlay::TOverlaySupportInfo )) ||
406 aInfo.Version() != KECamOverlaySupportInfoCurrentVersion)
408 User::Leave(KErrNotSupported);
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;
418 void CCamOverlay::GetAllOverlaysInZOrderL(RArray<TUint>& /*aOverlayHandles*/)
420 // Dummy implementation
423 void CCamOverlay::SetAllOverlaysInZOrderL(const RArray<TUint>& /*aOverlayHandles*/)
425 // Dummy implementation
428 void CCamOverlay::SetModifiableOverlayBitmapL(TUint aOverlayHandle, CFbsBitmap* aBitmap)
430 // Dummy implementation
431 iOverlays->At(aOverlayHandle)->iBitmap = aBitmap;
434 void CCamOverlay::GetAllOverlaysInZOrderL(CCamera::CCameraOverlay::TOverlayCameraMode aOverlayCameraMode, TInt aViewFinderHandle, RArray<TUint>& aOverlayHandles) const
436 // Dummy implementation
437 RArray<TInt> overlayFiltered;
439 aOverlayHandles.Reset();
441 // filter overlays for 'aOverlayCameraMode' and aViewFinderHandle (if applicable)
442 for(TInt index=0; index<iOverlays->Count(); index++)
444 if(iOverlays->At(index)->iOverlayParms.iCurrentModes & aOverlayCameraMode)
446 if(aOverlayCameraMode == CCamera::CCameraOverlay::EModeDirectViewfinder || aOverlayCameraMode == CCamera::CCameraOverlay::EModeClientViewfinder)
448 if(iOverlays->At(index)->iOverlayParms.iViewFinderHandle == aViewFinderHandle)
450 overlayFiltered.AppendL(index);
455 overlayFiltered.AppendL(index);
461 TInt maxZOrderHandle =0;
463 while(overlayFiltered.Count())
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++)
471 if(iOverlays->At(index)->iOverlayParms.iZOrder > zOrderMax)
473 zOrderMax = iOverlays->At(index)->iOverlayParms.iZOrder;
474 maxZOrderHandle = index;
478 aOverlayHandles.AppendL(maxZOrderHandle);
479 overlayFiltered.Remove(maxZOrderHandle);
482 overlayFiltered.Close() ;
485 void CCamOverlay::SetAllOverlaysInZOrderL(CCamera::CCameraOverlay::TOverlayCameraMode aOverlayCameraMode, TInt aViewFinderHandle, const RArray<TUint>& aOverlayHandles)
488 TBool available = EFalse;
491 for(TInt index=0; index<iOverlays->Count(); index++)
493 if(iOverlays->At(index)->iOverlayParms.iCurrentModes & aOverlayCameraMode)
495 if(aOverlayCameraMode == CCamera::CCameraOverlay::EModeDirectViewfinder || aOverlayCameraMode == CCamera::CCameraOverlay::EModeClientViewfinder)
497 if(iOverlays->At(index)->iOverlayParms.iViewFinderHandle == aViewFinderHandle)
508 overlayIndex = aOverlayHandles.Find(index);
511 if(overlayIndex == KErrNotFound)
513 User::Leave(KErrArgument);
518 if(overlayIndex != KErrNotFound)
520 User::Leave(KErrArgument);
523 }// boundary checking complete
525 //provide Z order values to aOverlayHandles
526 TUint decZorder = 100;
527 for(TInt index =0; index<aOverlayHandles.Count(); index++ )
529 iOverlays->At(aOverlayHandles[index])->iOverlayParms.iZOrder = decZorder;
530 iOverlays->At(aOverlayHandles[index])->iZOrderReverse = 100 - decZorder;
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));
542 * Defination for COverlay Class
544 CCamOverlay::COverlay* CCamOverlay::COverlay::NewL(const CCamera::CCameraOverlay::TOverlayParameters& aParameters, CFbsBitmap* aBitmap)
546 CCamOverlay::COverlay* self = new (ELeave) CCamOverlay::COverlay(aParameters, aBitmap);
547 CleanupStack::PushL(self);
549 CleanupStack::Pop(self);
553 void CCamOverlay::COverlay::ConstructL()
557 CCamOverlay::COverlay::COverlay(const CCamera::CCameraOverlay::TOverlayParameters& aParameters, CFbsBitmap* aBitmap):iOverlayParms(aParameters), iBitmap(aBitmap)
561 CCamOverlay::COverlay::~COverlay ()