|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of bitmap scaler class |
|
15 * : using Font and Bitmap Server bitmaps. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef CIHLSCALER_H |
|
20 #define CIHLSCALER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <MIHLScaler.h> |
|
24 #include <e32base.h> |
|
25 #include <gdi.h> |
|
26 |
|
27 // Define this to show throughput measurements |
|
28 //#define RD_MEASURE_THROUGHPUT |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CFbsBitmap; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 /** |
|
35 * CIHLScaler |
|
36 * |
|
37 * Implementation of Scaling processor |
|
38 * using Font and Bitmap Server bitmaps. |
|
39 * @lib IHL.lib |
|
40 * @since 3.0 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CIHLScaler ) : public CActive, public MIHLScaler |
|
43 { |
|
44 public: // Constructors and destructor |
|
45 |
|
46 /** |
|
47 * Two-phased constructor. |
|
48 */ |
|
49 static CIHLScaler* NewL( const TUint32 aOptions = 0 ); |
|
50 |
|
51 /* |
|
52 * Virtual destructor. |
|
53 */ |
|
54 virtual ~CIHLScaler(); |
|
55 |
|
56 public: // From base class MIHLScaler |
|
57 |
|
58 /* |
|
59 * From MIHLScaler, see base class header. |
|
60 */ |
|
61 TInt Scale( TRequestStatus& aStatus, |
|
62 const CFbsBitmap& aSrcBitmap, |
|
63 const TRect& aSrcRect, |
|
64 CFbsBitmap& aDstBitmap, |
|
65 const TRect& aDstRect ); |
|
66 |
|
67 /* |
|
68 * From MIHLScaler, see base class header. |
|
69 */ |
|
70 TBool IsBusy() const; |
|
71 |
|
72 /* |
|
73 * From MIHLScaler, see base class header. |
|
74 */ |
|
75 void CancelProcess(); |
|
76 |
|
77 /* |
|
78 * From MIHLScaler, see base class header. |
|
79 */ |
|
80 void SetFilter( MIHFilter* aFilter ); |
|
81 |
|
82 private: // From base class CActive |
|
83 |
|
84 /* |
|
85 * From CActive, see base class header. |
|
86 */ |
|
87 void DoCancel(); |
|
88 |
|
89 /* |
|
90 * From CActive, see base class header. |
|
91 */ |
|
92 void RunL(); |
|
93 |
|
94 /* |
|
95 * From CActive, see base class header. |
|
96 */ |
|
97 TInt RunError( TInt aError ); |
|
98 |
|
99 public: // Internal interface |
|
100 |
|
101 /** |
|
102 * Check if rectangle is inside size. |
|
103 * @since 3.0 |
|
104 * @return ETrue if rectangle is fully inside given area, EFalse if not. |
|
105 */ |
|
106 TBool IsValidRect( const TSize& aSize, const TRect& aRect ); |
|
107 |
|
108 private: // Private methods |
|
109 |
|
110 /* |
|
111 * Initialize process parameters and stepper values. |
|
112 * @return ETrue if only doing scaling (and not rotating) |
|
113 */ |
|
114 TBool InitStepperValues(); |
|
115 |
|
116 /* |
|
117 * Select and initialize fastest possible code path |
|
118 */ |
|
119 |
|
120 void InitCodePath(const TSize& aSrcSize, const TDisplayMode &aSrcMode, const TSize& aDstSize, const TDisplayMode &aDstMode, TBool aOnlyScaling); |
|
121 |
|
122 /* |
|
123 * Process step using nearest neighbour method. |
|
124 */ |
|
125 TBool ProcessNearestNeighbour(); |
|
126 TBool ProcessNearestNeighbour64K(); // For 16-bit non-compressed bitmaps |
|
127 TBool ProcessNearestNeighbour64KScaleOnly(); // For 16-bit non-compressed bitmaps (only scaling) |
|
128 TBool ProcessNearestNeighbour16MX(); // For 32-bit non-compressed bitmaps |
|
129 TBool ProcessNearestNeighbour16MXScaleOnly(); // For 32-bit non-compressed bitmaps (only scaling) |
|
130 |
|
131 /* |
|
132 * Process step using bilinear interpolation method. |
|
133 */ |
|
134 TBool ProcessBilinear(); |
|
135 |
|
136 /* |
|
137 * Complete dummy request. This causes RunL() method to be called. |
|
138 * Needed by state machine. |
|
139 */ |
|
140 void SelfComplete(); |
|
141 |
|
142 /* |
|
143 * Complete client process request. |
|
144 * This causes client RunL() method to be called. |
|
145 */ |
|
146 void RequestComplete( TInt aReason ); |
|
147 |
|
148 private: // Private constructors |
|
149 |
|
150 CIHLScaler( const TUint32 aOptions ); |
|
151 |
|
152 private: // Data |
|
153 |
|
154 // Ref: Process status |
|
155 TRequestStatus* iScalerStatus; |
|
156 TBool iNeedProcess; |
|
157 |
|
158 // Process options |
|
159 const TUint32 iOptions; |
|
160 |
|
161 // Ref: Source bitmap |
|
162 const CFbsBitmap* iSrcBitmap; |
|
163 TRect iSrcRect; |
|
164 |
|
165 // Ref: Destination bitmaps |
|
166 CFbsBitmap* iDstBitmap; |
|
167 TRect iDstRect; |
|
168 |
|
169 // Process position and stepping |
|
170 TPoint iSrcIncrementInner; |
|
171 TPoint iSrcIncrementOuter; |
|
172 TPoint iSrcPos; |
|
173 |
|
174 TInt iDstIncrementInner; |
|
175 TInt iDstIncrementOuter; |
|
176 TPoint iDstPos; |
|
177 |
|
178 TInt iProcessInner; |
|
179 TInt iProcessOuter; |
|
180 TSize iProcessSize; |
|
181 |
|
182 // For fast code path |
|
183 TInt iSrcPitchInPixels; |
|
184 TInt iDstPitchInPixels; |
|
185 TUint32 iScanlinesLeft; |
|
186 TUint32 iScanlinesPerRound; |
|
187 TInt iDstStartOffset; |
|
188 TInt iDstResidualPixels; |
|
189 |
|
190 // Only for measuring scaler throughput |
|
191 #ifdef RD_MEASURE_THROUGHPUT |
|
192 TUint32 iStartTime; |
|
193 #endif |
|
194 |
|
195 /* |
|
196 * Forward process step event to selected processing code path |
|
197 * Called by RunL() method. |
|
198 */ |
|
199 TBool (CIHLScaler::*ProcessingFunc)(); |
|
200 }; |
|
201 |
|
202 #endif // CIHLSCALER_H |
|
203 |
|
204 // End of File |