|
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 #ifndef IMAGEPLAYER_H |
|
17 #define IMAGEPLAYER_H |
|
18 |
|
19 /** @file |
|
20 @internalComponent */ |
|
21 |
|
22 class CFbsBitmap; |
|
23 |
|
24 /** |
|
25 Synchronously called upon next image frame |
|
26 */ |
|
27 class MImagePlayerObserver |
|
28 { |
|
29 public: |
|
30 virtual void OnPlayEvent(TInt aErrorCode, TUint aEvent, CFbsBitmap* aFrame, CFbsBitmap* aMask)=0; |
|
31 }; |
|
32 |
|
33 /** |
|
34 Provides abstraction layer over the CImageDecoder, see design document ICL_Design_Generic_ImgDisplPlugin.doc |
|
35 for more detailed description. |
|
36 */ |
|
37 class CImagePlayer: public CActive |
|
38 { |
|
39 public: |
|
40 enum |
|
41 { |
|
42 KNoFrameLimit =0 // means that player should play (decode) all the image frames |
|
43 }; |
|
44 CImagePlayer(MImagePlayerObserver& aObserver); |
|
45 ~CImagePlayer(); |
|
46 |
|
47 void Play(CImageDecoder& aDecoder, TDisplayMode aDisplayMode, TInt aFrameLimit=KNoFrameLimit); |
|
48 void Setup(const TSize& aDestSize,TInt aMaxReduction, TInt aMinReduction); |
|
49 void Pause(); |
|
50 void Resume(); |
|
51 |
|
52 inline const TFrameInfo& CurrentFrameInfo() const; |
|
53 TSize OriginalFrameSize() const; |
|
54 protected: |
|
55 void RunAgain(); |
|
56 inline CFbsBitmap* FrameBitmap(); |
|
57 inline CFbsBitmap* MaskBitmap(); |
|
58 void CreateBitmapsL(); |
|
59 void MergeFrameL(); |
|
60 static void CreateBitmapsL(CFbsBitmap*& aFrame, CFbsBitmap** aMask, const TSize& aSize, TDisplayMode aFrameMode); |
|
61 // from the CActive |
|
62 void RunL(); |
|
63 void DoCancel(); |
|
64 TInt RunError(TInt aError); |
|
65 |
|
66 private: |
|
67 MImagePlayerObserver& iObserver; |
|
68 TSize iDestSize; |
|
69 TInt iMaxReduction; |
|
70 TInt iMinReduction; |
|
71 TInt iFrameLimitToDecode; |
|
72 CImageDecoder* iDecoder; // not owned |
|
73 CFbsBitmap* iFrame; // owned |
|
74 CFbsBitmap* iMask; // owned |
|
75 const TFrameInfo* iCurrentFrameInfo; // not owned |
|
76 TInt iCurrentReduction; |
|
77 TBool iUseTempBitmap; // temporary bitmaps are used in case of animed GIFs to have precomposed animation done |
|
78 CFbsBitmap* iTmpFrame; // owned |
|
79 CFbsBitmap* iTmpMask; // owned |
|
80 TDisplayMode iDisplayMode; |
|
81 TInt iFrameNumber; |
|
82 TBool iIsPaused; // flag to indicate that all the subsequent operations should be paused until further notice |
|
83 TBool iNeedRunAfterResume;// if the AO needs run after resume (i.e. if it was "paused" while being active) |
|
84 TBool iIsAnimationSubframe; // indicates if the frame being decoded is a frame of animated GIF |
|
85 enum TState |
|
86 { |
|
87 EIdle, |
|
88 EDecoding, |
|
89 } iState; |
|
90 }; |
|
91 |
|
92 #include "ImagePlayer.inl" |
|
93 |
|
94 #endif // ndef IMAGEPLAYER_H |
|
95 |
|
96 |