First public contribution.
1 // Copyright (c) 2003-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include "BitDrawInterfaceId.h"
18 #include <graphics/lookuptable.h>
19 #include <graphics/blendingalgorithms.h>
21 TInt CDrawUTwentyFourBppBitmap::Construct(TSize aSize)
23 return Construct(aSize, aSize.iWidth << 2);
26 TInt CDrawUTwentyFourBppBitmap::Construct(TSize aSize, TInt aStride)
28 iDispMode = EColor16MU;
29 return CDrawThirtyTwoBppBitmapCommon::Construct(aSize, aStride);
33 MAlphaBlend::WriteRgbAlphaLine() implementation.
34 @see MAlphaBlend::WriteRgbAlphaLine()
36 void CDrawUTwentyFourBppBitmap::WriteRgbAlphaLine(TInt aX, TInt aY, TInt aLength,
37 const TUint8* aRgbBuffer,
38 const TUint8* aMaskBuffer,
39 MAlphaBlend::TShadowing aShadowing,
40 CGraphicsContext::TDrawMode /*aDrawMode*/)
42 // precondition for this function is that the aRgbBuffer lies on a word boundary
43 // Assert checks that the pointer is at a word boundary
44 __ASSERT_DEBUG(!(((TUint)aRgbBuffer) & 0x3), Panic(EScreenDriverPanicInvalidPointer));
47 TUint32* pixelPtr = PixelAddress(aX,aY);
48 TUint32* rgbBuffer = (TUint32*)aRgbBuffer;
49 const TInt pixelPtrInc = PixelAddressIncrement();
50 const TUint8* maskBufferPtrLimit = aMaskBuffer + aLength;
52 if (!(iShadowMode & (EFade | EShadow)) && (iUserDispMode == ENone))
54 while (aMaskBuffer < maskBufferPtrLimit)
56 *pixelPtr = CalcAlphaPixel(*rgbBuffer, *aMaskBuffer, *pixelPtr);
58 pixelPtr += pixelPtrInc;
64 while (aMaskBuffer < maskBufferPtrLimit)
66 TInt mask = *aMaskBuffer++;
69 TInt b = aRgbBuffer[0];
70 TInt g = aRgbBuffer[1];
71 TInt r = aRgbBuffer[2];
72 if(aShadowing == MAlphaBlend::EShdwBefore)
74 if (iShadowMode & EFade)
76 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset;
77 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset;
78 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset;
80 if (iShadowMode & EShadow)
89 // (mask * r + (255 - mask) * value) / 255 =
90 // ((257 * mask * (r - value)) >> 16) + value
91 TInt value = *pixelPtr & 0xffffff;
92 mask = (mask << 8) + mask; // mask = mask * 257
94 r = ((mask * (r - v)) >> 16) + v;
95 v = (value >> 8) & 0xff;
96 g = ((mask * (g - v)) >> 16) + v;
98 b = ((mask * (b - v)) >> 16) + v;
100 if(aShadowing == MAlphaBlend::EShdwAfter)
102 if (iShadowMode & EFade)
104 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset;
105 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset;
106 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset;
108 if (iShadowMode & EShadow)
115 // Convert colour if an incompatible UserDisplayMode is being used
116 CDrawBitmap::MapColorToUserDisplayMode(r,g,b);
117 *pixelPtr = (r<<16) | (g<<8) | b | 0xff000000;
120 pixelPtr += pixelPtrInc;
125 void CDrawUTwentyFourBppBitmap::ReadLine(TInt aX, TInt aY, TInt aLength, TAny* aBuffer, TDisplayMode aDispMode) const
127 if (aDispMode == EColor16MAP)
130 CDrawThirtyTwoBppBitmapCommon::ReadLine(aX, aY, aLength, aBuffer);
132 //Overwrite unused byte with 0xff to produce valid 16MAP data
133 TUint8* alphaptr = (TUint8*) aBuffer+3;
134 TUint8* bufEnd = (TUint8*) aBuffer + (aLength << 2);
135 while (alphaptr < bufEnd)
143 CDrawBitmap::ReadLine(aX, aY, aLength, aBuffer, aDispMode);
146 void CDrawUTwentyFourBppBitmap::BlendRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor)
148 const TInt sourceAlpha = aColor.Alpha();
149 if (sourceAlpha==255)// opaque
151 WriteRgbMulti(aX,aY,aLength,aHeight,aColor);
154 if (sourceAlpha==0)// transparent
157 TUint32* pixelPtr = PixelAddress(aX,aY);
158 TUint32* pixelRowPtrLimit = pixelPtr + (aHeight * iScanLineWords);
159 TUint32* pixelPtrLimit = pixelPtr + aLength;
161 const TUint32 sourceInternal=aColor.Internal();
162 const TUint32 s_rb = sourceInternal & 0x00FF00FF;
163 const TUint32 s_g = (sourceInternal & 0xFF00) >> 8;
164 const TUint32 mask2 = sourceAlpha | (sourceAlpha << 16);
165 while (pixelPtr < pixelRowPtrLimit)
167 for (TUint32* tempPixelPtr = pixelPtr; tempPixelPtr < pixelPtrLimit; tempPixelPtr++)
169 const TUint32 d = *tempPixelPtr;
170 const TUint32 d_rb = d & 0x00FF00FF;
171 const TUint32 rb = ((((sourceAlpha * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
173 const TInt d_g = (d & 0xFF00) >> 8;
174 const TInt g = ((sourceAlpha * (s_g - d_g)) >> 8) + d_g;
176 *tempPixelPtr = rb | (g<<8) | 0xff000000;
179 pixelPtr += iScanLineWords;
180 pixelPtrLimit += iScanLineWords;
184 void CDrawUTwentyFourBppBitmap::BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer)
186 TUint32* pixelPtr = PixelAddress(aX,aY);
188 const TUint32* bufferPtrLimit = aBuffer + aLength;
189 const TInt pixelPtrInc = (iOrientation == EOrientationNormal) ? 1 : PixelAddressIncrement();
191 while (aBuffer < bufferPtrLimit)
193 if((*aBuffer &0xFF000000) == 0xFF000000)
195 *pixelPtr = *aBuffer;
197 else if((*aBuffer & 0xFF000000))
199 // specialization of pre-multiplied blending when the destination alpha is always 255
200 const TUint32 src_rb = *aBuffer & 0x00FF00FF;
201 const TUint32 src_g = *aBuffer & 0x0000FF00;
202 const TUint32 mask = 0x100 - (*aBuffer >> 24);
203 TUint32 dst_rb = *pixelPtr & 0x00FF00FF;
204 TUint32 dst_g = *pixelPtr & 0x0000FF00;
205 dst_rb = (src_rb + ((mask * dst_rb) >> 8)) & 0x00FF00FF;
206 dst_g = (src_g + ((mask * dst_g) >> 8)) & 0x0000FF00;
207 *pixelPtr = 0xFF000000 | dst_rb | dst_g;
211 pixelPtr += pixelPtrInc;
215 TRgb CDrawUTwentyFourBppBitmap::RgbColor(TUint32 aColor) const
217 return TRgb::_Color16MU(aColor);
220 TUint32 CDrawUTwentyFourBppBitmap::Color(const TRgb& aColor)
222 return aColor._Color16MA() | 0xff000000;
226 // Copies an EColor64K pixel to an EColor16MU screen
227 FORCEINLINE static void CopyPixel(const TUint16*& aSrcPtr, TUint32*& aDestPtr, TInt aPixelPtrInc, const TUint32* aHighAdd, const TUint16* aLowAdd)
229 *aDestPtr = aHighAdd[(*aSrcPtr) >> 8] | aLowAdd[(*aSrcPtr) & 0xff];
230 aDestPtr += aPixelPtrInc;
235 // Copies two EColor64K pixels to an EColor16MU screen
236 FORCEINLINE static void CopyTwoPixels(const TUint32*& aSrcPtr, TUint32*& aDestPtr, TInt aPixelPtrInc, const TUint32* aHighAdd, const TUint16* aLowAdd)
238 const TUint16* scanPtr = reinterpret_cast<const TUint16*&>(aSrcPtr);
239 *aDestPtr = aHighAdd[(*scanPtr) >> 8] | aLowAdd[(*scanPtr) & 0xff];
240 aDestPtr += aPixelPtrInc;
242 *aDestPtr = aHighAdd[(*scanPtr) >> 8] | aLowAdd[(*scanPtr) & 0xff];
243 aDestPtr += aPixelPtrInc;
248 // Copies an EColor16MU pixel to an EColor16MU screen if necessary.
249 FORCEINLINE static void ProcessMaskPixel(const TUint32*& aSrcPtr, const TUint32 aMaskWord, TUint32& aSingleBitMask, TUint32*& aDestPtr, TInt aPixelPtrInc)
251 if (aMaskWord & aSingleBitMask)
253 *aDestPtr = *aSrcPtr;
256 aDestPtr += aPixelPtrInc;
257 aSingleBitMask <<= 1;
261 // Copies an EColor64K pixel to an EColor16MU screen if necessary.
262 FORCEINLINE static void ProcessMaskPixel(const TUint16*& aSrcPtr, const TUint32 aMaskWord, TUint32& aSingleBitMask, TUint32*& aDestPtr, TInt aPixelPtrInc, const TUint32* aHighAdd, const TUint16* aLowAdd)
264 if (aMaskWord & aSingleBitMask)
266 *aDestPtr = aHighAdd[(*aSrcPtr) >> 8] | aLowAdd[(*aSrcPtr) & 0xff];
269 aDestPtr += aPixelPtrInc;
270 aSingleBitMask <<= 1;
274 // Alpha-blends an EColor16MU pixel to an EColor16MU screen using a fixed mask value.
275 FORCEINLINE static void BlendAlphaPixel(const TUint32*& aSrcPtr, const TUint8 aMask, TUint32*& aDestPtr, TInt aPixelPtrInc)
277 const TUint32 s = *aSrcPtr++;
278 const TUint32 d = *aDestPtr;
280 // (a) (mask * src + (255 - mask) * dest) / 255 This ideal formula
281 // (b) ((mask * (src - dest)) >> 8) + dest A faster approximation to (a)
282 // (c) ((mask * (256 + src - dest) >> 8) + dest - mask Equivalent to (b) but can be used on multiple colors at a time
284 const TUint32 s_rb = s & 0x00FF00FF;
285 const TUint32 d_rb = d & 0x00FF00FF;
286 const TUint32 mask2 = aMask | (aMask << 16);
287 const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
289 const TInt s_g = (s & 0xFF00) >> 8;
290 const TInt d_g = (d & 0xFF00) >> 8;
291 const TInt g = ((aMask * (s_g - d_g)) >> 8) + d_g;
293 *aDestPtr = rb | (g<<8) | 0xff000000;
294 aDestPtr += aPixelPtrInc;
298 // Alpha-blends an EColor16MU pixel to an EColor16MU screen if necessary.
299 FORCEINLINE static void ProcessAlphaPixel(const TUint32*& aSrcPtr, const TUint8*& aMaskPtr, TUint32*& aDestPtr, TInt aPixelPtrInc)
301 const TInt mask = *aMaskPtr++;
307 aDestPtr += aPixelPtrInc;
309 else if (mask == 0xFF)
312 *aDestPtr = *aSrcPtr++;
313 aDestPtr += aPixelPtrInc;
317 BlendAlphaPixel(aSrcPtr, mask, aDestPtr, aPixelPtrInc);
322 // Alpha-blends an EColor64K pixel to an EColor16MU screen using a fixed mask value.
323 FORCEINLINE static void BlendAlphaPixel(const TUint16*& aSrcPtr, const TUint8 aMask, TUint32*& aDestPtr, TInt aPixelPtrInc)
325 const TUint32 s = *aSrcPtr++;
326 const TUint32 d = *aDestPtr;
328 // convert the source EColor64K red / blue pixels to EColor16MU
329 // the top two bits in EColor64K are used to fill the bottom two bits in EColor16MU
331 const TUint32 s_rb = ((s & 0xF800) << 8) | ((s & 0xE000) << 3) | ((s & 0x1F) << 3) | ((s & 0x1C) >>2);
332 const TUint32 d_rb = d & 0x00FF00FF;
333 const TUint32 mask2 = aMask | (aMask << 16);
334 const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
336 // convert the source EColor64K green pixel to EColor16MU
337 const TInt s_g = ((s & 0x07E0) >> 3) | ((s & 0x0600) >> 9);
338 const TInt d_g = (d & 0xFF00) >> 8;
339 const TInt g = ((aMask * (s_g - d_g)) >> 8) + d_g;
341 *aDestPtr = rb | (g<<8) | 0xff000000;
342 aDestPtr += aPixelPtrInc;
346 // Alpha-blends an EColor64K pixel to an EColor16MU screen if necessary.
347 FORCEINLINE static void ProcessAlphaPixel(const TUint16*& aSrcPtr, const TUint8*& aMaskPtr, TUint32*& aDestPtr, TInt aPixelPtrInc, const TUint32* aHighAdd, const TUint16* aLowAdd)
349 const TInt mask = *aMaskPtr++;
355 aDestPtr += aPixelPtrInc;
357 else if (mask == 0xFF)
360 CopyPixel(aSrcPtr, aDestPtr, aPixelPtrInc, aHighAdd, aLowAdd);
364 BlendAlphaPixel(aSrcPtr, mask, aDestPtr, aPixelPtrInc);
370 CDrawUTwentyFourBppBitmap::WriteAlphaLineEx() implementation.
372 @see MFastBlit::WriteAlphaLineEx()
374 void CDrawUTwentyFourBppBitmap::WriteAlphaLineEx(TInt aX, TInt aY, TInt aLength, TInt aSrcX,
375 const TUint32* aSrcPtr, TDisplayMode aSrcFormat,
376 TInt aMaskX, const TUint32* aMaskPtr,
377 MAlphaBlend::TShadowing aShadowing)
379 // Only certain pixel formats are supported. Caller should check this.
380 __ASSERT_DEBUG(aSrcFormat ==EColor16MU || aSrcFormat ==EColor64K, User::Invariant());
383 TUint32* pixelPtr = PixelAddress(aX,aY);
384 const TInt pixelPtrInc = PixelAddressIncrement();
386 if (aSrcFormat==EColor16MU)
388 if (!(iShadowMode & EFade) && !(iShadowMode & EShadow) && ((iUserDispMode==ENone) || (iUserDispMode==EColor16MU)) )
391 const TUint32* maskWordPtr = aMaskPtr + (aMaskX >> 2);
392 const TInt startBit = aMaskX & 0x3;
396 // Process initial incomplete mask word
397 const TUint32 maskWord = *maskWordPtr++;
398 TInt numPix = Min(aLength, 4 - startBit); // number of pixels to process from the first word of the mask
403 // maskWord is fully masked - skip the pixels
405 pixelPtr += pixelPtrInc * numPix;
407 else if (maskWord == 0xFFFFFFFF)
409 // maskWord is fully unmasked - copy the pixels
412 *pixelPtr = *aSrcPtr++;
413 pixelPtr += pixelPtrInc;
418 // At least one of the pixels needs to be blended
419 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord);
420 maskPtr8 += startBit;
423 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc);
428 TInt numMaskWords = aLength >> 2;
430 while (numMaskWords--)
432 // Process a complete mask word - 4 pixels
433 const TUint32 maskWord = *maskWordPtr++;
437 // maskWord is fully masked - skip 4 pixels
439 pixelPtr += pixelPtrInc << 2;
441 else if (maskWord == 0xFFFFFFFF)
443 // maskWord is fully unmasked - copy 4 pixels
444 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc;
445 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc;
446 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc;
447 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc;
451 // At least one of the 4 pixels needs to be blended
452 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord);
454 if (maskPtr8[0] && (maskPtr8[0] != 0xFF) &&
455 maskPtr8[1] && (maskPtr8[1] != 0xFF) &&
456 maskPtr8[2] && (maskPtr8[2] != 0xFF) &&
457 maskPtr8[3] && (maskPtr8[3] != 0xFF))
459 // Blend all 4 pixels inline
460 BlendAlphaPixel(aSrcPtr, maskPtr8[0], pixelPtr, pixelPtrInc);
461 BlendAlphaPixel(aSrcPtr, maskPtr8[1], pixelPtr, pixelPtrInc);
462 BlendAlphaPixel(aSrcPtr, maskPtr8[2], pixelPtr, pixelPtrInc);
463 BlendAlphaPixel(aSrcPtr, maskPtr8[3], pixelPtr, pixelPtrInc);
467 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc);
468 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc);
469 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc);
470 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc);
477 const TUint32 maskWord = *maskWordPtr;
480 // maskWord is fully masked - skip the pixels
483 if (maskWord == 0xFFFFFFFF)
485 // maskWord is fully unmasked - copy the pixels
488 *pixelPtr = *aSrcPtr++;
489 pixelPtr += pixelPtrInc;
494 // At least one of the pixels needs to be blended
495 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord);
498 ProcessAlphaPixel(aSrcPtr, maskPtr8, pixelPtr, pixelPtrInc);
505 // Non-optimised path including shadowing and UserDisplayMode conversion
506 const TUint8* srcPtr8 = reinterpret_cast<const TUint8*>(aSrcPtr + aSrcX);
507 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(aMaskPtr) + aMaskX;
511 TInt mask = *maskPtr8++;
517 if(aShadowing == MAlphaBlend::EShdwBefore)
519 if (iShadowMode & EFade)
521 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset;
522 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset;
523 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset;
525 if (iShadowMode & EShadow)
534 // (mask * r + (255 - mask) * value) / 255 =
535 // ((257 * mask * (r - value)) >> 16) + value
536 TInt value = *pixelPtr & 0xffffff;
537 mask = (mask << 8) + mask; // mask = mask * 257
538 TInt v = value >> 16;
539 r = ((mask * (r - v)) >> 16) + v;
540 v = (value >> 8) & 0xff;
541 g = ((mask * (g - v)) >> 16) + v;
543 b = ((mask * (b - v)) >> 16) + v;
545 if(aShadowing == MAlphaBlend::EShdwAfter)
547 if (iShadowMode & EFade)
549 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset;
550 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset;
551 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset;
553 if (iShadowMode & EShadow)
560 // Convert colour if an incompatible UserDisplayMode is being used
561 CDrawBitmap::MapColorToUserDisplayMode(r,g,b);
562 *pixelPtr = (r<<16) | (g<<8) | b | 0xff000000;
564 pixelPtr += pixelPtrInc;
570 else // (aSrcFormat==EColor64K)
572 const TUint16* srcPtr16 = reinterpret_cast<const TUint16*>(aSrcPtr) + aSrcX;
574 if (!(iShadowMode & EFade) && !(iShadowMode & EShadow) && ((iUserDispMode==ENone) || (iUserDispMode==EColor16MU)))
576 const TUint16* lowAdd = Convert16to32bppLow();
577 const TUint32* highAdd = Convert16to32bppHigh();
578 const TUint32* maskWordPtr = aMaskPtr + (aMaskX >> 2);
579 const TInt startBit = aMaskX & 0x3;
583 // Process initial incomplete mask word
584 const TUint32 maskWord = *maskWordPtr++;
585 TInt numPix = Min(aLength, 4 - startBit); // number of pixels to process from the first word of the mask
590 // maskWord is fully masked
592 pixelPtr += pixelPtrInc * numPix;
594 else if (maskWord == 0xFFFFFFFF)
596 // maskWord is fully unmasked
599 CopyPixel(srcPtr16, pixelPtr, pixelPtrInc, highAdd, lowAdd);
604 // At least one of the pixels needs to be blended
605 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord);
606 maskPtr8 += startBit;
609 ProcessAlphaPixel(srcPtr16, maskPtr8, pixelPtr, pixelPtrInc, highAdd, lowAdd);
614 TInt numMaskWords = aLength >> 2;
616 while (numMaskWords--)
618 // Process 4 mask pixels
619 const TUint32 maskWord = *maskWordPtr++;
623 // maskWord is fully masked - skip 4 pixels
625 pixelPtr += pixelPtrInc << 2;
627 else if (maskWord == 0xFFFFFFFF)
629 // maskWord is fully unmasked - copy and convert 4 pixels
630 const TUint32* srcPtr32 = (const TUint32*)srcPtr16;
631 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd);
632 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd);
633 srcPtr16 = (const TUint16*)srcPtr32;
637 // At least one of the 4 pixels needs to be blended
638 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord);
640 if (maskPtr8[0] && (maskPtr8[0] != 0xFF) &&
641 maskPtr8[1] && (maskPtr8[1] != 0xFF) &&
642 maskPtr8[2] && (maskPtr8[2] != 0xFF) &&
643 maskPtr8[3] && (maskPtr8[3] != 0xFF))
645 // Blend all 4 pixels inline
646 BlendAlphaPixel(srcPtr16, maskPtr8[0], pixelPtr, pixelPtrInc);
647 BlendAlphaPixel(srcPtr16, maskPtr8[1], pixelPtr, pixelPtrInc);
648 BlendAlphaPixel(srcPtr16, maskPtr8[2], pixelPtr, pixelPtrInc);
649 BlendAlphaPixel(srcPtr16, maskPtr8[3], pixelPtr, pixelPtrInc);
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 ProcessAlphaPixel(srcPtr16, maskPtr8, pixelPtr, pixelPtrInc, highAdd, lowAdd);
663 // Process final incomplete mask word
664 const TUint32 maskWord = *maskWordPtr; // this will over-read
667 // maskWord is fully masked - skip the pixels
670 if (maskWord == 0xFFFFFFFF)
672 // maskWord is fully unmasked - copy and convert the pixels
675 CopyPixel(srcPtr16, pixelPtr, pixelPtrInc, highAdd, lowAdd);
680 // At least one of the pixels needs to be blended
681 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(&maskWord);
684 ProcessAlphaPixel(srcPtr16, maskPtr8, pixelPtr, pixelPtrInc, highAdd, lowAdd);
691 // Non-optimised path including shadowing and UserDisplayMode conversion
692 const TUint8* maskPtr8 = reinterpret_cast<const TUint8*>(aMaskPtr) + aMaskX;
695 TInt mask = *maskPtr8++;
698 const TUint32 src = *srcPtr16;
699 TInt r = (src & 0xF800) >> 8;
700 r |= (src & 0xE000) >>13;
701 TInt g = (src & 0x07E0) >> 3;
702 g |= (src & 0x0600) >> 9;
703 TInt b = (src & 0x001F) << 3;
704 b |= (src & 0x001C) >> 2;
706 if(aShadowing == MAlphaBlend::EShdwBefore)
708 if (iShadowMode & EFade)
710 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset;
711 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset;
712 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset;
714 if (iShadowMode & EShadow)
723 // (mask * r + (255 - mask) * value) / 255 =
724 // ((257 * mask * (r - value)) >> 16) + value
725 const TInt value = *pixelPtr & 0xffffff;
726 mask = (mask << 8) + mask; // mask = mask * 257
727 TInt v = value >> 16;
728 r = ((mask * (r - v)) >> 16) + v;
729 v = (value >> 8) & 0xff;
730 g = ((mask * (g - v)) >> 16) + v;
732 b = ((mask * (b - v)) >> 16) + v;
734 if(aShadowing == MAlphaBlend::EShdwAfter)
736 if (iShadowMode & EFade)
738 r = ((r * iFadeMapFactor) >> 8) + iFadeMapOffset;
739 g = ((g * iFadeMapFactor) >> 8) + iFadeMapOffset;
740 b = ((b * iFadeMapFactor) >> 8) + iFadeMapOffset;
742 if (iShadowMode & EShadow)
749 // Convert colour if an incompatible UserDisplayMode is being used
750 CDrawBitmap::MapColorToUserDisplayMode(r,g,b);
751 *pixelPtr = (r<<16) | (g<<8) | b | 0xff000000;
754 pixelPtr += pixelPtrInc;
762 CDrawUTwentyFourBppBitmap::WriteMaskLineEx() implementation.
764 @see MFastBlit::WriteMaskLineEx()
766 void CDrawUTwentyFourBppBitmap::WriteMaskLineEx(TInt aX, TInt aY, TInt aLength, TInt aSrcX,
767 const TUint32* aSrcPtr, TDisplayMode aSrcFormat,
768 TInt aMaskX, const TUint32* aMaskPtr, TBool aInvertMask)
770 // Only certain pixel formats are supported. Caller should check this.
771 __ASSERT_DEBUG(aSrcFormat ==EColor16MU || aSrcFormat ==EColor64K, User::Invariant());
774 TUint32* pixelPtr = PixelAddress(aX,aY);
775 const TInt pixelPtrInc = PixelAddressIncrement();
776 const TUint32 invertWord = (aInvertMask ? 0xFFFFFFFF : 0); // to be XORed with the mask
778 if (aSrcFormat==EColor16MU)
782 if ((iUserDispMode==ENone) || (iUserDispMode==EColor16MU))
784 const TUint32* maskWordPtr = aMaskPtr + (aMaskX >> 5);
785 const TInt startBit = aMaskX & 0x1F;
789 // Process initial incomplete mask word
790 TUint32 maskWord = *maskWordPtr++;
791 maskWord ^= invertWord;
792 TInt numPix = Min(aLength, 32 - startBit); // number of pixels to process from the first word of the mask
797 // maskWord is fully masked - skip the pixels
799 pixelPtr += pixelPtrInc * numPix;
801 else if (maskWord == 0xFFFFFFFF)
803 // maskWord is fully unmasked - copy the pixels
806 *pixelPtr = *aSrcPtr++;
807 pixelPtr += pixelPtrInc;
812 // maskWord is partially masked - process each pixel
813 TUint32 singleBitMask = 1 << startBit;
816 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc);
821 TInt numMaskWords = aLength >> 5;
823 while (numMaskWords--)
825 // Process a complete mask word (32 pixels)
826 TUint32 maskWord = *maskWordPtr++;
827 maskWord ^= invertWord;
831 // maskWord is fully masked - skip 32 pixels
833 pixelPtr += pixelPtrInc << 5;
835 else if (maskWord == 0xFFFFFFFF)
837 // maskWord is fully unmasked - copy 32 pixels
840 pixelPtr=(TUint32*)Mem::Move(pixelPtr, aSrcPtr, 128);
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 *pixelPtr = *aSrcPtr++; pixelPtr += pixelPtrInc;
881 // maskWord is partially masked - process each of the 32 pixels
882 TUint32 singleBitMask = 1;
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 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc);
921 // Process final incomplete mask word
922 TUint32 maskWord = *maskWordPtr;
923 maskWord ^= invertWord;
927 // maskWord is fully masked - skip the pixels
930 if (maskWord == 0xFFFFFFFF)
932 // maskWord is fully unmasked - copy the pixels
935 *pixelPtr = *aSrcPtr++;
936 pixelPtr += pixelPtrInc;
941 // maskWord is partially masked - process each pixel
942 TUint32 singleBitMask = 1;
945 ProcessMaskPixel(aSrcPtr, maskWord, singleBitMask, pixelPtr, pixelPtrInc);
952 // Non-optimised path. UserDisplay mode is different to the true display mode
955 TUint32 mask = *(aMaskPtr + (aMaskX >> 5)) & (1 << (aMaskX & 0x1F));
962 TRgb pixel(*aSrcPtr);
963 MapColorToUserDisplayMode(pixel);
964 *pixelPtr = pixel.Value();
968 pixelPtr += pixelPtrInc;
973 else // (aSrcFormat==EColor64K)
975 const TUint16* srcPtr16 = reinterpret_cast<const TUint16*>(aSrcPtr) + aSrcX;
977 if ((iUserDispMode==ENone) || (iUserDispMode==EColor16MU))
979 const TUint16* lowAdd = Convert16to32bppLow();
980 const TUint32* highAdd = Convert16to32bppHigh();
981 const TUint32* maskWordPtr = aMaskPtr + (aMaskX >> 5);
982 const TInt startBit = aMaskX & 0x1F;
986 // Process initial incomplete mask word
987 TUint32 maskWord = *maskWordPtr++;
988 maskWord ^= invertWord;
989 TInt numPix = Min(aLength, 32 - startBit); // number of pixels to process from the first word of the mask
994 // maskWord is fully masked - skip the pixels
996 pixelPtr += pixelPtrInc * numPix;
998 else if (maskWord == 0xFFFFFFFF)
1000 // maskWord is fully unmasked - copy and convert the pixels
1003 CopyPixel(srcPtr16, pixelPtr, pixelPtrInc, highAdd, lowAdd);
1008 // maskWord is partially masked - process each of the pixels
1009 TUint32 singleBitMask = 1 << startBit;
1012 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd);
1017 TInt numMaskWords = aLength >> 5;
1019 while (numMaskWords--)
1021 // Process complete mask words
1022 TUint32 maskWord = *maskWordPtr++;
1023 maskWord ^= invertWord;
1027 // maskWord is fully masked - skip 32 pixels
1029 pixelPtr += pixelPtrInc << 5;
1031 else if (maskWord == 0xFFFFFFFF)
1033 // maskWord is fully unmasked - copy and convert 32 pixels
1034 const TUint32* srcPtr32 = (const TUint32*)srcPtr16;
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 CopyTwoPixels(srcPtr32, pixelPtr, pixelPtrInc, highAdd, lowAdd);
1051 srcPtr16 = (const TUint16*)srcPtr32;
1055 // maskWord is partially masked - process each of the 32 pixels
1056 TUint32 singleBitMask = 1;
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 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd);
1094 // Process final incomplete mask word
1095 TUint32 maskWord = *maskWordPtr; // this will over-read
1096 maskWord ^= invertWord;
1100 // maskWord is masked - skip the pixels
1104 if (maskWord == 0xFFFFFFFF)
1106 // maskWord is fully unmasked - copy and convert the pixels
1109 CopyPixel(srcPtr16, pixelPtr, pixelPtrInc, highAdd, lowAdd);
1114 // maskWord is partially masked - process each of the pixels
1115 TUint32 singleBitMask = 1;
1118 ProcessMaskPixel(srcPtr16, maskWord, singleBitMask, pixelPtr, pixelPtrInc, highAdd, lowAdd);
1125 // Non-optimised - expects aMaskPtr untouched and srcPtr16 to be accurate
1128 TUint32 mask = *(aMaskPtr + (aMaskX >> 5)) & (1 << (aMaskX & 0x1F));
1135 const TUint32 src = *srcPtr16;
1136 TUint32 color = (src & 0xF800) << 8; // R top 5
1137 color |= (src & 0xE000) << 3; // R bottom 3
1138 color |= (src & 0x07E0) << 5; // G top 6
1139 color |= (src & 0x0600) >> 1; // G bottom 2
1140 color |= (src & 0x001F) << 3; // B top 5
1141 color |= (src & 0x001C) >> 2; // B bottom 3
1143 MapColorToUserDisplayMode(pixel);
1144 *pixelPtr = pixel.Value();
1146 pixelPtr += pixelPtrInc;
1156 Implementation for CFbsDrawDevice::GetInterface().
1157 Retrieves a pointer to a specified interface of CFbsDrawDevice implementation.
1158 @param aInterfaceId Interface identifier of the interface to be retrieved.
1159 @param aInterface Address of variable that retrieves the specified interface.
1160 @return KErrNone If the interface is supported, KErrNotSupported otherwise.
1162 TInt CDrawUTwentyFourBppBitmap::GetInterface(TInt aInterfaceId, TAny*& aInterface)
1165 TInt ret = KErrNotSupported;
1167 switch (aInterfaceId)
1169 case KFastBlitInterfaceID:
1171 aInterface = static_cast<MFastBlit*>(this);
1177 return CDrawThirtyTwoBppBitmapCommon::GetInterface(aInterfaceId, aInterface);
1184 TInt CDrawUTwentyFourBppBitmap::WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
1185 TUint32 aOutlinePenColor, TUint32 aShadowColor,
1186 TUint32 aFillColor, const TUint8* aDataBuffer)
1189 TUint32* pixelPtr = PixelAddress(aX,aY);
1190 const TInt pixelPtrInc = PixelAddressIncrement();
1191 const TUint8* dataBufferPtrLimit = aDataBuffer + aLength;
1192 TInt blendedRedColor;
1193 TInt blendedGreenColor;
1194 TInt blendedBlueColor;
1198 const TUint16* normTable = PtrTo16BitNormalisationTable();
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;
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;
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;
1215 //Get alpha color. Equivalent to TRgb::Alpha()
1216 const TInt alphaOutlinePenColor = aOutlinePenColor >> 24;
1217 const TInt alphaShadowColor = aShadowColor >> 24;
1218 const TInt alphaFillColor = aFillColor >> 24;
1220 while (aDataBuffer < dataBufferPtrLimit)
1222 index = *aDataBuffer++;
1223 if (255 == FourColorBlendLookup[index][KBackgroundColorIndex])
1226 //No drawing required
1228 else if (255 == FourColorBlendLookup[index][KFillColorIndex])
1230 //Use fill colour to draw
1231 finalColor = aFillColor;
1232 AlphaBlendPixelToDest((finalColor | 0xff000000), alphaFillColor, pixelPtr);
1234 else if (255 == FourColorBlendLookup[index][KShadowColorIndex])
1236 //Use shadow colour to draw
1237 finalColor = aShadowColor;
1238 AlphaBlendPixelToDest((finalColor | 0xff000000), alphaShadowColor, pixelPtr);
1240 else if (255 == FourColorBlendLookup[index][KOutlineColorIndex])
1242 //Use outline colour to draw
1243 finalColor = aOutlinePenColor;
1244 AlphaBlendPixelToDest((finalColor | 0xff000000), alphaOutlinePenColor, pixelPtr);
1248 blendedRedColor = (redOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] * alphaOutlinePenColor +
1249 redShadowColor * FourColorBlendLookup[index][KShadowColorIndex] * alphaShadowColor +
1250 redFillColor * FourColorBlendLookup[index][KFillColorIndex] * alphaFillColor) >> 16;
1252 blendedGreenColor = (greenOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] * alphaOutlinePenColor +
1253 greenShadowColor * FourColorBlendLookup[index][KShadowColorIndex] * alphaShadowColor +
1254 greenFillColor * FourColorBlendLookup[index][KFillColorIndex] * alphaFillColor) >> 16;
1256 blendedBlueColor = (blueOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] * alphaOutlinePenColor +
1257 blueShadowColor * FourColorBlendLookup[index][KShadowColorIndex] * alphaShadowColor +
1258 blueFillColor * FourColorBlendLookup[index][KFillColorIndex] * alphaFillColor) >> 16;
1260 blendedAlpha = (alphaOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] +
1261 alphaShadowColor * FourColorBlendLookup[index][KShadowColorIndex] +
1262 alphaFillColor * FourColorBlendLookup[index][KFillColorIndex]) >> 8;
1264 finalColor = PMA2NonPMAPixel((blendedAlpha << 24) | (blendedRedColor << 16) | (blendedGreenColor << 8) | blendedBlueColor, normTable);
1265 AlphaBlendPixelToDest(finalColor | 0xff000000, blendedAlpha, pixelPtr);
1267 pixelPtr += pixelPtrInc;