|
1 // Copyright (c) 2003-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 "BMDRAW.H" |
|
17 #include "BitDrawInterfaceId.h" |
|
18 #include <graphics/lookuptable.h> |
|
19 |
|
20 TInt CDrawUTwentyFourBppBitmap::Construct(TSize aSize) |
|
21 { |
|
22 return Construct(aSize, aSize.iWidth << 2); |
|
23 } |
|
24 |
|
25 TInt CDrawUTwentyFourBppBitmap::Construct(TSize aSize, TInt aStride) |
|
26 { |
|
27 iDispMode = EColor16MU; |
|
28 return CDrawThirtyTwoBppBitmapCommon::Construct(aSize, aStride); |
|
29 } |
|
30 |
|
31 /** |
|
32 MAlphaBlend::WriteRgbAlphaLine() implementation. |
|
33 @see MAlphaBlend::WriteRgbAlphaLine() |
|
34 */ |
|
35 void CDrawUTwentyFourBppBitmap::WriteRgbAlphaLine(TInt aX, TInt aY, TInt aLength, |
|
36 const TUint8* aRgbBuffer, |
|
37 const TUint8* aMaskBuffer, |
|
38 MAlphaBlend::TShadowing aShadowing, |
|
39 CGraphicsContext::TDrawMode /*aDrawMode*/) |
|
40 { |
|
41 // precondition for this function is that the aRgbBuffer lies on a word boundary |
|
42 // Assert checks that the pointer is at a word boundary |
|
43 __ASSERT_DEBUG(!(((TUint)aRgbBuffer) & 0x3), Panic(EScreenDriverPanicInvalidPointer)); |
|
44 |
|
45 DeOrientate(aX,aY); |
|
46 TUint32* pixelPtr = PixelAddress(aX,aY); |
|
47 TUint32* rgbBuffer = (TUint32*)aRgbBuffer; |
|
48 const TInt pixelPtrInc = PixelAddressIncrement(); |
|
49 const TUint8* maskBufferPtrLimit = aMaskBuffer + aLength; |
|
50 |
|
51 if (!(iShadowMode & (EFade | EShadow)) && (iUserDispMode == ENone)) |
|
52 { |
|
53 while (aMaskBuffer < maskBufferPtrLimit) |
|
54 { |
|
55 *pixelPtr = CalcAlphaPixel(*rgbBuffer, *aMaskBuffer, *pixelPtr); |
|
56 aMaskBuffer++; |
|
57 pixelPtr += pixelPtrInc; |
|
58 rgbBuffer++; |
|
59 } |
|
60 } |
|
61 else |
|
62 { |
|
63 while (aMaskBuffer < maskBufferPtrLimit) |
|
64 { |
|
65 TInt mask = *aMaskBuffer++; |
|
66 if (mask) |
|
67 { |
|
68 TInt b = aRgbBuffer[0]; |
|
69 TInt g = aRgbBuffer[1]; |
|
70 TInt r = aRgbBuffer[2]; |
|
71 if(aShadowing == MAlphaBlend::EShdwBefore) |
|
72 { |
|
73 if (iShadowMode & EFade) |
|
74 { |
|
75 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
76 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
77 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
78 } |
|
79 if (iShadowMode & EShadow) |
|
80 { |
|
81 r = (Max(0,r-0x40)); |
|
82 g = (Max(0,g-0x40)); |
|
83 b = (Max(0,b-0x40)); |
|
84 } |
|
85 } |
|
86 if (mask != 0xff) |
|
87 { |
|
88 // (mask * r + (255 - mask) * value) / 255 = |
|
89 // ((257 * mask * (r - value)) >> 16) + value |
|
90 TInt value = *pixelPtr & 0xffffff; |
|
91 mask = (mask << 8) + mask; // mask = mask * 257 |
|
92 TInt v = value >> 16; |
|
93 r = ((mask * (r - v)) >> 16) + v; |
|
94 v = (value >> 8) & 0xff; |
|
95 g = ((mask * (g - v)) >> 16) + v; |
|
96 v = value & 0xff; |
|
97 b = ((mask * (b - v)) >> 16) + v; |
|
98 } |
|
99 if(aShadowing == MAlphaBlend::EShdwAfter) |
|
100 { |
|
101 if (iShadowMode & EFade) |
|
102 { |
|
103 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
104 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
105 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
106 } |
|
107 if (iShadowMode & EShadow) |
|
108 { |
|
109 r = (Max(0,r-0x40)); |
|
110 g = (Max(0,g-0x40)); |
|
111 b = (Max(0,b-0x40)); |
|
112 } |
|
113 } |
|
114 // Convert colour if an incompatible UserDisplayMode is being used |
|
115 CDrawBitmap::MapColorToUserDisplayMode(r,g,b); |
|
116 *pixelPtr = (r<<16) | (g<<8) | b | 0xff000000; |
|
117 } |
|
118 aRgbBuffer += 4; |
|
119 pixelPtr += pixelPtrInc; |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 void CDrawUTwentyFourBppBitmap::ReadLine(TInt aX, TInt aY, TInt aLength, TAny* aBuffer, TDisplayMode aDispMode) const |
|
125 { |
|
126 if (aDispMode == EColor16MAP) |
|
127 { |
|
128 DeOrientate(aX, aY); |
|
129 CDrawThirtyTwoBppBitmapCommon::ReadLine(aX, aY, aLength, aBuffer); |
|
130 |
|
131 //Overwrite unused byte with 0xff to produce valid 16MAP data |
|
132 TUint8* alphaptr = (TUint8*) aBuffer+3; |
|
133 TUint8* bufEnd = (TUint8*) aBuffer + (aLength << 2); |
|
134 while (alphaptr < bufEnd) |
|
135 { |
|
136 *alphaptr = 0xff; |
|
137 alphaptr+=4; |
|
138 } |
|
139 |
|
140 return; |
|
141 } |
|
142 CDrawBitmap::ReadLine(aX, aY, aLength, aBuffer, aDispMode); |
|
143 } |
|
144 |
|
145 void CDrawUTwentyFourBppBitmap::BlendRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor) |
|
146 { |
|
147 const TInt sourceAlpha = aColor.Alpha(); |
|
148 if (sourceAlpha==255)// opaque |
|
149 { |
|
150 WriteRgbMulti(aX,aY,aLength,aHeight,aColor); |
|
151 return; |
|
152 } |
|
153 if (sourceAlpha==0)// transparent |
|
154 return; |
|
155 |
|
156 TUint32* pixelPtr = PixelAddress(aX,aY); |
|
157 TUint32* pixelRowPtrLimit = pixelPtr + (aHeight * iScanLineWords); |
|
158 TUint32* pixelPtrLimit = pixelPtr + aLength; |
|
159 |
|
160 const TUint32 sourceInternal=aColor.Internal(); |
|
161 const TUint32 s_rb = sourceInternal & 0x00FF00FF; |
|
162 const TUint32 s_g = (sourceInternal & 0xFF00) >> 8; |
|
163 const TUint32 mask2 = sourceAlpha | (sourceAlpha << 16); |
|
164 while (pixelPtr < pixelRowPtrLimit) |
|
165 { |
|
166 for (TUint32* tempPixelPtr = pixelPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++) |
|
167 { |
|
168 const TUint32 d = *tempPixelPtr; |
|
169 const TUint32 d_rb = d & 0x00FF00FF; |
|
170 const TUint32 rb = ((((sourceAlpha * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; |
|
171 |
|
172 const TInt d_g = (d & 0xFF00) >> 8; |
|
173 const TInt g = ((sourceAlpha * (s_g - d_g)) >> 8) + d_g; |
|
174 |
|
175 *tempPixelPtr = rb | (g<<8) | 0xff000000; |
|
176 } |
|
177 |
|
178 pixelPtr += iScanLineWords; |
|
179 pixelPtrLimit += iScanLineWords; |
|
180 } |
|
181 } |
|
182 |
|
183 void CDrawUTwentyFourBppBitmap::BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) |
|
184 { |
|
185 TUint32* pixelPtr = PixelAddress(aX,aY); |
|
186 |
|
187 const TUint32* bufferPtrLimit = aBuffer + aLength; |
|
188 const TInt pixelPtrInc = (iOrientation == EOrientationNormal) ? 1 : PixelAddressIncrement(); |
|
189 |
|
190 while (aBuffer < bufferPtrLimit) |
|
191 { |
|
192 if((*aBuffer &0xFF000000) == 0xFF000000) |
|
193 { |
|
194 *pixelPtr = *aBuffer; |
|
195 } |
|
196 else if((*aBuffer & 0xFF000000)) |
|
197 { |
|
198 // specialization of pre-multiplied blending when the destination alpha is always 255 |
|
199 const TUint32 src_rb = *aBuffer & 0x00FF00FF; |
|
200 const TUint32 src_g = *aBuffer & 0x0000FF00; |
|
201 const TUint32 mask = 0x100 - (*aBuffer >> 24); |
|
202 TUint32 dst_rb = *pixelPtr & 0x00FF00FF; |
|
203 TUint32 dst_g = *pixelPtr & 0x0000FF00; |
|
204 dst_rb = (src_rb + ((mask * dst_rb) >> 8)) & 0x00FF00FF; |
|
205 dst_g = (src_g + ((mask * dst_g) >> 8)) & 0x0000FF00; |
|
206 *pixelPtr = 0xFF000000 | dst_rb | dst_g; |
|
207 } |
|
208 |
|
209 aBuffer++; |
|
210 pixelPtr += pixelPtrInc; |
|
211 } |
|
212 } |
|
213 |
|
214 TRgb CDrawUTwentyFourBppBitmap::RgbColor(TUint32 aColor) const |
|
215 { |
|
216 return TRgb::_Color16MU(aColor); |
|
217 } |
|
218 |
|
219 TUint32 CDrawUTwentyFourBppBitmap::Color(const TRgb& aColor) |
|
220 { |
|
221 return aColor._Color16MA() | 0xff000000; |
|
222 } |
|
223 |
|
224 |
|
225 // Copies an EColor64K pixel to an EColor16MU screen |
|
226 FORCEINLINE static void CopyPixel(const TUint16*& aSrcPtr, TUint32*& aDestPtr, TInt aPixelPtrInc, const TUint32* aHighAdd, const TUint16* aLowAdd) |
|
227 { |
|
228 *aDestPtr = aHighAdd[(*aSrcPtr) >> 8] | aLowAdd[(*aSrcPtr) & 0xff]; |
|
229 aDestPtr += aPixelPtrInc; |
|
230 aSrcPtr++; |
|
231 } |
|
232 |
|
233 |
|
234 // Copies two EColor64K pixels to an EColor16MU screen |
|
235 FORCEINLINE static void CopyTwoPixels(const TUint32*& aSrcPtr, TUint32*& aDestPtr, TInt aPixelPtrInc, const TUint32* aHighAdd, const TUint16* aLowAdd) |
|
236 { |
|
237 const TUint16* scanPtr = reinterpret_cast<const TUint16*&>(aSrcPtr); |
|
238 *aDestPtr = aHighAdd[(*scanPtr) >> 8] | aLowAdd[(*scanPtr) & 0xff]; |
|
239 aDestPtr += aPixelPtrInc; |
|
240 scanPtr++; |
|
241 *aDestPtr = aHighAdd[(*scanPtr) >> 8] | aLowAdd[(*scanPtr) & 0xff]; |
|
242 aDestPtr += aPixelPtrInc; |
|
243 aSrcPtr++; |
|
244 } |
|
245 |
|
246 |
|
247 // Copies an EColor16MU pixel to an EColor16MU screen if necessary. |
|
248 FORCEINLINE static void ProcessMaskPixel(const TUint32*& aSrcPtr, const TUint32 aMaskWord, TUint32& aSingleBitMask, TUint32*& aDestPtr, TInt aPixelPtrInc) |
|
249 { |
|
250 if (aMaskWord & aSingleBitMask) |
|
251 { |
|
252 *aDestPtr = *aSrcPtr; |
|
253 } |
|
254 aSrcPtr++; |
|
255 aDestPtr += aPixelPtrInc; |
|
256 aSingleBitMask <<= 1; |
|
257 } |
|
258 |
|
259 |
|
260 // Copies an EColor64K pixel to an EColor16MU screen if necessary. |
|
261 FORCEINLINE static void ProcessMaskPixel(const TUint16*& aSrcPtr, const TUint32 aMaskWord, TUint32& aSingleBitMask, TUint32*& aDestPtr, TInt aPixelPtrInc, const TUint32* aHighAdd, const TUint16* aLowAdd) |
|
262 { |
|
263 if (aMaskWord & aSingleBitMask) |
|
264 { |
|
265 *aDestPtr = aHighAdd[(*aSrcPtr) >> 8] | aLowAdd[(*aSrcPtr) & 0xff]; |
|
266 } |
|
267 aSrcPtr++; |
|
268 aDestPtr += aPixelPtrInc; |
|
269 aSingleBitMask <<= 1; |
|
270 } |
|
271 |
|
272 |
|
273 // Alpha-blends an EColor16MU pixel to an EColor16MU screen using a fixed mask value. |
|
274 FORCEINLINE static void BlendAlphaPixel(const TUint32*& aSrcPtr, const TUint8 aMask, TUint32*& aDestPtr, TInt aPixelPtrInc) |
|
275 { |
|
276 const TUint32 s = *aSrcPtr++; |
|
277 const TUint32 d = *aDestPtr; |
|
278 |
|
279 // (a) (mask * src + (255 - mask) * dest) / 255 This ideal formula |
|
280 // (b) ((mask * (src - dest)) >> 8) + dest A faster approximation to (a) |
|
281 // (c) ((mask * (256 + src - dest) >> 8) + dest - mask Equivalent to (b) but can be used on multiple colors at a time |
|
282 |
|
283 const TUint32 s_rb = s & 0x00FF00FF; |
|
284 const TUint32 d_rb = d & 0x00FF00FF; |
|
285 const TUint32 mask2 = aMask | (aMask << 16); |
|
286 const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; |
|
287 |
|
288 const TInt s_g = (s & 0xFF00) >> 8; |
|
289 const TInt d_g = (d & 0xFF00) >> 8; |
|
290 const TInt g = ((aMask * (s_g - d_g)) >> 8) + d_g; |
|
291 |
|
292 *aDestPtr = rb | (g<<8) | 0xff000000; |
|
293 aDestPtr += aPixelPtrInc; |
|
294 } |
|
295 |
|
296 |
|
297 // Alpha-blends an EColor16MU pixel to an EColor16MU screen if necessary. |
|
298 FORCEINLINE static void ProcessAlphaPixel(const TUint32*& aSrcPtr, const TUint8*& aMaskPtr, TUint32*& aDestPtr, TInt aPixelPtrInc) |
|
299 { |
|
300 const TInt mask = *aMaskPtr++; |
|
301 |
|
302 if (!mask) |
|
303 { |
|
304 // pixel is masked |
|
305 aSrcPtr++; |
|
306 aDestPtr += aPixelPtrInc; |
|
307 } |
|
308 else if (mask == 0xFF) |
|
309 { |
|
310 // pixel is unmasked |
|
311 *aDestPtr = *aSrcPtr++; |
|
312 aDestPtr += aPixelPtrInc; |
|
313 } |
|
314 else |
|
315 { |
|
316 BlendAlphaPixel(aSrcPtr, mask, aDestPtr, aPixelPtrInc); |
|
317 } |
|
318 } |
|
319 |
|
320 |
|
321 // Alpha-blends an EColor64K pixel to an EColor16MU screen using a fixed mask value. |
|
322 FORCEINLINE static void BlendAlphaPixel(const TUint16*& aSrcPtr, const TUint8 aMask, TUint32*& aDestPtr, TInt aPixelPtrInc) |
|
323 { |
|
324 const TUint32 s = *aSrcPtr++; |
|
325 const TUint32 d = *aDestPtr; |
|
326 |
|
327 // convert the source EColor64K red / blue pixels to EColor16MU |
|
328 // the top two bits in EColor64K are used to fill the bottom two bits in EColor16MU |
|
329 |
|
330 const TUint32 s_rb = ((s & 0xF800) << 8) | ((s & 0xE000) << 3) | ((s & 0x1F) << 3) | ((s & 0x1C) >>2); |
|
331 const TUint32 d_rb = d & 0x00FF00FF; |
|
332 const TUint32 mask2 = aMask | (aMask << 16); |
|
333 const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; |
|
334 |
|
335 // convert the source EColor64K green pixel to EColor16MU |
|
336 const TInt s_g = ((s & 0x07E0) >> 3) | ((s & 0x0600) >> 9); |
|
337 const TInt d_g = (d & 0xFF00) >> 8; |
|
338 const TInt g = ((aMask * (s_g - d_g)) >> 8) + d_g; |
|
339 |
|
340 *aDestPtr = rb | (g<<8) | 0xff000000; |
|
341 aDestPtr += aPixelPtrInc; |
|
342 } |
|
343 |
|
344 |
|
345 // Alpha-blends an EColor64K pixel to an EColor16MU screen if necessary. |
|
346 FORCEINLINE static void ProcessAlphaPixel(const TUint16*& aSrcPtr, const TUint8*& aMaskPtr, TUint32*& aDestPtr, TInt aPixelPtrInc, const TUint32* aHighAdd, const TUint16* aLowAdd) |
|
347 { |
|
348 const TInt mask = *aMaskPtr++; |
|
349 |
|
350 if (!mask) |
|
351 { |
|
352 // pixel is masked |
|
353 aSrcPtr++; |
|
354 aDestPtr += aPixelPtrInc; |
|
355 } |
|
356 else if (mask == 0xFF) |
|
357 { |
|
358 // pixel is unmasked |
|
359 CopyPixel(aSrcPtr, aDestPtr, aPixelPtrInc, aHighAdd, aLowAdd); |
|
360 } |
|
361 else |
|
362 { |
|
363 BlendAlphaPixel(aSrcPtr, mask, aDestPtr, aPixelPtrInc); |
|
364 } |
|
365 } |
|
366 |
|
367 |
|
368 /** |
|
369 CDrawUTwentyFourBppBitmap::WriteAlphaLineEx() implementation. |
|
370 @internalTechnology |
|
371 @see MFastBlit::WriteAlphaLineEx() |
|
372 */ |
|
373 void CDrawUTwentyFourBppBitmap::WriteAlphaLineEx(TInt aX, TInt aY, TInt aLength, TInt aSrcX, |
|
374 const TUint32* aSrcPtr, TDisplayMode aSrcFormat, |
|
375 TInt aMaskX, const TUint32* aMaskPtr, |
|
376 MAlphaBlend::TShadowing aShadowing) |
|
377 { |
|
378 // Only certain pixel formats are supported. Caller should check this. |
|
379 __ASSERT_DEBUG(aSrcFormat ==EColor16MU || aSrcFormat ==EColor64K, User::Invariant()); |
|
380 |
|
381 DeOrientate(aX,aY); |
|
382 TUint32* pixelPtr = PixelAddress(aX,aY); |
|
383 const TInt pixelPtrInc = PixelAddressIncrement(); |
|
384 |
|
385 if (aSrcFormat==EColor16MU) |
|
386 { |
|
387 if (!(iShadowMode & EFade) && !(iShadowMode & EShadow) && ((iUserDispMode==ENone) || (iUserDispMode==EColor16MU)) ) |
|
388 { |
|
389 aSrcPtr += aSrcX; |
|
390 const TUint32* maskWordPtr = aMaskPtr + (aMaskX >> 2); |
|
391 const TInt startBit = aMaskX & 0x3; |
|
392 |
|
393 if (startBit) |
|
394 { |
|
395 // Process initial incomplete mask word |
|
396 const TUint32 maskWord = *maskWordPtr++; |
|
397 TInt numPix = Min(aLength, 4 - startBit); // number of pixels to process from the first word of the mask |
|
398 aLength -= numPix; |
|
399 |
|
400 if (!maskWord) |
|
401 { |
|
402 // maskWord is fully masked - skip the pixels |
|
403 aSrcPtr += numPix; |
|
404 pixelPtr += pixelPtrInc * numPix; |
|
405 } |
|
406 else if (maskWord == 0xFFFFFFFF) |
|
407 { |
|
408 // maskWord is fully unmasked - copy the pixels |
|
409 while (numPix--) |
|
410 { |
|
411 *pixelPtr = *aSrcPtr++; |
|
412 pixelPtr += pixelPtrInc; |
|
413 } |
|
414 } |
|
415 else |
|
416 { |
|
417 // At least one of the pixels needs to be blended |
|
418 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord); |
|
419 maskPtr8 += startBit; |
|
420 while (numPix--) |
|
421 { |
|
422 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc); |
|
423 } |
|
424 } |
|
425 } |
|
426 |
|
427 TInt numMaskWords = aLength >> 2; |
|
428 aLength &= 0x3; |
|
429 while (numMaskWords--) |
|
430 { |
|
431 // Process a complete mask word - 4 pixels |
|
432 const TUint32 maskWord = *maskWordPtr++; |
|
433 |
|
434 if (!maskWord) |
|
435 { |
|
436 // maskWord is fully masked - skip 4 pixels |
|
437 aSrcPtr += 4; |
|
438 pixelPtr += pixelPtrInc << 2; |
|
439 } |
|
440 else if (maskWord == 0xFFFFFFFF) |
|
441 { |
|
442 // maskWord is fully unmasked - copy 4 pixels |
|
443 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
444 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
445 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
446 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
447 } |
|
448 else |
|
449 { |
|
450 // At least one of the 4 pixels needs to be blended |
|
451 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord); |
|
452 |
|
453 if (maskPtr8[0] && (maskPtr8[0] != 0xFF) && |
|
454 maskPtr8[1] && (maskPtr8[1] != 0xFF) && |
|
455 maskPtr8[2] && (maskPtr8[2] != 0xFF) && |
|
456 maskPtr8[3] && (maskPtr8[3] != 0xFF)) |
|
457 { |
|
458 // Blend all 4 pixels inline |
|
459 BlendAlphaPixel(aSrcPtr, maskPtr8[0], pixelPtr, pixelPtrInc); |
|
460 BlendAlphaPixel(aSrcPtr, maskPtr8[1], pixelPtr, pixelPtrInc); |
|
461 BlendAlphaPixel(aSrcPtr, maskPtr8[2], pixelPtr, pixelPtrInc); |
|
462 BlendAlphaPixel(aSrcPtr, maskPtr8[3], pixelPtr, pixelPtrInc); |
|
463 } |
|
464 else |
|
465 { |
|
466 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc); |
|
467 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc); |
|
468 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc); |
|
469 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc); |
|
470 } |
|
471 } |
|
472 } |
|
473 |
|
474 if (aLength) |
|
475 { |
|
476 const TUint32 maskWord = *maskWordPtr; |
|
477 if (!maskWord) |
|
478 { |
|
479 // maskWord is fully masked - skip the pixels |
|
480 return; |
|
481 } |
|
482 if (maskWord == 0xFFFFFFFF) |
|
483 { |
|
484 // maskWord is fully unmasked - copy the pixels |
|
485 while (aLength--) |
|
486 { |
|
487 *pixelPtr = *aSrcPtr++; |
|
488 pixelPtr += pixelPtrInc; |
|
489 } |
|
490 } |
|
491 else |
|
492 { |
|
493 // At least one of the pixels needs to be blended |
|
494 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord); |
|
495 while (aLength--) |
|
496 { |
|
497 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc); |
|
498 } |
|
499 } |
|
500 } |
|
501 } |
|
502 else |
|
503 { |
|
504 // Non-optimised path including shadowing and UserDisplayMode conversion |
|
505 const TUint8* srcPtr8 = reinterpret_cast<const TUint8*>(aSrcPtr + aSrcX); |
|
506 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(aMaskPtr) + aMaskX; |
|
507 |
|
508 while (aLength--) |
|
509 { |
|
510 TInt mask = *maskPtr8++; |
|
511 if (mask) |
|
512 { |
|
513 TInt b = srcPtr8[0]; |
|
514 TInt g = srcPtr8[1]; |
|
515 TInt r = srcPtr8[2]; |
|
516 if(aShadowing == MAlphaBlend::EShdwBefore) |
|
517 { |
|
518 if (iShadowMode & EFade) |
|
519 { |
|
520 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
521 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
522 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
523 } |
|
524 if (iShadowMode & EShadow) |
|
525 { |
|
526 r = (Max(0,r-0x40)); |
|
527 g = (Max(0,g-0x40)); |
|
528 b = (Max(0,b-0x40)); |
|
529 } |
|
530 } |
|
531 if (mask != 0xff) |
|
532 { |
|
533 // (mask * r + (255 - mask) * value) / 255 = |
|
534 // ((257 * mask * (r - value)) >> 16) + value |
|
535 TInt value = *pixelPtr & 0xffffff; |
|
536 mask = (mask << 8) + mask; // mask = mask * 257 |
|
537 TInt v = value >> 16; |
|
538 r = ((mask * (r - v)) >> 16) + v; |
|
539 v = (value >> 8) & 0xff; |
|
540 g = ((mask * (g - v)) >> 16) + v; |
|
541 v = value & 0xff; |
|
542 b = ((mask * (b - v)) >> 16) + v; |
|
543 } |
|
544 if(aShadowing == MAlphaBlend::EShdwAfter) |
|
545 { |
|
546 if (iShadowMode & EFade) |
|
547 { |
|
548 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
549 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
550 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
551 } |
|
552 if (iShadowMode & EShadow) |
|
553 { |
|
554 r = (Max(0,r-0x40)); |
|
555 g = (Max(0,g-0x40)); |
|
556 b = (Max(0,b-0x40)); |
|
557 } |
|
558 } |
|
559 // Convert colour if an incompatible UserDisplayMode is being used |
|
560 CDrawBitmap::MapColorToUserDisplayMode(r,g,b); |
|
561 *pixelPtr = (r<<16) | (g<<8) | b | 0xff000000; |
|
562 } |
|
563 pixelPtr += pixelPtrInc; |
|
564 srcPtr8 += 4; |
|
565 } |
|
566 } |
|
567 return; |
|
568 } |
|
569 else // (aSrcFormat==EColor64K) |
|
570 { |
|
571 const TUint16* srcPtr16 = reinterpret_cast<const TUint16*>(aSrcPtr) + aSrcX; |
|
572 |
|
573 if (!(iShadowMode & EFade) && !(iShadowMode & EShadow) && ((iUserDispMode==ENone) || (iUserDispMode==EColor16MU))) |
|
574 { |
|
575 const TUint16* lowAdd = Convert16to32bppLow(); |
|
576 const TUint32* highAdd = Convert16to32bppHigh(); |
|
577 const TUint32* maskWordPtr = aMaskPtr + (aMaskX >> 2); |
|
578 const TInt startBit = aMaskX & 0x3; |
|
579 |
|
580 if (startBit) |
|
581 { |
|
582 // Process initial incomplete mask word |
|
583 const TUint32 maskWord = *maskWordPtr++; |
|
584 TInt numPix = Min(aLength, 4 - startBit); // number of pixels to process from the first word of the mask |
|
585 aLength -= numPix; |
|
586 |
|
587 if (!maskWord) |
|
588 { |
|
589 // maskWord is fully masked |
|
590 srcPtr16 += numPix; |
|
591 pixelPtr += pixelPtrInc * numPix; |
|
592 } |
|
593 else if (maskWord == 0xFFFFFFFF) |
|
594 { |
|
595 // maskWord is fully unmasked |
|
596 while (numPix--) |
|
597 { |
|
598 CopyPixel(srcPtr16, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
599 } |
|
600 } |
|
601 else |
|
602 { |
|
603 // At least one of the pixels needs to be blended |
|
604 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord); |
|
605 maskPtr8 += startBit; |
|
606 while (numPix--) |
|
607 { |
|
608 ProcessAlphaPixel(srcPtr16, maskPtr8, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
609 } |
|
610 } |
|
611 } |
|
612 |
|
613 TInt numMaskWords = aLength >> 2; |
|
614 aLength &= 0x3; |
|
615 while (numMaskWords--) |
|
616 { |
|
617 // Process 4 mask pixels |
|
618 const TUint32 maskWord = *maskWordPtr++; |
|
619 |
|
620 if (!maskWord) |
|
621 { |
|
622 // maskWord is fully masked - skip 4 pixels |
|
623 srcPtr16 += 4; |
|
624 pixelPtr += pixelPtrInc << 2; |
|
625 } |
|
626 else if (maskWord == 0xFFFFFFFF) |
|
627 { |
|
628 // maskWord is fully unmasked - copy and convert 4 pixels |
|
629 const TUint32* srcPtr32 = (const TUint32*)srcPtr16; |
|
630 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
631 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
632 srcPtr16 = (const TUint16*)srcPtr32; |
|
633 } |
|
634 else |
|
635 { |
|
636 // At least one of the 4 pixels needs to be blended |
|
637 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord); |
|
638 |
|
639 if (maskPtr8[0] && (maskPtr8[0] != 0xFF) && |
|
640 maskPtr8[1] && (maskPtr8[1] != 0xFF) && |
|
641 maskPtr8[2] && (maskPtr8[2] != 0xFF) && |
|
642 maskPtr8[3] && (maskPtr8[3] != 0xFF)) |
|
643 { |
|
644 // Blend all 4 pixels inline |
|
645 BlendAlphaPixel(srcPtr16, maskPtr8[0], pixelPtr, pixelPtrInc); |
|
646 BlendAlphaPixel(srcPtr16, maskPtr8[1], pixelPtr, pixelPtrInc); |
|
647 BlendAlphaPixel(srcPtr16, maskPtr8[2], pixelPtr, pixelPtrInc); |
|
648 BlendAlphaPixel(srcPtr16, maskPtr8[3], pixelPtr, pixelPtrInc); |
|
649 } |
|
650 else |
|
651 { |
|
652 ProcessAlphaPixel(srcPtr16, maskPtr8, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
653 ProcessAlphaPixel(srcPtr16, maskPtr8, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
654 ProcessAlphaPixel(srcPtr16, maskPtr8, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
655 ProcessAlphaPixel(srcPtr16, maskPtr8, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
656 } |
|
657 } |
|
658 } |
|
659 |
|
660 if (aLength) |
|
661 { |
|
662 // Process final incomplete mask word |
|
663 const TUint32 maskWord = *maskWordPtr; // this will over-read |
|
664 if (!maskWord) |
|
665 { |
|
666 // maskWord is fully masked - skip the pixels |
|
667 return; |
|
668 } |
|
669 if (maskWord == 0xFFFFFFFF) |
|
670 { |
|
671 // maskWord is fully unmasked - copy and convert the pixels |
|
672 while (aLength--) |
|
673 { |
|
674 CopyPixel(srcPtr16, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
675 } |
|
676 } |
|
677 else |
|
678 { |
|
679 // At least one of the pixels needs to be blended |
|
680 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord); |
|
681 while (aLength--) |
|
682 { |
|
683 ProcessAlphaPixel(srcPtr16, maskPtr8, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
684 } |
|
685 } |
|
686 } |
|
687 } |
|
688 else |
|
689 { |
|
690 // Non-optimised path including shadowing and UserDisplayMode conversion |
|
691 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(aMaskPtr) + aMaskX; |
|
692 while (aLength--) |
|
693 { |
|
694 TInt mask = *maskPtr8++; |
|
695 if (mask) |
|
696 { |
|
697 const TUint32 src = *srcPtr16; |
|
698 TInt r = (src & 0xF800) >> 8; |
|
699 r |= (src & 0xE000) >>13; |
|
700 TInt g = (src & 0x07E0) >> 3; |
|
701 g |= (src & 0x0600) >> 9; |
|
702 TInt b = (src & 0x001F) << 3; |
|
703 b |= (src & 0x001C) >> 2; |
|
704 |
|
705 if(aShadowing == MAlphaBlend::EShdwBefore) |
|
706 { |
|
707 if (iShadowMode & EFade) |
|
708 { |
|
709 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
710 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
711 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
712 } |
|
713 if (iShadowMode & EShadow) |
|
714 { |
|
715 r = Max(0,r-0x40); |
|
716 g = Max(0,g-0x40); |
|
717 b = Max(0,b-0x40); |
|
718 } |
|
719 } |
|
720 if (mask != 0xff) |
|
721 { |
|
722 // (mask * r + (255 - mask) * value) / 255 = |
|
723 // ((257 * mask * (r - value)) >> 16) + value |
|
724 const TInt value = *pixelPtr & 0xffffff; |
|
725 mask = (mask << 8) + mask; // mask = mask * 257 |
|
726 TInt v = value >> 16; |
|
727 r = ((mask * (r - v)) >> 16) + v; |
|
728 v = (value >> 8) & 0xff; |
|
729 g = ((mask * (g - v)) >> 16) + v; |
|
730 v = value & 0xff; |
|
731 b = ((mask * (b - v)) >> 16) + v; |
|
732 } |
|
733 if(aShadowing == MAlphaBlend::EShdwAfter) |
|
734 { |
|
735 if (iShadowMode & EFade) |
|
736 { |
|
737 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
738 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
739 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset; |
|
740 } |
|
741 if (iShadowMode & EShadow) |
|
742 { |
|
743 r = Max(0,r-0x40); |
|
744 g = Max(0,g-0x40); |
|
745 b = Max(0,b-0x40); |
|
746 } |
|
747 } |
|
748 // Convert colour if an incompatible UserDisplayMode is being used |
|
749 CDrawBitmap::MapColorToUserDisplayMode(r,g,b); |
|
750 *pixelPtr = (r<<16) | (g<<8) | b | 0xff000000; |
|
751 } |
|
752 srcPtr16++; |
|
753 pixelPtr += pixelPtrInc; |
|
754 } |
|
755 } |
|
756 return; |
|
757 } |
|
758 } |
|
759 |
|
760 /** |
|
761 CDrawUTwentyFourBppBitmap::WriteMaskLineEx() implementation. |
|
762 @internalTechnology |
|
763 @see MFastBlit::WriteMaskLineEx() |
|
764 */ |
|
765 void CDrawUTwentyFourBppBitmap::WriteMaskLineEx(TInt aX, TInt aY, TInt aLength, TInt aSrcX, |
|
766 const TUint32* aSrcPtr, TDisplayMode aSrcFormat, |
|
767 TInt aMaskX, const TUint32* aMaskPtr, TBool aInvertMask) |
|
768 { |
|
769 // Only certain pixel formats are supported. Caller should check this. |
|
770 __ASSERT_DEBUG(aSrcFormat ==EColor16MU || aSrcFormat ==EColor64K, User::Invariant()); |
|
771 |
|
772 DeOrientate(aX,aY); |
|
773 TUint32* pixelPtr = PixelAddress(aX,aY); |
|
774 const TInt pixelPtrInc = PixelAddressIncrement(); |
|
775 const TUint32 invertWord = (aInvertMask ? 0xFFFFFFFF : 0); // to be XORed with the mask |
|
776 |
|
777 if (aSrcFormat==EColor16MU) |
|
778 { |
|
779 aSrcPtr += aSrcX; |
|
780 |
|
781 if ((iUserDispMode==ENone) || (iUserDispMode==EColor16MU)) |
|
782 { |
|
783 const TUint32* maskWordPtr = aMaskPtr + (aMaskX >> 5); |
|
784 const TInt startBit = aMaskX & 0x1F; |
|
785 |
|
786 if (startBit) |
|
787 { |
|
788 // Process initial incomplete mask word |
|
789 TUint32 maskWord = *maskWordPtr++; |
|
790 maskWord ^= invertWord; |
|
791 TInt numPix = Min(aLength, 32 - startBit); // number of pixels to process from the first word of the mask |
|
792 aLength -= numPix; |
|
793 |
|
794 if (!maskWord) |
|
795 { |
|
796 // maskWord is fully masked - skip the pixels |
|
797 aSrcPtr += numPix; |
|
798 pixelPtr += pixelPtrInc * numPix; |
|
799 } |
|
800 else if (maskWord == 0xFFFFFFFF) |
|
801 { |
|
802 // maskWord is fully unmasked - copy the pixels |
|
803 while (numPix--) |
|
804 { |
|
805 *pixelPtr = *aSrcPtr++; |
|
806 pixelPtr += pixelPtrInc; |
|
807 } |
|
808 } |
|
809 else |
|
810 { |
|
811 // maskWord is partially masked - process each pixel |
|
812 TUint32 singleBitMask = 1 << startBit; |
|
813 while (numPix--) |
|
814 { |
|
815 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
816 } |
|
817 } |
|
818 } |
|
819 |
|
820 TInt numMaskWords = aLength >> 5; |
|
821 aLength &= 0x1F; |
|
822 while (numMaskWords--) |
|
823 { |
|
824 // Process a complete mask word (32 pixels) |
|
825 TUint32 maskWord = *maskWordPtr++; |
|
826 maskWord ^= invertWord; |
|
827 |
|
828 if (!maskWord) |
|
829 { |
|
830 // maskWord is fully masked - skip 32 pixels |
|
831 aSrcPtr += 32; |
|
832 pixelPtr += pixelPtrInc << 5; |
|
833 } |
|
834 else if (maskWord == 0xFFFFFFFF) |
|
835 { |
|
836 // maskWord is fully unmasked - copy 32 pixels |
|
837 if (pixelPtrInc==1) |
|
838 { |
|
839 pixelPtr=(TUint32*)Mem::Move(pixelPtr, aSrcPtr, 128); |
|
840 aSrcPtr+= 32; |
|
841 } |
|
842 else |
|
843 { |
|
844 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
845 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
846 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
847 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
848 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
849 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
850 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
851 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
852 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
853 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
854 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
855 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
856 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
857 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
858 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
859 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
860 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
861 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
862 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
863 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
864 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
865 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
866 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
867 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
868 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
869 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
870 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
871 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
872 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
873 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
874 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
875 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc; |
|
876 } |
|
877 } |
|
878 else |
|
879 { |
|
880 // maskWord is partially masked - process each of the 32 pixels |
|
881 TUint32 singleBitMask = 1; |
|
882 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
883 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
884 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
885 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
886 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
887 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
888 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
889 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
890 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
891 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
892 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
893 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
894 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
895 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
896 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
897 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
898 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
899 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
900 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
901 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
902 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
903 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
904 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
905 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
906 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
907 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
908 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
909 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
910 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
911 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
912 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
913 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
914 } |
|
915 } |
|
916 |
|
917 |
|
918 if (aLength) |
|
919 { |
|
920 // Process final incomplete mask word |
|
921 TUint32 maskWord = *maskWordPtr; |
|
922 maskWord ^= invertWord; |
|
923 |
|
924 if (!maskWord) |
|
925 { |
|
926 // maskWord is fully masked - skip the pixels |
|
927 return; |
|
928 } |
|
929 if (maskWord == 0xFFFFFFFF) |
|
930 { |
|
931 // maskWord is fully unmasked - copy the pixels |
|
932 while (aLength--) |
|
933 { |
|
934 *pixelPtr = *aSrcPtr++; |
|
935 pixelPtr += pixelPtrInc; |
|
936 } |
|
937 } |
|
938 else |
|
939 { |
|
940 // maskWord is partially masked - process each pixel |
|
941 TUint32 singleBitMask = 1; |
|
942 while (aLength--) |
|
943 { |
|
944 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc); |
|
945 } |
|
946 } |
|
947 } |
|
948 } |
|
949 else |
|
950 { |
|
951 // Non-optimised path. UserDisplay mode is different to the true display mode |
|
952 while (aLength--) |
|
953 { |
|
954 TUint32 mask = *(aMaskPtr + (aMaskX >> 5)) & (1 << (aMaskX & 0x1F)); |
|
955 if (aInvertMask) |
|
956 { |
|
957 mask = !mask; |
|
958 } |
|
959 if (mask) |
|
960 { |
|
961 TRgb pixel(*aSrcPtr); |
|
962 MapColorToUserDisplayMode(pixel); |
|
963 *pixelPtr = pixel.Value(); |
|
964 } |
|
965 aSrcPtr++; |
|
966 aMaskX++; |
|
967 pixelPtr += pixelPtrInc; |
|
968 } |
|
969 } |
|
970 return; |
|
971 } |
|
972 else // (aSrcFormat==EColor64K) |
|
973 { |
|
974 const TUint16* srcPtr16 = reinterpret_cast<const TUint16*>(aSrcPtr) + aSrcX; |
|
975 |
|
976 if ((iUserDispMode==ENone) || (iUserDispMode==EColor16MU)) |
|
977 { |
|
978 const TUint16* lowAdd = Convert16to32bppLow(); |
|
979 const TUint32* highAdd = Convert16to32bppHigh(); |
|
980 const TUint32* maskWordPtr = aMaskPtr + (aMaskX >> 5); |
|
981 const TInt startBit = aMaskX & 0x1F; |
|
982 |
|
983 if (startBit) |
|
984 { |
|
985 // Process initial incomplete mask word |
|
986 TUint32 maskWord = *maskWordPtr++; |
|
987 maskWord ^= invertWord; |
|
988 TInt numPix = Min(aLength, 32 - startBit); // number of pixels to process from the first word of the mask |
|
989 aLength -= numPix; |
|
990 |
|
991 if (!maskWord) |
|
992 { |
|
993 // maskWord is fully masked - skip the pixels |
|
994 srcPtr16 += numPix; |
|
995 pixelPtr += pixelPtrInc * numPix; |
|
996 } |
|
997 else if (maskWord == 0xFFFFFFFF) |
|
998 { |
|
999 // maskWord is fully unmasked - copy and convert the pixels |
|
1000 while (numPix--) |
|
1001 { |
|
1002 CopyPixel(srcPtr16, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1003 } |
|
1004 } |
|
1005 else |
|
1006 { |
|
1007 // maskWord is partially masked - process each of the pixels |
|
1008 TUint32 singleBitMask = 1 << startBit; |
|
1009 while (numPix--) |
|
1010 { |
|
1011 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1012 } |
|
1013 } |
|
1014 } |
|
1015 |
|
1016 TInt numMaskWords = aLength >> 5; |
|
1017 aLength &= 0x1F; |
|
1018 while (numMaskWords--) |
|
1019 { |
|
1020 // Process complete mask words |
|
1021 TUint32 maskWord = *maskWordPtr++; |
|
1022 maskWord ^= invertWord; |
|
1023 |
|
1024 if (!maskWord) |
|
1025 { |
|
1026 // maskWord is fully masked - skip 32 pixels |
|
1027 srcPtr16 += 32; |
|
1028 pixelPtr += pixelPtrInc << 5; |
|
1029 } |
|
1030 else if (maskWord == 0xFFFFFFFF) |
|
1031 { |
|
1032 // maskWord is fully unmasked - copy and convert 32 pixels |
|
1033 const TUint32* srcPtr32 = (const TUint32*)srcPtr16; |
|
1034 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1035 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1036 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1037 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1038 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1039 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1040 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1041 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1042 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1043 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1044 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1045 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1046 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1047 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1048 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1049 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1050 srcPtr16 = (const TUint16*)srcPtr32; |
|
1051 } |
|
1052 else |
|
1053 { |
|
1054 // maskWord is partially masked - process each of the 32 pixels |
|
1055 TUint32 singleBitMask = 1; |
|
1056 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1057 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1058 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1059 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1060 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1061 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1062 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1063 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1064 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1065 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1066 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1067 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1068 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1069 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1070 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1071 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1072 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1073 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1074 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1075 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1076 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1077 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1078 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1079 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1080 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1081 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1082 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1083 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1084 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1085 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1086 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1087 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1088 } |
|
1089 } |
|
1090 |
|
1091 if (aLength) |
|
1092 { |
|
1093 // Process final incomplete mask word |
|
1094 TUint32 maskWord = *maskWordPtr; // this will over-read |
|
1095 maskWord ^= invertWord; |
|
1096 |
|
1097 if (!maskWord) |
|
1098 { |
|
1099 // maskWord is masked - skip the pixels |
|
1100 return; |
|
1101 } |
|
1102 |
|
1103 if (maskWord == 0xFFFFFFFF) |
|
1104 { |
|
1105 // maskWord is fully unmasked - copy and convert the pixels |
|
1106 while (aLength--) |
|
1107 { |
|
1108 CopyPixel(srcPtr16, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1109 } |
|
1110 } |
|
1111 else |
|
1112 { |
|
1113 // maskWord is partially masked - process each of the pixels |
|
1114 TUint32 singleBitMask = 1; |
|
1115 while (aLength--) |
|
1116 { |
|
1117 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd); |
|
1118 } |
|
1119 } |
|
1120 } |
|
1121 } |
|
1122 else |
|
1123 { |
|
1124 // Non-optimised - expects aMaskPtr untouched and srcPtr16 to be accurate |
|
1125 while (aLength--) |
|
1126 { |
|
1127 TUint32 mask = *(aMaskPtr + (aMaskX >> 5)) & (1 << (aMaskX & 0x1F)); |
|
1128 if (aInvertMask) |
|
1129 { |
|
1130 mask = !mask; |
|
1131 } |
|
1132 if (mask) |
|
1133 { |
|
1134 const TUint32 src = *srcPtr16; |
|
1135 TUint32 color = (src & 0xF800) << 8; // R top 5 |
|
1136 color |= (src & 0xE000) << 3; // R bottom 3 |
|
1137 color |= (src & 0x07E0) << 5; // G top 6 |
|
1138 color |= (src & 0x0600) >> 1; // G bottom 2 |
|
1139 color |= (src & 0x001F) << 3; // B top 5 |
|
1140 color |= (src & 0x001C) >> 2; // B bottom 3 |
|
1141 TRgb pixel(color); |
|
1142 MapColorToUserDisplayMode(pixel); |
|
1143 *pixelPtr = pixel.Value(); |
|
1144 } |
|
1145 pixelPtr += pixelPtrInc; |
|
1146 srcPtr16++; |
|
1147 aMaskX++; |
|
1148 } |
|
1149 } |
|
1150 return; |
|
1151 } |
|
1152 } |
|
1153 |
|
1154 /** |
|
1155 Implementation for CFbsDrawDevice::GetInterface(). |
|
1156 Retrieves a pointer to a specified interface of CFbsDrawDevice implementation. |
|
1157 @param aInterfaceId Interface identifier of the interface to be retrieved. |
|
1158 @param aInterface Address of variable that retrieves the specified interface. |
|
1159 @return KErrNone If the interface is supported, KErrNotSupported otherwise. |
|
1160 */ |
|
1161 TInt CDrawUTwentyFourBppBitmap::GetInterface(TInt aInterfaceId, TAny*& aInterface) |
|
1162 { |
|
1163 aInterface = NULL; |
|
1164 TInt ret = KErrNotSupported; |
|
1165 |
|
1166 switch (aInterfaceId) |
|
1167 { |
|
1168 case KFastBlitInterfaceID: |
|
1169 { |
|
1170 aInterface = static_cast<MFastBlit*>(this); |
|
1171 ret = KErrNone; |
|
1172 break; |
|
1173 } |
|
1174 default: |
|
1175 { |
|
1176 return CDrawThirtyTwoBppBitmapCommon::GetInterface(aInterfaceId, aInterface); |
|
1177 } |
|
1178 } |
|
1179 |
|
1180 return ret; |
|
1181 } |
|
1182 |
|
1183 TInt CDrawUTwentyFourBppBitmap::WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength, |
|
1184 TUint32 aOutlinePenColor, TUint32 aShadowColor, |
|
1185 TUint32 aFillColor, const TUint8* aDataBuffer) |
|
1186 { |
|
1187 const TInt alpha = aOutlinePenColor >> 24; |
|
1188 if (alpha==0 || aLength<=0) |
|
1189 return KErrNone; |
|
1190 DeOrientate(aX,aY); |
|
1191 TUint32* pixelPtr = PixelAddress(aX,aY); |
|
1192 const TInt pixelPtrInc = PixelAddressIncrement(); |
|
1193 const TUint8* dataBufferPtrLimit = aDataBuffer + aLength; |
|
1194 TInt blendedRedColor; |
|
1195 TInt blendedGreenColor; |
|
1196 TInt blendedBlueColor; |
|
1197 TUint8 index = 0; |
|
1198 TUint32 finalColor; |
|
1199 |
|
1200 //Get red color. Equivalent to TRgb::Red() |
|
1201 const TInt redOutlinePenColor = (aOutlinePenColor & 0xff0000) >> 16; |
|
1202 const TInt redShadowColor = (aShadowColor & 0xff0000) >> 16; |
|
1203 const TInt redFillColor = (aFillColor & 0xff0000) >> 16; |
|
1204 |
|
1205 //Get green color. Equivalent to TRgb::Green() |
|
1206 const TInt greenOutlinePenColor = (aOutlinePenColor & 0xff00) >> 8; |
|
1207 const TInt greenShadowColor = (aShadowColor & 0xff00) >> 8; |
|
1208 const TInt greenFillColor = (aFillColor & 0xff00) >> 8; |
|
1209 |
|
1210 //Get blue color. Equivalent to TRgb::Blue() |
|
1211 const TInt blueOutlinePenColor = aOutlinePenColor & 0xff; |
|
1212 const TInt blueShadowColor = aShadowColor & 0xff; |
|
1213 const TInt blueFillColor = aFillColor & 0xff; |
|
1214 |
|
1215 const TUint32 mask2 = alpha | (alpha << 16); |
|
1216 while (aDataBuffer < dataBufferPtrLimit) |
|
1217 { |
|
1218 index = *aDataBuffer++; |
|
1219 |
|
1220 if (255 == FourColorBlendLookup[index][KBackgroundColorIndex]) |
|
1221 { |
|
1222 //background colour |
|
1223 //No drawing required so move on to next pixel. |
|
1224 pixelPtr += pixelPtrInc; |
|
1225 continue; |
|
1226 } |
|
1227 else if (255 == FourColorBlendLookup[index][KFillColorIndex]) |
|
1228 { |
|
1229 //Use fill colour to draw |
|
1230 finalColor = aFillColor; |
|
1231 } |
|
1232 else if (255 == FourColorBlendLookup[index][KShadowColorIndex]) |
|
1233 { |
|
1234 //Use shadow colour to draw |
|
1235 finalColor = aShadowColor; |
|
1236 } |
|
1237 else if (255 == FourColorBlendLookup[index][KOutlineColorIndex]) |
|
1238 { |
|
1239 //Use outline colour to draw |
|
1240 finalColor = aOutlinePenColor; |
|
1241 } |
|
1242 else |
|
1243 { |
|
1244 TUint32 backgroundColor = *pixelPtr; |
|
1245 blendedRedColor = redOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
|
1246 redShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
|
1247 redFillColor * FourColorBlendLookup[index][KFillColorIndex] + |
|
1248 ((backgroundColor & 0xff0000) >> 16) * FourColorBlendLookup[index][KBackgroundColorIndex]; |
|
1249 |
|
1250 blendedGreenColor = greenOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
|
1251 greenShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
|
1252 greenFillColor * FourColorBlendLookup[index][KFillColorIndex] + |
|
1253 ((backgroundColor & 0xff00) >> 8) * FourColorBlendLookup[index][KBackgroundColorIndex]; |
|
1254 |
|
1255 blendedBlueColor = blueOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] + |
|
1256 blueShadowColor * FourColorBlendLookup[index][KShadowColorIndex] + |
|
1257 blueFillColor * FourColorBlendLookup[index][KFillColorIndex] + |
|
1258 (backgroundColor & 0xff) * FourColorBlendLookup[index][KBackgroundColorIndex]; |
|
1259 |
|
1260 //Equivalent to TRgb::TRgb(TUint32) |
|
1261 finalColor = ((blendedRedColor&0xFF00) << 8) | (blendedGreenColor&0xFF00) | (blendedBlueColor>>8); |
|
1262 } |
|
1263 |
|
1264 if (alpha != 0xff) |
|
1265 { |
|
1266 TUint32 backgroundColor = *pixelPtr; |
|
1267 //Draw the final colour |
|
1268 // |
|
1269 const TUint32 s_rb = finalColor & 0x00FF00FF; |
|
1270 const TUint32 s_g = (finalColor & 0xFF00) >> 8; |
|
1271 const TUint32 d_rb = backgroundColor & 0x00FF00FF; |
|
1272 const TUint32 rb = ((((alpha * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; |
|
1273 |
|
1274 const TInt d_g = (backgroundColor & 0xFF00) >> 8; |
|
1275 const TInt g = ((alpha * (s_g - d_g)) >> 8) + d_g; |
|
1276 |
|
1277 finalColor = rb | (g<<8); |
|
1278 } |
|
1279 |
|
1280 *pixelPtr = (finalColor | 0xff000000); |
|
1281 pixelPtr += pixelPtrInc; |
|
1282 } |
|
1283 return KErrNone; |
|
1284 } |