|
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 "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: Expands basic effect set. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <fbs.h> |
|
21 |
|
22 #include "AknsRlExpand.h" |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CAknsRlScanline::CAknsRlScanline |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CAknsRlScanline::CAknsRlScanline(): |
|
31 iSize( 0 ), iPitch( 0 ), iMemOwned( EFalse ), iMem32( NULL ) |
|
32 {} |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CAknsRlScanline::~CAknsRlScanline |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CAknsRlScanline::~CAknsRlScanline() |
|
39 { |
|
40 DeleteMem(); //lint !e1551 No exception thrown |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CAknsRlScanline::DeleteMem |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 void CAknsRlScanline::DeleteMem() |
|
48 { |
|
49 if( iMemOwned ) |
|
50 { |
|
51 delete [] iMem32; |
|
52 } |
|
53 |
|
54 iMem32 = NULL; |
|
55 iMemOwned = EFalse; |
|
56 iSize = 0; |
|
57 iPitch = 0; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CAknsRlScanline::BytesToDwords |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 TUint32 CAknsRlScanline::BytesToDwords( TUint32 aBytes ) const |
|
65 { |
|
66 // Smallest number of dwords that can contain all of the bytes |
|
67 return ( aBytes + 3 ) >> 2; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CAknsRlScanline::AllocateL |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void CAknsRlScanline::AllocateL( TUint32 aDwords ) |
|
75 { |
|
76 if( iSize == aDwords && iMemOwned ) |
|
77 { |
|
78 return; // Buffer size already ok |
|
79 } |
|
80 |
|
81 if( iMemOwned ) |
|
82 { |
|
83 delete [] iMem32; |
|
84 } |
|
85 |
|
86 iMem32 = NULL; |
|
87 iMem32 = new TUint32[ aDwords ]; //lint !e119 Quite enough params |
|
88 |
|
89 if( !iMem32 ) |
|
90 { |
|
91 User::Leave( KErrNoMemory ); |
|
92 } |
|
93 |
|
94 iMemOwned = ETrue; |
|
95 iSize = aDwords; |
|
96 iPitch = 0; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CAknsRlScanline::Color8L |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CAknsRlScanline::Color8L( TInt aWidth, TUint8 aValue ) |
|
104 { |
|
105 AllocateL( BytesToDwords( aWidth * sizeof( TUint8 ) ) ); |
|
106 |
|
107 TUint8* mem = (TUint8*) iMem32; |
|
108 for( TInt i=0; i < aWidth; i++ ) |
|
109 mem[i] = aValue; |
|
110 |
|
111 iPitch = -aWidth; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CAknsRlScanline::Color16L |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CAknsRlScanline::Color16L( TInt aWidth, TUint16 aValue ) |
|
119 { |
|
120 AllocateL( BytesToDwords( aWidth * sizeof( TUint16 ) ) ); |
|
121 |
|
122 TUint16* mem = (TUint16*) iMem32; |
|
123 for( TInt i=0; i < aWidth; i++ ) |
|
124 mem[i] = aValue; |
|
125 |
|
126 iPitch = -aWidth; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CAknsRlScanline::Color32L |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CAknsRlScanline::Color32L( TInt aWidth, TUint32 aValue ) |
|
134 { |
|
135 AllocateL( aWidth ); |
|
136 |
|
137 for( TInt i=0; i < aWidth; i++ ) |
|
138 iMem32[i] = aValue; |
|
139 |
|
140 iPitch = -aWidth; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CAknsRlScanline::Bitmap8L |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CAknsRlScanline::Bitmap8L( TInt aWidth, const CFbsBitmap& aBitmap ) |
|
148 { |
|
149 DeleteMem(); |
|
150 |
|
151 iMem32 = aBitmap.DataAddress(); //lint !e672 !e423 Referencing only |
|
152 // ScanLineLength returns bytes |
|
153 TInt scanW = CFbsBitmap::ScanLineLength( aWidth, aBitmap.DisplayMode()) / |
|
154 TInt( sizeof(TUint8) ); |
|
155 iPitch = scanW - aWidth; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CAknsRlScanline::Bitmap16L |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CAknsRlScanline::Bitmap16L( TInt aWidth, const CFbsBitmap& aBitmap ) |
|
163 { |
|
164 DeleteMem(); |
|
165 |
|
166 iMem32 = aBitmap.DataAddress(); //lint !e672 !e423 Referencing only |
|
167 // ScanLineLength returns bytes |
|
168 TInt scanW = CFbsBitmap::ScanLineLength( aWidth, aBitmap.DisplayMode()) / |
|
169 TInt( sizeof(TUint16) ); |
|
170 iPitch = scanW - aWidth; |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CAknsRlScanline::Bitmap32L |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CAknsRlScanline::Bitmap32L( TInt aWidth, const CFbsBitmap& aBitmap ) |
|
178 { |
|
179 DeleteMem(); |
|
180 |
|
181 iMem32 = aBitmap.DataAddress(); //lint !e672 !e423 Referencing only |
|
182 // ScanLineLength returns bytes |
|
183 TInt scanW = CFbsBitmap::ScanLineLength( aWidth, aBitmap.DisplayMode()) / |
|
184 TInt( sizeof(TUint32) ); |
|
185 iPitch = scanW - aWidth; |
|
186 } |
|
187 |
|
188 // ============================ MEMBER FUNCTIONS =============================== |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // C++ constructor. |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 CAknsRlScanlines::CAknsRlScanlines() |
|
195 {} |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // Destructor. |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 CAknsRlScanlines::~CAknsRlScanlines() |
|
202 {} |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // Symbian two-phased constructor. |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 CAknsRlScanlines* CAknsRlScanlines::NewL() |
|
209 { |
|
210 CAknsRlScanlines* self = new(ELeave) CAknsRlScanlines(); |
|
211 return self; |
|
212 } |
|
213 |
|
214 // End of file |