|
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 // testimageprocessing.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "test_image_processing.h" |
|
19 #include <ecamerrors.h> |
|
20 #include "ecamversion.h" |
|
21 |
|
22 CTestCamImgProc::CTestCamImgProc(CTestCamera& aOwner): iOwner(aOwner) |
|
23 {} |
|
24 |
|
25 CTestCamImgProc::~CTestCamImgProc() |
|
26 { |
|
27 iSupportedTranformations.Close(); |
|
28 iActiveTransformations.Close(); |
|
29 iActiveTransformSequence.Close(); |
|
30 |
|
31 CDataGlobal* globalData = static_cast <CDataGlobal*> (Dll::Tls()); |
|
32 if(globalData != NULL) |
|
33 { |
|
34 if(!globalData->iTestCamAdvSet && !globalData->iTestCamPresets && !globalData->iTestCamSnapshot) |
|
35 { |
|
36 delete globalData; |
|
37 Dll::FreeTls(); |
|
38 } |
|
39 else |
|
40 { |
|
41 globalData->iTestCamImgProc = NULL; |
|
42 Dll::SetTls(globalData); |
|
43 } |
|
44 } |
|
45 } |
|
46 |
|
47 CTestCamImgProc* CTestCamImgProc::NewL(CTestCamera& aOwner) |
|
48 { |
|
49 CDataGlobal* globalData = static_cast <CDataGlobal*> (Dll::Tls()); |
|
50 |
|
51 if(globalData == NULL) |
|
52 { |
|
53 globalData = new (ELeave) CDataGlobal; |
|
54 CleanupStack::PushL(globalData); |
|
55 globalData->iImgProcReferenceCount = 0; |
|
56 globalData->iTestCamImgProc = new (ELeave) CTestCamImgProc(aOwner); |
|
57 CleanupStack::PushL(globalData->iTestCamImgProc); |
|
58 globalData->iTestCamImgProc->ConstructL(); |
|
59 globalData->iTestCamImgProc->iRefCount = 1; |
|
60 User::LeaveIfError(Dll::SetTls(globalData)); |
|
61 CleanupStack::Pop(globalData->iTestCamImgProc); |
|
62 CleanupStack::Pop(globalData); |
|
63 return globalData->iTestCamImgProc; |
|
64 } |
|
65 else |
|
66 { |
|
67 if(globalData->iTestCamImgProc == NULL) |
|
68 { |
|
69 globalData->iImgProcReferenceCount = 0; |
|
70 globalData->iTestCamImgProc = new (ELeave) CTestCamImgProc(aOwner); |
|
71 CleanupStack::PushL(globalData->iTestCamImgProc); |
|
72 globalData->iTestCamImgProc->ConstructL(); |
|
73 globalData->iTestCamImgProc->iRefCount = 1; |
|
74 User::LeaveIfError(Dll::SetTls(globalData)); |
|
75 CleanupStack::Pop(globalData->iTestCamImgProc); |
|
76 return globalData->iTestCamImgProc; |
|
77 } |
|
78 |
|
79 CTestCamImgProc* self = globalData->iTestCamImgProc; |
|
80 |
|
81 globalData->iImgProcReferenceCount++; |
|
82 self->iRefCount = globalData->iImgProcReferenceCount + 1; |
|
83 if (globalData->iImgProcReferenceCount == KNumOfImgProcExtensions-1) |
|
84 { |
|
85 globalData->iTestCamImgProc = NULL; |
|
86 if(!globalData->iTestCamAdvSet && !globalData->iTestCamPresets && !globalData->iTestCamSnapshot) |
|
87 { |
|
88 delete globalData; |
|
89 Dll::FreeTls(); |
|
90 } |
|
91 else |
|
92 { |
|
93 User::LeaveIfError(Dll::SetTls(globalData)); |
|
94 } |
|
95 } |
|
96 else |
|
97 { |
|
98 User::LeaveIfError(Dll::SetTls(globalData)); |
|
99 } |
|
100 return self; |
|
101 } |
|
102 } |
|
103 |
|
104 void CTestCamImgProc::Release() |
|
105 { |
|
106 iRefCount--; |
|
107 if(iRefCount == 0) |
|
108 { |
|
109 iOwner.iImgProcImpl = NULL; |
|
110 delete this; |
|
111 } |
|
112 } |
|
113 |
|
114 void CTestCamImgProc::ConstructL() |
|
115 { |
|
116 iSupportedTranformations.Reset(); |
|
117 iSupportedTranformations.AppendL(KUidECamEventImageProcessingAdjustBrightness); |
|
118 iSupportedTranformations.AppendL(KUidECamEventImageProcessingAdjustContrast); |
|
119 |
|
120 iActiveTransformations.Reset(); |
|
121 |
|
122 iActiveTransformSequence.Reset(); |
|
123 } |
|
124 |
|
125 void CTestCamImgProc::GetSupportedTransformationsL(RArray<TUid>& aTransformations) const |
|
126 { |
|
127 aTransformations.Reset(); |
|
128 for(TInt index=0; index < iSupportedTranformations.Count(); index++) |
|
129 { |
|
130 aTransformations.AppendL(iSupportedTranformations[index]); |
|
131 } |
|
132 } |
|
133 |
|
134 void CTestCamImgProc::GetActiveTransformationsL(RArray<TUid>& aTransformations) const |
|
135 { |
|
136 aTransformations.Reset(); |
|
137 for(TInt index=0; index < iActiveTransformations.Count(); index++) |
|
138 { |
|
139 aTransformations.AppendL(iActiveTransformations[index]); |
|
140 } |
|
141 } |
|
142 |
|
143 void CTestCamImgProc::GetTransformationSupportedValuesL(TUid aTransformation, RArray<TInt>& aValues, TValueInfo& aInfo) const |
|
144 { |
|
145 TInt err = iActiveTransformations.Find(aTransformation); |
|
146 if(err == KErrNotFound) |
|
147 { |
|
148 User::Leave(err); |
|
149 } |
|
150 |
|
151 switch(aTransformation.iUid) |
|
152 { |
|
153 case KUidECamEventImageProcessingAdjustBrightnessUidValue: |
|
154 { |
|
155 aInfo = EContinuousRangeMinMax; |
|
156 aValues.Reset(); |
|
157 aValues.AppendL(KMinBrightness); |
|
158 aValues.AppendL(KMaxBrightness); |
|
159 break; |
|
160 } |
|
161 |
|
162 case KUidECamEventImageProcessingAdjustContrastUidValue: |
|
163 { |
|
164 aInfo = EContinuousRangeMinMax; |
|
165 aValues.Reset(); |
|
166 aValues.AppendL(KMinContrast); |
|
167 aValues.AppendL(KMaxContrast); |
|
168 break; |
|
169 } |
|
170 |
|
171 default: |
|
172 User::Leave(KErrNotSupported); |
|
173 } |
|
174 } |
|
175 |
|
176 TInt CTestCamImgProc::TransformationValue(TUid aTransformation) const |
|
177 { |
|
178 switch(aTransformation.iUid) |
|
179 { |
|
180 case KUidECamEventImageProcessingAdjustBrightnessUidValue: |
|
181 { |
|
182 return iOwner.iImgProcBrightness; |
|
183 } |
|
184 |
|
185 case KUidECamEventImageProcessingAdjustContrastUidValue: |
|
186 { |
|
187 return iOwner.iImgProcContrast; |
|
188 } |
|
189 |
|
190 default: |
|
191 return 0; |
|
192 } |
|
193 } |
|
194 |
|
195 TInt CTestCamImgProc::GetTransformationValue(TUid aTransformation, TInt& aTransformationValue) const |
|
196 { |
|
197 switch(aTransformation.iUid) |
|
198 { |
|
199 case KUidECamEventImageProcessingAdjustBrightnessUidValue: |
|
200 { |
|
201 aTransformationValue = iOwner.iImgProcBrightness; |
|
202 return KErrNone; |
|
203 } |
|
204 |
|
205 case KUidECamEventImageProcessingAdjustContrastUidValue: |
|
206 { |
|
207 aTransformationValue = iOwner.iImgProcContrast; |
|
208 return KErrNone; |
|
209 } |
|
210 |
|
211 default: |
|
212 return KErrNotSupported; |
|
213 } |
|
214 } |
|
215 |
|
216 void CTestCamImgProc::SetTransformationValue(TUid aTransformation, TInt aValue) |
|
217 { |
|
218 TInt eventError = iOwner.CheckReserveAndPower(); |
|
219 |
|
220 if(eventError == KErrNone) |
|
221 { |
|
222 switch(aTransformation.iUid) |
|
223 { |
|
224 case KUidECamEventImageProcessingAdjustBrightnessUidValue: |
|
225 { |
|
226 if(aValue < KMinBrightness) |
|
227 { |
|
228 iOwner.iImgProcBrightness = KMinBrightness; |
|
229 } |
|
230 else |
|
231 { |
|
232 if(aValue > KMaxBrightness) |
|
233 { |
|
234 iOwner.iImgProcBrightness = KMaxBrightness; |
|
235 } |
|
236 else |
|
237 { |
|
238 iOwner.iImgProcBrightness = aValue; |
|
239 } |
|
240 } |
|
241 break; |
|
242 } |
|
243 |
|
244 case KUidECamEventImageProcessingAdjustContrastUidValue: |
|
245 { |
|
246 if(aValue < KMinContrast) |
|
247 { |
|
248 iOwner.iImgProcContrast = KMinContrast; |
|
249 } |
|
250 else |
|
251 { |
|
252 if(aValue > KMaxContrast) |
|
253 { |
|
254 iOwner.iImgProcContrast = KMaxContrast; |
|
255 } |
|
256 else |
|
257 { |
|
258 iOwner.iImgProcContrast = aValue; |
|
259 } |
|
260 } |
|
261 break; |
|
262 } |
|
263 |
|
264 default: |
|
265 eventError = KErrNotSupported; |
|
266 } |
|
267 } |
|
268 |
|
269 if(eventError == KErrNone) |
|
270 { |
|
271 eventError = iActiveTransformations.Find(aTransformation); |
|
272 |
|
273 if(eventError == KErrNotFound) |
|
274 { |
|
275 eventError = iActiveTransformations.Append(aTransformation); |
|
276 |
|
277 if(eventError == KErrNone) |
|
278 { |
|
279 if(IsTransform(aTransformation)) |
|
280 { |
|
281 eventError = iActiveTransformSequence.Append(aTransformation); |
|
282 } |
|
283 } |
|
284 } |
|
285 else |
|
286 { |
|
287 eventError = KErrNone; |
|
288 } |
|
289 } |
|
290 |
|
291 TECAMEvent ecamevent(aTransformation, eventError); |
|
292 |
|
293 iOwner.iECamEvent = ecamevent; |
|
294 iOwner.iHandleEventAsync.CallBack(); |
|
295 } |
|
296 |
|
297 void CTestCamImgProc::GetActiveTransformSequenceL(RArray<TUid>& aTransformSequence) const |
|
298 { |
|
299 aTransformSequence.Reset(); |
|
300 for(TInt index=0; index < iActiveTransformSequence.Count(); index++) |
|
301 { |
|
302 aTransformSequence.AppendL(iActiveTransformSequence[index]); |
|
303 } |
|
304 } |
|
305 |
|
306 void CTestCamImgProc::SetActiveTransformSequenceL(RArray<TUid>& aTransformSequence) |
|
307 { |
|
308 TInt err = KErrNone; |
|
309 for(TInt index=0; index < aTransformSequence.Count(); index++) |
|
310 { |
|
311 err = iActiveTransformations.Find(aTransformSequence[index]); |
|
312 if(err == KErrNotFound) |
|
313 { |
|
314 User::Leave(err); |
|
315 } |
|
316 } |
|
317 |
|
318 iActiveTransformSequence.Reset(); |
|
319 for(TInt index=0; index < aTransformSequence.Count(); index++) |
|
320 { |
|
321 iActiveTransformSequence.AppendL(aTransformSequence[index]); |
|
322 } |
|
323 } |
|
324 |
|
325 void CTestCamImgProc::SetSourceRect(const TRect& /*aRect*/) |
|
326 { |
|
327 return; |
|
328 } |
|
329 |
|
330 void CTestCamImgProc::GetSourceRect(TRect& /*aRect*/) const |
|
331 { |
|
332 return; |
|
333 } |
|
334 |
|
335 void CTestCamImgProc::GetConcurrentColorSwappingsSupportedL(TInt& /*aConcurrentColorSwappingSupported*/) const |
|
336 { |
|
337 User::Leave(KErrNotSupported); |
|
338 } |
|
339 |
|
340 void CTestCamImgProc::GetColorSwapCapabilitiesL(TInt /*aIndex*/, CCamera::CCameraImageProcessing::TColorOperationCapabilities& /*aColorSwapCapabilities*/) const |
|
341 { |
|
342 User::Leave(KErrNotSupported); |
|
343 } |
|
344 |
|
345 void CTestCamImgProc::SetColorSwapEntry(TInt aIndex, const CCamera::CCameraImageProcessing::TColorOperationEntry& /*aColorSwapParameters*/) |
|
346 { |
|
347 TECAMEvent2 ecamevent2(KUidECamEventCIPSetColorSwapEntry, KErrNotSupported, aIndex); |
|
348 |
|
349 iOwner.iECamEvent2 = ecamevent2; |
|
350 iOwner.iHandleEvent2Async.CallBack(); |
|
351 } |
|
352 |
|
353 void CTestCamImgProc::RemoveColorSwapEntry(TInt aIndex) |
|
354 { |
|
355 TECAMEvent2 ecamevent2(KUidECamEventCIPRemoveColorSwapEntry, KErrNotSupported, aIndex); |
|
356 |
|
357 iOwner.iECamEvent2 = ecamevent2; |
|
358 iOwner.iHandleEvent2Async.CallBack(); |
|
359 } |
|
360 |
|
361 void CTestCamImgProc::GetColorSwapEntryL(TInt /*aIndex*/, CCamera::CCameraImageProcessing::TColorOperationEntry& /*aColorSwapParameters*/) const |
|
362 { |
|
363 User::Leave(KErrNotSupported); |
|
364 } |
|
365 |
|
366 void CTestCamImgProc::StartColorSwapping() |
|
367 { |
|
368 TECAMEvent ecamevent(KUidECamEventCIPStartColorSwap, KErrNotSupported); |
|
369 |
|
370 iOwner.iECamEvent = ecamevent; |
|
371 iOwner.iHandleEventAsync.CallBack(); |
|
372 } |
|
373 |
|
374 void CTestCamImgProc::CancelColorSwappingL() |
|
375 { |
|
376 User::Leave(KErrNotSupported); |
|
377 } |
|
378 |
|
379 void CTestCamImgProc::GetConcurrentColorAccentSupportedL(TInt& /*aConcurrentColorAccentSupported*/) const |
|
380 { |
|
381 User::Leave(KErrNotSupported); |
|
382 } |
|
383 |
|
384 void CTestCamImgProc::GetColorAccentCapabilitiesL(TInt /*aIndex*/, CCamera::CCameraImageProcessing::TColorOperationCapabilities& /*aColorAccentCapabilities*/) const |
|
385 { |
|
386 User::Leave(KErrNotSupported); |
|
387 } |
|
388 |
|
389 void CTestCamImgProc::SetColorAccentEntry(TInt aIndex, const CCamera::CCameraImageProcessing::TColorOperationEntry& /*aColorAccentParameters*/) |
|
390 { |
|
391 TECAMEvent2 ecamevent2(KUidECamEventCIPSetColorAccentEntry, KErrNotSupported, aIndex); |
|
392 |
|
393 iOwner.iECamEvent2 = ecamevent2; |
|
394 iOwner.iHandleEvent2Async.CallBack(); |
|
395 } |
|
396 |
|
397 void CTestCamImgProc::RemoveColorAccentEntry(TInt aIndex) |
|
398 { |
|
399 TECAMEvent2 ecamevent2(KUidECamEventCIPRemoveColorAccentEntry, KErrNotSupported, aIndex); |
|
400 |
|
401 iOwner.iECamEvent2 = ecamevent2; |
|
402 iOwner.iHandleEvent2Async.CallBack(); |
|
403 } |
|
404 |
|
405 void CTestCamImgProc::GetColorAccentEntryL(TInt /*aIndex*/, CCamera::CCameraImageProcessing::TColorOperationEntry& /*aColorAccentParameters*/) const |
|
406 { |
|
407 User::Leave(KErrNotSupported); |
|
408 } |
|
409 |
|
410 void CTestCamImgProc::StartColorAccent() |
|
411 { |
|
412 TECAMEvent ecamevent(KUidECamEventCIPStartColorAccent, KErrNotSupported); |
|
413 |
|
414 iOwner.iECamEvent = ecamevent; |
|
415 iOwner.iHandleEventAsync.CallBack(); |
|
416 } |
|
417 |
|
418 void CTestCamImgProc::CancelColorAccentL() |
|
419 { |
|
420 User::Leave(KErrNotSupported); |
|
421 } |
|
422 |
|
423 TBool CTestCamImgProc::IsTransform(TUid aTransformation) |
|
424 { |
|
425 switch(aTransformation.iUid) |
|
426 { |
|
427 //fall through |
|
428 case KUidECamEventImageProcessingTransformCropUidValue: |
|
429 case KUidECamEventImageProcessingTransformRotateUidValue: |
|
430 case KUidECamEventImageProcessingTransformMirrorUidValue: |
|
431 case KUidECamEventImageProcessingTransformScaleUidValue: |
|
432 case KUidECamEventImageProcessingSourceRectUidValue: |
|
433 case KUidECamEventImageProcessingNoiseReductionUidValue: |
|
434 case KUidECamEventImageProcessingGlareRemovalUidValue: |
|
435 { |
|
436 return ETrue; |
|
437 } |
|
438 default: |
|
439 return EFalse; |
|
440 } |
|
441 } |