|
1 // Copyright (c) 2008-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 <imageprocessor/imageprocessoroverlayintf.h> |
|
17 #include <imageprocessor/imageprocessoroverlay.h> |
|
18 #include "imageprocessorimpl.h" |
|
19 #include <imageprocessor/imageprocessor.h> |
|
20 |
|
21 #include <imageframe.h> |
|
22 |
|
23 namespace ImageProcessor |
|
24 { |
|
25 |
|
26 TOverlay::TOverlay(Plugin::MOverlay& aOverlayImpl, CImageProcessorImpl& aImageProcessorImpl) |
|
27 : iIsActive(EFalse), |
|
28 iIsInputSet(EFalse), |
|
29 iImageProcessorImpl(aImageProcessorImpl), |
|
30 iOverlayImpl(aOverlayImpl), |
|
31 iReserved(0) |
|
32 { |
|
33 } |
|
34 |
|
35 /** |
|
36 Gets the supported overlay image formats. |
|
37 |
|
38 @param aFormats |
|
39 The supported formats of ImageProcessor of the overlay image. |
|
40 */ |
|
41 EXPORT_C void TOverlay::SupportedInputFormatsL(RArray<TUid>& aFormats) const |
|
42 { |
|
43 aFormats = iImageProcessorImpl.OverlayInputFormatsL(); |
|
44 } |
|
45 |
|
46 /** |
|
47 Gets the supported overlay image sub formats. |
|
48 |
|
49 @param aFormat |
|
50 The supported format of ImageProcessor of the overlay image. |
|
51 |
|
52 @param aSubFormats |
|
53 The supported sub formats of ImageProcessor of the overlay image. |
|
54 */ |
|
55 EXPORT_C void TOverlay::SupportedInputSubFormatsL(TUid aFormat, RArray<TUid>& aSubFormats) const |
|
56 { |
|
57 iOverlayImpl.SupportedInputSubFormatsL(aFormat, aSubFormats); |
|
58 } |
|
59 |
|
60 /** |
|
61 Gets the supported overlay image frame formats. |
|
62 |
|
63 @param aFormats |
|
64 The supported formats of overlay image of ImageProcessor. |
|
65 */ |
|
66 EXPORT_C void TOverlay::SupportedInputImageFrameFormatsL(RArray<TUid>& aFormats) const |
|
67 { |
|
68 aFormats = iImageProcessorImpl.OverlayInputImageFrameFormatsL(); |
|
69 } |
|
70 |
|
71 /** |
|
72 Gets the supported overlay image display modes. |
|
73 |
|
74 @param aDisplayModes |
|
75 The supported display modes of overlay image of ImageProcessor. |
|
76 */ |
|
77 EXPORT_C void TOverlay::SupportedInputDisplayModesL(RArray<TDisplayMode>& aDisplayModes) const |
|
78 { |
|
79 aDisplayModes = iImageProcessorImpl.OverlayInputDisplayModesL(); |
|
80 } |
|
81 |
|
82 /** |
|
83 Specifies the file name and format of the overlay image. The input must be set only once and |
|
84 after the BeginL() is done. So, the SetInputL() must be called only once between BeginL() |
|
85 and EndL(). |
|
86 |
|
87 @param aFilename |
|
88 The file name of the overlay image. |
|
89 @param aFormat |
|
90 The format of the overlay image. |
|
91 @param aSubFormat |
|
92 The sub format of the overlay image. Currently is not supported, shoud set to KNullUid. |
|
93 |
|
94 @leave KErrNotReady |
|
95 BeginL() hasn't been called to create overlay. |
|
96 |
|
97 @leave KErrNotSupported |
|
98 The aSubFormat is not NULL. |
|
99 |
|
100 @leave KErrArgument |
|
101 The file name length is longer than KMaxFileName. |
|
102 |
|
103 @leave Other |
|
104 A range of system wide error codes. |
|
105 */ |
|
106 EXPORT_C void TOverlay::SetInputL(const TDesC& aFilename, const TUid& aFormat, const TUid& aSubFormat) |
|
107 { |
|
108 iOverlayImpl.SetInputL(aFilename, aFormat, aSubFormat); |
|
109 iImageProcessorImpl.ResetOverlayDrmInput(); |
|
110 iIsInputSet = ETrue; |
|
111 } |
|
112 |
|
113 /** |
|
114 Specifies the file pointer and format of the overlay image. The input must be set only once and |
|
115 after the BeginL() is done. So, the SetInputL() must be called only once between BeginL() |
|
116 and EndL(). |
|
117 |
|
118 @param aFile |
|
119 The pointer to the file of the overlay image. |
|
120 @param aFormat |
|
121 The format of the overlay image. |
|
122 @param aSubFormat |
|
123 The sub format of the overlay image. Currently is not supported, shoud set to KNullUid. |
|
124 |
|
125 @leave KErrNotSupported |
|
126 Always. Current this function is not supported. |
|
127 */ |
|
128 EXPORT_C void TOverlay::SetInputL(RFile& aFile, const TUid& aFormat, const TUid& aSubFormat) |
|
129 { |
|
130 iOverlayImpl.SetInputL(aFile, aFormat, aSubFormat); |
|
131 iImageProcessorImpl.ResetOverlayDrmInput(); |
|
132 iIsInputSet = ETrue; |
|
133 } |
|
134 |
|
135 /** |
|
136 Specifies the file pointer and format of the overlay image which is a DRM protected content source. |
|
137 The input must be set only once and after the BeginL() is done. So, the SetInputL() must be called |
|
138 only once between BeginL() and EndL(). |
|
139 |
|
140 @param aDrmFile |
|
141 The pointer to the DRM file of the overlay image. |
|
142 @param aFormat |
|
143 The format of the overlay image. |
|
144 @param aSubFormat |
|
145 The sub format of the overlay image. Currently is not supported, shoud set to KNullUid. |
|
146 |
|
147 @leave KErrNotSupported |
|
148 Always. Current this function is not supported. |
|
149 */ |
|
150 EXPORT_C void TOverlay::SetInputL(TMMSource& aDrmFile, const TUid& aFormat, const TUid& aSubFormat) |
|
151 { |
|
152 CImageProcessorDrmInput* drmInput = CImageProcessorDrmInput::NewL(aDrmFile); |
|
153 |
|
154 CleanupStack::PushL(drmInput); |
|
155 iOverlayImpl.SetInputL(*(drmInput->Buffer()), aFormat, aSubFormat); |
|
156 CleanupStack::Pop(drmInput); |
|
157 |
|
158 iImageProcessorImpl.ResetOverlayDrmInput(); |
|
159 iImageProcessorImpl.SetOverlayDrmInput(drmInput); |
|
160 iIsInputSet = ETrue; |
|
161 } |
|
162 |
|
163 /** |
|
164 Specifies the buffer pointer and format of the overlay image. The input must be set only once and |
|
165 after the BeginL() is done. So, the SetInputL() must be called only once between BeginL() |
|
166 and EndL(). |
|
167 |
|
168 @param aBuffer |
|
169 The pointer to the buffer of the overlay image. |
|
170 @param aFormat |
|
171 The format of the overlay image. |
|
172 @param aSubFormat |
|
173 The sub format of the overlay image. Currently is not supported, shoud set to KNullUid. |
|
174 |
|
175 @leave KErrNotReady |
|
176 BeginL() hasn't been called to create the overlay. |
|
177 |
|
178 @leave KErrNotSupported |
|
179 The aSubFormat is not NULL. |
|
180 |
|
181 @leave Other |
|
182 A range of system wide error codes. |
|
183 */ |
|
184 EXPORT_C void TOverlay::SetInputL(const TDesC8& aBuffer, const TUid& aFormat, const TUid& aSubFormat) |
|
185 { |
|
186 if (aBuffer.Size() == 0) |
|
187 { |
|
188 User::Leave(KErrArgument); |
|
189 } |
|
190 |
|
191 iOverlayImpl.SetInputL(aBuffer, aFormat, aSubFormat); |
|
192 iImageProcessorImpl.ResetOverlayDrmInput(); |
|
193 iIsInputSet = ETrue; |
|
194 } |
|
195 |
|
196 /** |
|
197 Specifies the bitmap and mask of the overlay image. |
|
198 Source bitmap must not be deleted or changed during lifetime of TOverlay instance. |
|
199 The input must be set only once and after the BeginL() is done. So, the SetInputL() must be called |
|
200 only once between BeginL() and EndL(). |
|
201 |
|
202 @param aBitmap |
|
203 The pointer to the bitmap of the overlay image. |
|
204 @param aMask |
|
205 The mask of the overlay image. Currently not supported, mush be NULL. |
|
206 |
|
207 @leave KErrNotReady |
|
208 BeginL() hasn't been called to create the overlay. |
|
209 |
|
210 @leave KErrNotSupported |
|
211 The aMask is not NULL. |
|
212 |
|
213 @leave Other |
|
214 A range of system wide error codes. |
|
215 */ |
|
216 EXPORT_C void TOverlay::SetInputL(const CFbsBitmap& aBitmap, const CFbsBitmap* aMask) |
|
217 { |
|
218 if (aBitmap.SizeInPixels() == TSize(0,0)) |
|
219 { |
|
220 User::Leave(KErrArgument); |
|
221 } |
|
222 |
|
223 if(aBitmap.Handle()!=0 && aBitmap.ExtendedBitmapType()!=KNullUid) |
|
224 { |
|
225 User::Leave(KErrNotSupported); |
|
226 } |
|
227 |
|
228 if(aMask!=NULL && aMask->Handle()!=0 && aMask->ExtendedBitmapType()!=KNullUid) |
|
229 { |
|
230 User::Leave(KErrNotSupported); |
|
231 } |
|
232 |
|
233 if ((aMask != NULL) && (aMask->SizeInPixels() == TSize(0,0))) |
|
234 { |
|
235 User::Leave(KErrArgument); |
|
236 } |
|
237 |
|
238 iOverlayImpl.SetInputL(aBitmap, aMask); |
|
239 iImageProcessorImpl.ResetOverlayDrmInput(); |
|
240 iIsInputSet = ETrue; |
|
241 } |
|
242 |
|
243 /** |
|
244 Specifies the binary image data of the overlay image. |
|
245 Source image frame buffer must not be deleted or changed during lifetime of TOverlay instance. |
|
246 The input must be set only once and after the BeginL() is done. So, the SetInputL() must be called |
|
247 only once between BeginL() and EndL(). |
|
248 |
|
249 @param aPixelBuffer |
|
250 The CImageFrame type pointer of the overlay image. |
|
251 |
|
252 @leave KErrNotReady |
|
253 BeginL() hasn't been called to create the overlay. |
|
254 |
|
255 @leave Other |
|
256 A range of system wide error codes. |
|
257 */ |
|
258 EXPORT_C void TOverlay::SetInputL(const CImageFrame& aPixelBuffer) |
|
259 { |
|
260 if (aPixelBuffer.FrameSizeInPixels() == TSize(0,0)) |
|
261 { |
|
262 User::Leave(KErrArgument); |
|
263 } |
|
264 |
|
265 iOverlayImpl.SetInputL(aPixelBuffer); |
|
266 iImageProcessorImpl.ResetOverlayDrmInput(); |
|
267 iIsInputSet = ETrue; |
|
268 } |
|
269 |
|
270 /** |
|
271 First step of the three stages overlay BeginL()/SetL()/EndL(). |
|
272 The state of the ImageProcessor is set to EEffectActive. |
|
273 |
|
274 @leave KErrNotReady |
|
275 The state of the ImageProcessor is not EInitialized or overlay is already begun. |
|
276 |
|
277 @leave Other |
|
278 A range of system wide error codes. |
|
279 */ |
|
280 EXPORT_C void TOverlay::BeginL() |
|
281 { |
|
282 __ASSERT_ALWAYS(((iImageProcessorImpl.State() == CImgProcessor::EInitialized) && !iIsActive), User::Leave(KErrNotReady)); |
|
283 iOverlayImpl.BeginL(); |
|
284 iImageProcessorImpl.SetStateL(CImgProcessor::EEffectActive); |
|
285 iIsActive = ETrue; |
|
286 } |
|
287 |
|
288 /** |
|
289 Second step of the three stages overlay BeginL()/SetL()/EndL(). |
|
290 Specifies the size, geometric centre position and angle of the overlay image. |
|
291 |
|
292 @param aSize |
|
293 The size of the overlay image. |
|
294 @param aPosition |
|
295 The position of the overlay image geometric centre. |
|
296 @param aAngle |
|
297 The angle of the overlay image. |
|
298 @leave KErrNotReady |
|
299 BeginL() hasn't been called to create the overlay. |
|
300 @leave KErrArgument |
|
301 Width or height of aSize is less than 0. |
|
302 @leave KErrArgument |
|
303 aSize does not preserve aspect ratio and the plugin implementation |
|
304 supports scaling with aspect ratio preserved only. |
|
305 @leave Other |
|
306 A range of system wide error codes. |
|
307 */ |
|
308 EXPORT_C void TOverlay::SetL(const TSize &aSize, const TPoint &aPosition, TReal32 aAngle) |
|
309 { |
|
310 __ASSERT_ALWAYS(iIsActive, User::Leave(KErrNotReady)); |
|
311 __ASSERT_ALWAYS(((aSize.iWidth > 0) && (aSize.iHeight > 0)), User::Leave(KErrArgument)); |
|
312 iOverlayImpl.SetL(aSize, aPosition, aAngle); |
|
313 } |
|
314 |
|
315 /** |
|
316 Second step of the three stages overlay BeginL()/SetL()/EndL(). |
|
317 Specifies the scale, geometric centre position and angle of the overlay image. |
|
318 |
|
319 @param aScaleX |
|
320 The scale of the overlay image width. |
|
321 @param aScaleY |
|
322 The scale of the overlay image height. |
|
323 @param aPosition |
|
324 The position of the overlay image geometric centre. |
|
325 @param aAngle |
|
326 The angle of the overlay image. |
|
327 @leave KErrArgument |
|
328 Scale is less than 0 or equal to 0 |
|
329 @leave KErrArgument |
|
330 aScaleX and aScaleY are not equal and the plugin implementation supports scaling with |
|
331 aspect ratio preserved only. |
|
332 @leave KErrNotReady |
|
333 BeginL() hasn't been called to create the overlay. |
|
334 @leave Other |
|
335 A range of system wide error codes. |
|
336 */ |
|
337 EXPORT_C void TOverlay::SetL(TReal32 aScaleX, TReal32 aScaleY, const TPoint &aPosition, TReal32 aAngle) |
|
338 { |
|
339 __ASSERT_ALWAYS(iIsActive, User::Leave(KErrNotReady)); |
|
340 __ASSERT_ALWAYS(((aScaleX > 0) && (aScaleY > 0)), User::Leave(KErrArgument)); |
|
341 iOverlayImpl.SetL(aScaleX, aScaleY, aPosition, aAngle); |
|
342 } |
|
343 |
|
344 /** |
|
345 Last step of the three stages overlay BeginL()/SetL()/EndL(). |
|
346 The state of the ImageProcessor is set to EInitialized. |
|
347 |
|
348 @leave KErrNotReady |
|
349 BeginL() hasn't been called to create the overlay. |
|
350 |
|
351 @leave Other |
|
352 A range of system wide error codes. |
|
353 */ |
|
354 EXPORT_C void TOverlay::EndL() |
|
355 { |
|
356 __ASSERT_ALWAYS(((iImageProcessorImpl.State() == CImgProcessor::EEffectActive) && |
|
357 (iIsActive) && |
|
358 (iIsInputSet) && |
|
359 (iImageProcessorImpl.IsInputSet())), User::Leave(KErrNotReady)); |
|
360 |
|
361 |
|
362 iOverlayImpl.EndL(); |
|
363 iImageProcessorImpl.SetStateL(CImgProcessor::EInitialized); |
|
364 iIsActive = EFalse; |
|
365 iIsInputSet = EFalse; |
|
366 iImageProcessorImpl.AppendOverlayDrmInputL(); |
|
367 } |
|
368 |
|
369 /** |
|
370 Resets the overlay parameters and state. |
|
371 |
|
372 @leave Other |
|
373 A range of system wide error codes. |
|
374 */ |
|
375 EXPORT_C void TOverlay::ResetL() |
|
376 { |
|
377 if (iIsActive) |
|
378 { |
|
379 EndL(); |
|
380 iImageProcessorImpl.UndoL(); |
|
381 } |
|
382 |
|
383 iImageProcessorImpl.ResetOverlayDrmInput(); |
|
384 iIsInputSet = EFalse; |
|
385 |
|
386 iOverlayImpl.ResetL(); |
|
387 } |
|
388 |
|
389 /** |
|
390 Gets the geometric centre position of the overlay image. |
|
391 |
|
392 @return The position of the overlay image geometric centre. |
|
393 |
|
394 @leave Other |
|
395 A range of system wide error codes. |
|
396 */ |
|
397 EXPORT_C TPoint TOverlay::PositionL() const |
|
398 { |
|
399 return iOverlayImpl.PositionL(); |
|
400 } |
|
401 |
|
402 /** |
|
403 Gets the size of the overlay image. |
|
404 |
|
405 @return The size of the overlay image. |
|
406 |
|
407 @leave Other |
|
408 A range of system wide error codes. |
|
409 */ |
|
410 EXPORT_C TSize TOverlay::SizeL() const |
|
411 { |
|
412 return iOverlayImpl.SizeL(); |
|
413 } |
|
414 |
|
415 /** |
|
416 Gets the angle of the overlay image. |
|
417 |
|
418 @return The angle of the overlay image. |
|
419 |
|
420 @leave Other |
|
421 A range of system wide error codes. |
|
422 */ |
|
423 EXPORT_C TReal32 TOverlay::AngleL() const |
|
424 { |
|
425 return iOverlayImpl.AngleL(); |
|
426 } |
|
427 |
|
428 /** |
|
429 Gets the scale of the overlay image. |
|
430 |
|
431 @param aScaleX |
|
432 The scale of the overlay image width. |
|
433 @param aScaleY |
|
434 The scale of the overlay image height. |
|
435 |
|
436 @leave Other |
|
437 A range of system wide error codes. |
|
438 */ |
|
439 EXPORT_C void TOverlay::GetScaleL(TReal32& aScaleX, TReal32& aScaleY) const |
|
440 { |
|
441 iOverlayImpl.GetScaleL(aScaleX, aScaleY); |
|
442 } |
|
443 |
|
444 }//namespace ImageProcessor |
|
445 |
|
446 //EOF |