|
1 /* |
|
2 * Copyright (c) 2006-2008 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __BITMAPTILER_H__ |
|
20 #define __BITMAPTILER_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32def.h> |
|
24 |
|
25 class CMaskedBitmap; |
|
26 class TSrcScanLine; |
|
27 class TSrcScanLineMasked; |
|
28 class TSrcScanLineAlpha; |
|
29 |
|
30 class TFastWrapUtil |
|
31 { |
|
32 public: |
|
33 TFastWrapUtil() {} |
|
34 TFastWrapUtil( const TPoint& aPt, TInt aWidth, TInt aHeight ) |
|
35 : iOrig( aPt ), iDelta( aPt ), iSrcWidth( aWidth ), iSrcHeight( aHeight ) {} |
|
36 void Set( const TPoint& aPt, TInt aWidth, TInt aHeight ) { iOrig = aPt; iDelta = aPt; iSrcWidth = aWidth, iSrcHeight = aHeight; } |
|
37 inline void NextLine(); |
|
38 inline void JumpLines( TInt aSteps ); |
|
39 inline void operator++() { if( ++iDelta.iX == iSrcWidth ) iDelta.iX = iOrig.iX; } |
|
40 inline const TPoint& operator*() const { return iDelta; } |
|
41 inline void operator+=( TInt aSteps ); |
|
42 |
|
43 private: |
|
44 TPoint iOrig; |
|
45 TPoint iDelta; |
|
46 TInt iSrcWidth, iSrcHeight; |
|
47 }; |
|
48 |
|
49 class CScanLineFetcher : public CBase |
|
50 { |
|
51 public: |
|
52 CScanLineFetcher( CMaskedBitmap* aImage, TInt aStartPos, TInt aStartLine ); |
|
53 |
|
54 virtual ~CScanLineFetcher() {} |
|
55 virtual void Fetch( TSrcScanLine& ) = 0; |
|
56 virtual void Fetch( TSrcScanLineMasked& ) = 0; |
|
57 virtual void Fetch( TSrcScanLineAlpha& aScanLine ) = 0; |
|
58 |
|
59 void operator++(); |
|
60 void operator+=( TInt aSteps ); |
|
61 void operator=( TInt aLine ) { iLine = aLine; } |
|
62 |
|
63 protected: |
|
64 CMaskedBitmap* iImage; |
|
65 TInt iLine; |
|
66 TInt iOffsetX; |
|
67 TFastWrapUtil iWrap; |
|
68 |
|
69 // scanline data |
|
70 TUint16* iBmpLine; |
|
71 TUint16* iMskLine; |
|
72 TInt iBmpLineSize; |
|
73 TInt iMskLineSize; |
|
74 }; |
|
75 |
|
76 class CCompressedScanLineFetcher : public CScanLineFetcher |
|
77 { |
|
78 public: |
|
79 static CCompressedScanLineFetcher* NewL( CMaskedBitmap* aImage, TInt aStartPos, TInt aStartLine ); |
|
80 |
|
81 CCompressedScanLineFetcher( CMaskedBitmap* aImage, TInt aStartPos, TInt aStartLine ); |
|
82 ~CCompressedScanLineFetcher(); |
|
83 void ConstructL(); |
|
84 |
|
85 // composite scanlines |
|
86 void Fetch( TSrcScanLine& ); |
|
87 void Fetch( TSrcScanLineMasked& ); |
|
88 void Fetch( TSrcScanLineAlpha& aScanLine ); |
|
89 }; |
|
90 |
|
91 class CFastScanLineFetcher : public CScanLineFetcher |
|
92 { |
|
93 public: |
|
94 static CFastScanLineFetcher* NewL( CMaskedBitmap* aImage, TInt aStartPos, TInt aStartLine ); |
|
95 |
|
96 CFastScanLineFetcher( CMaskedBitmap* aImage, TInt aStartPos, TInt aStartLine ); |
|
97 ~CFastScanLineFetcher(); |
|
98 void ConstructL(); |
|
99 |
|
100 // composite scanlines |
|
101 void Fetch( TSrcScanLine& ); |
|
102 void Fetch( TSrcScanLineMasked& ); |
|
103 void Fetch( TSrcScanLineAlpha& aScanLine ); |
|
104 }; |
|
105 |
|
106 // a 16-bit scanline |
|
107 class TSrcScanLine |
|
108 { |
|
109 public: |
|
110 TSrcScanLine() |
|
111 : iSrcLine( 0 ), iPos( 0 ) {} |
|
112 void Set( TUint16* aLine, TInt aStart ) { iSrcLine = aLine; iPos = aStart; } |
|
113 inline void operator++() { iPos++; } |
|
114 inline void operator+=( TInt aSteps ) { iPos+=aSteps; } |
|
115 inline void operator=( TInt aPos ) { iPos = aPos; } |
|
116 |
|
117 inline void Mix( TUint16* aTarget ); |
|
118 inline void Mix( TUint32* aTarget ); |
|
119 |
|
120 protected: |
|
121 TUint16* iSrcLine; |
|
122 TInt iPos; |
|
123 }; |
|
124 |
|
125 // a 16-bit 2-bit masked scanline |
|
126 class TSrcScanLineMasked |
|
127 { |
|
128 public: |
|
129 TSrcScanLineMasked() |
|
130 : iSrcLine(0), iSrcMask(0), iPos(0) {} |
|
131 void Set( TUint16* aLine, TUint16* aMask, TInt aStart ) { iSrcLine = aLine; iSrcMask = aMask; iPos = aStart; } |
|
132 inline void operator++() { iPos++; } |
|
133 inline void operator+=( TInt aStep ) { iPos+=aStep; } |
|
134 inline void operator=( TInt aPos ) { iPos = aPos; } |
|
135 inline void Mix( TUint16* aTarget ); |
|
136 inline void Mix( TUint32* aTarget ); |
|
137 |
|
138 protected: |
|
139 TUint16* iSrcLine; |
|
140 TUint16* iSrcMask; |
|
141 TInt iPos; |
|
142 }; |
|
143 |
|
144 // a 16-bit 8-bit alpha scanline |
|
145 class TSrcScanLineAlpha |
|
146 { |
|
147 public: |
|
148 TSrcScanLineAlpha() |
|
149 : iSrcLine(0), iAlpha(0), iPos(0) {} |
|
150 void Set( TUint16* aLine, TUint8* aAlpha, TInt aStart) { iSrcLine = aLine; iAlpha = aAlpha; iPos = aStart; } |
|
151 inline void operator++() { iPos++; } |
|
152 inline void operator+=( TInt aStep ) { iPos += aStep; } |
|
153 inline void operator=( TInt aPos ) { iPos = aPos; } |
|
154 inline void Mix( TUint16* aTarget ); |
|
155 inline void Mix( TUint32* aTarget ); |
|
156 |
|
157 protected: |
|
158 TUint16* iSrcLine; |
|
159 TUint8* iAlpha; |
|
160 TInt iPos; |
|
161 }; |
|
162 |
|
163 template <class S, typename T> |
|
164 class TScanLineTiler |
|
165 { |
|
166 public: |
|
167 TScanLineTiler( TInt aTrgWidth, TInt aOffsetX ) |
|
168 : iTrgWidth( aTrgWidth ), iOffsetX( aOffsetX ) { } |
|
169 void MixLine( T& aTarget, S& aSrcLine, TFastWrapUtil& aWrap ); |
|
170 private: |
|
171 TInt iTrgWidth; |
|
172 TInt iOffsetX; |
|
173 }; |
|
174 |
|
175 template <class S, typename T> |
|
176 void TileBitmap( T& aTarget, TInt aStride, CScanLineFetcher& aFetcher, TScanLineTiler<S, T>& aTiler, |
|
177 TInt aTrgHeight, TInt aSrcWidth, TInt aSrcHeight, const TPoint& aOffset ); |
|
178 |
|
179 // inline functions |
|
180 #include "BitmapTiler.inl" |
|
181 |
|
182 #endif //!__BITMAPTILER_H__ |